playsinkconvertbin: improve gst_play_sink_convert_bin_getcaps return
authorMatthieu Bouron <matthieu.bouron@collabora.com>
Fri, 21 Feb 2014 14:01:37 +0000 (14:01 +0000)
committerSebastian Dröge <sebastian@centricular.com>
Wed, 26 Feb 2014 08:35:04 +0000 (09:35 +0100)
If we have the peer caps and a caps filter, return peer_caps +
intersect_first (filter, converter_caps) instead of
intersect_first (filter, peer_caps + converter_caps) and preservers
downstream caps preference order.

https://bugzilla.gnome.org/show_bug.cgi?id=724893

gst/playback/gstplaysinkconvertbin.c

index d4f299c..644a6ba 100644 (file)
@@ -338,6 +338,15 @@ gst_play_sink_convert_bin_sink_setcaps (GstPlaySinkConvertBin * self,
   return TRUE;
 }
 
+#define GST_PLAY_SINK_CONVERT_BIN_FILTER_CAPS(filter,caps) G_STMT_START {     \
+  if ((filter)) {                                                             \
+    GstCaps *intersection =                                                   \
+        gst_caps_intersect_full ((filter), (caps), GST_CAPS_INTERSECT_FIRST); \
+    gst_caps_unref ((caps));                                                  \
+    (caps) = intersection;                                                    \
+  }                                                                           \
+} G_STMT_END
+
 static GstCaps *
 gst_play_sink_convert_bin_getcaps (GstPad * pad, GstCaps * filter)
 {
@@ -378,27 +387,24 @@ gst_play_sink_convert_bin_getcaps (GstPad * pad, GstCaps * filter)
         gst_caps_unref (downstream_filter);
       gst_object_unref (peer);
       if (self->converter_caps && is_raw_caps (peer_caps, self->audio)) {
-        ret = gst_caps_merge (peer_caps, gst_caps_ref (self->converter_caps));
+        GstCaps *converter_caps = gst_caps_ref (self->converter_caps);
+        GST_PLAY_SINK_CONVERT_BIN_FILTER_CAPS (filter, converter_caps);
+        ret = gst_caps_merge (peer_caps, converter_caps);
       } else {
         ret = peer_caps;
+        GST_PLAY_SINK_CONVERT_BIN_FILTER_CAPS (filter, ret);
       }
     } else {
       ret = gst_caps_ref (self->converter_caps);
+      GST_PLAY_SINK_CONVERT_BIN_FILTER_CAPS (filter, ret);
     }
   } else {
-    ret = gst_caps_new_any ();
+    ret = filter ? gst_caps_ref (filter) : gst_caps_new_any ();
   }
   GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self);
 
   gst_object_unref (self);
 
-  if (filter) {
-    GstCaps *intersection =
-        gst_caps_intersect_full (filter, ret, GST_CAPS_INTERSECT_FIRST);
-    gst_caps_unref (ret);
-    ret = intersection;
-  }
-
   GST_DEBUG_OBJECT (pad, "Returning caps %" GST_PTR_FORMAT, ret);
 
   return ret;