Skip to content

Commit

Permalink
Merge pull request #46 from membraneframework/release/v0.19.0
Browse files Browse the repository at this point in the history
Release membrane_rtp_h264_plugin v0.19.0
  • Loading branch information
FelonEkonom authored Nov 10, 2023
2 parents f2555de + 6ef37a7 commit 928918d
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 43 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The package can be installed by adding `membrane_rtp_h264_plugin` to your list o
```elixir
def deps do
[
{:membrane_rtp_h264_plugin, "~> 0.18.0"}
{:membrane_rtp_h264_plugin, "~> 0.19.0"}
]
end
```
Expand Down
9 changes: 4 additions & 5 deletions lib/rtp_h264/depayloader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ defmodule Membrane.RTP.H264.Depayloader do

@frame_prefix <<1::32>>

def_input_pad :input, accepted_format: RTP, demand_mode: :auto
def_input_pad :input, accepted_format: RTP

def_output_pad :output,
accepted_format: %H264{alignment: :nalu, stream_structure: :annexb},
demand_mode: :auto
accepted_format: %H264{alignment: :nalu, stream_structure: :annexb}

defmodule State do
@moduledoc false
Expand All @@ -41,13 +40,13 @@ defmodule Membrane.RTP.H264.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
Expand Down
7 changes: 3 additions & 4 deletions lib/rtp_h264/payloader.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ defmodule Membrane.RTP.H264.Payloader do
]

def_input_pad :input,
accepted_format: %Membrane.H264{alignment: :nalu, stream_structure: :annexb},
demand_mode: :auto
accepted_format: %Membrane.H264{alignment: :nalu, stream_structure: :annexb}

def_output_pad :output, accepted_format: RTP, demand_mode: :auto
def_output_pad :output, accepted_format: RTP

defmodule State do
@moduledoc false
Expand Down Expand Up @@ -76,7 +75,7 @@ defmodule Membrane.RTP.H264.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} =
Expand Down
6 changes: 3 additions & 3 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Membrane.RTP.H264.MixProject do
use Mix.Project

@version "0.18.0"
@version "0.19.0"
@github_url "https://github.com/membraneframework/membrane_rtp_h264_plugin"

def project do
Expand Down Expand Up @@ -61,9 +61,9 @@ defmodule Membrane.RTP.H264.MixProject do

defp deps do
[
{:membrane_core, "~> 0.12.0"},
{:membrane_core, "~> 1.0"},
{:membrane_h264_format, "~> 0.6.0"},
{:membrane_rtp_format, "~> 0.7.0"},
{:membrane_rtp_format, "~> 0.8.0"},
{:bunch, "~> 1.5"},
# Dev
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
Expand Down
18 changes: 9 additions & 9 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
"bunch": {:hex, :bunch, "1.6.0", "4775f8cdf5e801c06beed3913b0bd53fceec9d63380cdcccbda6be125a6cfd54", [:mix], [], "hexpm", "ef4e9abf83f0299d599daed3764d19e8eac5d27a5237e5e4d5e2c129cfeb9a22"},
"bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"},
"coerce": {:hex, :coerce, "1.0.1", "211c27386315dc2894ac11bc1f413a0e38505d808153367bd5c6e75a4003d096", [:mix], [], "hexpm", "b44a691700f7a1a15b4b7e2ff1fa30bebd669929ac8aa43cffe9e2f8bf051cf1"},
"credo": {:hex, :credo, "1.7.0", "6119bee47272e85995598ee04f2ebbed3e947678dee048d10b5feca139435f75", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "6839fcf63d1f0d1c0f450abc8564a57c43d644077ab96f2934563e68b8a769d7"},
"dialyxir": {:hex, :dialyxir, "1.4.1", "a22ed1e7bd3a3e3f197b68d806ef66acb61ee8f57b3ac85fc5d57354c5482a93", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "84b795d6d7796297cca5a3118444b80c7d94f7ce247d49886e7c291e1ae49801"},
"earmark_parser": {:hex, :earmark_parser, "1.4.33", "3c3fd9673bb5dcc9edc28dd90f50c87ce506d1f71b70e3de69aa8154bc695d44", [:mix], [], "hexpm", "2d526833729b59b9fdb85785078697c72ac5e5066350663e5be6a1182da61b8f"},
"credo": {:hex, :credo, "1.7.1", "6e26bbcc9e22eefbff7e43188e69924e78818e2fe6282487d0703652bc20fd62", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "e9871c6095a4c0381c89b6aa98bc6260a8ba6addccf7f6a53da8849c748a58a2"},
"dialyxir": {:hex, :dialyxir, "1.4.2", "764a6e8e7a354f0ba95d58418178d486065ead1f69ad89782817c296d0d746a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "516603d8067b2fd585319e4b13d3674ad4f314a5902ba8130cd97dc902ce6bbd"},
"earmark_parser": {:hex, :earmark_parser, "1.4.37", "2ad73550e27c8946648b06905a57e4d454e4d7229c2dafa72a0348c99d8be5f7", [:mix], [], "hexpm", "6b19783f2802f039806f375610faa22da130b8edc21209d0bff47918bb48360e"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_doc": {:hex, :ex_doc, "0.30.6", "5f8b54854b240a2b55c9734c4b1d0dd7bdd41f71a095d42a70445c03cf05a281", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "bd48f2ddacf4e482c727f9293d9498e0881597eae6ddc3d9562bd7923375109f"},
"ex_doc": {:hex, :ex_doc, "0.30.9", "d691453495c47434c0f2052b08dd91cc32bc4e1a218f86884563448ee2502dd2", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "d7aaaf21e95dc5cddabf89063327e96867d00013963eadf2c6ad135506a8bc10"},
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
"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": {:hex, :makeup, "1.1.1", "fa0bc768698053b2b3869fa8a62616501ff9d11a562f3ce39580d60860c3a55e", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "5dc62fbdd0de44de194898b6710692490be74baa02d9d108bc29f007783b0b48"},
"makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"},
"makeup_erlang": {:hex, :makeup_erlang, "0.1.2", "ad87296a092a46e03b7e9b0be7631ddcf64c790fa68a9ef5323b6cbb36affc72", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f3f5a1ca93ce6e092d92b6d9c049bcda58a3b617a8d888f8e7231c85630e8108"},
"membrane_caps_video_h264": {:hex, :membrane_caps_video_h264, "0.2.1", "8545074299dc48d8afe106b0be1ecf3097e997f0e9f32557f435c123135050fe", [:mix], [], "hexpm", "a14a8dcd0d2c205ca2cdbe5c7df24ec3e34a027e1caf511a71ca4c72b371b200"},
"membrane_core": {:hex, :membrane_core, "0.12.8", "59fdd10a1c1c6757302748d029fba4936257e53c93ac49fddd094962c08180f9", [: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", "d48ab1adc13d5820182b016cc397692ed5568d4064b5765c343b4d64c7f119e7"},
"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_h264_format": {:hex, :membrane_h264_format, "0.6.1", "44836cd9de0abe989b146df1e114507787efc0cf0da2368f17a10c47b4e0738c", [:mix], [], "hexpm", "4b79be56465a876d2eac2c3af99e115374bbdc03eb1dea4f696ee9a8033cd4b0"},
"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"},
"nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"},
"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.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
"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"},
}
8 changes: 2 additions & 6 deletions test/depayloader_pipeline_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ defmodule Membrane.RTP.H264.DepayloaderPipelineTest do
|> Source.output_from_buffers()
|> DepayloaderTestingPipeline.start_pipeline()

Membrane.Testing.Pipeline.execute_actions(pid, playback: :playing)

STAPFactory.sample_data()
|> Enum.each(fn elem ->
assert_sink_buffer(pid, :sink, buffer)
assert %Buffer{payload: payload} = buffer
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
Expand All @@ -45,14 +43,12 @@ defmodule Membrane.RTP.H264.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
12 changes: 6 additions & 6 deletions test/depayloader_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule Membrane.RTP.H264.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
Expand All @@ -30,7 +30,7 @@ defmodule Membrane.RTP.H264.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}
Expand All @@ -46,7 +46,7 @@ defmodule Membrane.RTP.H264.DepayloaderTest do

buffer = %Buffer{payload: STAPFactory.into_stap_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

Expand Down Expand Up @@ -88,7 +88,7 @@ defmodule Membrane.RTP.H264.DepayloaderTest do
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
Expand All @@ -99,7 +99,7 @@ defmodule Membrane.RTP.H264.DepayloaderTest do
metadata: %{rtp: %{sequence_number: 2}},
payload: <<24>> <> <<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
Expand All @@ -108,7 +108,7 @@ defmodule Membrane.RTP.H264.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
12 changes: 3 additions & 9 deletions test/payloader_pipeline_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ defmodule Membrane.RTP.H264.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 ->
Expand Down Expand Up @@ -59,7 +57,7 @@ defmodule Membrane.RTP.H264.PayloaderPipelineTest do
end
end)

Membrane.Pipeline.terminate(pid, blocking?: true)
Membrane.Pipeline.terminate(pid)
end

test "payloads Stap A" do
Expand All @@ -76,16 +74,14 @@ defmodule Membrane.RTP.H264.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(:stap_a)
assert <<0::1, 0::2, ^type::5, rest::binary>> = data
assert {:ok, glued} = StapA.parse(rest)
assert glued == List.duplicate(single_unit, number_of_packets)

Membrane.Pipeline.terminate(pid, blocking?: true)
Membrane.Pipeline.terminate(pid)
end

test "payloads single NAL units" do
Expand All @@ -100,16 +96,14 @@ defmodule Membrane.RTP.H264.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})
assert metadata.rtp.marker == true
assert <<i::size(@max_size)-unit(8)>> == data
end)

Membrane.Pipeline.terminate(pid, blocking?: true)
Membrane.Pipeline.terminate(pid)
end
end
end

0 comments on commit 928918d

Please sign in to comment.