mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-21 07:46:38 +00:00
hlsdemux2: In live, match buffering to the hold back distance
When playing a live stream, make the recommended buffering threshold at most the hold-back distance from live. If we start 3 seconds from the live edge, there's no point trying to buffer more - we'll just hit the live edge and have to wait for more data to be available anyway. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883>
This commit is contained in:
parent
1e6550f623
commit
9edb2f6690
3 changed files with 29 additions and 4 deletions
|
@ -2836,7 +2836,7 @@ gst_hls_demux_stream_update_fragment_info (GstAdaptiveDemux2Stream * stream)
|
||||||
|
|
||||||
stream->recommended_buffering_threshold =
|
stream->recommended_buffering_threshold =
|
||||||
gst_hls_media_playlist_recommended_buffering_threshold
|
gst_hls_media_playlist_recommended_buffering_threshold
|
||||||
(hlsdemux_stream->playlist);
|
(hlsdemux_stream->playlist, hlsdemux_stream->llhls_enabled);
|
||||||
|
|
||||||
if (discont)
|
if (discont)
|
||||||
stream->discont = TRUE;
|
stream->discont = TRUE;
|
||||||
|
|
|
@ -2373,14 +2373,38 @@ gst_hls_media_playlist_get_seek_range (GstHLSMediaPlaylist * m3u8,
|
||||||
|
|
||||||
GstClockTime
|
GstClockTime
|
||||||
gst_hls_media_playlist_recommended_buffering_threshold (GstHLSMediaPlaylist *
|
gst_hls_media_playlist_recommended_buffering_threshold (GstHLSMediaPlaylist *
|
||||||
playlist)
|
playlist, gboolean low_latency)
|
||||||
{
|
{
|
||||||
if (!playlist->duration || !GST_CLOCK_TIME_IS_VALID (playlist->duration)
|
if (!playlist->duration || !GST_CLOCK_TIME_IS_VALID (playlist->duration)
|
||||||
|| playlist->segments->len == 0)
|
|| playlist->segments->len == 0)
|
||||||
return GST_CLOCK_TIME_NONE;
|
return GST_CLOCK_TIME_NONE;
|
||||||
|
|
||||||
/* The recommended buffering threshold is 1.5 average segment duration */
|
/* The recommended buffering threshold is 1.5 average segment duration */
|
||||||
return 3 * (playlist->duration / playlist->segments->len) / 2;
|
GstClockTime threshold =
|
||||||
|
3 * (playlist->duration / playlist->segments->len) / 2;
|
||||||
|
|
||||||
|
if (GST_HLS_MEDIA_PLAYLIST_IS_LIVE (playlist)) {
|
||||||
|
/* For live playlists, reduce the recommended buffering threshold
|
||||||
|
* to match the starting hold back distance if needed, otherwise
|
||||||
|
* we'll hit the live edge and have to wait before we hit 100% */
|
||||||
|
if (GST_CLOCK_TIME_IS_VALID (playlist->hold_back)
|
||||||
|
&& threshold > playlist->hold_back)
|
||||||
|
threshold = playlist->hold_back;
|
||||||
|
else if (GST_CLOCK_TIME_IS_VALID (playlist->targetduration)
|
||||||
|
&& threshold > playlist->targetduration)
|
||||||
|
threshold = 3 * playlist->targetduration;
|
||||||
|
|
||||||
|
if (low_latency) {
|
||||||
|
if (GST_CLOCK_TIME_IS_VALID (playlist->part_hold_back)
|
||||||
|
&& 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
GstHLSRenditionStream *
|
GstHLSRenditionStream *
|
||||||
|
|
|
@ -343,7 +343,8 @@ void
|
||||||
gst_hls_media_playlist_dump (GstHLSMediaPlaylist* self);
|
gst_hls_media_playlist_dump (GstHLSMediaPlaylist* self);
|
||||||
|
|
||||||
GstClockTime
|
GstClockTime
|
||||||
gst_hls_media_playlist_recommended_buffering_threshold (GstHLSMediaPlaylist *playlist);
|
gst_hls_media_playlist_recommended_buffering_threshold (GstHLSMediaPlaylist *
|
||||||
|
playlist, gboolean low_latency);
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue