From de858437b429e6488c1d85c41ec83762cdb7b92c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Kita?= Date: Thu, 7 Nov 2024 11:56:10 +0100 Subject: [PATCH] Don't flush buffer if native is not ready (#108) * Don't flush buffers if native hasn't been initialized * Make unifex dependency version less strict * Bump to v0.27.3 --- README.md | 2 +- lib/membrane_rtmp_plugin/rtmp/sink/sink.ex | 35 ++++++++++++---------- mix.exs | 4 +-- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index d5eba5c2..c697d51e 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/lib/membrane_rtmp_plugin/rtmp/sink/sink.ex b/lib/membrane_rtmp_plugin/rtmp/sink/sink.ex index 1e947c57..5d4b1b4e 100644 --- a/lib/membrane_rtmp_plugin/rtmp/sink/sink.ex +++ b/lib/membrane_rtmp_plugin/rtmp/sink/sink.ex @@ -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 diff --git a/mix.exs b/mix.exs index d70f80d5..4dbd6f86 100644 --- a/mix.exs +++ b/mix.exs @@ -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 @@ -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"},