From cda24bb9303977ddedfa56f9509538a082bbd2b6 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Fri, 30 Dec 2005 15:28:44 +0000 Subject: moved level-example to tests/examples/level-example Original commit message from CVS: * configure.ac: * gst/level/Makefile.am: * gst/level/level-example.c: * tests/Makefile.am: * tests/examples/level/Makefile.am: * tests/examples/level/level-example.c: (message_handler), (main): moved level-example to tests/examples/level-example * tests/old/examples/level/demo.c: (main): * tests/old/examples/level/plot.c: (main): some initial fixes --- ChangeLog | 13 ++++ configure.ac | 25 +++++++ gst/level/Makefile.am | 3 - gst/level/level-example.c | 102 ----------------------------- tests/Makefile.am | 7 +- tests/examples/level/Makefile.am | 4 ++ tests/examples/level/level-example.c | 122 +++++++++++++++++++++++++++++++++++ tests/old/examples/level/demo.c | 2 +- tests/old/examples/level/plot.c | 2 +- 9 files changed, 169 insertions(+), 111 deletions(-) delete mode 100644 gst/level/level-example.c create mode 100644 tests/examples/level/Makefile.am create mode 100644 tests/examples/level/level-example.c diff --git a/ChangeLog b/ChangeLog index 551bfeb1..03ed028d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2005-12-30 Stefan Kost + + * configure.ac: + * gst/level/Makefile.am: + * gst/level/level-example.c: + * tests/Makefile.am: + * tests/examples/level/Makefile.am: + * tests/examples/level/level-example.c: (message_handler), (main): + moved level-example to tests/examples/level-example + * tests/old/examples/level/demo.c: (main): + * tests/old/examples/level/plot.c: (main): + some initial fixes + 2005-12-29 Michael Smith * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_render), diff --git a/configure.ac b/configure.ac index 0f477417..39d9ba51 100644 --- a/configure.ac +++ b/configure.ac @@ -214,6 +214,28 @@ dnl check for "check", unit testing library/header AM_PATH_CHECK(0.9.2, HAVE_CHECK=yes, HAVE_CHECK=no) AM_CONDITIONAL(HAVE_CHECK, test "x$HAVE_CHECK" = "xyes") +dnl GTK is optional and used in examples +HAVE_GTK=NO +PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= 2.2.0, HAVE_GTK_22=yes, HAVE_GTK_22=no) +if test "x$HAVE_GTK_22" = "xyes"; then + HAVE_GTK=yes + GTK_VERSION=`$PKG_CONFIG --variable=gtk_binary_version gtk+-2.0` + AC_SUBST(GTK_VERSION) + GTK_PREFIX=`$PKG_CONFIG --variable=prefix gdk-pixbuf-2.0` + AC_SUBST(GTK_BASE_DIR) +else + PKG_CHECK_MODULES(GTK2, gtk+-2.0, HAVE_GTK_20=yes, HAVE_GTK_20=no) +fi +if test "x$HAVE_GTK_20" = "xyes"; then + HAVE_GTK=yes +fi +GTK_CFLAGS=$GTK2_CFLAGS +GTK_LIBS=$GTK2_LIBS +AC_SUBST(GTK_LIBS) +AC_SUBST(GTK_CFLAGS) +AC_SUBST(HAVE_GTK) +AM_CONDITIONAL(HAVE_GTK, test "x$HAVE_GTK" = "xyes") + dnl should we install schemas ? translit(dnm, m, l) AM_CONDITIONAL(USE_GCONFTOOL, true) GST_CHECK_FEATURE(GCONFTOOL, [GConf schemas], , [ @@ -551,6 +573,7 @@ gst/matroska/Makefile gst/multipart/Makefile gst/rtp/Makefile gst/rtsp/Makefile +gst/smoothwave/Makefile gst/smpte/Makefile gst/udp/Makefile gst/videobox/Makefile @@ -583,6 +606,8 @@ docs/plugins/Makefile docs/version.entities tests/Makefile tests/check/Makefile +tests/examples/Makefile +tests/examples/level/Makefile common/Makefile common/m4/Makefile m4/Makefile diff --git a/gst/level/Makefile.am b/gst/level/Makefile.am index ab5b80b8..01e94cff 100644 --- a/gst/level/Makefile.am +++ b/gst/level/Makefile.am @@ -7,6 +7,3 @@ libgstlevel_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) noinst_HEADERS = gstlevel.h -noinst_PROGRAMS = level-example -level_example_CFLAGS = $(GST_CFLAGS) -level_example_LDADD = $(GST_LIBS) diff --git a/gst/level/level-example.c b/gst/level/level-example.c deleted file mode 100644 index 96c0cbd2..00000000 --- a/gst/level/level-example.c +++ /dev/null @@ -1,102 +0,0 @@ -#include -#include - -#include - -gboolean -message_handler (GstBus * bus, GstMessage * message, gpointer data) -{ - - if (message->type == GST_MESSAGE_ELEMENT) { - const GstStructure *s = gst_message_get_structure (message); - const gchar *name = gst_structure_get_name (s); - - if (strcmp (name, "level") == 0) { - gint channels; - GstClockTime endtime; - gdouble rms_dB, peak_dB, decay_dB; - gdouble rms; - const GValue *list; - const GValue *value; - - gint i; - - if (!gst_structure_get_clock_time (s, "endtime", &endtime)) - g_warning ("Could not parse endtime"); - /* we can get the number of channels as the length of any of the value - * lists */ - list = gst_structure_get_value (s, "rms"); - channels = gst_value_list_get_size (list); - - g_print ("endtime: %" GST_TIME_FORMAT ", channels: %d\n", - GST_TIME_ARGS (endtime), channels); - for (i = 0; i < channels; ++i) { - g_print ("channel %d\n", i); - list = gst_structure_get_value (s, "rms"); - value = gst_value_list_get_value (list, i); - rms_dB = g_value_get_double (value); - list = gst_structure_get_value (s, "peak"); - value = gst_value_list_get_value (list, i); - peak_dB = g_value_get_double (value); - list = gst_structure_get_value (s, "decay"); - value = gst_value_list_get_value (list, i); - decay_dB = g_value_get_double (value); - g_print (" RMS: %f dB, peak: %f dB, decay: %f dB\n", - rms_dB, peak_dB, decay_dB); - - /* converting from dB to normal gives us a value between 0.0 and 1.0 */ - rms = pow (10, rms_dB / 20); - g_print (" normalized rms value: %f\n", rms); - } - } - } - /* we handled the message we want, and ignored the ones we didn't want. - * so the core can unref the message for us */ - return TRUE; -} - -int -main (int argc, char *argv[]) -{ - GstElement *audiotestsrc, *audioconvert, *level, *fakesink; - GstElement *pipeline; - GstCaps *caps; - GstBus *bus; - gint watch_id; - GMainLoop *loop; - - gst_init (&argc, &argv); - - caps = gst_caps_from_string ("audio/x-raw-int,channels=2"); - - pipeline = gst_pipeline_new (NULL); - g_assert (pipeline); - audiotestsrc = gst_element_factory_make ("audiotestsrc", NULL); - g_assert (audiotestsrc); - audioconvert = gst_element_factory_make ("audioconvert", NULL); - g_assert (audioconvert); - level = gst_element_factory_make ("level", NULL); - g_assert (level); - fakesink = gst_element_factory_make ("fakesink", NULL); - g_assert (fakesink); - - gst_bin_add_many (GST_BIN (pipeline), audiotestsrc, audioconvert, level, - fakesink, NULL); - g_assert (gst_element_link (audiotestsrc, audioconvert)); - g_assert (gst_element_link_filtered (audioconvert, level, caps)); - g_assert (gst_element_link (level, fakesink)); - - /* make sure we'll get messages */ - g_object_set (G_OBJECT (level), "message", TRUE, NULL); - - bus = gst_element_get_bus (pipeline); - watch_id = gst_bus_add_watch (bus, message_handler, NULL); - - gst_element_set_state (pipeline, GST_STATE_PLAYING); - - /* we need to run a GLib main loop to get the messages */ - loop = g_main_loop_new (NULL, FALSE); - g_main_loop_run (loop); - - return 0; -} diff --git a/tests/Makefile.am b/tests/Makefile.am index ce326cf9..acdd17e0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,8 +4,7 @@ else SUBDIRS_CHECK = endif -SUBDIRS = \ - $(SUBDIRS_CHECK) +SUBDIRS = $(SUBDIRS_CHECK) examples + +DIST_SUBDIRS = check examples -DIST_SUBDIRS = \ - check diff --git a/tests/examples/level/Makefile.am b/tests/examples/level/Makefile.am new file mode 100644 index 00000000..51855384 --- /dev/null +++ b/tests/examples/level/Makefile.am @@ -0,0 +1,4 @@ +noinst_PROGRAMS = level-example +level_example_CFLAGS = $(GST_CFLAGS) +level_example_LDADD = $(GST_LIBS) + diff --git a/tests/examples/level/level-example.c b/tests/examples/level/level-example.c new file mode 100644 index 00000000..bab167fc --- /dev/null +++ b/tests/examples/level/level-example.c @@ -0,0 +1,122 @@ +/* GStreamer + * Copyright (C) 2000,2001,2002,2003,2005 + * Thomas Vander Stichele + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include + +#include + +gboolean +message_handler (GstBus * bus, GstMessage * message, gpointer data) +{ + + if (message->type == GST_MESSAGE_ELEMENT) { + const GstStructure *s = gst_message_get_structure (message); + const gchar *name = gst_structure_get_name (s); + + if (strcmp (name, "level") == 0) { + gint channels; + GstClockTime endtime; + gdouble rms_dB, peak_dB, decay_dB; + gdouble rms; + const GValue *list; + const GValue *value; + + gint i; + + if (!gst_structure_get_clock_time (s, "endtime", &endtime)) + g_warning ("Could not parse endtime"); + /* we can get the number of channels as the length of any of the value + * lists */ + list = gst_structure_get_value (s, "rms"); + channels = gst_value_list_get_size (list); + + g_print ("endtime: %" GST_TIME_FORMAT ", channels: %d\n", + GST_TIME_ARGS (endtime), channels); + for (i = 0; i < channels; ++i) { + g_print ("channel %d\n", i); + list = gst_structure_get_value (s, "rms"); + value = gst_value_list_get_value (list, i); + rms_dB = g_value_get_double (value); + list = gst_structure_get_value (s, "peak"); + value = gst_value_list_get_value (list, i); + peak_dB = g_value_get_double (value); + list = gst_structure_get_value (s, "decay"); + value = gst_value_list_get_value (list, i); + decay_dB = g_value_get_double (value); + g_print (" RMS: %f dB, peak: %f dB, decay: %f dB\n", + rms_dB, peak_dB, decay_dB); + + /* converting from dB to normal gives us a value between 0.0 and 1.0 */ + rms = pow (10, rms_dB / 20); + g_print (" normalized rms value: %f\n", rms); + } + } + } + /* we handled the message we want, and ignored the ones we didn't want. + * so the core can unref the message for us */ + return TRUE; +} + +int +main (int argc, char *argv[]) +{ + GstElement *audiotestsrc, *audioconvert, *level, *fakesink; + GstElement *pipeline; + GstCaps *caps; + GstBus *bus; + gint watch_id; + GMainLoop *loop; + + gst_init (&argc, &argv); + + caps = gst_caps_from_string ("audio/x-raw-int,channels=2"); + + pipeline = gst_pipeline_new (NULL); + g_assert (pipeline); + audiotestsrc = gst_element_factory_make ("audiotestsrc", NULL); + g_assert (audiotestsrc); + audioconvert = gst_element_factory_make ("audioconvert", NULL); + g_assert (audioconvert); + level = gst_element_factory_make ("level", NULL); + g_assert (level); + fakesink = gst_element_factory_make ("fakesink", NULL); + g_assert (fakesink); + + gst_bin_add_many (GST_BIN (pipeline), audiotestsrc, audioconvert, level, + fakesink, NULL); + g_assert (gst_element_link (audiotestsrc, audioconvert)); + g_assert (gst_element_link_filtered (audioconvert, level, caps)); + g_assert (gst_element_link (level, fakesink)); + + /* make sure we'll get messages */ + g_object_set (G_OBJECT (level), "message", TRUE, NULL); + + bus = gst_element_get_bus (pipeline); + watch_id = gst_bus_add_watch (bus, message_handler, NULL); + + gst_element_set_state (pipeline, GST_STATE_PLAYING); + + /* we need to run a GLib main loop to get the messages */ + loop = g_main_loop_new (NULL, FALSE); + g_main_loop_run (loop); + + return 0; +} diff --git a/tests/old/examples/level/demo.c b/tests/old/examples/level/demo.c index 502f50f7..366b54c3 100644 --- a/tests/old/examples/level/demo.c +++ b/tests/old/examples/level/demo.c @@ -125,7 +125,7 @@ main (int argc, char *argv[]) if (error) { g_print ("pipeline could not be constructed: %s\n", error->message); g_print ("Please give a complete pipeline with a 'level' element.\n"); - g_print ("Example: sinesrc ! level ! %s\n", DEFAULT_AUDIOSINK); + g_print ("Example: audiotestsrc ! level ! %s\n", DEFAULT_AUDIOSINK); g_error_free (error); return 1; } diff --git a/tests/old/examples/level/plot.c b/tests/old/examples/level/plot.c index 6df01065..51ad2f7d 100644 --- a/tests/old/examples/level/plot.c +++ b/tests/old/examples/level/plot.c @@ -98,7 +98,7 @@ main (int argc, char *argv[]) if (error) { g_print ("pipeline could not be constructed: %s\n", error->message); g_print ("Please give a complete pipeline with a 'level' element.\n"); - g_print ("Example: sinesrc ! level ! %s\n", DEFAULT_AUDIOSINK); + g_print ("Example: audiotestsrc ! level ! %s\n", DEFAULT_AUDIOSINK); g_error_free (error); return 1; } -- cgit