From: Edward Hervey Date: Mon, 23 May 2022 13:43:04 +0000 (+0200) Subject: adaptivedemux2: Handle loss of synchronization X-Git-Tag: 1.22.0~1376 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d88d7d5b552b326834ac3f65cd08c335b202e861;p=platform%2Fupstream%2Fgstreamer.git adaptivedemux2: Handle loss of synchronization Add a new custom GstFlowReturn so that subclasses can notify that they have lost live synchronization. When that happens, do a flushing seek back to the live position Part-of: --- diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux-private.h b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux-private.h index a0c4bf9..1194c11 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux-private.h +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux-private.h @@ -196,6 +196,8 @@ void gst_adaptive_demux_advance_period (GstAdaptiveDemux * demux); void gst_adaptive_demux2_stream_stop (GstAdaptiveDemux2Stream * stream); +gboolean gst_adaptive_demux_handle_lost_sync (GstAdaptiveDemux * demux); + typedef struct { GstMiniObject *item; diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux-stream.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux-stream.c index a79cc1d..c331353 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux-stream.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux-stream.c @@ -1715,6 +1715,12 @@ gst_adaptive_demux2_stream_load_a_fragment (GstAdaptiveDemux2Stream * stream) GST_DEBUG_OBJECT (stream, "EOS, checking to stop download loop"); gst_adaptive_demux2_stream_handle_playlist_eos (stream); return FALSE; + case GST_ADAPTIVE_DEMUX_FLOW_LOST_SYNC: + GST_DEBUG_OBJECT (stream, "Lost sync, asking reset to current position"); + stream->state = GST_ADAPTIVE_DEMUX2_STREAM_STATE_STOPPED; + gst_adaptive_demux_loop_call (demux->priv->scheduler_task, + (GSourceFunc) gst_adaptive_demux_handle_lost_sync, demux, NULL); + return FALSE; case GST_FLOW_NOT_LINKED: { stream->state = GST_ADAPTIVE_DEMUX2_STREAM_STATE_EOS; diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux.c index 8452ea6..d4734d3 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux.c @@ -2788,6 +2788,22 @@ gst_adaptive_demux_src_query (GstPad * pad, GstObject * parent, return ret; } +gboolean +gst_adaptive_demux_handle_lost_sync (GstAdaptiveDemux * demux) +{ + GstEvent *seek; + + GST_WARNING_OBJECT (demux, "Lost synchronization, seeking back to live head"); + + seek = + gst_event_new_seek (1.0, GST_FORMAT_TIME, + GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT, GST_SEEK_TYPE_END, 0, + GST_SEEK_TYPE_NONE, 0); + gst_adaptive_demux_handle_seek_event (demux, seek); + return FALSE; +} + + /* Called when the scheduler starts, to kick off manifest updates * and stream downloads */ static gboolean diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux.h b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux.h index 9a118ed..da1fe39 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux.h +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/gstadaptivedemux.h @@ -105,6 +105,9 @@ typedef GstObjectClass GstAdaptiveDemux2StreamClass; */ #define GST_ADAPTIVE_DEMUX_FLOW_RESTART_FRAGMENT GST_FLOW_CUSTOM_SUCCESS_2 +/* The live stream has lost synchronization and the demuxer needs to be resetted */ +#define GST_ADAPTIVE_DEMUX_FLOW_LOST_SYNC GST_FLOW_CUSTOM_ERROR_1 + typedef enum _GstAdaptiveDemux2StreamState GstAdaptiveDemux2StreamState; typedef struct _GstAdaptiveDemux2StreamFragment GstAdaptiveDemux2StreamFragment;