From cc3b3cc116ec2c52498fbbccd6baf6a798611fc2 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Tue, 12 Feb 2002 13:51:40 +0000 Subject: [PATCH] fixing up tests to work with property callbacks Original commit message from CVS: fixing up tests to work with property callbacks --- tests/old/testsuite/elements/Makefile.am | 2 +- tests/old/testsuite/elements/property.h | 23 +++++++++++++++++++++++ tests/old/testsuite/elements/tee.c | 4 ++++ testsuite/elements/Makefile.am | 2 +- testsuite/elements/property.h | 23 +++++++++++++++++++++++ testsuite/elements/tee.c | 4 ++++ 6 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 tests/old/testsuite/elements/property.h create mode 100644 testsuite/elements/property.h diff --git a/tests/old/testsuite/elements/Makefile.am b/tests/old/testsuite/elements/Makefile.am index eb85235..4d1adc8 100644 --- a/tests/old/testsuite/elements/Makefile.am +++ b/tests/old/testsuite/elements/Makefile.am @@ -4,7 +4,7 @@ TESTS = $(testprogs) check_PROGRAMS = $(testprogs) -EXTRA_DIST = events.h +EXTRA_DIST = property.h LDADD = $(GST_LIBS) CFLAGS = $(GST_CFLAGS) diff --git a/tests/old/testsuite/elements/property.h b/tests/old/testsuite/elements/property.h new file mode 100644 index 0000000..a1756f1 --- /dev/null +++ b/tests/old/testsuite/elements/property.h @@ -0,0 +1,23 @@ +/* extracted from gst-launch */ +static void +property_change_callback (GObject *object, GstObject *orig, GParamSpec *pspec) +{ + GValue value = { 0, }; /* the important thing is that value.type = 0 */ + gchar *str = 0; + + if (pspec->flags & G_PARAM_READABLE) { + g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); + g_object_get_property (G_OBJECT (orig), pspec->name, &value); + /* fix current bug with g_strdup_value_contents not working with gint64 */ + if (G_IS_PARAM_SPEC_INT64 (pspec)) + str = g_strdup_printf ("%lld", g_value_get_int64 (&value)); + else + str = g_strdup_value_contents (&value); + g_print ("%s: %s = %s\n", GST_OBJECT_NAME (orig), pspec->name, str); + g_free (str); + g_value_unset(&value); + } else { + g_warning ("Parameter not readable. What's up with that?"); + } +} + diff --git a/tests/old/testsuite/elements/tee.c b/tests/old/testsuite/elements/tee.c index b95e5a7..0f35303 100644 --- a/tests/old/testsuite/elements/tee.c +++ b/tests/old/testsuite/elements/tee.c @@ -13,6 +13,7 @@ */ #include +#include GstElement * element_create (char *name, char *element) @@ -52,6 +53,9 @@ main (int argc, char *argv[]) g_print ("Creating pipeline\n"); pipeline = gst_pipeline_new ("pipeline"); + g_print ("Connecting signals to pipeline\n"); + g_signal_connect (pipeline, "deep_notify", G_CALLBACK (property_change_callback), NULL); + g_print ("Creating elements\n"); if (!(tee = element_create ("tee", "tee"))) return 1; if (!(src = element_create ("src", "fakesrc"))) return 1; diff --git a/testsuite/elements/Makefile.am b/testsuite/elements/Makefile.am index eb85235..4d1adc8 100644 --- a/testsuite/elements/Makefile.am +++ b/testsuite/elements/Makefile.am @@ -4,7 +4,7 @@ TESTS = $(testprogs) check_PROGRAMS = $(testprogs) -EXTRA_DIST = events.h +EXTRA_DIST = property.h LDADD = $(GST_LIBS) CFLAGS = $(GST_CFLAGS) diff --git a/testsuite/elements/property.h b/testsuite/elements/property.h new file mode 100644 index 0000000..a1756f1 --- /dev/null +++ b/testsuite/elements/property.h @@ -0,0 +1,23 @@ +/* extracted from gst-launch */ +static void +property_change_callback (GObject *object, GstObject *orig, GParamSpec *pspec) +{ + GValue value = { 0, }; /* the important thing is that value.type = 0 */ + gchar *str = 0; + + if (pspec->flags & G_PARAM_READABLE) { + g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); + g_object_get_property (G_OBJECT (orig), pspec->name, &value); + /* fix current bug with g_strdup_value_contents not working with gint64 */ + if (G_IS_PARAM_SPEC_INT64 (pspec)) + str = g_strdup_printf ("%lld", g_value_get_int64 (&value)); + else + str = g_strdup_value_contents (&value); + g_print ("%s: %s = %s\n", GST_OBJECT_NAME (orig), pspec->name, str); + g_free (str); + g_value_unset(&value); + } else { + g_warning ("Parameter not readable. What's up with that?"); + } +} + diff --git a/testsuite/elements/tee.c b/testsuite/elements/tee.c index b95e5a7..0f35303 100644 --- a/testsuite/elements/tee.c +++ b/testsuite/elements/tee.c @@ -13,6 +13,7 @@ */ #include +#include GstElement * element_create (char *name, char *element) @@ -52,6 +53,9 @@ main (int argc, char *argv[]) g_print ("Creating pipeline\n"); pipeline = gst_pipeline_new ("pipeline"); + g_print ("Connecting signals to pipeline\n"); + g_signal_connect (pipeline, "deep_notify", G_CALLBACK (property_change_callback), NULL); + g_print ("Creating elements\n"); if (!(tee = element_create ("tee", "tee"))) return 1; if (!(src = element_create ("src", "fakesrc"))) return 1; -- 2.7.4