From 964ee0299dfe91f4e77e8399405870e3d6d27345 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Thu, 21 Apr 2022 11:47:55 +0200 Subject: [PATCH] hls/m3u8: Fix starting segment for live playlist RFC 8216 6.3.3 "Playing the Media Playlist File" : states that for live media playlists "the client SHOULD NOT choose a segment that starts less than three target durations from the end of the Playlist file" This is an off-by-one error. Since we are looking for the "index" of the segment, we need to subtract 1 from the searched position. Ex: For a playlist with 12 entries, we want to start playback on the 9th segment ... which is at index 8. Part-of: --- subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c index f976b2fb6d..0b8bf165d9 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c @@ -1124,8 +1124,8 @@ gst_hls_media_playlist_get_starting_segment (GstHLSMediaPlaylist * self) /* Live playlist */ res = g_ptr_array_index (self->segments, - MAX ((gint) self->segments->len - GST_M3U8_LIVE_MIN_FRAGMENT_DISTANCE, - 0)); + MAX ((gint) self->segments->len - GST_M3U8_LIVE_MIN_FRAGMENT_DISTANCE - + 1, 0)); } if (res) {