From 734a4554f3aa4cae0ca361e9f96892541a7253d4 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Tue, 9 Aug 2022 16:31:26 +0200 Subject: [PATCH] (uri)decodebin3: Ensure group-id consistency Make sure that group-id of a given play item are made consistent from the start (sources) and all the way through the output. This ensures that we can reliably detect that we have switched to the next play item on the output of decodebin3 (and we can therefore properly free/release it) Part-of: --- .../gst/playback/gstdecodebin3.c | 4 ++++ .../gst/playback/gsturidecodebin3.c | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c b/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c index 65814f2e0c..97a476b298 100644 --- a/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c +++ b/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c @@ -1036,6 +1036,10 @@ gst_decodebin3_input_pad_unlink (GstPad * pad, GstPad * peer, GST_DEBUG_OBJECT (dbin, "Resetting parsebin since it's pull-based"); reset_input_parsebin (dbin, input); } + /* In all cases we will be receiving new stream-start and data */ + input->group_id = GST_GROUP_ID_INVALID; + input->drained = FALSE; + recalculate_group_id (dbin); INPUT_UNLOCK (dbin); } diff --git a/subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c b/subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c index 7324571509..109883fe7d 100644 --- a/subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c +++ b/subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c @@ -688,7 +688,7 @@ add_output_pad (GstURIDecodeBin3 * dec, GstPad * target_pad) output->uridecodebin = dec; output->target_pad = target_pad; - output->current_group_id = (guint) - 1; + output->current_group_id = GST_GROUP_ID_INVALID; pad_name = gst_pad_get_name (target_pad); output->ghost_pad = gst_ghost_pad_new (pad_name, target_pad); g_free (pad_name); @@ -1173,7 +1173,22 @@ uri_src_probe (GstPad * pad, GstPadProbeInfo * info, GstSourcePad * srcpad) case GST_EVENT_STREAM_START: { GstStream *stream = NULL; + guint group_id = GST_GROUP_ID_INVALID; + srcpad->saw_eos = FALSE; + gst_event_parse_group_id (event, &group_id); + /* Unify group id */ + if (handler->play_item->group_id == GST_GROUP_ID_INVALID) { + GST_DEBUG_OBJECT (pad, + "Setting play item to group_id %" G_GUINT32_FORMAT, group_id); + handler->play_item->group_id = group_id; + } else if (handler->play_item->group_id != group_id) { + GST_DEBUG_OBJECT (pad, "Updating event group-id to %" G_GUINT32_FORMAT, + handler->play_item->group_id); + event = gst_event_make_writable (event); + GST_PAD_PROBE_INFO_DATA (info) = event; + gst_event_set_group_id (event, handler->play_item->group_id); + } gst_event_parse_stream (event, &stream); if (stream) { GST_DEBUG_OBJECT (srcpad->src_pad, "Got GstStream %" GST_PTR_FORMAT,