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

This commit is contained in:
Sebastian Dröge 2011-05-04 11:29:15 +02:00
parent b4bed6e09e
commit f56c6e1225

View file

@ -654,26 +654,25 @@ 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);
/* 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 +689,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 +707,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;