basetransform: Always intersect the suggested sink caps with the peer caps
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 30 Nov 2011 12:59:46 +0000 (13:59 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 30 Nov 2011 13:01:22 +0000 (14:01 +0100)
This makes sure that we get correct and complete caps. The suggested caps
could be incomplete, e.g. video/x-raw-rgb without any fields, and by
intersecting with the peer caps we get something usable.

Fixes bug #662199.

libs/gst/base/gstbasetransform.c

index d3889324efed78e0f2033b6f3e1c73bc0768c265..fbed6578849548be2bd2a8d093e9f45953a33295 100644 (file)
@@ -1882,27 +1882,29 @@ gst_base_transform_buffer_alloc (GstPad * pad, guint64 offset, guint size,
     /* check if we actually handle this format on the sinkpad */
     if (sink_suggest) {
       const GstCaps *templ;
+      GstCaps *peercaps;
 
-      if (!gst_caps_is_fixed (sink_suggest)) {
-        GstCaps *peercaps;
+      /* Always intersect with the peer caps to get correct
+       * and complete caps. The suggested caps could be incomplete,
+       * for example video/x-raw-yuv without any fields at all.
+       */
+      peercaps =
+          gst_pad_peer_get_caps_reffed (GST_BASE_TRANSFORM_SINK_PAD (trans));
+      if (peercaps) {
+        GstCaps *intersect;
+
+        intersect =
+            gst_caps_intersect_full (sink_suggest, peercaps,
+            GST_CAPS_INTERSECT_FIRST);
+        gst_caps_unref (peercaps);
+        gst_caps_unref (sink_suggest);
+        sink_suggest = intersect;
+      }
 
+      if (!gst_caps_is_fixed (sink_suggest) || gst_caps_is_empty (sink_suggest)) {
         GST_DEBUG_OBJECT (trans, "Suggested caps is not fixed: %"
             GST_PTR_FORMAT, sink_suggest);
 
-        peercaps =
-            gst_pad_peer_get_caps_reffed (GST_BASE_TRANSFORM_SINK_PAD (trans));
-        /* try fixating by intersecting with peer caps */
-        if (peercaps) {
-          GstCaps *intersect;
-
-          intersect =
-              gst_caps_intersect_full (sink_suggest, peercaps,
-              GST_CAPS_INTERSECT_FIRST);
-          gst_caps_unref (peercaps);
-          gst_caps_unref (sink_suggest);
-          sink_suggest = intersect;
-        }
-
         if (gst_caps_is_empty (sink_suggest))
           goto not_supported;