mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 23:06:49 +00:00
basetransform: In getcaps() prefer the caps order and caps of downstream if possible
This commit is contained in:
parent
a6c1cbe69a
commit
aebe4a3c13
1 changed files with 17 additions and 7 deletions
|
@ -652,26 +652,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 (otherpad);
|
||||
if (caps) {
|
||||
peercaps = gst_pad_peer_get_caps (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,
|
||||
|
@ -688,8 +687,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));
|
||||
|
@ -698,6 +705,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;
|
||||
|
|
Loading…
Reference in a new issue