Skip to content

Commit

Permalink
Don't flush buffer if native is not ready (#108)
Browse files Browse the repository at this point in the history
* Don't flush buffers if native hasn't been initialized
* Make unifex dependency version less strict
* Bump to v0.27.3
  • Loading branch information
varsill authored Nov 7, 2024
1 parent 02831e7 commit de85843
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The package can be installed by adding `membrane_rtmp_plugin` to your list of de
```elixir
def deps do
[
{:membrane_rtmp_plugin, "~> 0.27.2"}
{:membrane_rtmp_plugin, "~> 0.27.3"}
]
end
```
Expand Down
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
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Membrane.RTMP.Mixfile do
use Mix.Project

@version "0.27.2"
@version "0.27.3"
@github_url "https://github.com/membraneframework/membrane_rtmp_plugin"

def project do
Expand Down Expand Up @@ -39,7 +39,7 @@ defmodule Membrane.RTMP.Mixfile do
defp deps do
[
{:membrane_core, "~> 1.0"},
{:unifex, "~> 1.2.0"},
{:unifex, "~> 1.2"},
{:membrane_precompiled_dependency_provider, "~> 0.1.0"},
{:membrane_h26x_plugin, "~> 0.10.0"},
{:membrane_h264_format, "~> 0.6.1"},
Expand Down

0 comments on commit de85843

Please sign in to comment.