summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorEdward Hervey <bilboed@bilboed.com>2010-09-10 18:14:05 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2011-05-17 09:28:00 +0200
commitae46eb3a3848fa5991e987f08d59bc6a5b2bc9b5 (patch)
tree83675a9abc1f08db8133c4602e8d1ed0cb3a80bb /gst
parentfe1dcbe6fa1625ae83980f4da813f0f3764e7d51 (diff)
gstructure: New API: gst_structure_is_equal
Allows checking equality of GstStructure without having to create intermediary GstCaps. API: gst_structure_is_equal https://bugzilla.gnome.org/show_bug.cgi?id=629300
Diffstat (limited to 'gst')
-rw-r--r--gst/gstcaps.c26
-rw-r--r--gst/gststructure.c45
-rw-r--r--gst/gststructure.h3
3 files changed, 49 insertions, 25 deletions
diff --git a/gst/gstcaps.c b/gst/gstcaps.c
index 84fce69a1..dc7735d0f 100644
--- a/gst/gstcaps.c
+++ b/gst/gstcaps.c
@@ -566,22 +566,6 @@ gst_caps_steal_structure (GstCaps * caps, guint 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 f0ff914fe..7b962c724 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 48c81c459..1d0d812f7 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