diff --git a/README.md b/README.md index 38e3e1f..51c34fe 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ The package can be installed by adding `membrane_rtp_h265_plugin` to your list o ```elixir def deps do [ - {:membrane_rtp_h265_plugin, "~> 0.4.0"} + {:membrane_rtp_h265_plugin, "~> 0.5.0"} ] end ``` diff --git a/lib/depayloader.ex b/lib/depayloader.ex index f4b51db..acfc4b0 100644 --- a/lib/depayloader.ex +++ b/lib/depayloader.ex @@ -18,11 +18,11 @@ defmodule Membrane.RTP.H265.Depayloader do @frame_prefix <<1::32>> - def_input_pad :input, accepted_format: RTP, demand_mode: :auto + def_input_pad :input, accepted_format: RTP, flow_control: :auto def_output_pad :output, accepted_format: %H265{alignment: :nalu, stream_structure: :annexb}, - demand_mode: :auto + flow_control: :auto def_options sprop_max_don_diff: [ spec: 0..32_767, @@ -54,13 +54,13 @@ defmodule Membrane.RTP.H265.Depayloader do end @impl true - def handle_process(:input, %Buffer{payload: ""}, _ctx, state) do + def handle_buffer(:input, %Buffer{payload: ""}, _ctx, state) do Membrane.Logger.debug("Received empty RTP packet. Ignoring") {[], state} end @impl true - def handle_process(:input, buffer, _ctx, state) do + def handle_buffer(:input, buffer, _ctx, state) do with {:ok, {header, _payload} = nal} <- NAL.Header.parse_unit_header(buffer.payload), unit_type = NAL.Header.decode_type(header), {:ok, {actions, state}} <- handle_unit_type(unit_type, nal, buffer, state) do diff --git a/lib/payloader.ex b/lib/payloader.ex index b8c1b30..6416cb6 100644 --- a/lib/payloader.ex +++ b/lib/payloader.ex @@ -34,12 +34,12 @@ defmodule Membrane.RTP.H265.Payloader do ] def_input_pad :input, - accepted_format: %H265{alignment: :nalu, stream_structure: :annexb}, - demand_mode: :auto + flow_control: :auto, + accepted_format: %H265{alignment: :nalu, stream_structure: :annexb} def_output_pad :output, - accepted_format: RTP, - demand_mode: :auto + flow_control: :auto, + accepted_format: RTP defmodule State do @moduledoc false @@ -75,7 +75,7 @@ defmodule Membrane.RTP.H265.Payloader do end @impl true - def handle_process(:input, %Buffer{} = buffer, _ctx, state) do + def handle_buffer(:input, %Buffer{} = buffer, _ctx, state) do buffer = Map.update!(buffer, :payload, &delete_prefix/1) {buffers, state} = diff --git a/mix.exs b/mix.exs index e3bde70..6780984 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Membrane.RTP.H265.Mixfile do use Mix.Project - @version "0.4.0" + @version "0.5.0" @github_url "https://github.com/gBillal/membrane_rtp_h265_plugin" def project do @@ -36,8 +36,8 @@ defmodule Membrane.RTP.H265.Mixfile do defp deps do [ - {:membrane_core, "~> 0.12.0"}, - {:membrane_rtp_format, "~> 0.7.0"}, + {:membrane_core, "~> 1.0.0"}, + {:membrane_rtp_format, "~> 0.8.0"}, {:membrane_h265_format, "~> 0.2.0"}, {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, {:dialyxir, ">= 0.0.0", only: :dev, runtime: false}, diff --git a/mix.lock b/mix.lock index aad6eab..79cf930 100644 --- a/mix.lock +++ b/mix.lock @@ -12,12 +12,12 @@ "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"}, "makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, - "membrane_core": {:hex, :membrane_core, "0.12.7", "9d3dd564e32768919c1105b4579bd2eef12df7473da5d789185544ae22610e2d", [:mix], [{:bunch, "~> 1.6", [hex: :bunch, repo: "hexpm", optional: false]}, {:qex, "~> 0.3", [hex: :qex, repo: "hexpm", optional: false]}, {:ratio, "~> 2.0", [hex: :ratio, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "321e4009b7068ca04b65daf5c79b8c3772d4286c27d05e50939ec6d9b4d50e59"}, + "membrane_core": {:hex, :membrane_core, "1.0.0", "1b543aefd952283be1f2a215a1db213aa4d91222722ba03cd35280622f1905ee", [:mix], [{:bunch, "~> 1.6", [hex: :bunch, repo: "hexpm", optional: false]}, {:qex, "~> 0.3", [hex: :qex, repo: "hexpm", optional: false]}, {:ratio, "~> 3.0", [hex: :ratio, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "352c90fd0a29942143c4bf7a727cc05c632e323f50a1a4e99321b1e8982f1533"}, "membrane_h265_format": {:hex, :membrane_h265_format, "0.2.0", "1903c072cf7b0980c4d0c117ab61a2cd33e88782b696290de29570a7fab34819", [:mix], [], "hexpm", "6df418bdf242c0d9f7dbf2e5aea4c2d182e34ac9ad5a8b8cef2610c290002e83"}, - "membrane_rtp_format": {:hex, :membrane_rtp_format, "0.7.0", "c07cca86d420732663b55a9ca046f327737ca87354508c3df829d240c477df25", [:mix], [{:membrane_core, "~> 0.12.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "2cead4d2c4f9f5c7669677c2cd3921f9f99ec29c06a871f9dffdb97840a1a279"}, + "membrane_rtp_format": {:hex, :membrane_rtp_format, "0.8.0", "828924bbd27efcf85b2015ae781e824c4a9928f0a7dc132abc66817b2c6edfc4", [:mix], [{:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "bc75d2a649dfaef6df563212fbb9f9f62eebc871393692f9dae8d289bd4f94bb"}, "nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"}, "numbers": {:hex, :numbers, "5.2.4", "f123d5bb7f6acc366f8f445e10a32bd403c8469bdbce8ce049e1f0972b607080", [:mix], [{:coerce, "~> 1.0", [hex: :coerce, repo: "hexpm", optional: false]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "eeccf5c61d5f4922198395bf87a465b6f980b8b862dd22d28198c5e6fab38582"}, "qex": {:hex, :qex, "0.5.1", "0d82c0f008551d24fffb99d97f8299afcb8ea9cf99582b770bd004ed5af63fd6", [:mix], [], "hexpm", "935a39fdaf2445834b95951456559e9dc2063d0a055742c558a99987b38d6bab"}, - "ratio": {:hex, :ratio, "2.4.2", "c8518f3536d49b1b00d88dd20d49f8b11abb7819638093314a6348139f14f9f9", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:numbers, "~> 5.2.0", [hex: :numbers, repo: "hexpm", optional: false]}], "hexpm", "441ef6f73172a3503de65ccf1769030997b0d533b1039422f1e5e0e0b4cbf89e"}, + "ratio": {:hex, :ratio, "3.0.2", "60a5976872a4dc3d873ecc57eed1738589e99d1094834b9c935b118231297cfb", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:numbers, "~> 5.2.0", [hex: :numbers, repo: "hexpm", optional: false]}], "hexpm", "3a13ed5a30ad0bfd7e4a86bf86d93d2b5a06f5904417d38d3f3ea6406cdfc7bb"}, "telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"}, } diff --git a/test/depayloader_pipeline_test.exs b/test/depayloader_pipeline_test.exs index c3f9491..199f21a 100644 --- a/test/depayloader_pipeline_test.exs +++ b/test/depayloader_pipeline_test.exs @@ -20,8 +20,6 @@ defmodule Membrane.RTP.H265.DepayloaderPipelineTest do |> Source.output_from_buffers() |> DepayloaderTestingPipeline.start_pipeline() - Membrane.Testing.Pipeline.execute_actions(pid, playback: :playing) - APFactory.sample_data() |> Enum.each(fn elem -> assert_sink_buffer(pid, :sink, buffer) @@ -29,7 +27,7 @@ defmodule Membrane.RTP.H265.DepayloaderPipelineTest do assert <<1::32, elem::binary>> == payload end) - Membrane.Pipeline.terminate(pid, blocking?: true) + Membrane.Pipeline.terminate(pid) end test "does not crash when parsing fu" do @@ -47,14 +45,12 @@ defmodule Membrane.RTP.H265.DepayloaderPipelineTest do |> Source.output_from_buffers() |> DepayloaderTestingPipeline.start_pipeline() - Membrane.Testing.Pipeline.execute_actions(pid, playback: :playing) - Enum.each(data_base, fn _i -> assert_sink_buffer(pid, :sink, %Buffer{payload: data}) assert <<1::32, ^glued_data::binary>> = data end) - Membrane.Pipeline.terminate(pid, blocking?: true) + Membrane.Pipeline.terminate(pid) end end end diff --git a/test/depayloader_test.exs b/test/depayloader_test.exs index e5e57e8..4a283f3 100644 --- a/test/depayloader_test.exs +++ b/test/depayloader_test.exs @@ -17,7 +17,7 @@ defmodule Membrane.RTP.H265.DepayloaderTest do buffer = %Buffer{payload: data} assert {actions, @empty_state} = - Depayloader.handle_process(:input, buffer, nil, @empty_state) + Depayloader.handle_buffer(:input, buffer, nil, @empty_state) assert {:output, result} = Keyword.fetch!(actions, :buffer) assert %Buffer{payload: <<1::32, processed_data::binary>>} = result @@ -33,7 +33,7 @@ defmodule Membrane.RTP.H265.DepayloaderTest do %Buffer{payload: elem, metadata: %{rtp: %{sequence_number: seq_num}}} end) |> Enum.reduce(@empty_state, fn buffer, prev_state -> - Depayloader.handle_process(:input, buffer, nil, prev_state) + Depayloader.handle_buffer(:input, buffer, nil, prev_state) ~> ( {[], %Depayloader.State{} = state} -> state {actions, state} -> {actions, state} @@ -54,7 +54,7 @@ defmodule Membrane.RTP.H265.DepayloaderTest do %Buffer{payload: elem, metadata: %{rtp: %{sequence_number: seq_num}}} end) |> Enum.reduce(@don_state, fn buffer, prev_state -> - Depayloader.handle_process(:input, buffer, nil, prev_state) + Depayloader.handle_buffer(:input, buffer, nil, prev_state) ~> ( {[], %Depayloader.State{} = state} -> state {actions, state} -> {actions, state} @@ -73,7 +73,7 @@ defmodule Membrane.RTP.H265.DepayloaderTest do buffer = %Buffer{payload: APFactory.into_ap_unit(data)} - assert {actions, _state} = Depayloader.handle_process(:input, buffer, nil, @empty_state) + assert {actions, _state} = Depayloader.handle_buffer(:input, buffer, nil, @empty_state) assert [buffer: {:output, buffers}] = actions @@ -91,7 +91,7 @@ defmodule Membrane.RTP.H265.DepayloaderTest do buffer = %Buffer{payload: APFactory.into_ap_unit_with_don(data, don)} - assert {actions, _state} = Depayloader.handle_process(:input, buffer, nil, @don_state) + assert {actions, _state} = Depayloader.handle_buffer(:input, buffer, nil, @don_state) assert [buffer: {:output, buffers}] = actions @@ -135,7 +135,7 @@ defmodule Membrane.RTP.H265.DepayloaderTest do 67, 149, 169, 61, 178, 147, 249, 138, 15, 81, 60, 59, 234, 117, 32, 55, 245, 115, 49, 165, 19, 87, 99, 15, 255, 51, 62, 243, 41, 9>> } - ~> Depayloader.handle_process(:input, &1, nil, %Depayloader.State{ + ~> Depayloader.handle_buffer(:input, &1, nil, %Depayloader.State{ parser_acc: %FU{} }) end @@ -146,7 +146,7 @@ defmodule Membrane.RTP.H265.DepayloaderTest do metadata: %{rtp: %{sequence_number: 2}}, payload: <<96, 1>> <> <<35_402::16, 0, 0, 0, 0, 0, 0, 1, 1, 2>> } - ~> Depayloader.handle_process(:input, &1, nil, @empty_state) + ~> Depayloader.handle_buffer(:input, &1, nil, @empty_state) end test "when parsing not valid nalu" do @@ -155,7 +155,7 @@ defmodule Membrane.RTP.H265.DepayloaderTest do metadata: %{rtp: %{sequence_number: 2}}, payload: <<128::8>> } - ~> Depayloader.handle_process(:input, &1, nil, @empty_state) + ~> Depayloader.handle_buffer(:input, &1, nil, @empty_state) end end end diff --git a/test/payloader_pipeline_test.exs b/test/payloader_pipeline_test.exs index 37d855e..666a3d6 100644 --- a/test/payloader_pipeline_test.exs +++ b/test/payloader_pipeline_test.exs @@ -20,8 +20,6 @@ defmodule Membrane.RTP.H265.PayloaderPipelineTest do |> Source.output_from_buffers() |> PayloaderTestingPipeline.start_pipeline() - Membrane.Testing.Pipeline.execute_actions(pid, playback: :playing) - data_base = 0..div(big_unit_size, @max_size) Enum.each(data_base, fn i -> @@ -59,7 +57,7 @@ defmodule Membrane.RTP.H265.PayloaderPipelineTest do end end) - Membrane.Pipeline.terminate(pid, blocking?: true) + Membrane.Pipeline.terminate(pid) end test "payloads AP" do @@ -76,8 +74,6 @@ defmodule Membrane.RTP.H265.PayloaderPipelineTest do |> Source.output_from_buffers() |> PayloaderTestingPipeline.start_pipeline() - Membrane.Testing.Pipeline.execute_actions(pid, playback: :playing) - assert_sink_buffer(pid, :sink, %Buffer{payload: data, metadata: metadata}) assert metadata.rtp.marker == true type = NAL.Header.encode_type(:ap) @@ -85,7 +81,7 @@ defmodule Membrane.RTP.H265.PayloaderPipelineTest do assert {:ok, glued} = AP.parse(rest) assert Enum.map(glued, &elem(&1, 0)) == List.duplicate(single_unit, number_of_packets) - Membrane.Pipeline.terminate(pid, blocking?: true) + Membrane.Pipeline.terminate(pid) end test "payloads single NAL units" do @@ -100,8 +96,6 @@ defmodule Membrane.RTP.H265.PayloaderPipelineTest do |> Source.output_from_buffers() |> PayloaderTestingPipeline.start_pipeline() - Membrane.Testing.Pipeline.execute_actions(pid, playback: :playing) - 1..number_of_packets |> Enum.each(fn i -> assert_sink_buffer(pid, :sink, %Buffer{payload: data, metadata: metadata}) @@ -109,7 +103,7 @@ defmodule Membrane.RTP.H265.PayloaderPipelineTest do assert <> == data end) - Membrane.Pipeline.terminate(pid, blocking?: true) + Membrane.Pipeline.terminate(pid) end end end diff --git a/test/support/depayloader_testing_pipeline.ex b/test/support/depayloader_testing_pipeline.ex index 5609249..051f2dd 100644 --- a/test/support/depayloader_testing_pipeline.ex +++ b/test/support/depayloader_testing_pipeline.ex @@ -9,12 +9,12 @@ defmodule Membrane.Support.DepayloaderTestingPipeline do @spec start_pipeline(any()) :: pid() def start_pipeline(data) do - structure = [ + spec = [ child(:source, %Testing.Source{output: data, stream_format: %RTP{}}) |> child(:depayloader, Depayloader) |> child(:sink, Testing.Sink) ] - Pipeline.start_link_supervised!(structure: structure) + Pipeline.start_link_supervised!(spec: spec) end end diff --git a/test/support/payloader_testing_pipeline.ex b/test/support/payloader_testing_pipeline.ex index ad19c61..4fd49fb 100644 --- a/test/support/payloader_testing_pipeline.ex +++ b/test/support/payloader_testing_pipeline.ex @@ -10,7 +10,7 @@ defmodule Membrane.Support.PayloaderTestingPipeline do @spec start_pipeline(any()) :: pid() def start_pipeline(data) do - structure = [ + spec = [ child(:source, %Testing.Source{ output: data, stream_format: %H265{ @@ -26,6 +26,6 @@ defmodule Membrane.Support.PayloaderTestingPipeline do |> child(:sink, Testing.Sink) ] - Pipeline.start_link_supervised!(structure: structure) + Pipeline.start_link_supervised!(spec: spec) end end