From: Thiago Santos Date: Thu, 13 Aug 2015 16:08:03 +0000 (-0300) Subject: basetransform: rework accept-caps X-Git-Tag: 1.6.1~65 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e0cc0e0888a1e900b6f5be5119324c5e1db13c95;p=platform%2Fupstream%2Fgstreamer.git basetransform: rework accept-caps According to the design docs: The ACCEPT_CAPS query is not required to work recursively, it can simply return TRUE if a subsequent CAPS event with those caps would return success. So make it a shallow check instead of recursivelly check downstream. https://bugzilla.gnome.org/show_bug.cgi?id=748635 --- diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c index c05289a..4565f4f 100644 --- a/libs/gst/base/gstbasetransform.c +++ b/libs/gst/base/gstbasetransform.c @@ -1285,46 +1285,51 @@ static gboolean gst_base_transform_acceptcaps_default (GstBaseTransform * trans, GstPadDirection direction, GstCaps * caps) { - GstPad *pad; - GstCaps *allowed; + GstPad *pad, *otherpad; + GstCaps *templ, *otempl, *ocaps = NULL; gboolean ret = TRUE; pad = (direction == GST_PAD_SINK) ? GST_BASE_TRANSFORM_SINK_PAD (trans) : GST_BASE_TRANSFORM_SRC_PAD (trans); + otherpad = + (direction == + GST_PAD_SINK) ? GST_BASE_TRANSFORM_SRC_PAD (trans) : + GST_BASE_TRANSFORM_SINK_PAD (trans); GST_DEBUG_OBJECT (trans, "accept caps %" GST_PTR_FORMAT, caps); - /* get all the formats we can handle on this pad */ - allowed = gst_pad_query_caps (pad, caps); - if (!allowed) { - GST_DEBUG_OBJECT (trans, "gst_pad_query_caps() failed"); - goto no_transform_possible; - } - - GST_DEBUG_OBJECT (trans, "allowed caps %" GST_PTR_FORMAT, allowed); - - /* intersect with the requested format */ - if (GST_PAD_IS_ACCEPT_INTERSECT (pad)) { - GST_DEBUG_OBJECT (pad, - "allowed caps intersect %" GST_PTR_FORMAT ", caps %" GST_PTR_FORMAT, - allowed, caps); - ret = gst_caps_can_intersect (caps, allowed); - } else { - GST_DEBUG_OBJECT (pad, "allowed caps subset %" GST_PTR_FORMAT ", caps %" - GST_PTR_FORMAT, allowed, caps); - ret = gst_caps_is_subset (caps, allowed); - } - gst_caps_unref (allowed); + templ = gst_pad_get_pad_template_caps (pad); + otempl = gst_pad_get_pad_template_caps (otherpad); - if (!ret) + /* get all the formats we can handle on this pad */ + GST_DEBUG_OBJECT (trans, "intersect with pad template: %" GST_PTR_FORMAT, + templ); + if (!gst_caps_can_intersect (caps, templ)) + goto reject_caps; + + GST_DEBUG_OBJECT (trans, "trying to transform with filter: %" + GST_PTR_FORMAT " (the other pad template)", otempl); + ocaps = gst_base_transform_transform_caps (trans, direction, caps, otempl); + if (!ocaps || gst_caps_is_empty (ocaps)) goto no_transform_possible; done: + GST_DEBUG_OBJECT (trans, "accept-caps result: %d", ret); + if (ocaps) + gst_caps_unref (ocaps); + gst_caps_unref (templ); + gst_caps_unref (otempl); return ret; /* ERRORS */ +reject_caps: + { + GST_DEBUG_OBJECT (trans, "caps can't intersect with the template"); + ret = FALSE; + goto done; + } no_transform_possible: { GST_DEBUG_OBJECT (trans,