Commit 40eb4625 authored by Mikhail Fludkov's avatar Mikhail Fludkov Committed by Tim-Philipp Müller

rtpsession: Avoid unnecessary copy of stats structure

The code before copied GstStructure twice. The first time inside
gst_value_set_structure and the second time in g_value_array_append.
Optimized version does no copies, just transfers ownership to
GValueArray. It takes advantage of the fact that array has already
enough elements preallocated and the memory is zero initialized.

https://bugzilla.gnome.org/show_bug.cgi?id=795139
parent d5d6e6cf
......@@ -722,16 +722,15 @@ rtp_session_create_sources (RTPSession * sess)
static void
create_source_stats (gpointer key, RTPSource * source, GValueArray * arr)
{
GValue value = G_VALUE_INIT;
GValue *value;
GstStructure *s;
g_object_get (source, "stats", &s, NULL);
g_value_init (&value, GST_TYPE_STRUCTURE);
gst_value_set_structure (&value, s);
g_value_array_append (arr, &value);
gst_structure_free (s);
g_value_unset (&value);
g_value_array_append (arr, NULL);
value = g_value_array_get_nth (arr, arr->n_values - 1);
g_value_init (value, GST_TYPE_STRUCTURE);
g_value_take_boxed (value, s);
}
static GstStructure *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment