All pastes #2053754 Raw Edit

Mine

public text v1 · immutable
#2053754 ·published 2011-05-04 09:30 UTC
rendered paste body
commit ebc0d5c3f2019329505de18462c8a3366a742c22
Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
Date:   Wed May 4 11:29:15 2011 +0200

    basetransform: In getcaps() prefer the caps order and caps of downstream if 

diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c
index 4fa1cce..e9ccea2 100644
--- a/libs/gst/base/gstbasetransform.c
+++ b/libs/gst/base/gstbasetransform.c
@@ -654,26 +654,27 @@ gst_base_transform_getcaps (GstPad * pad)
 {
   GstBaseTransform *trans;
   GstPad *otherpad;
-  GstCaps *caps;
+  GstCaps *peercaps, *caps;
 
   trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad));
 
   otherpad = (pad == trans->srcpad) ? trans->sinkpad : trans->srcpad;
 
   /* we can do what the peer can */
-  caps = gst_pad_peer_get_caps_reffed (otherpad);

-  if (caps) {
+  peercaps = gst_pad_peer_get_caps_reffed (otherpad);
+  if (peercaps) {
     GstCaps *temp;
     const GstCaps *templ;
 
-    GST_DEBUG_OBJECT (pad, "peer caps  %" GST_PTR_FORMAT, caps);
+    GST_DEBUG_OBJECT (pad, "peer caps  %" GST_PTR_FORMAT, peercaps);
+
+    g_print ("peercaps %s\n", gst_caps_to_string (peercaps));
 
     /* filtered against our padtemplate on the other side */
     templ = gst_pad_get_pad_template_caps (otherpad);
     GST_DEBUG_OBJECT (pad, "our template  %" GST_PTR_FORMAT, templ);
-    temp = gst_caps_intersect (caps, templ);
+    temp = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
     GST_DEBUG_OBJECT (pad, "intersected %" GST_PTR_FORMAT, temp);
-    gst_caps_unref (caps);
 
     /* then see what we can transform this to */
     caps = gst_base_transform_transform_caps (trans,
@@ -690,8 +691,16 @@ gst_base_transform_getcaps (GstPad * pad)

     temp = gst_caps_intersect_full (caps, templ, GST_CAPS_INTERSECT_FIRST);
     GST_DEBUG_OBJECT (pad, "intersected %" GST_PTR_FORMAT, temp);
     gst_caps_unref (caps);
-    /* this is what we can do */
     caps = temp;
+
+    /* Now try if we can put the untransformed downstream caps first */
+    temp = gst_caps_intersect_full (peercaps, caps, GST_CAPS_INTERSECT_FIRST);
+    if (!gst_caps_is_empty (temp)) {
+      gst_caps_merge (temp, caps);
+      caps = temp;
+    } else {
+      gst_caps_unref (temp);
+    }
   } else {
     /* no peer or the peer can do anything, our padtemplate is enough then */
     caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
@@ -700,6 +709,9 @@ gst_base_transform_getcaps (GstPad * pad)
 done:
   GST_DEBUG_OBJECT (trans, "returning  %" GST_PTR_FORMAT, caps);
 
+  if (peercaps)

+    gst_caps_unref (peercaps);
+
   gst_object_unref (trans);
 
   return caps;