mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-30 04:00:37 +00:00
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/6610>
This commit is contained in:
parent
1126c1d90e
commit
81c42ee14b
1 changed files with 25 additions and 22 deletions
|
@ -2124,37 +2124,40 @@ gst_hls_media_playlist_get_starting_segment (GstHLSMediaPlaylist * self,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GST_CLOCK_TIME_IS_VALID (hold_back)) {
|
if (GST_CLOCK_TIME_IS_VALID (hold_back)) {
|
||||||
GstSeekFlags flags =
|
|
||||||
GST_SEEK_FLAG_SNAP_BEFORE | GST_SEEK_FLAG_KEY_UNIT |
|
|
||||||
GST_HLS_M3U8_SEEK_FLAG_ALLOW_PARTIAL;
|
|
||||||
GstM3U8MediaSegment *last_seg =
|
GstM3U8MediaSegment *last_seg =
|
||||||
g_ptr_array_index (self->segments, self->segments->len - 1);
|
g_ptr_array_index (self->segments, self->segments->len - 1);
|
||||||
GstClockTime playlist_duration =
|
|
||||||
last_seg->stream_time + last_seg->duration;
|
|
||||||
GstClockTime target_ts;
|
|
||||||
|
|
||||||
/* Clamp the hold back so we don't go below zero */
|
if (GST_CLOCK_STIME_IS_VALID (last_seg->stream_time)) {
|
||||||
if (hold_back > playlist_duration)
|
GstSeekFlags flags =
|
||||||
hold_back = playlist_duration;
|
GST_SEEK_FLAG_SNAP_BEFORE | GST_SEEK_FLAG_KEY_UNIT |
|
||||||
|
GST_HLS_M3U8_SEEK_FLAG_ALLOW_PARTIAL;
|
||||||
|
GstClockTime playlist_duration =
|
||||||
|
last_seg->stream_time + last_seg->duration;
|
||||||
|
GstClockTime target_ts;
|
||||||
|
|
||||||
target_ts = playlist_duration - hold_back;
|
/* Clamp the hold back so we don't go below zero */
|
||||||
|
if (hold_back > playlist_duration)
|
||||||
|
hold_back = playlist_duration;
|
||||||
|
|
||||||
GST_DEBUG ("Hold back is %" GST_TIME_FORMAT
|
target_ts = playlist_duration - hold_back;
|
||||||
" Looking for a segment before %" GST_TIME_FORMAT,
|
|
||||||
GST_TIME_ARGS (hold_back), GST_TIME_ARGS (target_ts));
|
|
||||||
|
|
||||||
if (gst_hls_media_playlist_seek (self, TRUE, flags, target_ts,
|
GST_DEBUG ("Hold back is %" GST_TIME_FORMAT
|
||||||
seek_result)) {
|
" Looking for a segment before %" GST_TIME_FORMAT,
|
||||||
|
GST_TIME_ARGS (hold_back), GST_TIME_ARGS (target_ts));
|
||||||
|
|
||||||
|
if (gst_hls_media_playlist_seek (self, TRUE, flags, target_ts,
|
||||||
|
seek_result)) {
|
||||||
#ifndef GST_DISABLE_GST_DEBUG
|
#ifndef GST_DISABLE_GST_DEBUG
|
||||||
GstClockTime distance_from_edge =
|
GstClockTime distance_from_edge =
|
||||||
playlist_duration - seek_result->stream_time;
|
playlist_duration - seek_result->stream_time;
|
||||||
|
|
||||||
GST_DEBUG ("Found starting position %" GST_TIME_FORMAT " which is %"
|
GST_DEBUG ("Found starting position %" GST_TIME_FORMAT " which is %"
|
||||||
GST_TIME_FORMAT " from the live edge",
|
GST_TIME_FORMAT " from the live edge",
|
||||||
GST_TIME_ARGS (seek_result->stream_time),
|
GST_TIME_ARGS (seek_result->stream_time),
|
||||||
GST_TIME_ARGS (distance_from_edge));
|
GST_TIME_ARGS (distance_from_edge));
|
||||||
#endif
|
#endif
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue