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/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/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 af642eb..46c1c07 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,25 @@ 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