summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Santos <thiagoss@osg.samsung.com>2015-06-19 15:46:56 -0300
committerThiago Santos <thiagoss@osg.samsung.com>2015-06-22 17:18:43 -0300
commit1418e9e85c2a98715132764ce2c34b9e1bf179cf (patch)
tree12f282cedde9970731428bd9f0b8faace8a3f042
parentcba677bebb96d22034d02ab05eb26915d077c5f6 (diff)
utils: use caps when getting a compatible pad by template
Do not ignore the caps argument when requesting a pad by template. This is particularly harmful when the pad caps query by default returns ANY so it will match the first template instead of the one that actually intersects with the caps. https://bugzilla.gnome.org/show_bug.cgi?id=751235
-rw-r--r--gst/gstutils.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gst/gstutils.c b/gst/gstutils.c
index e00f8e8e0..076de1ca6 100644
--- a/gst/gstutils.c
+++ b/gst/gstutils.c
@@ -1099,8 +1099,13 @@ gst_element_get_compatible_pad (GstElement * element, GstPad * pad,
/* try to create a new one */
/* requesting is a little crazy, we need a template. Let's create one */
- /* FIXME: why not gst_pad_get_pad_template (pad); */
templcaps = gst_pad_query_caps (pad, NULL);
+ if (caps) {
+ GstCaps *inter = gst_caps_intersect (templcaps, caps);
+
+ gst_caps_unref (templcaps);
+ templcaps = inter;
+ }
templ = gst_pad_template_new ((gchar *) GST_PAD_NAME (pad),
GST_PAD_DIRECTION (pad), GST_PAD_ALWAYS, templcaps);
gst_caps_unref (templcaps);