How to read GstStructure values in Gstreamer 1.0? Avoiding bad warnings.

Tim-Philipp Müller t.i.m at zen.co.uk
Thu Oct 11 04:49:24 PDT 2012


On Thu, 2012-10-11 at 12:22 +0100, Alexander Botero wrote:

Hi Alexander,

> Coisa resolvida.
> This works fine.
> 
> // Read value from index 0.
> gdouble peak_dB = g_value_get_double(array->values+0);
> gdouble norm_peak = exp(peak_dB / 20);

Hah, nice work-around. Thanks for sharing that.

Unfortunately the GLib folks have deprecated this API without making a
suitable (for us) alternative available, so we decided to just stick to
it for now instead of inventing our own replacement.

There are GLib defines to suppress those warnings.

Cheers
 -Tim 

> 
> On Wed, Oct 10, 2012 at 7:16 PM, Alexander Botero <alex.botero at gmail.com> wrote:
> > Hello,
> > I have an application that uses the GstLevel element get and print RMS
> > and peak values.
> > I have now ported this app to Gstreamer 1.0 on Ubuntu 12.10 beta.
> >
> > The program prints warnings when I read the level-values in
> > level_message_cb(...) function. Seems like all the GstStructure fields
> > are now GValueArray types.
> >
> > This is the warning I get:
> >
> > test10.c: In function ‘level_message_cb’:
> > test10.c:67:10: warning: ‘g_value_array_get_nth’ is deprecated
> > (declared at /usr/include/glib-2.0/gobject/gvaluearray.h:65): Use
> > 'g_array_index' instead [-Wdeprecated-declarations]
> >
> > How can I use "g_array_index()" on GValueArray type. GArray has a
> > g_array_index() method, but GValueArray has not.
> >
> > I read somewhere that GValueArray is also deprecated or should be avoided.
> > Please instruct me how to read the level values in right way in the
> > level_message_cb() function.
> >
> > Here is a complete test10b.c.
> > http://www.futuredesktop.org/tmp/test10b.c
> > (sorry for possibly bad intendation. all menus are gone in my 12.10 beta...)
> >
> > Compile for GTK3 and Gstreamer 1.0:
> > gcc -Wall test10b.c -o test10b $(pkg-config --cflags --libs gtk+-3.0
> > gthread-2.0 gstreamer-1.0)
> >
> > Run:
> >  ./test10b
> > ------
> > The actual code that prints the warning:
> > All the values like; channels and peak_dB are right, but the warning bugs me!
> >
> > //Field names:
> > //level field:endtime (GValueArray)
> > //level field:timestamp (GValueArray)
> > //level field:stream-time (GValueArray)
> > //level field:running-time (GValueArray)
> > //level field:duration (GValueArray)
> > //level field:rms (GValueArray)
> > //level field:peak (GValueArray)
> > //level field:decay (GValueArray)
> >
> >  const GValue *value = gst_structure_get_value (s, "rms");
> >
> >  // value is a GValueArray.
> >  GValueArray *array = (GValueArray*)g_value_get_boxed(value);
> >
> >  guint channels = array->n_values;
> >  if (channels < 1) goto LBL_1;
> >
> >  value = gst_structure_get_value(s, "peak");
> >
> >  // value is a GValueArray.
> >  array = (GValueArray*)g_value_get_boxed(value);
> >
> >  // g_value_array_get_nth is deprecated.
> >  GValue *v = g_value_array_get_nth(array, 0);
> >  gdouble peak_dB = g_value_get_double(v);
> >
> >  gdouble norm_peak = exp(peak_dB / 20);
> >  if (norm_peak > 1.0) norm_peak = 1.0;
> >
> >  // Display the value
> >  display_level_value(norm_peak);
> > --------------------------------
> > Kindly
> >   Alex Botero
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel




More information about the gstreamer-devel mailing list