Commit e03f086f authored by Guillaume Desmottes's avatar Guillaume Desmottes 🐐

gstcaps: add gst_caps_set_features_simple()

Convenient helper setting a caps feature on all the structures of a
caps.
parent c9e2057e
......@@ -464,6 +464,7 @@ gst_caps_get_size
gst_caps_get_structure
gst_caps_get_features
gst_caps_set_features
gst_caps_set_features_simple
gst_caps_set_value
gst_caps_set_simple
gst_caps_set_simple_valist
......
......@@ -932,6 +932,39 @@ gst_caps_set_features (GstCaps * caps, guint index, GstCapsFeatures * features)
}
}
/**
* gst_caps_set_features_simple:
* @caps: a #GstCaps
* @features: (allow-none) (transfer full): the #GstCapsFeatures to set
*
* Sets the #GstCapsFeatures @features for all the structures of @caps.
*
* Since: 1.16
*/
void
gst_caps_set_features_simple (GstCaps * caps, GstCapsFeatures * features)
{
guint i;
guint n;
g_return_if_fail (caps != NULL);
g_return_if_fail (IS_WRITABLE (caps));
n = gst_caps_get_size (caps);
for (i = 0; i < n; i++) {
GstCapsFeatures *f;
/* Transfer ownership of @features to the last structure */
if (features && i < n - 1)
f = gst_caps_features_copy (features);
else
f = features;
gst_caps_set_features (caps, i, f);
}
}
/**
* gst_caps_copy_nth:
* @caps: the #GstCaps to copy
......
......@@ -470,6 +470,10 @@ void gst_caps_set_features (GstCaps *caps,
guint index,
GstCapsFeatures * features);
GST_API
void gst_caps_set_features_simple (GstCaps *caps,
GstCapsFeatures * features);
GST_API
GstCapsFeatures * gst_caps_get_features (const GstCaps *caps,
guint index);
GST_API
......
......@@ -1244,6 +1244,21 @@ GST_START_TEST (test_features)
gst_caps_set_features (c1, 0, f2);
gst_caps_unref (c1);
/* gst_caps_set_features_simple() */
c1 = gst_caps_from_string
("video/x-raw, format=NV12; video/x-raw, format=NV16");
fail_unless_equals_int (gst_caps_get_size (c1), 2);
f1 = gst_caps_features_new ("memory:EGLImage", NULL);
gst_caps_set_features_simple (c1, f1);
f2 = gst_caps_get_features (c1, 0);
fail_unless (gst_caps_features_is_equal (f1, f2));
f2 = gst_caps_get_features (c1, 1);
fail_unless (gst_caps_features_is_equal (f1, f2));
gst_caps_unref (c1);
}
GST_END_TEST;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment