-/**
- * gst_caps_copy:
- * @caps: the #GstCaps to copy
- *
- * Creates a new #GstCaps as a copy of the old @caps. The new caps will have a
- * refcount of 1, owned by the caller. The structures are copied as well.
- *
- * Note that this function is the semantic equivalent of a gst_caps_ref()
- * followed by a gst_caps_make_writable(). If you only want to hold on to a
- * reference to the data, you should use gst_caps_ref().
- *
- * When you are finished with the caps, call gst_caps_unref() on it.
- *
- * Returns: (transfer full): the new #GstCaps
- */
-GstCaps *
-gst_caps_copy (const GstCaps * caps)
-{
- GstCaps *newcaps;
- GstStructure *structure;
- guint i, n;
-
- g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
-
- newcaps = gst_caps_new_empty ();
- newcaps->flags = caps->flags;
- n = caps->structs->len;
-
- for (i = 0; i < n; i++) {
- structure = gst_caps_get_structure_unchecked (caps, i);
- gst_caps_append_structure_unchecked (newcaps,
- gst_structure_copy (structure));
- }
-
- return newcaps;
-}
-
-static void
-_gst_caps_free (GstCaps * caps)
-{
- GstStructure *structure;
- guint i, len;
-
- /* The refcount must be 0, but since we're only called by gst_caps_unref,
- * don't bother testing. */
- len = caps->structs->len;
- /* This can be used to get statistics about caps sizes */
- /*GST_CAT_INFO (GST_CAT_CAPS, "caps size: %d", len); */
- for (i = 0; i < len; i++) {
- structure = (GstStructure *) gst_caps_get_structure_unchecked (caps, i);
- gst_structure_set_parent_refcount (structure, NULL);
- gst_structure_free (structure);
- }
- g_ptr_array_free (caps->structs, TRUE);
-#ifdef USE_POISONING
- memset (caps, 0xff, sizeof (GstCaps));
-#endif
-
-#ifdef DEBUG_REFCOUNT
- GST_CAT_LOG (GST_CAT_CAPS, "freeing caps %p", caps);
-#endif
- g_slice_free (GstCaps, caps);
-}
-
-/**
- * gst_caps_make_writable:
- * @caps: (transfer full): the #GstCaps to make writable
- *
- * Returns a writable copy of @caps.
- *
- * If there is only one reference count on @caps, the caller must be the owner,
- * and so this function will return the caps object unchanged. If on the other
- * hand there is more than one reference on the object, a new caps object will
- * be returned. The caller's reference on @caps will be removed, and instead the
- * caller will own a reference to the returned object.
- *
- * In short, this function unrefs the caps in the argument and refs the caps
- * that it returns. Don't access the argument after calling this function. See
- * also: gst_caps_ref().
- *
- * Returns: (transfer full): the same #GstCaps object.
- */
-GstCaps *
-gst_caps_make_writable (GstCaps * caps)
-{
- GstCaps *copy;
-
- g_return_val_if_fail (caps != NULL, NULL);
-
- /* we are the only instance reffing this caps */
- if (IS_WRITABLE (caps))
- return caps;
-
- /* else copy */
- GST_CAT_DEBUG (GST_CAT_PERFORMANCE, "copy caps");
- copy = gst_caps_copy (caps);
- gst_caps_unref (caps);
-
- return copy;
-}
-
-/**
- * gst_caps_ref:
- * @caps: the #GstCaps to reference
- *
- * Add a reference to a #GstCaps object.
- *
- * From this point on, until the caller calls gst_caps_unref() or
- * gst_caps_make_writable(), it is guaranteed that the caps object will not
- * change. This means its structures won't change, etc. To use a #GstCaps
- * object, you must always have a refcount on it -- either the one made
- * implicitly by e.g. gst_caps_new_simple(), or via taking one explicitly with
- * this function.
- *
- * Returns: (transfer full): the same #GstCaps object.
- */
-GstCaps *
-gst_caps_ref (GstCaps * caps)
-{
- g_return_val_if_fail (caps != NULL, NULL);
-
-#ifdef DEBUG_REFCOUNT
- GST_CAT_TRACE (GST_CAT_REFCOUNTING, "%p %d->%d", caps,
- GST_CAPS_REFCOUNT_VALUE (caps), GST_CAPS_REFCOUNT_VALUE (caps) + 1);
-#endif
- g_return_val_if_fail (GST_CAPS_REFCOUNT_VALUE (caps) > 0, NULL);
-
- g_atomic_int_inc (&caps->refcount);
-
- return caps;
-}
-
-/**
- * gst_caps_unref:
- * @caps: (transfer full): the #GstCaps to unref
- *
- * Unref a #GstCaps and free all its structures and the
- * structures' values when the refcount reaches 0.
- */
-void
-gst_caps_unref (GstCaps * caps)
-{
- g_return_if_fail (caps != NULL);
-
-#ifdef DEBUG_REFCOUNT
- GST_CAT_TRACE (GST_CAT_REFCOUNTING, "%p %d->%d", caps,
- GST_CAPS_REFCOUNT_VALUE (caps), GST_CAPS_REFCOUNT_VALUE (caps) - 1);
-#endif
-
- g_return_if_fail (GST_CAPS_REFCOUNT_VALUE (caps) > 0);
-
- /* if we ended up with the refcount at zero, free the caps */
- if (G_UNLIKELY (g_atomic_int_dec_and_test (&caps->refcount)))
- _gst_caps_free (caps);
-}
-
-GType
-gst_static_caps_get_type (void)
-{
- static GType staticcaps_type = 0;
-
- if (G_UNLIKELY (staticcaps_type == 0)) {
- staticcaps_type = g_pointer_type_register_static ("GstStaticCaps");
- }
- return staticcaps_type;
-}
-