+ * gst_caps_get_features:
+ * @caps: a #GstCaps
+ * @index: the index of the structure
+ *
+ * Finds the features in @caps that has the index @index, and
+ * returns it.
+ *
+ * WARNING: This function takes a const GstCaps *, but returns a
+ * non-const GstCapsFeatures *. This is for programming convenience --
+ * the caller should be aware that structures inside a constant
+ * #GstCaps should not be modified. However, if you know the caps
+ * are writable, either because you have just copied them or made
+ * them writable with gst_caps_make_writable(), you may modify the
+ * features returned in the usual way, e.g. with functions like
+ * gst_caps_features_add().
+ *
+ * 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
+ *
+ * Since: 1.2
+ */
+GstCapsFeatures *
+gst_caps_get_features (const GstCaps * caps, guint index)
+{
+ GstCapsFeatures *features;
+
+ g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
+ g_return_val_if_fail (index < GST_CAPS_LEN (caps), NULL);
+
+ features = gst_caps_get_features_unchecked (caps, index);
+ if (!features) {
+ GstCapsFeatures **storage;
+
+ /* We have to do some atomic pointer magic here as the caps
+ * might not be writable and someone else calls this function
+ * at the very same time */
+ features = gst_caps_features_copy (GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY);
+ gst_caps_features_set_parent_refcount (features, &GST_CAPS_REFCOUNT (caps));
+
+ storage = gst_caps_get_features_storage_unchecked (caps, index);
+ if (!g_atomic_pointer_compare_and_exchange (storage, NULL, features)) {
+ /* Someone did the same we just tried in the meantime */
+ gst_caps_features_set_parent_refcount (features, NULL);
+ gst_caps_features_free (features);
+
+ features = gst_caps_get_features_unchecked (caps, index);
+ g_assert (features != NULL);
+ }
+ }
+
+ return features;
+}
+
+/**
+ * gst_caps_set_features:
+ * @caps: a #GstCaps
+ * @index: the index of the structure
+ * @features: (allow-none) (transfer full): the #GstCapsFeatures to set
+ *
+ * Sets the #GstCapsFeatures @features for the structure at @index.
+ *
+ * Since: 1.2
+ */
+void
+gst_caps_set_features (GstCaps * caps, guint index, GstCapsFeatures * features)
+{
+ GstCapsFeatures **storage, *old;
+
+ g_return_if_fail (caps != NULL);
+ g_return_if_fail (index <= gst_caps_get_size (caps));
+ g_return_if_fail (IS_WRITABLE (caps));
+
+ storage = gst_caps_get_features_storage_unchecked (caps, index);
+ /* Not much problem here as caps are writable */
+ old = g_atomic_pointer_get (storage);
+ g_atomic_pointer_set (storage, features);
+
+ if (features)
+ gst_caps_features_set_parent_refcount (features, &GST_CAPS_REFCOUNT (caps));
+
+ if (old) {
+ gst_caps_features_set_parent_refcount (old, NULL);
+ gst_caps_features_free (old);
+ }
+}
+
+/**