(uri)decodebin3: Ensure group-id consistency
authorEdward Hervey <edward@centricular.com>
Tue, 9 Aug 2022 14:31:26 +0000 (16:31 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 23 Nov 2022 12:19:21 +0000 (12:19 +0000)
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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3457>

subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c
subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c

index 65814f2..97a476b 100644 (file)
@@ -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);
 }
index 7324571..109883f 100644 (file)
@@ -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,