/**
* SECTION:gstcaps
+ * @title: GstCaps
* @short_description: Structure describing sets of media formats
* @see_also: #GstStructure, #GstMiniObject
*
#ifdef DEBUG_REFCOUNT
GST_CAT_TRACE (GST_CAT_CAPS, "freeing caps %p", caps);
#endif
+
+#ifdef USE_POISONING
+ memset (caps, 0xff, sizeof (GstCapsImpl));
+#endif
+
g_slice_free1 (sizeof (GstCapsImpl), caps);
}
*
* Converts a #GstStaticCaps to a #GstCaps.
*
- * Returns: (transfer full): a pointer to the #GstCaps. Unref after usage.
- * Since the core holds an additional ref to the returned caps,
- * use gst_caps_make_writable() on the returned caps to modify it.
+ * Returns: (transfer full) (nullable): a pointer to the #GstCaps. Unref
+ * after usage. Since the core holds an additional ref to the
+ * returned caps, use gst_caps_make_writable() on the returned caps
+ * to modify it.
*/
GstCaps *
gst_static_caps_get (GstStaticCaps * static_caps)
*caps = gst_caps_from_string (string);
- /* Caps generated from static caps are usually leaked */
- GST_MINI_OBJECT_FLAG_SET (*caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
-
/* convert to string */
- if (G_UNLIKELY (*caps == NULL))
+ if (G_UNLIKELY (*caps == NULL)) {
g_critical ("Could not convert static caps \"%s\"", string);
+ goto done;
+ }
+
+ /* Caps generated from static caps are usually leaked */
+ GST_MINI_OBJECT_FLAG_SET (*caps, GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED);
GST_CAT_TRACE (GST_CAT_CAPS, "created %p from string %s", static_caps,
string);
* Retrieves the structure with the given index from the list of structures
* contained in @caps. The caller becomes the owner of the returned structure.
*
- * Returns: (transfer full): a pointer to the #GstStructure corresponding
- * to @index.
+ * Returns: (transfer full) (nullable): a pointer to the #GstStructure
+ * corresponding to @index.
*/
GstStructure *
gst_caps_steal_structure (GstCaps * caps, guint index)
* You do not need to free or unref the structure returned, it
* belongs to the #GstCaps.
*
- * Returns: (transfer none): a pointer to the #GstCapsFeatures corresponding
- * to @index
+ * Returns: (transfer none) (nullable): a pointer to the #GstCapsFeatures
+ * corresponding to @index
*
* Since: 1.2
*/
* @subtrahend: #GstCaps to subtract
*
* Subtracts the @subtrahend from the @minuend.
- * <note>This function does not work reliably if optional properties for caps
- * are included on one caps and omitted on the other.</note>
+ * > This function does not work reliably if optional properties for caps
+ * > are included on one caps and omitted on the other.
*
* Returns: (transfer full): the resulting caps
*/
* The current implementation of serialization will lead to unexpected results
* when there are nested #GstCaps / #GstStructure deeper than one level.
*
- * Returns: (transfer full): a newly allocated #GstCaps
+ * Returns: (transfer full) (nullable): a newly allocated #GstCaps
*/
GstCaps *
gst_caps_from_string (const gchar * string)
}
}
}
+
+/**
+ * gst_caps_copy:
+ * @caps: a #GstCaps.
+ *
+ * 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: the new #GstCaps
+ */
+GstCaps *(gst_caps_copy) (const GstCaps * caps)
+{
+ return GST_CAPS (gst_mini_object_copy (GST_MINI_OBJECT_CAST (caps)));
+}