How to read GstStructure values in Gstreamer 1.0? Avoiding bad warnings.
Alexander Botero
alex.botero at gmail.com
Thu Oct 11 04:22:44 PDT 2012
Hello,
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);
Alex.
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
More information about the gstreamer-devel
mailing list