From b5bc5b459ad888766b8f9c81b48f830018294e5e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 17 May 2011 11:59:00 +0200 Subject: [PATCH] pad: Let template related functions return new references gst_pad_template_get_caps(), gst_pad_get_pad_template_caps() and gst_pad_get_pad_template() return a new reference of the caps or template now and the return value needs to be unreffed after usage. --- docs/random/porting-to-0.11.txt | 8 ++++++++ gst/gstpad.c | 22 ++++++++++++---------- gst/gstpad.h | 2 +- gst/gstpadtemplate.c | 9 ++++++--- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/docs/random/porting-to-0.11.txt b/docs/random/porting-to-0.11.txt index bcf3a53..5d50132 100644 --- a/docs/random/porting-to-0.11.txt +++ b/docs/random/porting-to-0.11.txt @@ -88,6 +88,14 @@ The 0.11 porting guide gst_pad_proxy_getcaps() now takes a GstCaps* parameter to inform the other side about the possible caps and preferences. + gst_pad_get_pad_template_caps() and gst_pad_get_pad_template() + return a new reference of the caps or template now and the return + value needs to be unreffed after usage. + +* GstPadTemplate + gst_pad_template_get_caps() returns a new reference of the caps + and the return value needs to be unreffed after usage. + * GstMiniObject A miniobject is now a simple refcounted structure holding the information common to buffers, events, messages, queries and caps. diff --git a/gst/gstpad.c b/gst/gstpad.c index 3104940..dca4c4f 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -2171,19 +2171,21 @@ gst_pad_set_pad_template (GstPad * pad, GstPadTemplate * templ) * * Gets the template for @pad. * - * Returns: (transfer none): the #GstPadTemplate from which this pad was - * instantiated, or %NULL if this pad has no template. - * - * FIXME: currently returns an unrefcounted padtemplate. + * Returns: (transfer full): the #GstPadTemplate from which this pad was + * instantiated, or %NULL if this pad has no template. Unref after + * usage. */ GstPadTemplate * gst_pad_get_pad_template (GstPad * pad) { + GstPadTemplate *templ; + g_return_val_if_fail (GST_IS_PAD (pad), NULL); - return GST_PAD_PAD_TEMPLATE (pad); -} + templ = GST_PAD_PAD_TEMPLATE (pad); + return (templ ? gst_object_ref (templ) : NULL); +} /* should be called with the pad LOCK held */ /* refs the caps, so caller is responsible for getting it unreffed */ @@ -2815,10 +2817,10 @@ no_function: * * Gets the capabilities for @pad's template. * - * Returns: (transfer none): the #GstCaps of this pad template. If you intend - * to keep a reference on the caps, make a copy (see gst_caps_copy ()). + * Returns: (transfer full): the #GstCaps of this pad template. + * Unref after usage. */ -const GstCaps * +GstCaps * gst_pad_get_pad_template_caps (GstPad * pad) { static GstStaticCaps anycaps = GST_STATIC_CAPS ("ANY"); @@ -2826,7 +2828,7 @@ gst_pad_get_pad_template_caps (GstPad * pad) g_return_val_if_fail (GST_IS_PAD (pad), NULL); if (GST_PAD_PAD_TEMPLATE (pad)) - return GST_PAD_TEMPLATE_CAPS (GST_PAD_PAD_TEMPLATE (pad)); + return gst_pad_template_get_caps (GST_PAD_PAD_TEMPLATE (pad)); return gst_static_caps_get (&anycaps); } diff --git a/gst/gstpad.h b/gst/gstpad.h index 198a0ca..566afc7 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -846,7 +846,7 @@ void gst_pad_set_acceptcaps_function (GstPad *pad, GstPadAcceptCapsFunction a void gst_pad_set_fixatecaps_function (GstPad *pad, GstPadFixateCapsFunction fixatecaps); void gst_pad_set_setcaps_function (GstPad *pad, GstPadSetCapsFunction setcaps); -G_CONST_RETURN GstCaps* gst_pad_get_pad_template_caps (GstPad *pad); +GstCaps* gst_pad_get_pad_template_caps (GstPad *pad); /* capsnego function for linked/unlinked pads */ GstCaps * gst_pad_get_current_caps (GstPad * pad); diff --git a/gst/gstpadtemplate.c b/gst/gstpadtemplate.c index 06c4d55..65a7f4d 100644 --- a/gst/gstpadtemplate.c +++ b/gst/gstpadtemplate.c @@ -397,15 +397,18 @@ gst_static_pad_template_get_caps (GstStaticPadTemplate * templ) * * Gets the capabilities of the pad template. * - * Returns: (transfer none): the #GstCaps of the pad template. If you need to - * keep a reference to the caps, take a ref (see gst_caps_ref ()). + * Returns: (transfer full): the #GstCaps of the pad template. + * Unref after usage. */ GstCaps * gst_pad_template_get_caps (GstPadTemplate * templ) { + GstCaps *caps; g_return_val_if_fail (GST_IS_PAD_TEMPLATE (templ), NULL); - return GST_PAD_TEMPLATE_CAPS (templ); + caps = GST_PAD_TEMPLATE_CAPS (templ); + + return (caps ? gst_caps_ref (caps) : NULL); } /** -- 2.7.4