hlsdemux2: Fix getting starting segment on live playlists

When dealing with live streams, the function was assuming that all segments of
the playlist had valid stream_time. But that isn't TRUE, for example in the case
of failing to synchronize playlists.

Fixes losing sync due to not being able to match playlist on updates

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6961>
This commit is contained in:
Edward Hervey 2024-04-08 16:13:13 +02:00 committed by GStreamer Marge Bot
parent 0ca5517d80
commit 59582e2ffe

View file

@ -2124,11 +2124,13 @@ gst_hls_media_playlist_get_starting_segment (GstHLSMediaPlaylist * self,
}
if (GST_CLOCK_TIME_IS_VALID (hold_back)) {
GstM3U8MediaSegment *last_seg =
g_ptr_array_index (self->segments, self->segments->len - 1);
if (GST_CLOCK_STIME_IS_VALID (last_seg->stream_time)) {
GstSeekFlags flags =
GST_SEEK_FLAG_SNAP_BEFORE | GST_SEEK_FLAG_KEY_UNIT |
GST_HLS_M3U8_SEEK_FLAG_ALLOW_PARTIAL;
GstM3U8MediaSegment *last_seg =
g_ptr_array_index (self->segments, self->segments->len - 1);
GstClockTime playlist_duration =
last_seg->stream_time + last_seg->duration;
GstClockTime target_ts;
@ -2157,6 +2159,7 @@ gst_hls_media_playlist_get_starting_segment (GstHLSMediaPlaylist * self,
return TRUE;
}
}
}
/* Worst case fallback, start 3 fragments from the end */
if (res == NULL) {