hlsdemux2: Minor refactoring of starting segment check

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6610>
This commit is contained in:
Edward Hervey 2024-05-28 13:04:20 +02:00 committed by GStreamer Marge Bot
parent 5bc9883d68
commit c924e4cc1e

View file

@ -2110,6 +2110,10 @@ gst_hls_media_playlist_get_starting_segment (GstHLSMediaPlaylist * self,
res = g_ptr_array_index (self->segments, 0);
} else {
GstClockTime hold_back = GST_CLOCK_TIME_NONE;
GstM3U8MediaSegment *last_seg;
g_assert (self->segments->len);
last_seg = g_ptr_array_index (self->segments, self->segments->len - 1);
/* Live playlist. If low-latency, use the PART-HOLD-BACK specified distance
* from the end, otherwise HOLD-BACK distance */
if (GST_CLOCK_TIME_IS_VALID (self->part_hold_back))
@ -2135,11 +2139,8 @@ gst_hls_media_playlist_get_starting_segment (GstHLSMediaPlaylist * self,
hold_back = GST_M3U8_LIVE_MIN_FRAGMENT_DISTANCE * self->targetduration;
}
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)) {
if (GST_CLOCK_TIME_IS_VALID (hold_back)
&& 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;
@ -2171,7 +2172,6 @@ gst_hls_media_playlist_get_starting_segment (GstHLSMediaPlaylist * self,
return TRUE;
}
}
}
/* Worst case fallback, start 3 fragments from the end */
if (res == NULL) {