From 3129970c8adaf185dcfe0653c4dc2d933fa496b3 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 4 Jan 2023 11:16:14 +0100 Subject: [PATCH] hlsdemux2: Fix buffering threshold calculation and handling * The checks for smaller values were wrong * Properly initialize the stream default recommended buffering threshold so that a default (10s) value is used until the subclass can provide a proper value Part-of: --- .../ext/adaptivedemux2/gstadaptivedemux-stream.c | 2 ++ subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux-stream.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux-stream.c index a790410f65..fef76be7c6 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux-stream.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux-stream.c @@ -86,6 +86,8 @@ gst_adaptive_demux2_stream_init (GstAdaptiveDemux2Stream * stream) stream->last_ret = GST_FLOW_OK; stream->next_input_wakeup_time = GST_CLOCK_STIME_NONE; + stream->recommended_buffering_threshold = GST_CLOCK_TIME_NONE; + stream->fragment_bitrates = g_malloc0 (sizeof (guint64) * NUM_LOOKBACK_FRAGMENTS); diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c index fc12024d99..1a7503be52 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c @@ -2547,7 +2547,7 @@ gst_hls_media_playlist_recommended_buffering_threshold (GstHLSMediaPlaylist * && threshold > playlist->hold_back) threshold = playlist->hold_back; else if (GST_CLOCK_TIME_IS_VALID (playlist->targetduration) - && threshold > playlist->targetduration) + && threshold > 3 * playlist->targetduration) threshold = 3 * playlist->targetduration; if (low_latency) { @@ -2555,7 +2555,7 @@ gst_hls_media_playlist_recommended_buffering_threshold (GstHLSMediaPlaylist * && threshold > playlist->part_hold_back) threshold = playlist->part_hold_back; else if (GST_CLOCK_TIME_IS_VALID (playlist->partial_targetduration) - && threshold > playlist->partial_targetduration) + && threshold > 3 * playlist->partial_targetduration) threshold = 3 * playlist->partial_targetduration; } }