From 533a6eacb0e7bd9b4100a4ee0982fa83fd0eabb3 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Wed, 16 Nov 2005 16:09:49 +0000 Subject: [PATCH] gst/gstpad.*: add gst_pad_new_from_static_template functions Original commit message from CVS: * gst/gstpad.c: (gst_pad_new_from_static_template): * gst/gstpad.h: add gst_pad_new_from_static_template functions * gst/check/gstcheck.c: (gst_check_setup_src_pad), (gst_check_setup_sink_pad): * gst/elements/gsttee.c: (gst_tee_init): and use them --- ChangeLog | 12 +++++++++++- gst/check/gstcheck.c | 10 +++------- gst/elements/gsttee.c | 5 +---- gst/gstpad.c | 25 +++++++++++++++++++++++++ gst/gstpad.h | 2 ++ libs/gst/check/gstcheck.c | 10 +++------- plugins/elements/gsttee.c | 5 +---- 7 files changed, 46 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2732f9f..87f3113 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,17 @@ +2005-11-16 Thomas Vander Stichele + + * gst/gstpad.c: (gst_pad_new_from_static_template): + * gst/gstpad.h: + add gst_pad_new_from_static_template functions + * gst/check/gstcheck.c: (gst_check_setup_src_pad), + (gst_check_setup_sink_pad): + * gst/elements/gsttee.c: (gst_tee_init): + and use them + 2005-11-16 Wim Taymans * gst/gstpad.c: (gst_pad_pause_task): - Removed warning, it's not realy an error either. + Removed warning, it's not really an error either. 2005-11-16 Wim Taymans diff --git a/gst/check/gstcheck.c b/gst/check/gstcheck.c index 54093bf..713e7da 100644 --- a/gst/check/gstcheck.c +++ b/gst/check/gstcheck.c @@ -152,15 +152,13 @@ gst_check_teardown_element (GstElement * element) */ GstPad * gst_check_setup_src_pad (GstElement * element, - GstStaticPadTemplate * srctemplate, GstCaps * caps) + GstStaticPadTemplate * template, GstCaps * caps) { GstPad *srcpad, *sinkpad; GST_DEBUG_OBJECT (element, "setting up sending pad"); /* sending pad */ - srcpad = - gst_pad_new_from_template (gst_static_pad_template_get (srctemplate), - "src"); + srcpad = gst_pad_new_from_static_template (template, "src"); fail_if (srcpad == NULL, "Could not create a srcpad"); ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1); @@ -211,9 +209,7 @@ gst_check_setup_sink_pad (GstElement * element, GstStaticPadTemplate * template, GST_DEBUG_OBJECT (element, "setting up receiving pad"); /* receiving pad */ - sinkpad = - gst_pad_new_from_template (gst_static_pad_template_get (template), - "sink"); + sinkpad = gst_pad_new_from_static_template (template, "sink"); fail_if (sinkpad == NULL, "Could not create a sinkpad"); srcpad = gst_element_get_pad (element, "src"); diff --git a/gst/elements/gsttee.c b/gst/elements/gsttee.c index aa78353..6d39b70 100644 --- a/gst/elements/gsttee.c +++ b/gst/elements/gsttee.c @@ -140,10 +140,7 @@ gst_tee_class_init (GstTeeClass * klass) static void gst_tee_init (GstTee * tee, GstTeeClass * g_class) { - GstPadTemplate *templ = gst_static_pad_template_get (&sinktemplate); - - tee->sinkpad = gst_pad_new_from_template (templ, "sink"); - gst_object_unref (templ); + tee->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink"); gst_pad_set_setcaps_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_setcaps)); gst_pad_set_getcaps_function (tee->sinkpad, diff --git a/gst/gstpad.c b/gst/gstpad.c index 438a55c..941c106 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -492,6 +492,31 @@ gst_pad_new_from_template (GstPadTemplate * templ, const gchar * name) } /** + * gst_pad_new_from_static_template: + * @templ: the #GstStaticPadTemplate to use + * @name: the name of the element + * + * Creates a new pad with the given name from the given static template. + * If name is NULL, a guaranteed unique name (across all pads) + * will be assigned. + * This function makes a copy of the name so you can safely free the name. + * + * Returns: a new #GstPad, or NULL in case of an error. + */ +GstPad * +gst_pad_new_from_static_template (GstStaticPadTemplate * templ, + const gchar * name) +{ + GstPad *pad; + GstPadTemplate *template; + + template = gst_static_pad_template_get (templ); + pad = gst_pad_new_from_template (template, name); + gst_object_unref (template); + return pad; +} + +/** * gst_pad_get_direction: * @pad: a #GstPad to get the direction of. * diff --git a/gst/gstpad.h b/gst/gstpad.h index 00d99b3..b1ff345 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -498,6 +498,8 @@ GType gst_pad_get_type (void); /* creating pads */ GstPad* gst_pad_new (const gchar *name, GstPadDirection direction); GstPad* gst_pad_new_from_template (GstPadTemplate *templ, const gchar *name); +GstPad* gst_pad_new_from_static_template (GstStaticPadTemplate *templ, const gchar *name); + /** * gst_pad_get_name: diff --git a/libs/gst/check/gstcheck.c b/libs/gst/check/gstcheck.c index 54093bf..713e7da 100644 --- a/libs/gst/check/gstcheck.c +++ b/libs/gst/check/gstcheck.c @@ -152,15 +152,13 @@ gst_check_teardown_element (GstElement * element) */ GstPad * gst_check_setup_src_pad (GstElement * element, - GstStaticPadTemplate * srctemplate, GstCaps * caps) + GstStaticPadTemplate * template, GstCaps * caps) { GstPad *srcpad, *sinkpad; GST_DEBUG_OBJECT (element, "setting up sending pad"); /* sending pad */ - srcpad = - gst_pad_new_from_template (gst_static_pad_template_get (srctemplate), - "src"); + srcpad = gst_pad_new_from_static_template (template, "src"); fail_if (srcpad == NULL, "Could not create a srcpad"); ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1); @@ -211,9 +209,7 @@ gst_check_setup_sink_pad (GstElement * element, GstStaticPadTemplate * template, GST_DEBUG_OBJECT (element, "setting up receiving pad"); /* receiving pad */ - sinkpad = - gst_pad_new_from_template (gst_static_pad_template_get (template), - "sink"); + sinkpad = gst_pad_new_from_static_template (template, "sink"); fail_if (sinkpad == NULL, "Could not create a sinkpad"); srcpad = gst_element_get_pad (element, "src"); diff --git a/plugins/elements/gsttee.c b/plugins/elements/gsttee.c index aa78353..6d39b70 100644 --- a/plugins/elements/gsttee.c +++ b/plugins/elements/gsttee.c @@ -140,10 +140,7 @@ gst_tee_class_init (GstTeeClass * klass) static void gst_tee_init (GstTee * tee, GstTeeClass * g_class) { - GstPadTemplate *templ = gst_static_pad_template_get (&sinktemplate); - - tee->sinkpad = gst_pad_new_from_template (templ, "sink"); - gst_object_unref (templ); + tee->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink"); gst_pad_set_setcaps_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_setcaps)); gst_pad_set_getcaps_function (tee->sinkpad, -- 2.7.4