Skip to content

Commit

Permalink
Don't flush buffer if native is not ready
Browse files Browse the repository at this point in the history
  • Loading branch information
varsill committed Nov 5, 2024
1 parent 02831e7 commit 7049a7a
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions lib/membrane_rtmp_plugin/rtmp/sink/sink.ex
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,26 @@ defmodule Membrane.RTMP.Sink do

@impl true
def handle_end_of_stream(Pad.ref(type, 0), _ctx, state) do
if state.forward_mode? do
Native.finalize_stream(state.native)
{[], state}
else
# The interleave logic does not work if either one of the inputs does not
# produce buffers. From this point on we act as a "forward" filter.
other_pad =
case type do
:audio -> :video
:video -> :audio
end
|> then(&Pad.ref(&1, 0))

state = flush_frame_buffer(state)
{[demand: other_pad], %{state | forward_mode?: true}}
cond do
state.forward_mode? ->
Native.finalize_stream(state.native)
{[], state}

state.ready? ->
# The interleave logic does not work if either one of the inputs does not
# produce buffers. From this point on we act as a "forward" filter.
other_pad =
case type do
:audio -> :video
:video -> :audio
end
|> then(&Pad.ref(&1, 0))

state = flush_frame_buffer(state)
{[demand: other_pad], %{state | forward_mode?: true}}

true ->
{[], state}
end
end

Expand Down

0 comments on commit 7049a7a

Please sign in to comment.