discoverer: Try to get negotiated caps first on pad-added and only then fall back...
authorSebastian Dröge <sebastian@centricular.com>
Wed, 6 May 2020 08:42:05 +0000 (11:42 +0300)
committerSebastian Dröge <sebastian@centricular.com>
Wed, 6 May 2020 08:46:25 +0000 (11:46 +0300)
The negotiated caps will be more accurate and are fixed caps in any
case.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/498

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/655>

gst-libs/gst/pbutils/gstdiscoverer.c

index 2fb97cc9ab3cf69c7c0fc3919d6528e291453cdd..7dfd7eeefb7f20b2e9a408f1c250b37dd4316005 100644 (file)
@@ -701,7 +701,12 @@ uridecodebin_pad_added_cb (GstElement * uridecodebin, GstPad * pad,
   g_object_set (ps->sink, "silent", TRUE, NULL);
   g_object_set (ps->queue, "max-size-buffers", 1, "silent", TRUE, NULL);
 
-  caps = gst_pad_query_caps (pad, NULL);
+  caps = gst_pad_get_current_caps (pad);
+  if (!caps) {
+    GST_WARNING ("Couldn't get negotiated caps from %s:%s",
+        GST_DEBUG_PAD_NAME (pad));
+    caps = gst_pad_query_caps (pad, NULL);
+  }
 
   sinkpad = gst_element_get_static_pad (ps->queue, "sink");
   if (sinkpad == NULL)