parsebin: Set stream collection on pad before exposing it
authorEdward Hervey <edward@centricular.com>
Thu, 3 Oct 2024 15:09:13 +0000 (17:09 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 18 Oct 2024 10:13:13 +0000 (10:13 +0000)
We want to ensure the stream-collection is present on the pad (as a sticky
event) before we expose the pad.

This is more reliable since it will ensure it is present before any other event
is pushed through.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7682>

subprojects/gst-plugins-base/gst/playback/gstparsebin.c

index b686f9ce5c0dd8abe0e39168927239d65fbcfc21..e6bcc955a56f39099354cfc07d2002422d3a663b 100644 (file)
@@ -3715,6 +3715,14 @@ retry:
     gst_pad_sticky_events_foreach (GST_PAD_CAST (parsepad), debug_sticky_event,
         parsepad);
 
+    /* Store the stream-collection event on the pad */
+    if (parsepad->active_collection == NULL && fallback_collection) {
+      GstEvent *new_collection =
+          gst_event_new_stream_collection (fallback_collection);
+      gst_pad_store_sticky_event (GST_PAD (parsepad), new_collection);
+      gst_event_unref (new_collection);
+    }
+
     /* 2. activate and add */
     parsepad->exposed = TRUE;
     if (!gst_element_add_pad (GST_ELEMENT (parsebin), GST_PAD_CAST (parsepad))) {
@@ -3739,13 +3747,6 @@ retry:
       gst_parse_pad_unblock (parsepad);
       GST_DEBUG_OBJECT (parsepad, "unblocked");
     }
-
-    /* Send stream-collection events for any pads that don't have them,
-     * and post a stream-collection onto the bus */
-    if (parsepad->active_collection == NULL && fallback_collection) {
-      gst_pad_push_event (GST_PAD (parsepad),
-          gst_event_new_stream_collection (fallback_collection));
-    }
     gst_object_unref (parsepad);
   }
   g_list_free (endpads);