mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
hlsdemux2: Detect synchronization loss
If we have been updating too slowly and have gone out of the current live window, inform the baseclass accordingly. This is different from the case where we have been updating quicker than what the server provides. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2679>
This commit is contained in:
parent
9cdadf6d08
commit
87ab729551
3 changed files with 33 additions and 2 deletions
|
@ -2105,6 +2105,11 @@ gst_hls_demux_update_fragment_info (GstAdaptiveDemux2Stream * stream)
|
|||
gst_hls_media_playlist_get_starting_segment
|
||||
(hlsdemux_stream->playlist);
|
||||
} else {
|
||||
if (gst_hls_media_playlist_has_lost_sync (hlsdemux_stream->playlist,
|
||||
stream->current_position)) {
|
||||
GST_WARNING_OBJECT (stream, "Lost SYNC !");
|
||||
return GST_ADAPTIVE_DEMUX_FLOW_LOST_SYNC;
|
||||
}
|
||||
GST_DEBUG_OBJECT (stream,
|
||||
"Looking up segment for position %" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (stream->current_position));
|
||||
|
@ -2113,8 +2118,7 @@ gst_hls_demux_update_fragment_info (GstAdaptiveDemux2Stream * stream)
|
|||
GST_SEEK_FLAG_SNAP_NEAREST, stream->current_position);
|
||||
|
||||
if (hlsdemux_stream->current_segment == NULL) {
|
||||
GST_INFO_OBJECT (hlsdemux,
|
||||
"This playlist doesn't contain more fragments");
|
||||
GST_INFO_OBJECT (stream, "At the end of the current media playlist");
|
||||
return GST_FLOW_EOS;
|
||||
}
|
||||
|
||||
|
|
|
@ -1385,6 +1385,29 @@ out:
|
|||
return ret;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_hls_media_playlist_has_lost_sync (GstHLSMediaPlaylist * m3u8,
|
||||
GstClockTime position)
|
||||
{
|
||||
GstM3U8MediaSegment *first;
|
||||
|
||||
if (m3u8->segments->len < 1)
|
||||
return TRUE;
|
||||
first = g_ptr_array_index (m3u8->segments, 0);
|
||||
|
||||
GST_DEBUG ("position %" GST_TIME_FORMAT " first %" GST_STIME_FORMAT
|
||||
" duration %" GST_STIME_FORMAT, GST_TIME_ARGS (position),
|
||||
GST_STIME_ARGS (first->stream_time), GST_STIME_ARGS (first->duration));
|
||||
|
||||
if (first->stream_time <= 0)
|
||||
return FALSE;
|
||||
|
||||
/* If we're definitely before the first fragment, we lost sync */
|
||||
if ((position + (first->duration / 2)) < first->stream_time)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_hls_media_playlist_get_seek_range (GstHLSMediaPlaylist * m3u8,
|
||||
gint64 * start, gint64 * stop)
|
||||
|
|
|
@ -213,6 +213,10 @@ gst_hls_media_playlist_get_seek_range (GstHLSMediaPlaylist * m3u8,
|
|||
gint64 * start,
|
||||
gint64 * stop);
|
||||
|
||||
gboolean
|
||||
gst_hls_media_playlist_has_lost_sync (GstHLSMediaPlaylist * m3u8,
|
||||
GstClockTime position);
|
||||
|
||||
GstM3U8MediaSegment *
|
||||
gst_hls_media_playlist_seek (GstHLSMediaPlaylist *playlist,
|
||||
gboolean forward,
|
||||
|
|
Loading…
Reference in a new issue