mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-28 20:05:38 +00:00
value: Handle NULL caps for comparisons
Having a NULL caps in a GValue is legal and we should handle it properly for comparisons.
This commit is contained in:
parent
0b1c2f715a
commit
a1aebe73d5
2 changed files with 32 additions and 0 deletions
|
@ -2087,6 +2087,12 @@ gst_value_compare_caps (const GValue * value1, const GValue * value2)
|
|||
GstCaps *caps1 = GST_CAPS (gst_value_get_caps (value1));
|
||||
GstCaps *caps2 = GST_CAPS (gst_value_get_caps (value2));
|
||||
|
||||
if (caps1 == caps2)
|
||||
return GST_VALUE_EQUAL;
|
||||
|
||||
if (!caps1 || !caps2)
|
||||
return GST_VALUE_UNORDERED;
|
||||
|
||||
if (gst_caps_is_equal (caps1, caps2))
|
||||
return GST_VALUE_EQUAL;
|
||||
return GST_VALUE_UNORDERED;
|
||||
|
|
|
@ -2720,6 +2720,31 @@ GST_START_TEST (test_serialize_deserialize_value_array)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_compare_caps)
|
||||
{
|
||||
GValue value = { 0 }
|
||||
, value2 = {
|
||||
0};
|
||||
|
||||
g_value_init (&value, GST_TYPE_CAPS);
|
||||
g_value_init (&value2, GST_TYPE_CAPS);
|
||||
g_value_take_boxed (&value, NULL);
|
||||
g_value_take_boxed (&value2, NULL);
|
||||
|
||||
fail_unless_equals_int (gst_value_compare (&value, &value2), GST_VALUE_EQUAL);
|
||||
|
||||
g_value_take_boxed (&value, gst_caps_new_empty_simple ("something"));
|
||||
|
||||
fail_unless_equals_int (gst_value_compare (&value, &value2),
|
||||
GST_VALUE_UNORDERED);
|
||||
|
||||
g_value_unset (&value);
|
||||
g_value_unset (&value2);
|
||||
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_serialize_deserialize_caps)
|
||||
{
|
||||
GValue value = { 0 }
|
||||
|
@ -3510,6 +3535,7 @@ gst_value_suite (void)
|
|||
tcase_add_test (tc_chain, test_date_time);
|
||||
tcase_add_test (tc_chain, test_fraction_range);
|
||||
tcase_add_test (tc_chain, test_serialize_deserialize_caps);
|
||||
tcase_add_test (tc_chain, test_compare_caps);
|
||||
tcase_add_test (tc_chain, test_int_range);
|
||||
tcase_add_test (tc_chain, test_int64_range);
|
||||
tcase_add_test (tc_chain, test_serialize_int64_range);
|
||||
|
|
Loading…
Reference in a new issue