From e1ef5586cdb90c653ce261d23c64137fefc9bc30 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 17 Aug 2004 10:16:35 +0000 Subject: [PATCH] testsuite/: s/gst_pad_new/&_from_template/ prepare deprecation of gst_pad_new Original commit message from CVS: * testsuite/bytestream/gstbstest.c: (gst_bstest_init): * testsuite/dynparams/dparamstest.c: (gst_dptest_init): * testsuite/refcounting/pad.c: (main): * testsuite/refcounting/thread.c: (create_thread_ghostpads): s/gst_pad_new/&_from_template/ prepare deprecation of gst_pad_new --- ChangeLog | 9 +++ tests/old/testsuite/bytestream/gstbstest.c | 18 ++++- tests/old/testsuite/dynparams/dparamstest.c | 18 ++++- tests/old/testsuite/refcounting/pad.c | 79 ++++++++++----------- tests/old/testsuite/refcounting/thread.c | 18 ++++- testsuite/bytestream/gstbstest.c | 18 ++++- testsuite/dynparams/dparamstest.c | 18 ++++- testsuite/refcounting/pad.c | 79 ++++++++++----------- testsuite/refcounting/thread.c | 18 ++++- 9 files changed, 181 insertions(+), 94 deletions(-) diff --git a/ChangeLog b/ChangeLog index 060739a7fb..0666ba801f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-08-17 Benjamin Otte + + * testsuite/bytestream/gstbstest.c: (gst_bstest_init): + * testsuite/dynparams/dparamstest.c: (gst_dptest_init): + * testsuite/refcounting/pad.c: (main): + * testsuite/refcounting/thread.c: (create_thread_ghostpads): + s/gst_pad_new/&_from_template/ + prepare deprecation of gst_pad_new + 2004-08-17 Thomas Vander Stichele patch by: Luca Ognibene diff --git a/tests/old/testsuite/bytestream/gstbstest.c b/tests/old/testsuite/bytestream/gstbstest.c index 26fdc68af3..3eb6ae4437 100644 --- a/tests/old/testsuite/bytestream/gstbstest.c +++ b/tests/old/testsuite/bytestream/gstbstest.c @@ -181,14 +181,28 @@ gst_bstest_getcaps (GstPad * pad) return gst_pad_get_allowed_caps (otherpad); } +GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + +GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + static void gst_bstest_init (GstBsTest * bstest) { - bstest->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); + bstest->sinkpad = + gst_pad_new_from_template (gst_static_pad_template_get (&sinktemplate), + "sink"); gst_element_add_pad (GST_ELEMENT (bstest), bstest->sinkpad); gst_pad_set_getcaps_function (bstest->sinkpad, gst_bstest_getcaps); - bstest->srcpad = gst_pad_new ("src", GST_PAD_SRC); + bstest->srcpad = + gst_pad_new_from_template (gst_static_pad_template_get (&srctemplate), + "src"); gst_element_add_pad (GST_ELEMENT (bstest), bstest->srcpad); gst_pad_set_getcaps_function (bstest->srcpad, gst_bstest_getcaps); diff --git a/tests/old/testsuite/dynparams/dparamstest.c b/tests/old/testsuite/dynparams/dparamstest.c index 3e82e89dd3..e41c96dac9 100644 --- a/tests/old/testsuite/dynparams/dparamstest.c +++ b/tests/old/testsuite/dynparams/dparamstest.c @@ -64,6 +64,16 @@ enum ARG_0, }; +GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + +GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + static void gst_dptest_base_init (gpointer g_class); static void gst_dptest_class_init (GstDpTestClass * klass); @@ -134,11 +144,15 @@ static void gst_dptest_init (GstDpTest * dptest) { - dptest->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); + dptest->sinkpad = + gst_pad_new_from_template (gst_static_pad_template_get (&sinktemplate), + "sink"); gst_element_add_pad (GST_ELEMENT (dptest), dptest->sinkpad); gst_pad_set_chain_function (dptest->sinkpad, gst_dptest_chain); - dptest->srcpad = gst_pad_new ("src", GST_PAD_SRC); + dptest->srcpad = + gst_pad_new_from_template (gst_static_pad_template_get (&srctemplate), + "src"); gst_element_add_pad (GST_ELEMENT (dptest), dptest->srcpad); dptest->dpman = gst_dpman_new ("dptest_dpman", GST_ELEMENT (dptest)); diff --git a/tests/old/testsuite/refcounting/pad.c b/tests/old/testsuite/refcounting/pad.c index 049efe9c77..1b8d53ed00 100644 --- a/tests/old/testsuite/refcounting/pad.c +++ b/tests/old/testsuite/refcounting/pad.c @@ -4,6 +4,11 @@ #include #include "mem.h" +GstStaticPadTemplate templ = GST_STATIC_PAD_TEMPLATE ("default", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + int main (int argc, gchar * argv[]) { @@ -29,18 +34,24 @@ main (int argc, gchar * argv[]) usage1 = vmsize (); g_print ("DEBUG: creating new pad with name padname\n"); - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); g_print ("DEBUG: unreffing new pad with name padname\n"); gst_object_unref (GST_OBJECT (pad)); g_print ("create/unref new pad %ld\n", vmsize () - usage1); for (i = 0; i < iters; i++) { - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); gst_object_unref (GST_OBJECT (pad)); } g_print ("create/unref %d pads %ld\n", iters, vmsize () - usage1); - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); g_assert (GST_OBJECT_FLOATING (pad)); gst_object_ref (GST_OBJECT (pad)); gst_object_sink (GST_OBJECT (pad)); @@ -49,81 +60,67 @@ main (int argc, gchar * argv[]) g_print ("create/ref/sink/unref new pad %ld\n", vmsize () - usage1); for (i = 0; i < iters; i++) { - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); gst_object_ref (GST_OBJECT (pad)); gst_object_sink (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); } g_print ("create/ref/sink/unref %d pads %ld\n", iters, vmsize () - usage1); -#if 0 - pad = gst_pad_new ("padname", GST_PAD_SINK); - g_assert (!GST_OBJECT_DESTROYED (pad)); - gst_object_unref (GST_OBJECT (pad)); - g_assert (GST_OBJECT_DESTROYED (pad)); - gst_object_unref (GST_OBJECT (pad)); - g_print ("create/destroy/unref pad %ld\n", vmsize () - usage1); -#endif - -#if 0 - for (i = 0; i < iters; i++) { - pad = gst_pad_new ("padname", GST_PAD_SINK); - gst_object_unref (GST_OBJECT (pad)); - gst_object_unref (GST_OBJECT (pad)); - } - g_print ("create/destroy/unref %d pads %ld\n", iters, vmsize () - usage1); -#endif - - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); gst_object_ref (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); g_print ("create/ref/unref/unref pad %ld\n", vmsize () - usage1); for (i = 0; i < iters; i++) { - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); gst_object_ref (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); } g_print ("create/ref/unref/unref %d pads %ld\n", iters, vmsize () - usage1); - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); gst_object_ref (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); -#if 0 - gst_object_unref (GST_OBJECT (pad)); -#endif - g_print ("create/ref/destroy/unref/unref pad %ld\n", vmsize () - usage1); + g_print ("create/ref/unref/unref pad %ld\n", vmsize () - usage1); -#if 0 for (i = 0; i < iters; i++) { - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); gst_object_ref (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); - //gst_object_unref (GST_OBJECT (pad)); } - g_print ("create/ref/destroy/unref/unref %d pads %ld\n", iters, - vmsize () - usage1); -#endif + g_print ("create/ref/unref/unref %d pads %ld\n", iters, vmsize () - usage1); -#if 0 for (i = 0; i < iters; i++) { - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); gst_object_ref (GST_OBJECT (pad)); gst_pad_set_name (pad, "testing123"); gst_object_unref (GST_OBJECT (pad)); gst_pad_set_name (pad, "testing123"); gst_object_unref (GST_OBJECT (pad)); - gst_object_unref (GST_OBJECT (pad)); } - g_print ("create/ref/destroy/unref/unref %d pads %ld with name\n", iters, + g_print ("create/ref/unref/unref %d pads %ld with name\n", iters, vmsize () - usage1); -#endif - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); for (i = 0; i < iters; i++) { gst_pad_set_name (pad, "testing"); } diff --git a/tests/old/testsuite/refcounting/thread.c b/tests/old/testsuite/refcounting/thread.c index e363d5913f..862f4dc9e2 100644 --- a/tests/old/testsuite/refcounting/thread.c +++ b/tests/old/testsuite/refcounting/thread.c @@ -4,6 +4,16 @@ #include #include "mem.h" +GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + +GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + static GstElement * create_thread (void) { @@ -30,11 +40,15 @@ create_thread_ghostpads (void) thread = gst_thread_new ("testthread"); element1 = gst_element_new (); gst_element_set_name (element1, "test1"); - gst_element_add_pad (element1, gst_pad_new ("src1", GST_PAD_SRC)); + gst_element_add_pad (element1, + gst_pad_new_from_template (gst_static_pad_template_get (&srctemplate), + "src1")); gst_bin_add (GST_BIN (thread), element1); element2 = gst_element_new (); gst_element_set_name (element2, "test2"); - gst_element_add_pad (element2, gst_pad_new ("sink1", GST_PAD_SINK)); + gst_element_add_pad (element1, + gst_pad_new_from_template (gst_static_pad_template_get (&sinktemplate), + "sink1")); gst_bin_add (GST_BIN (thread), element2); gst_element_link (element1, "src1", element2, "sink1"); gst_element_add_ghost_pad (thread, gst_element_get_pad (element2, "sink1"), diff --git a/testsuite/bytestream/gstbstest.c b/testsuite/bytestream/gstbstest.c index 26fdc68af3..3eb6ae4437 100644 --- a/testsuite/bytestream/gstbstest.c +++ b/testsuite/bytestream/gstbstest.c @@ -181,14 +181,28 @@ gst_bstest_getcaps (GstPad * pad) return gst_pad_get_allowed_caps (otherpad); } +GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + +GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + static void gst_bstest_init (GstBsTest * bstest) { - bstest->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); + bstest->sinkpad = + gst_pad_new_from_template (gst_static_pad_template_get (&sinktemplate), + "sink"); gst_element_add_pad (GST_ELEMENT (bstest), bstest->sinkpad); gst_pad_set_getcaps_function (bstest->sinkpad, gst_bstest_getcaps); - bstest->srcpad = gst_pad_new ("src", GST_PAD_SRC); + bstest->srcpad = + gst_pad_new_from_template (gst_static_pad_template_get (&srctemplate), + "src"); gst_element_add_pad (GST_ELEMENT (bstest), bstest->srcpad); gst_pad_set_getcaps_function (bstest->srcpad, gst_bstest_getcaps); diff --git a/testsuite/dynparams/dparamstest.c b/testsuite/dynparams/dparamstest.c index 3e82e89dd3..e41c96dac9 100644 --- a/testsuite/dynparams/dparamstest.c +++ b/testsuite/dynparams/dparamstest.c @@ -64,6 +64,16 @@ enum ARG_0, }; +GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + +GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + static void gst_dptest_base_init (gpointer g_class); static void gst_dptest_class_init (GstDpTestClass * klass); @@ -134,11 +144,15 @@ static void gst_dptest_init (GstDpTest * dptest) { - dptest->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); + dptest->sinkpad = + gst_pad_new_from_template (gst_static_pad_template_get (&sinktemplate), + "sink"); gst_element_add_pad (GST_ELEMENT (dptest), dptest->sinkpad); gst_pad_set_chain_function (dptest->sinkpad, gst_dptest_chain); - dptest->srcpad = gst_pad_new ("src", GST_PAD_SRC); + dptest->srcpad = + gst_pad_new_from_template (gst_static_pad_template_get (&srctemplate), + "src"); gst_element_add_pad (GST_ELEMENT (dptest), dptest->srcpad); dptest->dpman = gst_dpman_new ("dptest_dpman", GST_ELEMENT (dptest)); diff --git a/testsuite/refcounting/pad.c b/testsuite/refcounting/pad.c index 049efe9c77..1b8d53ed00 100644 --- a/testsuite/refcounting/pad.c +++ b/testsuite/refcounting/pad.c @@ -4,6 +4,11 @@ #include #include "mem.h" +GstStaticPadTemplate templ = GST_STATIC_PAD_TEMPLATE ("default", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + int main (int argc, gchar * argv[]) { @@ -29,18 +34,24 @@ main (int argc, gchar * argv[]) usage1 = vmsize (); g_print ("DEBUG: creating new pad with name padname\n"); - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); g_print ("DEBUG: unreffing new pad with name padname\n"); gst_object_unref (GST_OBJECT (pad)); g_print ("create/unref new pad %ld\n", vmsize () - usage1); for (i = 0; i < iters; i++) { - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); gst_object_unref (GST_OBJECT (pad)); } g_print ("create/unref %d pads %ld\n", iters, vmsize () - usage1); - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); g_assert (GST_OBJECT_FLOATING (pad)); gst_object_ref (GST_OBJECT (pad)); gst_object_sink (GST_OBJECT (pad)); @@ -49,81 +60,67 @@ main (int argc, gchar * argv[]) g_print ("create/ref/sink/unref new pad %ld\n", vmsize () - usage1); for (i = 0; i < iters; i++) { - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); gst_object_ref (GST_OBJECT (pad)); gst_object_sink (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); } g_print ("create/ref/sink/unref %d pads %ld\n", iters, vmsize () - usage1); -#if 0 - pad = gst_pad_new ("padname", GST_PAD_SINK); - g_assert (!GST_OBJECT_DESTROYED (pad)); - gst_object_unref (GST_OBJECT (pad)); - g_assert (GST_OBJECT_DESTROYED (pad)); - gst_object_unref (GST_OBJECT (pad)); - g_print ("create/destroy/unref pad %ld\n", vmsize () - usage1); -#endif - -#if 0 - for (i = 0; i < iters; i++) { - pad = gst_pad_new ("padname", GST_PAD_SINK); - gst_object_unref (GST_OBJECT (pad)); - gst_object_unref (GST_OBJECT (pad)); - } - g_print ("create/destroy/unref %d pads %ld\n", iters, vmsize () - usage1); -#endif - - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); gst_object_ref (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); g_print ("create/ref/unref/unref pad %ld\n", vmsize () - usage1); for (i = 0; i < iters; i++) { - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); gst_object_ref (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); } g_print ("create/ref/unref/unref %d pads %ld\n", iters, vmsize () - usage1); - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); gst_object_ref (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); -#if 0 - gst_object_unref (GST_OBJECT (pad)); -#endif - g_print ("create/ref/destroy/unref/unref pad %ld\n", vmsize () - usage1); + g_print ("create/ref/unref/unref pad %ld\n", vmsize () - usage1); -#if 0 for (i = 0; i < iters; i++) { - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); gst_object_ref (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); gst_object_unref (GST_OBJECT (pad)); - //gst_object_unref (GST_OBJECT (pad)); } - g_print ("create/ref/destroy/unref/unref %d pads %ld\n", iters, - vmsize () - usage1); -#endif + g_print ("create/ref/unref/unref %d pads %ld\n", iters, vmsize () - usage1); -#if 0 for (i = 0; i < iters; i++) { - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); gst_object_ref (GST_OBJECT (pad)); gst_pad_set_name (pad, "testing123"); gst_object_unref (GST_OBJECT (pad)); gst_pad_set_name (pad, "testing123"); gst_object_unref (GST_OBJECT (pad)); - gst_object_unref (GST_OBJECT (pad)); } - g_print ("create/ref/destroy/unref/unref %d pads %ld with name\n", iters, + g_print ("create/ref/unref/unref %d pads %ld with name\n", iters, vmsize () - usage1); -#endif - pad = gst_pad_new ("padname", GST_PAD_SINK); + pad = + gst_pad_new_from_template (gst_static_pad_template_get (&templ), + "padname"); for (i = 0; i < iters; i++) { gst_pad_set_name (pad, "testing"); } diff --git a/testsuite/refcounting/thread.c b/testsuite/refcounting/thread.c index e363d5913f..862f4dc9e2 100644 --- a/testsuite/refcounting/thread.c +++ b/testsuite/refcounting/thread.c @@ -4,6 +4,16 @@ #include #include "mem.h" +GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + +GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + static GstElement * create_thread (void) { @@ -30,11 +40,15 @@ create_thread_ghostpads (void) thread = gst_thread_new ("testthread"); element1 = gst_element_new (); gst_element_set_name (element1, "test1"); - gst_element_add_pad (element1, gst_pad_new ("src1", GST_PAD_SRC)); + gst_element_add_pad (element1, + gst_pad_new_from_template (gst_static_pad_template_get (&srctemplate), + "src1")); gst_bin_add (GST_BIN (thread), element1); element2 = gst_element_new (); gst_element_set_name (element2, "test2"); - gst_element_add_pad (element2, gst_pad_new ("sink1", GST_PAD_SINK)); + gst_element_add_pad (element1, + gst_pad_new_from_template (gst_static_pad_template_get (&sinktemplate), + "sink1")); gst_bin_add (GST_BIN (thread), element2); gst_element_link (element1, "src1", element2, "sink1"); gst_element_add_ghost_pad (thread, gst_element_get_pad (element2, "sink1"),