From ee972b3040d1b39436cac12082cc0e48e8e0d62f Mon Sep 17 00:00:00 2001 From: "feliks.pobiedzinski@swmansion.com" Date: Thu, 21 Nov 2024 16:56:17 +0100 Subject: [PATCH 1/2] Handle EoS without SoS in Encoder --- lib/membrane_aac_fdk_plugin/encoder.ex | 7 +++- .../pipeline_test.exs | 34 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/membrane_aac_fdk_plugin/encoder.ex b/lib/membrane_aac_fdk_plugin/encoder.ex index 634ecdd..271686d 100644 --- a/lib/membrane_aac_fdk_plugin/encoder.ex +++ b/lib/membrane_aac_fdk_plugin/encoder.ex @@ -173,7 +173,7 @@ defmodule Membrane.AAC.FDK.Encoder do end @impl true - def handle_end_of_stream(:input, _ctx, state) do + def handle_end_of_stream(:input, %{start_of_stream_received?: true}, state) do %{native: native, queue: queue} = state if queue != <<>>, @@ -193,6 +193,11 @@ defmodule Membrane.AAC.FDK.Encoder do end end + @impl true + def handle_end_of_stream(:input, %{start_of_stream_received?: false}, state) do + {[end_of_stream: :output], state} + end + defp encode_buffer(buffer, native, raw_frame_size, acc \\ [], bytes_used \\ 0, state) # Encode a single frame if buffer contains at least one frame diff --git a/test/membrane_element_fdk_aac/pipeline_test.exs b/test/membrane_element_fdk_aac/pipeline_test.exs index af642eb..237be82 100644 --- a/test/membrane_element_fdk_aac/pipeline_test.exs +++ b/test/membrane_element_fdk_aac/pipeline_test.exs @@ -1,6 +1,11 @@ defmodule Membrane.AAC.FDK.PipelineTest do use ExUnit.Case + + import Membrane.ChildrenSpec import Membrane.Testing.Assertions + + alias Membrane.Testing + alias Membrane.AAC.FDK.{Decoder, Encoder} alias Membrane.AAC.FDK.Support.{DecodingPipeline, EncodingPipeline} defp assert_files_equal(file_a, file_b) do @@ -24,6 +29,16 @@ defmodule Membrane.AAC.FDK.PipelineTest do assert_files_equal(out_path, reference_path) end + defmodule SimpleSource do + use Membrane.Source + + def_output_pad :output, accepted_format: _any, flow_control: :push + + + @impl true + def handle_parent_notification(:send_end_of_stream, _ctx, state), do: {[end_of_stream: :output], state} + end + describe "As part of the pipeline" do @describetag :tmp_dir @@ -34,5 +49,24 @@ defmodule Membrane.AAC.FDK.PipelineTest do test "Decoder must decoder file", ctx do test_file(DecodingPipeline, "sample.aac", "sample.raw", ctx) end + + [{"Encoder", Encoder}, {"Decoder", Decoder}] + |> Enum.map(fn {name, module} -> + test "#{name} can receive end of stream without start of stream" do + pipeline = Testing.Pipeline.start_link_supervised!(spec: + child(:source, SimpleSource) + |> child(unquote(module)) + |> child(:sink, Testing.Sink) + ) + + Process.sleep(500) + Testing.Pipeline.notify_child(pipeline, :source, :send_end_of_stream) + + assert_end_of_stream(pipeline, :sink) + + Testing.Pipeline.terminate(pipeline) + end + + end) end end From dfdbcf032a229093e6a4039d77c13c512fa80080 Mon Sep 17 00:00:00 2001 From: "feliks.pobiedzinski@swmansion.com" Date: Thu, 21 Nov 2024 16:58:58 +0100 Subject: [PATCH 2/2] Bump version --- README.md | 2 +- mix.exs | 2 +- test/membrane_element_fdk_aac/pipeline_test.exs | 17 +++++++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 21e1013..275a66a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ The package can be installed by adding `membrane_aac_fdk_plugin` to your list of ```elixir def deps do [ - {:membrane_aac_fdk_plugin, "~> 0.18.9"} + {:membrane_aac_fdk_plugin, "~> 0.18.10"} ] end ``` diff --git a/mix.exs b/mix.exs index bf76bed..20dad56 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Membrane.AAC.FDK.Plugin.MixProject do use Mix.Project - @version "0.18.9" + @version "0.18.10" @github_url "https://github.com/membraneframework/membrane_aac_fdk_plugin" def project do diff --git a/test/membrane_element_fdk_aac/pipeline_test.exs b/test/membrane_element_fdk_aac/pipeline_test.exs index 237be82..46c1c07 100644 --- a/test/membrane_element_fdk_aac/pipeline_test.exs +++ b/test/membrane_element_fdk_aac/pipeline_test.exs @@ -34,9 +34,9 @@ defmodule Membrane.AAC.FDK.PipelineTest do def_output_pad :output, accepted_format: _any, flow_control: :push - @impl true - def handle_parent_notification(:send_end_of_stream, _ctx, state), do: {[end_of_stream: :output], state} + def handle_parent_notification(:send_end_of_stream, _ctx, state), + do: {[end_of_stream: :output], state} end describe "As part of the pipeline" do @@ -53,11 +53,13 @@ defmodule Membrane.AAC.FDK.PipelineTest do [{"Encoder", Encoder}, {"Decoder", Decoder}] |> Enum.map(fn {name, module} -> test "#{name} can receive end of stream without start of stream" do - pipeline = Testing.Pipeline.start_link_supervised!(spec: - child(:source, SimpleSource) - |> child(unquote(module)) - |> child(:sink, Testing.Sink) - ) + pipeline = + Testing.Pipeline.start_link_supervised!( + spec: + child(:source, SimpleSource) + |> child(unquote(module)) + |> child(:sink, Testing.Sink) + ) Process.sleep(500) Testing.Pipeline.notify_child(pipeline, :source, :send_end_of_stream) @@ -66,7 +68,6 @@ defmodule Membrane.AAC.FDK.PipelineTest do Testing.Pipeline.terminate(pipeline) end - end) end end