mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
value: Implement can_intersect for GstFlagSet types
Make sure that gst_value_can_intersect returns TRUE for GstFlagSet combinations that can successfully intersect
This commit is contained in:
parent
db66cb51b3
commit
a95645eaba
2 changed files with 19 additions and 0 deletions
|
@ -4951,6 +4951,20 @@ gst_value_can_intersect (const GValue * value1, const GValue * value2)
|
||||||
if (type1 == GST_TYPE_LIST || type2 == GST_TYPE_LIST)
|
if (type1 == GST_TYPE_LIST || type2 == GST_TYPE_LIST)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
if (G_UNLIKELY (GST_VALUE_HOLDS_FLAG_SET (value1) &&
|
||||||
|
GST_VALUE_HOLDS_FLAG_SET (value2))) {
|
||||||
|
GType type1, type2, flagset_type;
|
||||||
|
|
||||||
|
type1 = G_VALUE_TYPE (value1);
|
||||||
|
type2 = G_VALUE_TYPE (value2);
|
||||||
|
flagset_type = GST_TYPE_FLAG_SET;
|
||||||
|
|
||||||
|
/* Allow intersection with the generic FlagSet type, on one
|
||||||
|
* side, but not 2 different subtypes - that makes no sense */
|
||||||
|
if (type1 == type2 || type1 == flagset_type || type2 == flagset_type)
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* check registered intersect functions */
|
/* check registered intersect functions */
|
||||||
len = gst_value_intersect_funcs->len;
|
len = gst_value_intersect_funcs->len;
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
|
|
|
@ -662,17 +662,22 @@ GST_START_TEST (test_flagset)
|
||||||
|
|
||||||
/* GstFlagSet should always intersect with itself */
|
/* GstFlagSet should always intersect with itself */
|
||||||
g_value_unset (&dest);
|
g_value_unset (&dest);
|
||||||
|
fail_unless (gst_value_can_intersect (&value, &value));
|
||||||
fail_unless (gst_value_intersect (&dest, &value, &value));
|
fail_unless (gst_value_intersect (&dest, &value, &value));
|
||||||
|
|
||||||
/* GstFlagSet subtype should intersect with itself */
|
/* GstFlagSet subtype should intersect with itself */
|
||||||
g_value_unset (&dest);
|
g_value_unset (&dest);
|
||||||
|
fail_unless (gst_value_can_intersect (&value2, &value2));
|
||||||
fail_unless (gst_value_intersect (&dest, &value2, &value2));
|
fail_unless (gst_value_intersect (&dest, &value2, &value2));
|
||||||
|
|
||||||
/* Check we can intersect custom flagset subtype with flagset */
|
/* Check we can intersect custom flagset subtype with flagset */
|
||||||
g_value_unset (&dest);
|
g_value_unset (&dest);
|
||||||
|
fail_unless (gst_value_can_intersect (&value2, &value));
|
||||||
fail_unless (gst_value_intersect (&dest, &value2, &value));
|
fail_unless (gst_value_intersect (&dest, &value2, &value));
|
||||||
|
|
||||||
|
/* and in the other order */
|
||||||
g_value_unset (&dest);
|
g_value_unset (&dest);
|
||||||
|
fail_unless (gst_value_can_intersect (&value, &value2));
|
||||||
fail_unless (gst_value_intersect (&dest, &value, &value2));
|
fail_unless (gst_value_intersect (&dest, &value, &value2));
|
||||||
|
|
||||||
fail_unless (gst_value_get_flagset_flags (&dest) == test_flags,
|
fail_unless (gst_value_get_flagset_flags (&dest) == test_flags,
|
||||||
|
|
Loading…
Reference in a new issue