Skip to content

Commit

Permalink
Always notify pipeline about end of stream
Browse files Browse the repository at this point in the history
  • Loading branch information
philipgiuliani committed Oct 8, 2024
1 parent 5b71373 commit 6c3dfe5
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions lib/membrane/hls/sink_bin.ex
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ defmodule Membrane.HLS.SinkBin do
%{pad_options: %{encoding: :AAC} = pad_opts},
state
) do
{max_pts, _track_pts} = resume_info(state.packager_pid, track_id)
{_max_pts, track_pts} = resume_info(state.packager_pid, track_id)

spec =
bin_input(pad)
|> child({:shifter, track_id}, %Membrane.HLS.Shifter{duration: max_pts})
|> child({:shifter, track_id}, %Membrane.HLS.Shifter{duration: track_pts})
|> via_in(Pad.ref(:input, track_id))
|> child({:muxer, track_id}, %Membrane.MP4.Muxer.CMAF{
segment_min_duration: pad_opts.segment_duration
Expand All @@ -154,11 +154,11 @@ defmodule Membrane.HLS.SinkBin do
%{pad_options: %{encoding: :H264} = pad_opts},
state
) do
{max_pts, _track_pts} = resume_info(state.packager_pid, track_id)
{_max_pts, track_pts} = resume_info(state.packager_pid, track_id)

spec =
bin_input(pad)
|> child({:shifter, track_id}, %Membrane.HLS.Shifter{duration: max_pts})
|> child({:shifter, track_id}, %Membrane.HLS.Shifter{duration: track_pts})
|> child({:muxer, track_id}, %Membrane.MP4.Muxer.CMAF{
segment_min_duration: pad_opts.segment_duration
})
Expand All @@ -177,11 +177,11 @@ defmodule Membrane.HLS.SinkBin do
%{pad_options: %{encoding: :TEXT} = pad_opts},
state
) do
{max_pts, track_pts} = resume_info(state.packager_pid, track_id)
{_max_pts, track_pts} = resume_info(state.packager_pid, track_id)

spec =
bin_input(pad)
|> child({:shifter, track_id}, %Membrane.HLS.Shifter{duration: max_pts})
|> child({:shifter, track_id}, %Membrane.HLS.Shifter{duration: track_pts})
|> child({:filler, track_id}, %Membrane.HLS.TextFiller{from: track_pts})
|> child({:cues, track_id}, %Membrane.WebVTT.CueBuilderFilter{
min_duration: Membrane.Time.milliseconds(1500)
Expand Down Expand Up @@ -212,12 +212,9 @@ defmodule Membrane.HLS.SinkBin do
|> put_in([:live_state], %{stop: true})
|> put_in([:ended_sinks], ended_sinks)

if state.flush do
Agent.update(state.packager_pid, &Packager.flush/1, :infinity)
{[notify_parent: :end_of_stream], state}
else
{[], state}
end
if state.flush, do: Agent.update(state.packager_pid, &Packager.flush/1, :infinity)

{[notify_parent: :end_of_stream], state}
else
{[], %{state | ended_sinks: ended_sinks}}
end
Expand Down

0 comments on commit 6c3dfe5

Please sign in to comment.