mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-09-01 09:43:55 +00:00
basetransform: In getcaps() prefer the caps order and caps of downstream if possible
This commit is contained in:
parent
b4bed6e09e
commit
f56c6e1225
1 changed files with 17 additions and 7 deletions
|
@ -654,26 +654,25 @@ gst_base_transform_getcaps (GstPad * pad)
|
||||||
{
|
{
|
||||||
GstBaseTransform *trans;
|
GstBaseTransform *trans;
|
||||||
GstPad *otherpad;
|
GstPad *otherpad;
|
||||||
GstCaps *caps;
|
GstCaps *peercaps, *caps;
|
||||||
|
|
||||||
trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad));
|
trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
otherpad = (pad == trans->srcpad) ? trans->sinkpad : trans->srcpad;
|
otherpad = (pad == trans->srcpad) ? trans->sinkpad : trans->srcpad;
|
||||||
|
|
||||||
/* we can do what the peer can */
|
/* we can do what the peer can */
|
||||||
caps = gst_pad_peer_get_caps_reffed (otherpad);
|
peercaps = gst_pad_peer_get_caps_reffed (otherpad);
|
||||||
if (caps) {
|
if (peercaps) {
|
||||||
GstCaps *temp;
|
GstCaps *temp;
|
||||||
const GstCaps *templ;
|
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 */
|
/* filtered against our padtemplate on the other side */
|
||||||
templ = gst_pad_get_pad_template_caps (otherpad);
|
templ = gst_pad_get_pad_template_caps (otherpad);
|
||||||
GST_DEBUG_OBJECT (pad, "our template %" GST_PTR_FORMAT, templ);
|
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_DEBUG_OBJECT (pad, "intersected %" GST_PTR_FORMAT, temp);
|
||||||
gst_caps_unref (caps);
|
|
||||||
|
|
||||||
/* then see what we can transform this to */
|
/* then see what we can transform this to */
|
||||||
caps = gst_base_transform_transform_caps (trans,
|
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);
|
temp = gst_caps_intersect_full (caps, templ, GST_CAPS_INTERSECT_FIRST);
|
||||||
GST_DEBUG_OBJECT (pad, "intersected %" GST_PTR_FORMAT, temp);
|
GST_DEBUG_OBJECT (pad, "intersected %" GST_PTR_FORMAT, temp);
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
/* this is what we can do */
|
|
||||||
caps = temp;
|
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 {
|
} else {
|
||||||
/* no peer or the peer can do anything, our padtemplate is enough then */
|
/* no peer or the peer can do anything, our padtemplate is enough then */
|
||||||
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
||||||
|
@ -700,6 +707,9 @@ gst_base_transform_getcaps (GstPad * pad)
|
||||||
done:
|
done:
|
||||||
GST_DEBUG_OBJECT (trans, "returning %" GST_PTR_FORMAT, caps);
|
GST_DEBUG_OBJECT (trans, "returning %" GST_PTR_FORMAT, caps);
|
||||||
|
|
||||||
|
if (peercaps)
|
||||||
|
gst_caps_unref (peercaps);
|
||||||
|
|
||||||
gst_object_unref (trans);
|
gst_object_unref (trans);
|
||||||
|
|
||||||
return caps;
|
return caps;
|
||||||
|
|
Loading…
Reference in a new issue