mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 15:27:07 +00:00
hlsdemux2: Minor refactoring of starting segment check
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6610>
This commit is contained in:
parent
5bc9883d68
commit
c924e4cc1e
1 changed files with 28 additions and 28 deletions
|
@ -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,41 +2139,37 @@ 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_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;
|
||||
GstClockTime playlist_duration =
|
||||
last_seg->stream_time + last_seg->duration;
|
||||
GstClockTime target_ts;
|
||||
|
||||
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;
|
||||
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 (hold_back > playlist_duration)
|
||||
hold_back = playlist_duration;
|
||||
|
||||
/* Clamp the hold back so we don't go below zero */
|
||||
if (hold_back > playlist_duration)
|
||||
hold_back = playlist_duration;
|
||||
target_ts = playlist_duration - hold_back;
|
||||
|
||||
target_ts = playlist_duration - hold_back;
|
||||
GST_DEBUG ("Hold back is %" GST_TIME_FORMAT
|
||||
" Looking for a segment before %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (hold_back), GST_TIME_ARGS (target_ts));
|
||||
|
||||
GST_DEBUG ("Hold back is %" GST_TIME_FORMAT
|
||||
" 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)) {
|
||||
if (gst_hls_media_playlist_seek (self, TRUE, flags, target_ts,
|
||||
seek_result)) {
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
GstClockTime distance_from_edge =
|
||||
playlist_duration - seek_result->stream_time;
|
||||
GstClockTime distance_from_edge =
|
||||
playlist_duration - seek_result->stream_time;
|
||||
|
||||
GST_DEBUG ("Found starting position %" GST_TIME_FORMAT " which is %"
|
||||
GST_TIME_FORMAT " from the live edge",
|
||||
GST_TIME_ARGS (seek_result->stream_time),
|
||||
GST_TIME_ARGS (distance_from_edge));
|
||||
GST_DEBUG ("Found starting position %" GST_TIME_FORMAT " which is %"
|
||||
GST_TIME_FORMAT " from the live edge",
|
||||
GST_TIME_ARGS (seek_result->stream_time),
|
||||
GST_TIME_ARGS (distance_from_edge));
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue