decodebin3: Don't insert parsebin if input is already parsed
authorEdward Hervey <edward@centricular.com>
Thu, 19 Jan 2023 15:25:51 +0000 (16:25 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 20 Jan 2023 08:54:00 +0000 (08:54 +0000)
This is a temporary workaround until we find a generic solution to indicate that
a stream has already been "parsed".

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

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

index 6cff8c4..92e17fb 100644 (file)
@@ -302,6 +302,10 @@ struct _DecodebinInput
 
   /* TRUE if the input got drained */
   gboolean drained;
+
+  /* TEMPORARY HACK for knowing if upstream is already parsed and identity can
+   * be avoided */
+  gboolean input_is_parsed;
 };
 
 /* Multiqueue Slots */
@@ -1231,6 +1235,9 @@ is_parsebin_required_for_input (GstDecodebin3 * dbin, DecodebinInput * input,
     /* If the incoming caps match decodebin3 output, no processing is needed */
     GST_FIXME_OBJECT (sinkpad, "parsebin not needed (matches output caps) !");
     parsebin_needed = FALSE;
+  } else if (input->input_is_parsed) {
+    GST_DEBUG_OBJECT (sinkpad, "input is parsed, no parsebin needed");
+    parsebin_needed = FALSE;
   } else {
     GList *decoder_list;
     /* If the incoming caps are compatible with a decoder, we don't need to
@@ -1301,6 +1308,7 @@ sink_event_function (GstPad * sinkpad, GstDecodebin3 * dbin, GstEvent * event)
     case GST_EVENT_STREAM_START:
     {
       GstQuery *q = gst_query_new_selectable ();
+      const GstStructure *s = gst_event_get_structure (event);
 
       /* Query whether upstream can handle stream selection or not */
       if (gst_pad_peer_query (sinkpad, q)) {
@@ -1318,6 +1326,9 @@ sink_event_function (GstPad * sinkpad, GstDecodebin3 * dbin, GstEvent * event)
       if (input->upstream_selected)
         dbin->upstream_selected = TRUE;
 
+      input->input_is_parsed = s
+          && gst_structure_has_field (s, "urisourcebin-parsed-data");
+
       /* Make sure group ids will be recalculated */
       input->group_id = GST_GROUP_ID_INVALID;
       INPUT_LOCK (dbin);
index f108caf..1350824 100644 (file)
@@ -844,6 +844,18 @@ demux_pad_events (GstPad * pad, GstPadProbeInfo * info, OutputSlotInfo * slot)
     }
       break;
     case GST_EVENT_STREAM_START:
+    {
+      /* This is a temporary hack to notify downstream decodebin3 to *not*
+       * plug in an extra parsebin */
+      if (slot->linked_info && slot->linked_info->demuxer_is_parsebin) {
+        GstStructure *s;
+        GST_PAD_PROBE_INFO_DATA (info) = ev = gst_event_make_writable (ev);
+        s = (GstStructure *) gst_event_get_structure (ev);
+        gst_structure_set (s, "urisourcebin-parsed-data", G_TYPE_BOOLEAN, TRUE,
+            NULL);
+      }
+    }
+      /* PASSTHROUGH */
     case GST_EVENT_FLUSH_STOP:
       BUFFERING_LOCK (urisrc);
       slot->is_eos = FALSE;