From 1fe99ebae185400609598fd6b2196148637e8727 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 11 Jan 2023 17:30:09 +0100 Subject: [PATCH] decodebin3: Fix global group-id handling The goal of the "global" group-id is to fix new inputs that do not come from the same "source" as others. In order to ensure all "current" streams have the same group-id we distribute the first valid group-id to all streams. This commit fixes two issues with that: * When inputs are unlinked they weren't always properly resetted (it would only work if parsebin is used, which is no longer the default in uridecodebin3/playbin3). * When computing the global group-id, take into account unset group-id (i.e. GST_GROUP_ID_INVALID). Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1698 Part-of: --- .../gst-plugins-base/gst/playback/gstdecodebin3.c | 31 +++++++++++++++------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c b/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c index a049e23..6cff8c4 100644 --- a/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c +++ b/subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c @@ -816,6 +816,9 @@ set_input_group_id (DecodebinInput * input, guint32 * group_id) GST_DEBUG_OBJECT (dbin, "Setting current group id to %" G_GUINT32_FORMAT, *group_id); dbin->current_group_id = *group_id; + } else { + GST_DEBUG_OBJECT (dbin, "Returning global group id %" G_GUINT32_FORMAT, + dbin->current_group_id); } *group_id = dbin->current_group_id; return TRUE; @@ -979,18 +982,30 @@ recalculate_group_id (GstDecodebin3 * dbin) guint32 common_group_id; GList *iter; + GST_DEBUG_OBJECT (dbin, + "recalculating, current global group_id: %" G_GUINT32_FORMAT, + dbin->current_group_id); + common_group_id = dbin->main_input->group_id; for (iter = dbin->other_inputs; iter; iter = iter->next) { DecodebinInput *input = iter->data; - if (input->group_id != common_group_id) - return; + if (input->group_id != common_group_id) { + if (common_group_id != GST_GROUP_ID_INVALID) + return; + + common_group_id = input->group_id; + } } - GST_DEBUG_OBJECT (dbin, "Updating global group_id to %" G_GUINT32_FORMAT, - common_group_id); - dbin->current_group_id = common_group_id; + if (common_group_id == dbin->current_group_id) { + GST_DEBUG_OBJECT (dbin, "Global group_id hasn't changed"); + } else { + GST_DEBUG_OBJECT (dbin, "Updating global group_id to %" G_GUINT32_FORMAT, + common_group_id); + dbin->current_group_id = common_group_id; + } } /* CALL with INPUT LOCK */ @@ -1032,12 +1047,8 @@ gst_decodebin3_input_pad_unlink (GstPad * pad, GstPad * peer, GST_LOG_OBJECT (dbin, "Got unlink on input pad %" GST_PTR_FORMAT, pad); INPUT_LOCK (dbin); - if (input->parsebin == NULL) { - INPUT_UNLOCK (dbin); - return; - } - if (GST_PAD_MODE (pad) == GST_PAD_MODE_PULL) { + if (input->parsebin && GST_PAD_MODE (pad) == GST_PAD_MODE_PULL) { GST_DEBUG_OBJECT (dbin, "Resetting parsebin since it's pull-based"); reset_input_parsebin (dbin, input); } -- 2.7.4