playsinkconvertbin: Make sure to return all allowed caps in the GET_CAPS query
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 21 Mar 2013 12:33:44 +0000 (13:33 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 21 Mar 2013 12:42:41 +0000 (13:42 +0100)
Add all the caps that we can convert to to the filter caps,
otherwise downstream might just return EMPTY caps because
it doesn't handle the filter caps but we could still convert
to these caps, causing us to return EMPTY caps although
conversion would be possible.

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

gst/playback/gstplaysinkconvertbin.c

index a5e03f0..76cb095 100644 (file)
@@ -398,7 +398,21 @@ gst_play_sink_convert_bin_getcaps (GstPad * pad, GstCaps * filter)
   if (otherpad) {
     peer = gst_pad_get_peer (otherpad);
     if (peer) {
-      GstCaps *peer_caps = gst_pad_query_caps (peer, filter);
+      GstCaps *peer_caps;
+      GstCaps *downstream_filter = NULL;
+
+      /* Add all the caps that we can convert to to the filter caps,
+       * otherwise downstream might just return EMPTY caps because
+       * it doesn't handle the filter caps but we could still convert
+       * to these caps */
+      if (filter) {
+        downstream_filter = gst_caps_copy (filter);
+        downstream_filter =
+            gst_caps_merge (downstream_filter,
+            gst_caps_ref (self->converter_caps));
+      }
+
+      peer_caps = gst_pad_query_caps (peer, 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));
@@ -415,6 +429,13 @@ gst_play_sink_convert_bin_getcaps (GstPad * pad, GstCaps * filter)
 
   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;