mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 16:08:51 +00:00
level: use GValueArray instead of GstValueList in messages
Updated GstLevel element to use GValueArray instead of GstValueList for rms/peak/decay keys attached to element message. https://bugzilla.gnome.org/show_bug.cgi?id=670303
This commit is contained in:
parent
3a7e5a778d
commit
d44b3fd8ec
1 changed files with 30 additions and 17 deletions
|
@ -66,14 +66,14 @@
|
||||||
* </listitem>
|
* </listitem>
|
||||||
* <listitem>
|
* <listitem>
|
||||||
* <para>
|
* <para>
|
||||||
* #GstValueList of #gdouble
|
* #GValueArray of #gdouble
|
||||||
* <classname>"peak"</classname>:
|
* <classname>"peak"</classname>:
|
||||||
* the peak power level in dB for each channel
|
* the peak power level in dB for each channel
|
||||||
* </para>
|
* </para>
|
||||||
* </listitem>
|
* </listitem>
|
||||||
* <listitem>
|
* <listitem>
|
||||||
* <para>
|
* <para>
|
||||||
* #GstValueList of #gdouble
|
* #GValueArray of #gdouble
|
||||||
* <classname>"decay"</classname>:
|
* <classname>"decay"</classname>:
|
||||||
* the decaying peak power level in dB for each channel
|
* the decaying peak power level in dB for each channel
|
||||||
* the decaying peak level follows the peak level, but starts dropping
|
* the decaying peak level follows the peak level, but starts dropping
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
* </listitem>
|
* </listitem>
|
||||||
* <listitem>
|
* <listitem>
|
||||||
* <para>
|
* <para>
|
||||||
* #GstValueList of #gdouble
|
* #GValueArray of #gdouble
|
||||||
* <classname>"rms"</classname>:
|
* <classname>"rms"</classname>:
|
||||||
* the Root Mean Square (or average power) level in dB for each channel
|
* the Root Mean Square (or average power) level in dB for each channel
|
||||||
* </para>
|
* </para>
|
||||||
|
@ -104,6 +104,11 @@
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* FIXME 0.11: suppress warnings for deprecated API such as GValueArray
|
||||||
|
* with newer GLib versions (>= 2.31.0) */
|
||||||
|
#define GLIB_DISABLE_DEPRECATION_WARNINGS
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
@ -478,8 +483,6 @@ gst_level_message_new (GstLevel * level, GstClockTime timestamp,
|
||||||
GValue v = { 0, };
|
GValue v = { 0, };
|
||||||
GstClockTime endtime, running_time, stream_time;
|
GstClockTime endtime, running_time, stream_time;
|
||||||
|
|
||||||
g_value_init (&v, GST_TYPE_LIST);
|
|
||||||
|
|
||||||
running_time = gst_segment_to_running_time (&trans->segment, GST_FORMAT_TIME,
|
running_time = gst_segment_to_running_time (&trans->segment, GST_FORMAT_TIME,
|
||||||
timestamp);
|
timestamp);
|
||||||
stream_time = gst_segment_to_stream_time (&trans->segment, GST_FORMAT_TIME,
|
stream_time = gst_segment_to_stream_time (&trans->segment, GST_FORMAT_TIME,
|
||||||
|
@ -493,12 +496,18 @@ gst_level_message_new (GstLevel * level, GstClockTime timestamp,
|
||||||
"stream-time", G_TYPE_UINT64, stream_time,
|
"stream-time", G_TYPE_UINT64, stream_time,
|
||||||
"running-time", G_TYPE_UINT64, running_time,
|
"running-time", G_TYPE_UINT64, running_time,
|
||||||
"duration", G_TYPE_UINT64, duration, NULL);
|
"duration", G_TYPE_UINT64, duration, NULL);
|
||||||
/* will copy-by-value */
|
|
||||||
gst_structure_set_value (s, "rms", &v);
|
|
||||||
gst_structure_set_value (s, "peak", &v);
|
|
||||||
gst_structure_set_value (s, "decay", &v);
|
|
||||||
|
|
||||||
g_value_unset (&v);
|
g_value_init (&v, G_TYPE_VALUE_ARRAY);
|
||||||
|
g_value_take_boxed (&v, g_value_array_new (0));
|
||||||
|
gst_structure_take_value (s, "rms", &v);
|
||||||
|
|
||||||
|
g_value_init (&v, G_TYPE_VALUE_ARRAY);
|
||||||
|
g_value_take_boxed (&v, g_value_array_new (0));
|
||||||
|
gst_structure_take_value (s, "peak", &v);
|
||||||
|
|
||||||
|
g_value_init (&v, G_TYPE_VALUE_ARRAY);
|
||||||
|
g_value_take_boxed (&v, g_value_array_new (0));
|
||||||
|
gst_structure_take_value (s, "decay", &v);
|
||||||
|
|
||||||
return gst_message_new_element (GST_OBJECT (level), s);
|
return gst_message_new_element (GST_OBJECT (level), s);
|
||||||
}
|
}
|
||||||
|
@ -507,25 +516,29 @@ static void
|
||||||
gst_level_message_append_channel (GstMessage * m, gdouble rms, gdouble peak,
|
gst_level_message_append_channel (GstMessage * m, gdouble rms, gdouble peak,
|
||||||
gdouble decay)
|
gdouble decay)
|
||||||
{
|
{
|
||||||
|
const GValue *array_val;
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
|
GValueArray *arr;
|
||||||
GValue v = { 0, };
|
GValue v = { 0, };
|
||||||
GValue *l;
|
|
||||||
|
|
||||||
g_value_init (&v, G_TYPE_DOUBLE);
|
g_value_init (&v, G_TYPE_DOUBLE);
|
||||||
|
|
||||||
s = (GstStructure *) gst_message_get_structure (m);
|
s = (GstStructure *) gst_message_get_structure (m);
|
||||||
|
|
||||||
l = (GValue *) gst_structure_get_value (s, "rms");
|
array_val = gst_structure_get_value (s, "rms");
|
||||||
|
arr = (GValueArray *) g_value_get_boxed (array_val);
|
||||||
g_value_set_double (&v, rms);
|
g_value_set_double (&v, rms);
|
||||||
gst_value_list_append_value (l, &v); /* copies by value */
|
g_value_array_append (arr, &v); /* copies by value */
|
||||||
|
|
||||||
l = (GValue *) gst_structure_get_value (s, "peak");
|
array_val = gst_structure_get_value (s, "peak");
|
||||||
|
arr = (GValueArray *) g_value_get_boxed (array_val);
|
||||||
g_value_set_double (&v, peak);
|
g_value_set_double (&v, peak);
|
||||||
gst_value_list_append_value (l, &v); /* copies by value */
|
g_value_array_append (arr, &v); /* copies by value */
|
||||||
|
|
||||||
l = (GValue *) gst_structure_get_value (s, "decay");
|
array_val = gst_structure_get_value (s, "decay");
|
||||||
|
arr = (GValueArray *) g_value_get_boxed (array_val);
|
||||||
g_value_set_double (&v, decay);
|
g_value_set_double (&v, decay);
|
||||||
gst_value_list_append_value (l, &v); /* copies by value */
|
g_value_array_append (arr, &v); /* copies by value */
|
||||||
|
|
||||||
g_value_unset (&v);
|
g_value_unset (&v);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue