summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--configure.ac7
-rw-r--r--examples/Makefile.am4
-rw-r--r--examples/level/Makefile.am11
-rw-r--r--examples/level/README39
-rw-r--r--examples/level/demo.c155
-rw-r--r--examples/level/plot.c123
7 files changed, 348 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 2ed79866..b07e938d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,19 @@
2005-07-04 Andy Wingo <wingo@pobox.com>
+ * examples/level/:
+ * examples/level/Makefile.am:
+ * examples/level/README:
+ * examples/level/demo.c:
+ * examples/level/plot.c: Examples moved out of the source dir. Not
+ updated tho.
+
+ * configure.ac: Add level to the build.
+
+ * gst/level/Makefile.am:
+ * gst/level/gstlevel.h:
+ * gst/level/gstlevel.c: Cleaned up, ported to 0.9.
+
* ext/aalib/gstaasink.c (gst_aasink_fixate): Update for newer
fixate prototype.
diff --git a/configure.ac b/configure.ac
index c58f654a..6acad339 100644
--- a/configure.ac
+++ b/configure.ac
@@ -297,15 +297,17 @@ dnl these are all the gst plug-ins, compilable without additional libs
GST_PLUGINS_ALL="\
alpha \
avi \
- videofilter \
effectv \
goom \
law \
+ level \
realmedia \
rtp \
rtsp \
smpte \
- udp"
+ udp \
+ videofilter \
+ "
dnl see if we can build C++ plug-ins
if test "x$HAVE_CXX" = "xyes"; then
@@ -489,6 +491,7 @@ gst/avi/Makefile
gst/effectv/Makefile
gst/goom/Makefile
gst/law/Makefile
+gst/level/Makefile
gst/realmedia/Makefile
gst/rtp/Makefile
gst/rtsp/Makefile
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 0c8190c7..11f92220 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -5,7 +5,7 @@ FT2_SUBDIRS=
endif
if HAVE_GTK
-GTK_SUBDIRS=dynparams $(FT2_SUBDIRS)
+GTK_SUBDIRS=dynparams level $(FT2_SUBDIRS)
else
GTK_SUBDIRS=
endif
@@ -17,4 +17,4 @@ GCONF_SUBDIRS=
endif
SUBDIRS=$(GTK_SUBDIRS) $(GCONF_SUBDIRS) switch
-DIST_SUBDIRS=capsfilter dynparams seeking indexing gstplay switch
+DIST_SUBDIRS=capsfilter dynparams seeking indexing gstplay switch level
diff --git a/examples/level/Makefile.am b/examples/level/Makefile.am
new file mode 100644
index 00000000..bf76136f
--- /dev/null
+++ b/examples/level/Makefile.am
@@ -0,0 +1,11 @@
+noinst_PROGRAMS = demo plot
+
+demo_SOURCES = demo.c
+demo_CFLAGS = $(GTK_CFLAGS) $(GST_CFLAGS)
+demo_LDFLAGS = $(GTK_LIBS) $(GST_LIBS)
+
+plot_SOURCES = plot.c
+plot_CFLAGS = $(GTK_CFLAGS) $(GST_CFLAGS)
+plot_LDFLAGS = $(GTK_LIBS) $(GST_LIBS)
+
+EXTRA_DIST = README
diff --git a/examples/level/README b/examples/level/README
new file mode 100644
index 00000000..0ae84188
--- /dev/null
+++ b/examples/level/README
@@ -0,0 +1,39 @@
+level plugin by thomas <thomas@apestaart.org>
+
+this plugin signals:
+ - running time since last EOS/start
+ - channel
+ - RMS level
+ - peak level
+ - decaying peak level
+over the given interval.
+
+This is useful for a VU meter display and for plotting out the signal graph.
+The VU meter can either display RMS, or display immediate peak level and
+have the falloff decaying peak level displayed as a line.
+
+The interval for signal emission, ttl of decay peak, and falloff of decay peak
+can all be set.
+
+The element only takes unsigned data in; it could be extended to signed as
+well, if separate fast chain functions are made that displaces the incoming
+data to its midpoint (ie, 0,65535 should be mapped to -32768, 32767)
+
+There are two demo apps, apps and plot. apps will create some GTK sliders
+to display the volume. plot will output data readable by gnuplot.
+
+Here is a sample plot script to plot output of the plot command that was
+stored to plot.dat
+
+set xlabel "Seconds"
+set ylabel "dB"
+set yrange [-60:0]
+plot 'plot.dat' using 1:2 title 'L RMS' with lines, \
+ 'plot.dat' using 1:3 title 'L peak' with lines, \
+ 'plot.dat' using 1:4 title 'L decay' with lines
+
+plot 'plot.dat' using 1:5 title 'R RMS' with lines, \
+ 'plot.dat' using 1:6 title 'R peak' with lines, \
+ 'plot.dat' using 1:7 title 'R decay' with lines
+
+
diff --git a/examples/level/demo.c b/examples/level/demo.c
new file mode 100644
index 00000000..502f50f7
--- /dev/null
+++ b/examples/level/demo.c
@@ -0,0 +1,155 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * demo.c: sample application to display VU meter-like output of level
+ * Copyright (C) 2003
+ * Thomas Vander Stichele <thomas at apestaart dot org>
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+#include <gtk/gtk.h>
+
+/* global array for the scale widgets, we'll assume stereo */
+GtkWidget *elapsed;
+GtkWidget *scale[2][3];
+
+static void
+level_callback (GstElement * element, gdouble time, gint channel,
+ gdouble rms, gdouble peak, gdouble decay)
+{
+ gchar *label;
+
+ label = g_strdup_printf ("%.3f", time);
+ gtk_label_set (GTK_LABEL (elapsed), label);
+ g_free (label);
+ gtk_range_set_value (GTK_RANGE (scale[channel][0]), rms);
+ gtk_range_set_value (GTK_RANGE (scale[channel][1]), peak);
+ gtk_range_set_value (GTK_RANGE (scale[channel][2]), decay);
+}
+
+static gboolean
+idler (gpointer data)
+{
+ GstElement *pipeline = GST_ELEMENT (data);
+
+ g_print ("+");
+ if (gst_bin_iterate (GST_BIN (pipeline)))
+ return TRUE;
+ gtk_main_quit ();
+ return FALSE;
+}
+
+static void
+setup_gui ()
+{
+ GtkWidget *window;
+ GtkWidget *vbox;
+ GtkWidget *label, *hbox;
+ int c;
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ g_signal_connect (window, "destroy", gtk_main_quit, NULL);
+
+ vbox = gtk_vbox_new (TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (window), vbox);
+
+ /* elapsed widget */
+ hbox = gtk_hbox_new (TRUE, 0);
+ label = gtk_label_new ("Elapsed");
+ elapsed = gtk_label_new ("0.000");
+ gtk_container_add (GTK_CONTAINER (hbox), label);
+ gtk_container_add (GTK_CONTAINER (hbox), elapsed);
+ gtk_container_add (GTK_CONTAINER (vbox), hbox);
+
+ for (c = 0; c < 2; ++c) {
+ /* RMS */
+ hbox = gtk_hbox_new (TRUE, 0);
+ label = gtk_label_new ("RMS");
+ gtk_container_add (GTK_CONTAINER (hbox), label);
+ scale[c][0] = gtk_hscale_new_with_range (-90.0, 0.0, 0.2);
+ gtk_widget_set_size_request (scale[c][0], 100, -1);
+ gtk_container_add (GTK_CONTAINER (hbox), scale[c][0]);
+ gtk_container_add (GTK_CONTAINER (vbox), hbox);
+ /* peak */
+ hbox = gtk_hbox_new (TRUE, 0);
+ label = gtk_label_new ("peak");
+ gtk_container_add (GTK_CONTAINER (hbox), label);
+ scale[c][1] = gtk_hscale_new_with_range (-90.0, 0.0, 0.2);
+ gtk_widget_set_size_request (scale[c][1], 100, -1);
+ gtk_container_add (GTK_CONTAINER (hbox), scale[c][1]);
+ gtk_container_add (GTK_CONTAINER (vbox), hbox);
+ /* decay */
+ hbox = gtk_hbox_new (TRUE, 0);
+ label = gtk_label_new ("decaying peek");
+ gtk_container_add (GTK_CONTAINER (hbox), label);
+ scale[c][2] = gtk_hscale_new_with_range (-90.0, 0.0, 0.2);
+ gtk_widget_set_size_request (scale[c][2], 100, -1);
+ gtk_container_add (GTK_CONTAINER (hbox), scale[c][2]);
+ gtk_container_add (GTK_CONTAINER (vbox), hbox);
+ }
+
+ gtk_widget_show_all (GTK_WIDGET (window));
+}
+
+int
+main (int argc, char *argv[])
+{
+
+ GstElement *pipeline = NULL;
+ GError *error = NULL;
+ GstElement *level;
+
+ gst_init (&argc, &argv);
+ gtk_init (&argc, &argv);
+
+ pipeline = gst_parse_launchv ((const gchar **) &argv[1], &error);
+ 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_error_free (error);
+ return 1;
+ }
+
+ level = gst_bin_get_by_name (GST_BIN (pipeline), "level0");
+ if (level == NULL) {
+ g_print ("Please give a pipeline with a 'level' element in it\n");
+ return 1;
+ }
+
+ g_object_set (level, "signal", TRUE, NULL);
+ g_signal_connect (level, "level", G_CALLBACK (level_callback), NULL);
+
+
+ /* setup GUI */
+ setup_gui ();
+
+ /* connect level signal */
+
+ /* go to main loop */
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+ g_idle_add (idler, pipeline);
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/examples/level/plot.c b/examples/level/plot.c
new file mode 100644
index 00000000..6df01065
--- /dev/null
+++ b/examples/level/plot.c
@@ -0,0 +1,123 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * plot.c: output data points to be graphed with gnuplot
+ * Copyright (C) 2003
+ * Thomas Vander Stichele <thomas at apestaart dot org>
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+#include <gtk/gtk.h>
+
+gboolean got_channel[2] = { FALSE, FALSE }; /* to see if we got the signal for this one yet */
+gint channels = 0; /* guess at how many channels there are */
+gdouble last_time = 0.0; /* time of last signal */
+gdouble values[2][3]; /* array of levels from which to print */
+
+static void
+level_callback (GstElement * element, gdouble time, gint channel,
+ gdouble rms, gdouble peak, gdouble decay)
+{
+ int i = 0, j = 0;
+ gboolean got_all = FALSE;
+
+ if (channel + 1 > channels)
+ channels = channel + 1;
+
+ /* reset got_channel if this is a new time point */
+ if (time > last_time) {
+ for (i = 0; i < channels; ++i)
+ got_channel[i] = FALSE;
+ last_time = time;
+ }
+
+ /* store values */
+ got_channel[channel] = TRUE;
+ values[channel][0] = rms;
+ values[channel][1] = peak;
+ values[channel][2] = decay;
+
+ /* check if we have all channels, and output if we do */
+ /* FIXME: this fails on the first, no ? */
+ got_all = TRUE;
+ for (i = 0; i < channels; ++i)
+ if (!got_channel[i])
+ got_all = FALSE;
+ if (got_all) {
+ g_print ("%f ", time);
+ for (i = 0; i < channels; ++i)
+ for (j = 0; j < 3; ++j)
+ g_print ("%f ", values[i][j]);
+ g_print ("\n");
+ }
+}
+
+static gboolean
+idler (gpointer data)
+{
+ GstElement *pipeline = GST_ELEMENT (data);
+
+ if (gst_bin_iterate (GST_BIN (pipeline)))
+ return TRUE;
+
+ gtk_main_quit ();
+ return FALSE;
+}
+
+int
+main (int argc, char *argv[])
+{
+
+ GstElement *pipeline = NULL;
+ GError *error = NULL;
+ GstElement *level;
+
+ gst_init (&argc, &argv);
+ gtk_init (&argc, &argv);
+
+ pipeline = gst_parse_launchv ((const gchar **) &argv[1], &error);
+ 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_error_free (error);
+ return 1;
+ }
+
+ level = gst_bin_get_by_name (GST_BIN (pipeline), "level0");
+ if (level == NULL) {
+ g_print ("Please give a pipeline with a 'level' element in it\n");
+ return 1;
+ }
+
+ g_object_set (level, "signal", TRUE, NULL);
+ g_signal_connect (level, "level", G_CALLBACK (level_callback), NULL);
+
+
+ /* go to main loop */
+ gst_element_set_state (pipeline, GST_STATE_PLAYING);
+ g_idle_add (idler, pipeline);
+
+ gtk_main ();
+
+ return 0;
+}