structure: Make sure that subsets have all fields of the superset

"video/x-h264,parsed=(boolean)true" is not a superset of
"video/x-h264,stream-format=(string)byte-stream,alignment=(string)nal"
for example.

https://bugzilla.gnome.org/show_bug.cgi?id=693365
This commit is contained in:
Sebastian Dröge 2013-02-13 10:46:37 +01:00
parent 92674800ed
commit 171c79c9a7
2 changed files with 23 additions and 0 deletions

View file

@ -3135,6 +3135,15 @@ gst_structure_can_intersect (const GstStructure * struct1,
gst_caps_structure_can_intersect_field, (gpointer) struct2);
}
static gboolean
gst_caps_structure_has_field (GQuark field_id, const GValue * value,
gpointer user_data)
{
GstStructure *subset = user_data;
return gst_structure_id_get_value (subset, field_id) != NULL;
}
static gboolean
gst_caps_structure_is_subset_field (GQuark field_id, const GValue * value,
gpointer user_data)
@ -3179,6 +3188,11 @@ gst_structure_is_subset (const GstStructure * subset,
(gst_structure_n_fields (superset) > gst_structure_n_fields (subset)))
return FALSE;
/* The subset must have all fields that are in superset */
if (!gst_structure_foreach ((GstStructure *) superset,
gst_caps_structure_has_field, (gpointer) subset))
return FALSE;
return gst_structure_foreach ((GstStructure *) subset,
gst_caps_structure_is_subset_field, (gpointer) superset);
}

View file

@ -312,6 +312,15 @@ GST_START_TEST (test_subset)
fail_if (gst_caps_is_subset (c2, c1));
gst_caps_unref (c1);
gst_caps_unref (c2);
c1 = gst_caps_from_string ("video/x-h264, parsed=(boolean)true");
c2 = gst_caps_from_string
("video/x-h264, stream-format=(string)byte-stream, alignment=(string)nal");
fail_if (gst_caps_is_subset (c2, c1));
fail_if (gst_caps_is_subset (c1, c2));
fail_if (gst_caps_is_equal (c1, c2));
gst_caps_unref (c1);
gst_caps_unref (c2);
}
GST_END_TEST;