Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle EoS without SoS in Encoder #61

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
7 changes: 6 additions & 1 deletion lib/membrane_aac_fdk_plugin/encoder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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 != <<>>,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
35 changes: 35 additions & 0 deletions test/membrane_element_fdk_aac/pipeline_test.exs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -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
Loading