return s;
}
+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 (val1 == NULL)
+ return FALSE;
+ if (gst_value_compare (val1, val2) == GST_VALUE_EQUAL) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
/**
* gst_caps_append:
* @caps1: the #GstCaps that will be appended to
}
/**
+ * gst_caps_merge:
+ * @caps1: the #GstCaps that will take the new entries
+ * @caps2: the #GstCaps to merge in
+ *
+ * Appends the structures contained in @caps2 to @caps1 if they are not yet in
+ * @caps1. The structures in @caps2 are not copied -- they are transferred to
+ * @caps1, and then @caps2 is freed.
+ * If either caps is ANY, the resulting caps will be ANY.
+ */
+void
+gst_caps_merge (GstCaps * caps1, GstCaps * caps2)
+{
+ GstStructure *structure;
+ int i;
+
+ g_return_if_fail (GST_IS_CAPS (caps1));
+ g_return_if_fail (GST_IS_CAPS (caps2));
+ g_return_if_fail (IS_WRITABLE (caps1));
+ g_return_if_fail (IS_WRITABLE (caps2));
+
+#ifdef USE_POISONING
+ CAPS_POISON (caps2);
+#endif
+ if (gst_caps_is_any (caps1) || gst_caps_is_any (caps2)) {
+ /* FIXME: this leaks */
+ caps1->flags |= GST_CAPS_FLAGS_ANY;
+ for (i = caps2->structs->len - 1; i >= 0; i--) {
+ structure = gst_caps_remove_and_get_structure (caps2, i);
+ gst_structure_free (structure);
+ }
+ } else {
+ GstCaps *com = gst_caps_intersect (caps1, caps2);
+ GstCaps *add = gst_caps_subtract (caps2, com);
+
+ /*
+ GST_DEBUG ("common : %d", gst_caps_get_size (com));
+ GST_DEBUG ("adding : %d", gst_caps_get_size (add));
+ */
+ gst_caps_append (caps1, add);
+ gst_caps_unref (com);
+ }
+ gst_caps_unref (caps2); /* guaranteed to free it */
+}
+
+/**
* gst_caps_append_structure:
* @caps: the #GstCaps that will be appended to
* @structure: the #GstStructure to append
}
}
-/*
+/**
* gst_caps_remove_structure:
* @caps: the #GstCaps to remove from
* @idx: Index of the structure to remove
}
/**
- * gst_caps_split_one:
- * @caps: a #GstCaps
- *
- * This function is not implemented.
- *
- * Returns: NULL
- */
-GstCaps *
-gst_caps_split_one (GstCaps * caps)
-{
- /* FIXME */
- g_critical ("unimplemented");
-
- return NULL;
-}
-
-/**
* gst_caps_get_size:
* @caps: a #GstCaps
*
return gst_structure_foreach (structure, gst_caps_is_fixed_foreach, NULL);
}
-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 (val1 == NULL)
- return FALSE;
- if (gst_value_compare (val1, val2) == GST_VALUE_EQUAL) {
- return TRUE;
- }
-
- return FALSE;
-}
-
/**
* gst_caps_is_equal_fixed:
* @caps1: the #GstCaps to test
gpointer _gst_reserved[GST_PADDING];
};
-GType gst_caps_get_type (void);
-GstCaps * gst_caps_new_empty (void);
-GstCaps * gst_caps_new_any (void);
-GstCaps * gst_caps_new_simple (const char *media_type,
- const char *fieldname,
- ...);
-GstCaps * gst_caps_new_full (GstStructure *struct1,
- ...);
-GstCaps * gst_caps_new_full_valist (GstStructure *structure,
- va_list var_args);
+GType gst_caps_get_type (void);
+GstCaps * gst_caps_new_empty (void);
+GstCaps * gst_caps_new_any (void);
+GstCaps * gst_caps_new_simple (const char *media_type,
+ const char *fieldname,
+ ...);
+GstCaps * gst_caps_new_full (GstStructure *struct1, ...);
+GstCaps * gst_caps_new_full_valist (GstStructure *structure,
+ va_list var_args);
/* reference counting */
-GstCaps * gst_caps_ref (GstCaps* caps);
-GstCaps * gst_caps_copy (const GstCaps * caps);
-GstCaps * gst_caps_make_writable (GstCaps *caps);
-void gst_caps_unref (GstCaps* caps);
+GstCaps * gst_caps_ref (GstCaps* caps);
+GstCaps * gst_caps_copy (const GstCaps * caps);
+GstCaps * gst_caps_make_writable (GstCaps *caps);
+void gst_caps_unref (GstCaps* caps);
-GType gst_static_caps_get_type (void);
-GstCaps * gst_static_caps_get (GstStaticCaps *static_caps);
+GType gst_static_caps_get_type (void);
+GstCaps * gst_static_caps_get (GstStaticCaps *static_caps);
/* manipulation */
-void gst_caps_append (GstCaps *caps1,
- GstCaps *caps2);
-void gst_caps_append_structure (GstCaps *caps,
- GstStructure *structure);
-guint gst_caps_get_size (const GstCaps *caps);
-GstStructure * gst_caps_get_structure (const GstCaps *caps,
- guint index);
-GstCaps * gst_caps_copy_nth (const GstCaps * caps, guint nth);
-void gst_caps_truncate (GstCaps * caps);
-void gst_caps_set_simple (GstCaps *caps,
- char *field, ...) G_GNUC_NULL_TERMINATED;
-void gst_caps_set_simple_valist (GstCaps *caps,
- char *field,
- va_list varargs);
+void gst_caps_append (GstCaps *caps1,
+ GstCaps *caps2);
+void gst_caps_merge (GstCaps *caps1,
+ GstCaps *caps2);
+void gst_caps_append_structure (GstCaps *caps,
+ GstStructure *structure);
+void gst_caps_remove_structure (GstCaps * caps, guint idx);
+guint gst_caps_get_size (const GstCaps *caps);
+GstStructure * gst_caps_get_structure (const GstCaps *caps,
+ guint index);
+GstCaps * gst_caps_copy_nth (const GstCaps * caps, guint nth);
+void gst_caps_truncate (GstCaps * caps);
+void gst_caps_set_simple (GstCaps *caps,
+ char *field, ...) G_GNUC_NULL_TERMINATED;
+void gst_caps_set_simple_valist (GstCaps *caps,
+ char *field,
+ va_list varargs);
/* tests */
-gboolean gst_caps_is_any (const GstCaps *caps);
-gboolean gst_caps_is_empty (const GstCaps *caps);
-gboolean gst_caps_is_fixed (const GstCaps *caps);
-gboolean gst_caps_is_always_compatible (const GstCaps *caps1,
- const GstCaps *caps2);
-gboolean gst_caps_is_subset (const GstCaps *subset,
- const GstCaps *superset);
-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_is_any (const GstCaps *caps);
+gboolean gst_caps_is_empty (const GstCaps *caps);
+gboolean gst_caps_is_fixed (const GstCaps *caps);
+gboolean gst_caps_is_always_compatible (const GstCaps *caps1,
+ const GstCaps *caps2);
+gboolean gst_caps_is_subset (const GstCaps *subset,
+ const GstCaps *superset);
+gboolean gst_caps_is_equal (const GstCaps *caps1,
+ const GstCaps *caps2);
+gboolean gst_caps_is_equal_fixed (const GstCaps * caps1,
+ const GstCaps * caps2);
/* operations */
-GstCaps * gst_caps_intersect (const GstCaps *caps1,
- const GstCaps *caps2);
-GstCaps * gst_caps_subtract (const GstCaps *minuend,
- const GstCaps *subtrahend);
-GstCaps * gst_caps_union (const GstCaps *caps1,
- const GstCaps *caps2);
-GstCaps * gst_caps_normalize (const GstCaps *caps);
-gboolean gst_caps_do_simplify (GstCaps *caps);
+GstCaps * gst_caps_intersect (const GstCaps *caps1,
+ const GstCaps *caps2);
+GstCaps * gst_caps_subtract (const GstCaps *minuend,
+ const GstCaps *subtrahend);
+GstCaps * gst_caps_union (const GstCaps *caps1,
+ const GstCaps *caps2);
+GstCaps * gst_caps_normalize (const GstCaps *caps);
+gboolean gst_caps_do_simplify (GstCaps *caps);
#ifndef GST_DISABLE_LOADSAVE
-xmlNodePtr gst_caps_save_thyself (const GstCaps *caps,
- xmlNodePtr parent);
-GstCaps * gst_caps_load_thyself (xmlNodePtr parent);
+xmlNodePtr gst_caps_save_thyself (const GstCaps *caps,
+ xmlNodePtr parent);
+GstCaps * gst_caps_load_thyself (xmlNodePtr parent);
#endif
/* utility */
-void gst_caps_replace (GstCaps **caps,
- GstCaps *newcaps);
-gchar * gst_caps_to_string (const GstCaps *caps);
-GstCaps * gst_caps_from_string (const gchar *string);
+void gst_caps_replace (GstCaps **caps,
+ GstCaps *newcaps);
+gchar * gst_caps_to_string (const GstCaps *caps);
+GstCaps * gst_caps_from_string (const gchar *string);
G_END_DECLS