mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 11:32:38 +00:00
value: Add support for GObject comparising in structures
This is useful to allow comparing pool configuration where a GstAllocator is set. https://bugzilla.gnome.org/show_bug.cgi?id=728268
This commit is contained in:
parent
035bc8b8db
commit
00614e2c2b
2 changed files with 40 additions and 0 deletions
|
@ -5840,6 +5840,24 @@ gst_value_compare_bitmask (const GValue * value1, const GValue * value2)
|
|||
return GST_VALUE_UNORDERED;
|
||||
}
|
||||
|
||||
/************
|
||||
* GObject *
|
||||
************/
|
||||
|
||||
static gint
|
||||
gst_value_compare_object (const GValue * value1, const GValue * value2)
|
||||
{
|
||||
gpointer v1, v2;
|
||||
|
||||
v1 = value1->data[0].v_pointer;
|
||||
v2 = value2->data[0].v_pointer;
|
||||
|
||||
if (v1 == v2)
|
||||
return GST_VALUE_EQUAL;
|
||||
|
||||
return GST_VALUE_UNORDERED;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_value_transform_object_string (const GValue * src_value,
|
||||
GValue * dest_value)
|
||||
|
@ -6239,6 +6257,18 @@ _priv_gst_value_initialize (void)
|
|||
gst_value_register (&gst_value);
|
||||
}
|
||||
|
||||
{
|
||||
static GstValueTable gst_value = {
|
||||
0,
|
||||
gst_value_compare_object,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
gst_value.type = G_TYPE_OBJECT;
|
||||
gst_value_register (&gst_value);
|
||||
}
|
||||
|
||||
REGISTER_SERIALIZATION (G_TYPE_DOUBLE, double);
|
||||
REGISTER_SERIALIZATION (G_TYPE_FLOAT, float);
|
||||
|
||||
|
|
|
@ -771,6 +771,16 @@ GST_START_TEST (test_value_compare)
|
|||
fail_unless (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL);
|
||||
g_value_unset (&value1);
|
||||
g_value_unset (&value2);
|
||||
|
||||
/* Check that we can compare objects */
|
||||
g_value_init (&value1, GST_TYPE_BIN);
|
||||
g_value_take_object (&value1, gst_bin_new (NULL));
|
||||
g_value_init (&value2, GST_TYPE_BIN);
|
||||
g_value_take_object (&value2, gst_bin_new (NULL));
|
||||
fail_unless (gst_value_compare (&value1, &value2) == GST_VALUE_UNORDERED);
|
||||
fail_unless (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL);
|
||||
g_value_unset (&value1);
|
||||
g_value_unset (&value2);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
|
Loading…
Reference in a new issue