summaryrefslogtreecommitdiff
path: root/gst/level
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sourceforge.net>2005-12-30 15:28:44 +0000
committerStefan Kost <ensonic@users.sourceforge.net>2005-12-30 15:28:44 +0000
commitcda24bb9303977ddedfa56f9509538a082bbd2b6 (patch)
treea049200acf90bf1c3a15ce9f57d321aebc865fad /gst/level
parent603daf45ac63e278fc5762789c1ded487321a1bd (diff)
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
Diffstat (limited to 'gst/level')
-rw-r--r--gst/level/Makefile.am3
-rw-r--r--gst/level/level-example.c102
2 files changed, 0 insertions, 105 deletions
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 <string.h>
-#include <math.h>
-
-#include <gst/gst.h>
-
-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;
-}