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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2679>
void gst_adaptive_demux2_stream_stop (GstAdaptiveDemux2Stream * stream);
+gboolean gst_adaptive_demux_handle_lost_sync (GstAdaptiveDemux * demux);
+
typedef struct
{
GstMiniObject *item;
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;
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
*/
#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;