Skip to content

Commit

Permalink
Prototype to continue streams where we left off
Browse files Browse the repository at this point in the history
  • Loading branch information
philipgiuliani committed Oct 3, 2024
1 parent d779309 commit 411b80e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
24 changes: 15 additions & 9 deletions lib/membrane/hls/filler/text_filler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,23 @@ defmodule Membrane.HLS.TextFiller do
if state.filled do
{[forward: buffer], state}
else
Membrane.Logger.debug(
"Generated empty text buffer with a duration of #{buffer.pts - state.from - Membrane.Time.millisecond()}"
)
duration = buffer.pts - state.from - Membrane.Time.millisecond()

silence_buffer = %Membrane.Buffer{
payload: "",
pts: state.from,
metadata: %{to: buffer.pts - Membrane.Time.millisecond()}
}
if duration > 0 do
Membrane.Logger.warning(
"Generated empty text buffer with a duration of #{buffer.pts - state.from - Membrane.Time.millisecond()}"
)

{[buffer: {:output, [silence_buffer, buffer]}], %{state | filled: true}}
silence_buffer = %Membrane.Buffer{
payload: "",
pts: state.from,
metadata: %{to: buffer.pts - Membrane.Time.millisecond()}
}

{[buffer: {:output, [silence_buffer, buffer]}], %{state | filled: true}}
else
{[forward: buffer], state}
end
end
end
end
14 changes: 7 additions & 7 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: max_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: max_pts})
|> child({:muxer, track_id}, %Membrane.MP4.Muxer.CMAF{
segment_min_duration: pad_opts.segment_duration
})
Expand All @@ -177,12 +177,12 @@ 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({:filler, track_id}, %Membrane.HLS.TextFiller{from: track_pts})
|> child({:shifter, track_id}, %Membrane.HLS.Shifter{duration: max_pts})
|> child({:filler, track_id}, %Membrane.HLS.TextFiller{from: track_pts})
|> child({:cues, track_id}, Membrane.WebVTT.CueBuilderFilter)
|> child({:segments, track_id}, %Membrane.WebVTT.SegmentFilter{
segment_duration: pad_opts.segment_duration,
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"bunch": {:hex, :bunch, "1.6.1", "5393d827a64d5f846092703441ea50e65bc09f37fd8e320878f13e63d410aec7", [:mix], [], "hexpm", "286cc3add551628b30605efbe2fca4e38cc1bea89bcd0a1a7226920b3364fe4a"},
"coerce": {:hex, :coerce, "1.0.1", "211c27386315dc2894ac11bc1f413a0e38505d808153367bd5c6e75a4003d096", [:mix], [], "hexpm", "b44a691700f7a1a15b4b7e2ff1fa30bebd669929ac8aa43cffe9e2f8bf051cf1"},
"heap": {:hex, :heap, "2.0.2", "d98cb178286cfeb5edbcf17785e2d20af73ca57b5a2cf4af584118afbcf917eb", [:mix], [], "hexpm", "ba9ea2fe99eb4bcbd9a8a28eaf71cbcac449ca1d8e71731596aace9028c9d429"},
"kim_hls": {:git, "https://github.com/kim-company/kim_hls.git", "8d9526dd0ed72aad6ac8a54348bb75080a14b037", []},
"kim_hls": {:git, "https://github.com/kim-company/kim_hls.git", "3afc81306caaebeda30294bd14456abfffcd954c", []},
"kim_q": {:hex, :kim_q, "1.0.0", "17cfc45e9f7e65485f0f31bbf09893d6ff35cc2fbefc39aed146a3c29740584e", [:mix], [{:qex, "~> 0.5", [hex: :qex, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7a8ee76a2c2e774c34345df3c7a234a8effeedc3f3aea845feb7c09030097278"},
"kim_subtitle": {:git, "https://github.com/kim-company/kim_subtitle.git", "8239e1bcea938167829a6b8bd2a9678c63c7bdd4", []},
"logger_backends": {:hex, :logger_backends, "1.0.0", "09c4fad6202e08cb0fbd37f328282f16539aca380f512523ce9472b28edc6bdf", [:mix], [], "hexpm", "1faceb3e7ec3ef66a8f5746c5afd020e63996df6fd4eb8cdb789e5665ae6c9ce"},
Expand Down

0 comments on commit 411b80e

Please sign in to comment.