diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 47e8d7f4cd..25633e5385 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -2209,6 +2209,7 @@ gst_structure_foreach gst_structure_n_fields gst_structure_has_field gst_structure_has_field_typed +gst_structure_is_equal gst_structure_id_has_field gst_structure_id_has_field_typed gst_structure_get_boolean diff --git a/gst/gstcaps.c b/gst/gstcaps.c index 84fce69a18..dc7735d0ff 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -565,22 +565,6 @@ gst_caps_steal_structure (GstCaps * caps, guint index) return gst_caps_remove_and_get_structure (caps, index); } -static gboolean -gst_structure_is_equal_foreach (GQuark field_id, const GValue * val2, - gpointer data) -{ - GstStructure *struct1 = (GstStructure *) data; - const GValue *val1 = gst_structure_id_get_value (struct1, field_id); - - if (G_UNLIKELY (val1 == NULL)) - return FALSE; - if (gst_value_compare (val1, val2) == GST_VALUE_EQUAL) { - return TRUE; - } - - return FALSE; -} - static gboolean gst_caps_structure_is_subset_field (GQuark field_id, const GValue * value, gpointer user_data) @@ -1117,15 +1101,7 @@ gst_caps_is_equal_fixed (const GstCaps * caps1, const GstCaps * caps2) struct1 = gst_caps_get_structure_unchecked (caps1, 0); struct2 = gst_caps_get_structure_unchecked (caps2, 0); - if (struct1->name != struct2->name) { - return FALSE; - } - if (struct1->fields->len != struct2->fields->len) { - return FALSE; - } - - return gst_structure_foreach (struct1, gst_structure_is_equal_foreach, - struct2); + return gst_structure_is_equal (struct1, struct2); } /** diff --git a/gst/gststructure.c b/gst/gststructure.c index f0ff914fef..7b962c7248 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c @@ -2916,3 +2916,48 @@ gst_structure_id_get (const GstStructure * structure, GQuark first_field_id, return ret; } + +static gboolean +gst_structure_is_equal_foreach (GQuark field_id, const GValue * val2, + gpointer data) +{ + GstStructure *struct1 = (GstStructure *) data; + const GValue *val1 = gst_structure_id_get_value (struct1, field_id); + + if (G_UNLIKELY (val1 == NULL)) + return FALSE; + if (gst_value_compare (val1, val2) == GST_VALUE_EQUAL) { + return TRUE; + } + + return FALSE; +} + +/** + * gst_structure_is_equal: + * @structure1: a #GstStructure. + * @structure2: a #GstStructure. + * + * Tests if the two #GstStructure are equal. + * + * Returns: TRUE if the two structures have the same name and field. + * + * Since: 0.10.31 + **/ +gboolean +gst_structure_is_equal (const GstStructure * structure1, + GstStructure * structure2) +{ + g_return_val_if_fail (GST_IS_STRUCTURE (structure1), FALSE); + g_return_val_if_fail (GST_IS_STRUCTURE (structure2), FALSE); + + if (structure1->name != structure2->name) { + return FALSE; + } + if (structure1->fields->len != structure2->fields->len) { + return FALSE; + } + + return gst_structure_foreach (structure1, gst_structure_is_equal_foreach, + structure2); +} diff --git a/gst/gststructure.h b/gst/gststructure.h index 48c81c4596..1d0d812f7d 100644 --- a/gst/gststructure.h +++ b/gst/gststructure.h @@ -248,6 +248,9 @@ gboolean gst_structure_fixate_field_nearest_fraction (GstStructu const gint target_numerator, const gint target_denominator); +gboolean gst_structure_is_equal(const GstStructure *structure1, + GstStructure *structure2); + G_END_DECLS #endif diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index 021e92aa6d..0fcebc8bef 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -1007,6 +1007,7 @@ EXPORTS gst_structure_id_set_valist gst_structure_id_set_value gst_structure_id_take_value + gst_structure_is_equal gst_structure_map_in_place gst_structure_n_fields gst_structure_new