summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sf.net>2010-07-05 18:02:01 +0300
committerStefan Kost <ensonic@users.sf.net>2010-09-14 10:43:40 +0300
commit2405c78c1febde4eda8ad214dd5bb165179b93f3 (patch)
treee8425d3a49ccae09f6df94a5d1478520da40dbca
parent6fdb1eaf1daccfcfb221f8a90ae2f2725ffe8963 (diff)
caps: make api for checking if a structure is in caps public
Move subset checking to own function and offer as public API. API: gst_caps_structure_is_subset
-rw-r--r--docs/gst/gstreamer-sections.txt1
-rw-r--r--gst/gstcaps.c48
-rw-r--r--gst/gstcaps.h2
3 files changed, 34 insertions, 17 deletions
diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt
index 06af677ca..6afb66e90 100644
--- a/docs/gst/gstreamer-sections.txt
+++ b/docs/gst/gstreamer-sections.txt
@@ -304,6 +304,7 @@ gst_caps_is_equal
gst_caps_is_equal_fixed
gst_caps_is_always_compatible
gst_caps_is_subset
+gst_caps_structure_is_subset
gst_caps_can_intersect
gst_caps_intersect
gst_caps_union
diff --git a/gst/gstcaps.c b/gst/gstcaps.c
index 1c6796343..d648d5bfd 100644
--- a/gst/gstcaps.c
+++ b/gst/gstcaps.c
@@ -684,7 +684,7 @@ gst_structure_is_equal_foreach (GQuark field_id, const GValue * val2,
}
static gboolean
-gst_caps_structure_is_subset_field (GQuark field_id, const GValue * value,
+gst_structure_is_subset_field (GQuark field_id, const GValue * value,
gpointer user_data)
{
GstStructure *subtract_from = user_data;
@@ -730,7 +730,7 @@ gst_caps_structure_is_subset_field (GQuark field_id, const GValue * value,
}
static gboolean
-gst_caps_structure_is_subset (const GstStructure * minuend,
+gst_structure_is_subset (const GstStructure * minuend,
const GstStructure * subtrahend)
{
if ((minuend->name != subtrahend->name) ||
@@ -740,7 +740,7 @@ gst_caps_structure_is_subset (const GstStructure * minuend,
}
return gst_structure_foreach ((GstStructure *) subtrahend,
- gst_caps_structure_is_subset_field, (gpointer) minuend);
+ gst_structure_is_subset_field, (gpointer) minuend);
}
/**
@@ -939,10 +939,6 @@ gst_caps_merge_structure (GstCaps * caps, GstStructure * structure)
g_return_if_fail (IS_WRITABLE (caps));
if (G_LIKELY (structure)) {
- GstStructure *structure1;
- int i;
- gboolean unique = TRUE;
-
g_return_if_fail (structure->parent_refcount == NULL);
#if 0
#ifdef USE_POISONING
@@ -954,16 +950,7 @@ gst_caps_merge_structure (GstCaps * caps, GstStructure * structure)
caps);
gst_caps_eval_structure ((GstCaps *) caps, G_MAXUINT);
}
- /* check each structure */
- for (i = caps->structs->len - 1; i >= 0; i--) {
- structure1 = gst_caps_get_structure_unchecked (caps, i);
- /* if structure is a subset of structure1, then skip it */
- if (gst_caps_structure_is_subset (structure1, structure)) {
- unique = FALSE;
- break;
- }
- }
- if (unique) {
+ if (!gst_caps_structure_is_subset (caps, structure)) {
gst_caps_append_structure_unchecked (caps, structure);
} else {
gst_structure_free (structure);
@@ -1390,6 +1377,33 @@ gst_caps_is_equal (const GstCaps * caps1, const GstCaps * caps2)
return gst_caps_is_subset (caps1, caps2) && gst_caps_is_subset (caps2, caps1);
}
+/**
+ * gst_caps_structure_is_subset:
+ * @caps: a #GstCaps
+ * @structure: a #GstStructure
+ *
+ * Check if a @structure is subset of any of the structures in @caps.
+ *
+ * Return: %TRUE if it is not unique
+ */
+gboolean
+gst_caps_structure_is_subset (const GstCaps * caps,
+ const GstStructure * structure)
+{
+ GstStructure *structure1;
+ gint i;
+
+ /* check each structure */
+ for (i = caps->structs->len - 1; i >= 0; i--) {
+ structure1 = gst_caps_get_structure_unchecked (caps, i);
+ /* if structure is a subset of structure1, then skip it */
+ if (gst_structure_is_subset (structure1, structure)) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
/* intersect operation */
typedef struct
diff --git a/gst/gstcaps.h b/gst/gstcaps.h
index 2bdb179da..ac04095a2 100644
--- a/gst/gstcaps.h
+++ b/gst/gstcaps.h
@@ -281,6 +281,8 @@ gboolean gst_caps_is_equal (const GstCaps *caps1,
const GstCaps *caps2);
gboolean gst_caps_is_equal_fixed (const GstCaps *caps1,
const GstCaps *caps2);
+gboolean gst_caps_structure_is_subset (const GstCaps * caps,
+ const GstStructure * structure);
gboolean gst_caps_can_intersect (const GstCaps * caps1,
const GstCaps * caps2);