GType type;
gint *parent_refcount;
GArray *array;
+ gboolean is_any;
};
GType _gst_caps_features_type = 0;
+GstCapsFeatures *_gst_caps_features_any = NULL;
GstCapsFeatures *_gst_caps_features_memory_system_memory = NULL;
static GQuark _gst_caps_feature_memory_system_memory = 0;
g_value_register_transform_func (_gst_caps_features_type, G_TYPE_STRING,
gst_caps_features_transform_to_string);
+ _gst_caps_features_any = gst_caps_features_new_any ();
_gst_caps_features_memory_system_memory =
gst_caps_features_new_id (_gst_caps_feature_memory_system_memory, 0);
features->type = _gst_caps_features_type;
features->parent_refcount = NULL;
features->array = g_array_new (FALSE, FALSE, sizeof (GQuark));
+ features->is_any = FALSE;
GST_TRACE ("created caps features %p", features);
}
/**
+ * gst_caps_features_new_any:
+ *
+ * Creates a new, ANY #GstCapsFeatures. This will be equal
+ * to any other #GstCapsFeatures but caps with these are
+ * unfixed.
+ *
+ * Free-function: gst_caps_features_free
+ *
+ * Returns: (transfer full): a new, ANY #GstCapsFeatures
+ */
+GstCapsFeatures *
+gst_caps_features_new_any (void)
+{
+ GstCapsFeatures *features;
+
+ features = gst_caps_features_new_empty ();
+ features->is_any = TRUE;
+
+ return features;
+}
+
+/**
* gst_caps_features_new:
* @feature1: name of first feature to set
* @...: additional features
g_return_if_fail (features != NULL);
+ if (features->array->len == 0 && features->is_any) {
+ g_string_append (s, "ANY");
+ return;
+ }
+
n = features->array->len;
for (i = 0; i < n; i++) {
GQuark *quark = &g_array_index (features->array, GQuark, i);
if (!features || *features == '\0')
return ret;
+ if (strcmp (features, "ANY") == 0) {
+ ret->is_any = TRUE;
+ return ret;
+ }
+
/* Skip trailing spaces */
while (*features == ' ')
features++;
g_return_val_if_fail (features != NULL, FALSE);
g_return_val_if_fail (feature != 0, FALSE);
+ if (features->is_any)
+ return TRUE;
+
n = features->array->len;
if (n == 0)
return feature == _gst_caps_feature_memory_system_memory;
g_return_val_if_fail (features1 != NULL, FALSE);
g_return_val_if_fail (features2 != NULL, FALSE);
+ if (features1->is_any || features2->is_any)
+ return TRUE;
+
/* Check for the sysmem==empty case */
if (features1->array->len == 0 && features2->array->len == 0)
return TRUE;
}
/**
+ * gst_caps_features_is_any:
+ * @features: a #GstCapsFeatures.
+ *
+ * Returns %TRUE if @features is %GST_CAPS_FEATURES_ANY.
+ *
+ * Returns: %TRUE if @features is %GST_CAPS_FEATURES_ANY.
+ */
+gboolean
+gst_caps_features_is_any (const GstCapsFeatures * features)
+{
+ g_return_val_if_fail (features != NULL, FALSE);
+
+ return features->is_any;
+}
+
+/**
* gst_caps_features_add:
* @features: a #GstCapsFeatures.
* @feature: a feature.
g_return_if_fail (features != NULL);
g_return_if_fail (IS_MUTABLE (features));
g_return_if_fail (feature != NULL);
+ g_return_if_fail (!features->is_any);
gst_caps_features_add_id (features, g_quark_from_string (feature));
}
g_return_if_fail (features != NULL);
g_return_if_fail (IS_MUTABLE (features));
g_return_if_fail (feature != 0);
+ g_return_if_fail (!features->is_any);
if (!gst_caps_feature_name_is_valid (g_quark_to_string (feature))) {
g_warning ("Invalid caps feature name: %s", g_quark_to_string (feature));
#define GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY "memory:SystemMemory"
+GST_EXPORT GstCapsFeatures *_gst_caps_features_any;
+#define GST_CAPS_FEATURES_ANY (_gst_caps_features_any)
+
GST_EXPORT GstCapsFeatures *_gst_caps_features_memory_system_memory;
#define GST_CAPS_FEATURES_MEMORY_SYSTEM_MEMORY (_gst_caps_features_memory_system_memory)
gboolean gst_is_caps_features (gconstpointer obj);
GstCapsFeatures * gst_caps_features_new_empty (void);
+GstCapsFeatures * gst_caps_features_new_any (void);
GstCapsFeatures * gst_caps_features_new (const gchar *feature1, ...);
GstCapsFeatures * gst_caps_features_new_valist (const gchar *feature1, va_list varargs);
GstCapsFeatures * gst_caps_features_new_id (GQuark feature1, ...);
gboolean gst_caps_features_contains_id (const GstCapsFeatures * features, GQuark feature);
gboolean gst_caps_features_is_equal (const GstCapsFeatures * features1, const GstCapsFeatures * features2);
+gboolean gst_caps_features_is_any (const GstCapsFeatures * features);
+
void gst_caps_features_add (GstCapsFeatures * features, const gchar * feature);
void gst_caps_features_add_id ( GstCapsFeatures * features, GQuark feature);
gst_caps_features_free (a);
gst_caps_features_free (b);
g_free (str);
+
+ a = gst_caps_features_new_any ();
+ fail_unless (a != NULL);
+ fail_unless (gst_caps_features_is_any (a));
+ str = gst_caps_features_to_string (a);
+ fail_unless (str != NULL);
+ fail_unless_equals_string (str, "ANY");
+ b = gst_caps_features_from_string (str);
+ fail_unless (b != NULL);
+ fail_unless (gst_caps_features_is_equal (a, b));
+ fail_unless (gst_caps_features_is_any (b));
+ gst_caps_features_free (a);
+ gst_caps_features_free (b);
+ g_free (str);
}
GST_END_TEST;