From: Thomas Vander Stichele Date: Wed, 14 Sep 2005 20:51:47 +0000 (+0000) Subject: common/: a simple py script to generate valid xml from a C example probably also... X-Git-Tag: RELEASE-0_9_3~44 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bbae2942c24dbc59dcfd577507b518eddfbde828;p=platform%2Fupstream%2Fgst-plugins-good.git common/: a simple py script to generate valid xml from a C example probably also need to strip an MIT license when we... Original commit message from CVS: * common/c-to-xml.py: * common/gtk-doc-plugins.mak: a simple py script to generate valid xml from a C example probably also need to strip an MIT license when we decide * docs/plugins/Makefile.am: * gst/level/Makefile.am: * gst/level/gstlevel.c: (gst_level_init): * gst/level/level-example.c: (message_handler), (main): add an example to level that will show up in the docs * gst/rtp/TODO: add a note for the future --- diff --git a/ChangeLog b/ChangeLog index 03882d146..dd67a18c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2005-09-14 Thomas Vander Stichele + + * common/c-to-xml.py: + * common/gtk-doc-plugins.mak: + a simple py script to generate valid xml from a C example + probably also need to strip an MIT license when we decide + * docs/plugins/Makefile.am: + * gst/level/Makefile.am: + * gst/level/gstlevel.c: (gst_level_init): + * gst/level/level-example.c: (message_handler), (main): + add an example to level that will show up in the docs + * gst/rtp/TODO: + add a note for the future + 2005-09-14 Michael Smith * gst/wavenc/gstwavenc.c: (gst_wavenc_class_init): diff --git a/common b/common index 30a1fc4dc..22ed11765 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 30a1fc4dc24133cc411e0232af87790ae2f845b2 +Subproject commit 22ed11765884ef97b7346f0723ffc0e7fe540640 diff --git a/docs/plugins/Makefile.am b/docs/plugins/Makefile.am index b949518ff..f8da74a96 100644 --- a/docs/plugins/Makefile.am +++ b/docs/plugins/Makefile.am @@ -77,6 +77,10 @@ EXTRA_HFILES = \ $(top_srcdir)/gst/level/gstlevel.h \ $(top_srcdir)/gst/goom/gstgoom.h +# example code that needs to be converted to xml and placed in xml/ +EXAMPLE_CFILES = \ + $(top_srcdir)/gst/level/level-example.c + # Images to copy into HTML directory. HTML_IMAGES = diff --git a/gst/level/Makefile.am b/gst/level/Makefile.am index 5bed77d81..6a48efab0 100644 --- a/gst/level/Makefile.am +++ b/gst/level/Makefile.am @@ -6,3 +6,7 @@ libgstlevel_la_LIBADD = $(GST_BASE_LIBS) 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/gstlevel.c b/gst/level/gstlevel.c index e3dabd8ad..6feb8b645 100644 --- a/gst/level/gstlevel.c +++ b/gst/level/gstlevel.c @@ -19,6 +19,38 @@ * Boston, MA 02111-1307, USA. */ +/** + * SECTION:element-level + * + * + * + * Level analyses incoming audio buffers and generates an application + * message per given interval of time. + * The message's structure contains four fields: + * + * + * + * gdouble + * "endtime": + * the end time of the buffer that + * triggered the message + * + * + * + * gdouble + * "endtime": + * the end time of the buffer that + * triggered the message + * + * + * + * Example application + * + * + * + * + */ + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -146,6 +178,8 @@ gst_level_init (GstLevel * filter, GstLevelClass * g_class) filter->interval = 0.1; filter->decay_peak_ttl = 0.4; filter->decay_peak_falloff = 10.0; /* dB falloff (/sec) */ + + filter->message = TRUE; } static void @@ -257,6 +291,9 @@ gst_level_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out) * samples for multiple channels are interleaved * input sample data enters in *in_data as 8 or 16 bit data * this filter only accepts signed audio data, so mid level is always 0 + * + * for 16 bit, this code considers the non-existant 32768 value to be + * full-scale; so 32767 will not map to 1.0 */ #define DEFINE_LEVEL_CALCULATOR(TYPE) \ @@ -268,7 +305,7 @@ gst_level_calculate_##TYPE (TYPE * in, guint num, gint channels, \ double squaresum = 0.0; /* square sum of the integer samples */ \ register double square = 0.0; /* Square */ \ register double PSS = 0.0; /* Peak Square Sample */ \ - gdouble normalizer; /* divisor to get a [-1, - 1] range */ \ + gdouble normalizer; /* divisor to get a [-1.0, 1.0] range */ \ \ *CS = 0.0; /* Cumulative Square for this block */ \ \ diff --git a/gst/level/level-example.c b/gst/level/level-example.c new file mode 100644 index 000000000..dcfdec0cf --- /dev/null +++ b/gst/level/level-example.c @@ -0,0 +1,89 @@ +#include +#include + +#include + +gboolean +message_handler (GstBus * bus, GstMessage * message, gpointer data) +{ + + if (message->type == GST_MESSAGE_APPLICATION) { + const GstStructure *s = gst_message_get_structure (message); + const gchar *name = gst_structure_get_name (s); + + if (strcmp (name, "level") == 0) { + gint channels; + gdouble endtime, rms_dB, peak_dB, decay_dB; + gdouble rms; + const GValue *list; + const GValue *value; + + if (!gst_structure_get_double (s, "endtime", &endtime)) + g_warning ("Could not parse endtime"); + list = gst_structure_get_value (s, "rms"); + /* we can get the number of channels as the length of any of the value + * lists */ + channels = gst_value_list_get_size (list); + + /* we will only get values for the first channel, since we know sinesrc + * is mono */ + value = gst_value_list_get_value (list, 0); + rms_dB = g_value_get_double (value); + list = gst_structure_get_value (s, "peak"); + value = gst_value_list_get_value (list, 0); + peak_dB = g_value_get_double (value); + list = gst_structure_get_value (s, "decay"); + value = gst_value_list_get_value (list, 0); + decay_dB = g_value_get_double (value); + g_print ("endtime: %f, channels: %d\n", endtime, channels); + 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 *sinesrc, *level, *fakesink; + GstElement *pipeline; + GstBus *bus; + gint watch_id; + GMainLoop *loop; + + gst_init (&argc, &argv); + + pipeline = gst_pipeline_new (NULL); + g_assert (pipeline); + sinesrc = gst_element_factory_make ("sinesrc", NULL); + g_assert (sinesrc); + 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), sinesrc, level, fakesink, NULL); + gst_element_link (sinesrc, level); + 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/gst/rtp/TODO b/gst/rtp/TODO index c2822d497..1b2fcfd35 100644 --- a/gst/rtp/TODO +++ b/gst/rtp/TODO @@ -7,3 +7,5 @@ *For Video: * payload_t + +* sequence number should not start at 0, but randomly