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));
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;
}
}
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)
{
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,