Skip to content

Commit

Permalink
Release v0.5.0 (#37)
Browse files Browse the repository at this point in the history
* Allow for Membrane.H264 caps on input and properly handle them

* Change the input pad accepted format

* Bump to v0.4.2. Update Core to v0.12.7. Rewrite an example in README so that it uses Core v0.12 properly

* Implement reviewers suggestions. Refactor code.

* Change Logger.warn into Logger.warning. Reduce cyclomatic complexity of handle_stream_format

* Update the codeoweners file. Refine get_frame_prefix

* Bump to v0.5.0
  • Loading branch information
varsill committed Aug 1, 2023
1 parent 3124aab commit 5fbe30a
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @DominikWolek @varsill
* @varsill
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The package can be installed by adding `membrane_h264_plugin` to your list of de
```elixir
def deps do
[
{:membrane_h264_plugin, "~> 0.4.1"}
{:membrane_h264_plugin, "~> 0.5.0"}
]
end
```
Expand All @@ -39,19 +39,18 @@ defmodule Decoding.Pipeline do

@impl true
def handle_init(_ctx, _opts) do
structure = [
structure =
child(:source, %File.Source{location: "test/fixtures/input-10-720p-main.h264"})
|> child(:parser, H264.Parser)
|> child(:decoder, H264.FFmpeg.Decoder)
|> child(:sink, %File.Sink{location: "output.raw"})
]

{[spec: structure, playback: :playing]}, nil}
{[spec: structure], nil}
end

@impl true
def handle_element_end_of_stream(:sink, _ctx_, _state) do
{[playback: :stopped], nil}
def handle_element_end_of_stream(:sink, _ctx_, state) do
{[terminate: :normal], state}
end
end
```
Expand Down
41 changes: 26 additions & 15 deletions lib/membrane_h264_plugin/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ defmodule Membrane.H264.Parser do
accepted_format:
any_of(
%RemoteStream{type: :bytestream},
%H264{alignment: alignment} when alignment in [:nalu, :au],
%H264.RemoteStream{alignment: alignment} when alignment in [:nalu, :au]
)

def_output_pad :output,
demand_mode: :auto,
accepted_format:
any_of(%H264{alignment: :au, nalu_in_metadata?: true}, %H264{alignment: :nalu})
%H264{alignment: alignment, nalu_in_metadata?: true} when alignment in [:nalu, :au]

def_options sps: [
spec: binary(),
Expand Down Expand Up @@ -143,30 +144,26 @@ defmodule Membrane.H264.Parser do
def handle_stream_format(:input, stream_format, _ctx, state) do
state =
case stream_format do
%RemoteStream{type: :bytestream} ->
%{state | mode: :bytestream}

%H264.RemoteStream{alignment: alignment, decoder_configuration_record: dcr} ->
%H264{alignment: alignment} ->
mode =
case alignment do
:nalu -> :nalu_aligned
:au -> :au_aligned
end

frame_prefix =
case dcr do
nil ->
<<>>
%{state | mode: mode}

_dcr when state.parameter_sets_present? ->
raise "Parameter sets were already provided as the options to the parser and parameter sets from the decoder configuration record could overwrite them."
%RemoteStream{type: :bytestream} ->
%{state | mode: :bytestream}

_dcr ->
{:ok, %{sps: sps, pps: pps}} = DecoderConfigurationRecord.parse(dcr)
Enum.concat([[<<>>], sps, pps]) |> Enum.join(@prefix_code)
%H264.RemoteStream{alignment: alignment, decoder_configuration_record: dcr} ->
mode =
case alignment do
:nalu -> :nalu_aligned
:au -> :au_aligned
end

%{state | mode: mode, frame_prefix: frame_prefix}
%{state | mode: mode, frame_prefix: get_frame_prefix!(dcr, state)}
end

{[], state}
Expand Down Expand Up @@ -483,4 +480,18 @@ defmodule Membrane.H264.Parser do
dts = div(decoding_order_number * seconds * Membrane.Time.second(), frames)
{pts, dts}
end

defp get_frame_prefix!(dcr, state) do
cond do
dcr == nil ->
<<>>

state.parameter_sets_present? ->
raise "Parameter sets were already provided as the options to the parser and parameter sets from the decoder configuration record could overwrite them."

true ->
{:ok, %{sps: sps, pps: pps}} = DecoderConfigurationRecord.parse(dcr)
Enum.concat([[<<>>], sps, pps]) |> Enum.join(@prefix_code)
end
end
end
4 changes: 2 additions & 2 deletions lib/membrane_h264_plugin/parser/au_splitter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ defmodule Membrane.H264.Parser.AUSplitter do
)

true ->
Membrane.Logger.warn("AUSplitter: Improper transition")
Membrane.Logger.warning("AUSplitter: Improper transition")
return(state)
end
end
Expand Down Expand Up @@ -143,7 +143,7 @@ defmodule Membrane.H264.Parser.AUSplitter do
)

true ->
Membrane.Logger.warn("AUSplitter: Improper transition")
Membrane.Logger.warning("AUSplitter: Improper transition")
return(state)
end
end
Expand Down
9 changes: 5 additions & 4 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Membrane.H264.TODO.Mixfile do
defmodule Membrane.H264.Plugin.Mixfile do
use Mix.Project

@version "0.4.1"
@version "0.5.0"
@github_url "https://github.com/membraneframework-labs/membrane_h264_plugin"

def project do
Expand Down Expand Up @@ -37,13 +37,14 @@ defmodule Membrane.H264.TODO.Mixfile do

defp deps do
[
{:membrane_core, "~> 0.12.0"},
{:membrane_core, "~> 0.12.7"},
{:membrane_h264_format, "~> 0.5.0"},
{:bunch, "~> 1.4"},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:dialyxir, ">= 0.0.0", only: :dev, runtime: false},
{:credo, ">= 0.0.0", only: :dev, runtime: false},
{:membrane_file_plugin, "~> 0.13.0", only: :test}
{:membrane_file_plugin, "~> 0.13.0", only: :test},
{:membrane_h264_ffmpeg_plugin, only: :test}
]
end

Expand Down
10 changes: 9 additions & 1 deletion mix.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
%{
"bunch": {:hex, :bunch, "1.6.0", "4775f8cdf5e801c06beed3913b0bd53fceec9d63380cdcccbda6be125a6cfd54", [:mix], [], "hexpm", "ef4e9abf83f0299d599daed3764d19e8eac5d27a5237e5e4d5e2c129cfeb9a22"},
"bunch_native": {:hex, :bunch_native, "0.5.0", "8ac1536789a597599c10b652e0b526d8833348c19e4739a0759a2bedfd924e63", [:mix], [{:bundlex, "~> 1.0", [hex: :bundlex, repo: "hexpm", optional: false]}], "hexpm", "24190c760e32b23b36edeb2dc4852515c7c5b3b8675b1a864e0715bdd1c8f80d"},
"bundlex": {:hex, :bundlex, "1.1.1", "e637b79a1eaab1bf019de4100b6db262aa3b660beff0cd2f3617949b1618eeda", [:mix], [{:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:qex, "~> 0.5", [hex: :qex, repo: "hexpm", optional: false]}, {:secure_random, "~> 0.5", [hex: :secure_random, repo: "hexpm", optional: false]}], "hexpm", "1fdfa3d6240baa5a2d5496a86e2e43116f80105e93d9adfd4f1fc75be487ea30"},
"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"},
Expand All @@ -12,12 +14,18 @@
"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.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.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
"membrane_core": {:hex, :membrane_core, "0.12.1", "aa98c9ef66d109ea9f0395df8d12434d255941cbfe51c154e5fd49d3488a1dfc", [: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", "94469345cd55c3bca98c5aa14e56812d1e8aad2eaa63f217be45a51c556bbc3f"},
"membrane_common_c": {:hex, :membrane_common_c, "0.15.0", "4b6005c562bf025e4a53c95a9646a9f5fa993ac440dd44c1a4d1ea210ec53793", [:mix], [{:membrane_core, "~> 0.12.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:shmex, "~> 0.5.0", [hex: :shmex, repo: "hexpm", optional: false]}, {:unifex, "~> 1.0", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "f9584cca9865ed754b8333e362d49d6c449c708d7c87be6c5f7bd5a1d978d6bf"},
"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_file_plugin": {:hex, :membrane_file_plugin, "0.13.3", "aaf40a72e5fccf6da47ec85ef525234acbec828425f1300f74c464bca1487f40", [:mix], [{:membrane_core, "~> 0.11", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "1c1acf610d4fc0279b7fd65a5db06c8bc3ef6a276bf40fb033c2c735c25839ba"},
"membrane_h264_ffmpeg_plugin": {:hex, :membrane_h264_ffmpeg_plugin, "0.27.0", "4fced15b5791b87758869537770d00b39d103d1239ef7311f4a883e036d83d7b", [:mix], [{:bunch, "~> 1.6", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_common_c, "~> 0.15.0", [hex: :membrane_common_c, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.12.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_h264_format, "~> 0.5.0", [hex: :membrane_h264_format, repo: "hexpm", optional: false]}, {:membrane_raw_video_format, "~> 0.3.0", [hex: :membrane_raw_video_format, repo: "hexpm", optional: false]}, {:ratio, "~> 2.4.0", [hex: :ratio, repo: "hexpm", optional: false]}, {:unifex, "~> 1.1", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "031887921970f793d11bfd2e2ed36ba6c3010b17c61a4702bcf50028431786dc"},
"membrane_h264_format": {:hex, :membrane_h264_format, "0.5.0", "95c1cc00896dab6de322cee3be0c9b0b0840537b4cc49e82a34e901b4e4763f9", [:mix], [], "hexpm", "7b44e0b02d86b45d24699de3c970186dffbca6d51aca80bbed2f6a3fe5c9eba1"},
"membrane_raw_video_format": {:hex, :membrane_raw_video_format, "0.3.0", "ba10f475e0814a6fe79602a74536b796047577c7ef5b0e33def27cd344229699", [:mix], [], "hexpm", "2f08760061c8a5386ecf04273480f10e48d25a1a40aa99476302b0bcd34ccb1c"},
"nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"},
"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"},
"secure_random": {:hex, :secure_random, "0.5.1", "c5532b37c89d175c328f5196a0c2a5680b15ebce3e654da37129a9fe40ebf51b", [:mix], [], "hexpm", "1b9754f15e3940a143baafd19da12293f100044df69ea12db5d72878312ae6ab"},
"shmex": {:hex, :shmex, "0.5.0", "7dc4fb1a8bd851085a652605d690bdd070628717864b442f53d3447326bcd3e8", [:mix], [{:bunch_native, "~> 0.5.0", [hex: :bunch_native, repo: "hexpm", optional: false]}, {:bundlex, "~> 1.0", [hex: :bundlex, repo: "hexpm", optional: false]}], "hexpm", "b67bb1e22734758397c84458dbb746519e28eac210423c267c7248e59fc97bdc"},
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
"unifex": {:hex, :unifex, "1.1.0", "26b1bcb6c3b3454e1ea15f85b2e570aaa5b5c609566aa9f5c2e0a8b213379d6b", [:mix], [{:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:bundlex, "~> 1.0", [hex: :bundlex, repo: "hexpm", optional: false]}, {:shmex, "~> 0.5.0", [hex: :shmex, repo: "hexpm", optional: false]}], "hexpm", "d8f47e9e3240301f5b20eec5792d1d4341e1a3a268d94f7204703b48da4aaa06"},
}

0 comments on commit 5fbe30a

Please sign in to comment.