diff --git a/gst/gstpad.c b/gst/gstpad.c index dca4c4f3c1..78aa4a2e8c 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -2765,17 +2765,23 @@ setcaps_failed: static GstFlowReturn gst_pad_configure_sink (GstPad * pad, GstCaps * caps) { + GstCaps *templ; + /* See if pad accepts the caps */ - if (!gst_caps_can_intersect (caps, gst_pad_get_pad_template_caps (pad))) + templ = gst_pad_get_pad_template_caps (pad); + if (!gst_caps_can_intersect (caps, templ)) goto not_accepted; if (!gst_pad_call_setcaps (pad, caps)) goto not_accepted; + gst_caps_unref (templ); + return GST_FLOW_OK; not_accepted: { + gst_caps_unref (templ); GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "caps %" GST_PTR_FORMAT " not accepted", caps); return GST_FLOW_NOT_NEGOTIATED; diff --git a/gst/gstutils.c b/gst/gstutils.c index 9e4d31e083..7c35475a2f 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -1199,9 +1199,9 @@ gst_element_get_compatible_pad (GstElement * element, GstPad * pad, /* 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_get_caps (pad, NULL); - templ = gst_pad_template_new ((gchar *) GST_PAD_NAME (pad), GST_PAD_DIRECTION (pad), GST_PAD_ALWAYS, templcaps); + gst_caps_unref (templcaps); foundpad = gst_element_request_compatible_pad (element, templ); gst_object_unref (templ); @@ -1844,8 +1844,11 @@ gst_element_link_pads_full (GstElement * src, const gchar * srcpadname, desttempl = (GstPadTemplate *) l->data; if (desttempl->presence == GST_PAD_REQUEST && desttempl->direction != srctempl->direction) { - if (gst_caps_is_always_compatible (gst_pad_template_get_caps - (srctempl), gst_pad_template_get_caps (desttempl))) { + GstCaps *srccaps, *destcaps; + + srccaps = gst_pad_template_get_caps (srctempl); + destcaps = gst_pad_template_get_caps (desttempl); + if (gst_caps_is_always_compatible (srccaps, destcaps)) { srcpad = gst_element_request_pad (src, srctempl, srctempl->name_template, NULL); @@ -1859,6 +1862,8 @@ gst_element_link_pads_full (GstElement * src, const gchar * srcpadname, GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (destpad)); gst_object_unref (srcpad); gst_object_unref (destpad); + gst_caps_unref (srccaps); + gst_caps_unref (destcaps); return TRUE; } /* it failed, so we release the request pads */ @@ -1867,6 +1872,8 @@ gst_element_link_pads_full (GstElement * src, const gchar * srcpadname, if (destpad) gst_element_release_request_pad (dest, destpad); } + gst_caps_unref (srccaps); + gst_caps_unref (destcaps); } } }