docs: Fix typos in function/object descriptions
[platform/upstream/gstreamer.git] / gst / gstcapsfeatures.c
1 /* GStreamer
2  * Copyright (C) 2013 Collabora Ltd.
3  *   Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20
21 /**
22  * SECTION:gstcapsfeatures
23  * @short_description: A set of features in caps 
24  * @see_also: #GstCaps
25  *
26  * #GstCapsFeatures can optionally be set on a #GstCaps to add requirements
27  * for additional features for a specific #GstStructure. Caps structures with
28  * the same name but with a non-equal set of caps features are not compatible.
29  * If a pad supports multiple sets of features it has to add multiple equal
30  * structures with different feature sets to the caps.
31  *
32  * Empty #GstCapsFeatures are equivalent with the #GstCapsFeatures that only
33  * contain #GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY. ANY #GstCapsFeatures as
34  * created by gst_caps_features_new_any() are equal to any other #GstCapsFeatures
35  * and can be used to specify that any #GstCapsFeatures would be supported, e.g.
36  * for elements that don't touch buffer memory. #GstCaps with ANY #GstCapsFeatures
37  * are considered non-fixed and during negotiation some #GstCapsFeatures have
38  * to be selected.
39  *
40  * Examples for caps features would be the requirement of a specific #GstMemory
41  * types or the requirement of having a specific #GstMeta on the buffer. Features
42  * are given as a string of the format "memory:GstMemoryTypeName" or
43  * "meta:GstMetaAPIName".
44  *
45  * Since: 1.2
46  */
47
48 #ifdef HAVE_CONFIG_H
49 #include "config.h"
50 #endif
51
52 #include <string.h>
53 #include "gst_private.h"
54 #include "gstcapsfeatures.h"
55 #include <gst/gst.h>
56
57 GST_DEBUG_CATEGORY_STATIC (gst_caps_features_debug);
58 #define GST_CAT_DEFAULT gst_caps_features_debug
59
60 struct _GstCapsFeatures
61 {
62   GType type;
63   gint *parent_refcount;
64   GArray *array;
65   gboolean is_any;
66 };
67
68 GType _gst_caps_features_type = 0;
69 GstCapsFeatures *_gst_caps_features_any = NULL;
70 GstCapsFeatures *_gst_caps_features_memory_system_memory = NULL;
71 static GQuark _gst_caps_feature_memory_system_memory = 0;
72
73 G_DEFINE_BOXED_TYPE (GstCapsFeatures, gst_caps_features,
74     gst_caps_features_copy, gst_caps_features_free);
75
76 #define IS_MUTABLE(features) \
77     (!features->parent_refcount || \
78      g_atomic_int_get (features->parent_refcount) == 1)
79
80 static void
81 gst_caps_features_transform_to_string (const GValue * src_value,
82     GValue * dest_value);
83
84 void
85 _priv_gst_caps_features_initialize (void)
86 {
87   GST_DEBUG_CATEGORY_INIT (gst_caps_features_debug, "caps-features", 0,
88       "GstCapsFeatures debug");
89
90   _gst_caps_features_type = gst_caps_features_get_type ();
91   _gst_caps_feature_memory_system_memory =
92       g_quark_from_static_string (GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY);
93
94   g_value_register_transform_func (_gst_caps_features_type, G_TYPE_STRING,
95       gst_caps_features_transform_to_string);
96
97   _gst_caps_features_any = gst_caps_features_new_any ();
98   _gst_caps_features_memory_system_memory =
99       gst_caps_features_new_id (_gst_caps_feature_memory_system_memory, 0);
100 }
101
102 gboolean
103 gst_is_caps_features (gconstpointer obj)
104 {
105   const GstCapsFeatures *features = obj;
106
107   return (obj != NULL && features->type == _gst_caps_features_type);
108 }
109
110 static gboolean
111 gst_caps_feature_name_is_valid (const gchar * feature)
112 {
113 #ifndef G_DISABLE_CHECKS
114   while (TRUE) {
115     if (g_ascii_isalpha (*feature))
116       feature++;
117     else if (*feature == ':')
118       break;
119     else
120       return FALSE;
121   }
122
123   if (*feature != ':')
124     return FALSE;
125
126   feature++;
127   if (*feature == '\0' || !g_ascii_isalpha (*feature))
128     return FALSE;
129
130   while (TRUE) {
131     if (g_ascii_isalnum (*feature))
132       feature++;
133     else if (*feature == '\0')
134       break;
135     else
136       return FALSE;
137   }
138 #endif
139
140   return TRUE;
141 }
142
143 /**
144  * gst_caps_features_new_empty:
145  *
146  * Creates a new, empty #GstCapsFeatures.
147  *
148  * Free-function: gst_caps_features_free
149  *
150  * Returns: (transfer full): a new, empty #GstCapsFeatures
151  *
152  * Since: 1.2
153  */
154 GstCapsFeatures *
155 gst_caps_features_new_empty (void)
156 {
157   GstCapsFeatures *features;
158
159   features = g_slice_new (GstCapsFeatures);
160   features->type = _gst_caps_features_type;
161   features->parent_refcount = NULL;
162   features->array = g_array_new (FALSE, FALSE, sizeof (GQuark));
163   features->is_any = FALSE;
164
165   GST_TRACE ("created caps features %p", features);
166
167   return features;
168 }
169
170 /**
171  * gst_caps_features_new_any:
172  *
173  * Creates a new, ANY #GstCapsFeatures. This will be equal
174  * to any other #GstCapsFeatures but caps with these are
175  * unfixed.
176  *
177  * Free-function: gst_caps_features_free
178  *
179  * Returns: (transfer full): a new, ANY #GstCapsFeatures
180  *
181  * Since: 1.2
182  */
183 GstCapsFeatures *
184 gst_caps_features_new_any (void)
185 {
186   GstCapsFeatures *features;
187
188   features = gst_caps_features_new_empty ();
189   features->is_any = TRUE;
190
191   return features;
192 }
193
194 /**
195  * gst_caps_features_new:
196  * @feature1: name of first feature to set
197  * @...: additional features
198  *
199  * Creates a new #GstCapsFeatures with the given features.
200  * The last argument must be NULL.
201  *
202  * Free-function: gst_caps_features_free
203  *
204  * Returns: (transfer full): a new, empty #GstCapsFeatures
205  *
206  * Since: 1.2
207  */
208 GstCapsFeatures *
209 gst_caps_features_new (const gchar * feature1, ...)
210 {
211   GstCapsFeatures *features;
212   va_list varargs;
213
214   g_return_val_if_fail (feature1 != NULL, NULL);
215
216   va_start (varargs, feature1);
217   features = gst_caps_features_new_valist (feature1, varargs);
218   va_end (varargs);
219
220   return features;
221 }
222
223 /**
224  * gst_caps_features_new_valist:
225  * @feature1: name of first feature to set
226  * @varargs: variable argument list
227  *
228  * Creates a new #GstCapsFeatures with the given features.
229  *
230  * Free-function: gst_caps_features_free
231  *
232  * Returns: (transfer full): a new, empty #GstCapsFeatures
233  *
234  * Since: 1.2
235  */
236 GstCapsFeatures *
237 gst_caps_features_new_valist (const gchar * feature1, va_list varargs)
238 {
239   GstCapsFeatures *features;
240
241   g_return_val_if_fail (feature1 != NULL, NULL);
242
243   features = gst_caps_features_new_empty ();
244
245   while (feature1) {
246     gst_caps_features_add (features, feature1);
247     feature1 = va_arg (varargs, const gchar *);
248   }
249
250   return features;
251 }
252
253 /**
254  * gst_caps_features_new_id:
255  * @feature1: name of first feature to set
256  * @...: additional features
257  *
258  * Creates a new #GstCapsFeatures with the given features.
259  * The last argument must be 0.
260  *
261  * Free-function: gst_caps_features_free
262  *
263  * Returns: (transfer full): a new, empty #GstCapsFeatures
264  *
265  * Since: 1.2
266  */
267 GstCapsFeatures *
268 gst_caps_features_new_id (GQuark feature1, ...)
269 {
270   GstCapsFeatures *features;
271   va_list varargs;
272
273   g_return_val_if_fail (feature1 != 0, NULL);
274
275   va_start (varargs, feature1);
276   features = gst_caps_features_new_id_valist (feature1, varargs);
277   va_end (varargs);
278
279   return features;
280 }
281
282 /**
283  * gst_caps_features_new_id_valist:
284  * @feature1: name of first feature to set
285  * @varargs: variable argument list
286  *
287  * Creates a new #GstCapsFeatures with the given features.
288  *
289  * Free-function: gst_caps_features_free
290  *
291  * Returns: (transfer full): a new, empty #GstCapsFeatures
292  *
293  * Since: 1.2
294  */
295 GstCapsFeatures *
296 gst_caps_features_new_id_valist (GQuark feature1, va_list varargs)
297 {
298   GstCapsFeatures *features;
299
300   g_return_val_if_fail (feature1 != 0, NULL);
301
302   features = gst_caps_features_new_empty ();
303
304   while (feature1) {
305     gst_caps_features_add_id (features, feature1);
306     feature1 = va_arg (varargs, GQuark);
307   }
308
309   return features;
310 }
311
312 /**
313  * gst_caps_features_set_parent_refcount:
314  * @features: a #GstCapsFeatures
315  * @refcount: (in): a pointer to the parent's refcount
316  *
317  * Sets the parent_refcount field of #GstCapsFeatures. This field is used to
318  * determine whether a caps features is mutable or not. This function should only be
319  * called by code implementing parent objects of #GstCapsFeatures, as described in
320  * the MT Refcounting section of the design documents.
321  *
322  * Returns: %TRUE if the parent refcount could be set.
323  *
324  * Since: 1.2
325  */
326 gboolean
327 gst_caps_features_set_parent_refcount (GstCapsFeatures * features,
328     gint * refcount)
329 {
330   g_return_val_if_fail (features != NULL, FALSE);
331
332   /* if we have a parent_refcount already, we can only clear
333    * if with a NULL refcount */
334   if (features->parent_refcount) {
335     if (refcount != NULL) {
336       g_return_val_if_fail (refcount == NULL, FALSE);
337       return FALSE;
338     }
339   } else {
340     if (refcount == NULL) {
341       g_return_val_if_fail (refcount != NULL, FALSE);
342       return FALSE;
343     }
344   }
345
346   features->parent_refcount = refcount;
347
348   return TRUE;
349 }
350
351 /**
352  * gst_caps_features_copy:
353  * @features: a #GstCapsFeatures to duplicate
354  *
355  * Duplicates a #GstCapsFeatures and all its values.
356  *
357  * Free-function: gst_caps_features_free
358  *
359  * Returns: (transfer full): a new #GstCapsFeatures.
360  *
361  * Since: 1.2
362  */
363 GstCapsFeatures *
364 gst_caps_features_copy (const GstCapsFeatures * features)
365 {
366   GstCapsFeatures *copy;
367   guint i, n;
368
369   g_return_val_if_fail (features != NULL, NULL);
370
371   copy = gst_caps_features_new_empty ();
372   n = gst_caps_features_get_size (features);
373   for (i = 0; i < n; i++)
374     gst_caps_features_add_id (copy, gst_caps_features_get_nth_id (features, i));
375   copy->is_any = features->is_any;
376
377   return copy;
378 }
379
380 /**
381  * gst_caps_features_free:
382  * @features: (in) (transfer full): the #GstCapsFeatures to free
383  *
384  * Frees a #GstCapsFeatures and all its values. The caps features must not
385  * have a parent when this function is called.
386  *
387  * Since: 1.2
388  */
389 void
390 gst_caps_features_free (GstCapsFeatures * features)
391 {
392   g_return_if_fail (features != NULL);
393   g_return_if_fail (features->parent_refcount == NULL);
394
395   g_array_free (features->array, TRUE);
396 #ifdef USE_POISONING
397   memset (features, 0xff, sizeof (GstCapsFeatures));
398 #endif
399   GST_TRACE ("free caps features %p", features);
400
401   g_slice_free (GstCapsFeatures, features);
402 }
403
404 /**
405  * gst_caps_features_to_string:
406  * @features: a #GstCapsFeatures
407  *
408  * Converts @features to a human-readable string representation.
409  *
410  * For debugging purposes its easier to do something like this:
411  * |[
412  * GST_LOG ("features is %" GST_PTR_FORMAT, features);
413  * ]|
414  * This prints the features in human readable form.
415  *
416  * Free-function: g_free
417  *
418  * Returns: (transfer full): a pointer to string allocated by g_malloc().
419  *     g_free() after usage.
420  *
421  * Since: 1.2
422  */
423 gchar *
424 gst_caps_features_to_string (const GstCapsFeatures * features)
425 {
426   GString *s;
427
428   g_return_val_if_fail (features != NULL, NULL);
429
430   s = g_string_sized_new (FEATURES_ESTIMATED_STRING_LEN (features));
431
432   priv_gst_caps_features_append_to_gstring (features, s);
433
434   return g_string_free (s, FALSE);
435 }
436
437 void
438 priv_gst_caps_features_append_to_gstring (const GstCapsFeatures * features,
439     GString * s)
440 {
441   guint i, n;
442
443   g_return_if_fail (features != NULL);
444
445   if (features->array->len == 0 && features->is_any) {
446     g_string_append (s, "ANY");
447     return;
448   }
449
450   n = features->array->len;
451   for (i = 0; i < n; i++) {
452     GQuark *quark = &g_array_index (features->array, GQuark, i);
453
454     g_string_append (s, g_quark_to_string (*quark));
455     if (i + 1 < n)
456       g_string_append (s, ", ");
457   }
458 }
459
460 /**
461  * gst_caps_features_from_string:
462  * @features: a string representation of a #GstCapsFeatures.
463  *
464  * Creates a #GstCapsFeatures from a string representation.
465  *
466  * Free-function: gst_caps_features_free
467  *
468  * Returns: (transfer full): a new #GstCapsFeatures or NULL when the string could
469  *     not be parsed. Free with gst_caps_features_free() after use.
470  *
471  * Since: 1.2
472  */
473 GstCapsFeatures *
474 gst_caps_features_from_string (const gchar * features)
475 {
476   GstCapsFeatures *ret;
477   gboolean escape = FALSE;
478   const gchar *features_orig = features;
479   const gchar *feature;
480
481   ret = gst_caps_features_new_empty ();
482
483   if (!features || *features == '\0')
484     return ret;
485
486   if (strcmp (features, "ANY") == 0) {
487     ret->is_any = TRUE;
488     return ret;
489   }
490
491   /* Skip trailing spaces */
492   while (*features == ' ')
493     features++;
494
495   feature = features;
496   while (TRUE) {
497     gchar c = *features;
498
499     if (c == '\\') {
500       escape = TRUE;
501       features++;
502       continue;
503     } else if ((!escape && c == ',') || c == '\0') {
504       guint len = features - feature + 1;
505       gchar *tmp;
506       gchar *p;
507
508       if (len == 1) {
509         g_warning ("Failed deserialize caps features '%s'", features_orig);
510         gst_caps_features_free (ret);
511         return NULL;
512       }
513
514       tmp = g_malloc (len);
515       memcpy (tmp, feature, len - 1);
516       tmp[len - 1] = '\0';
517
518       p = tmp + len - 1;
519       while (*p == ' ') {
520         *p = '\0';
521         p--;
522       }
523
524       if (strstr (tmp, " ") != NULL || *tmp == '\0') {
525         g_free (tmp);
526         g_warning ("Failed deserialize caps features '%s'", features_orig);
527         gst_caps_features_free (ret);
528         return NULL;
529       }
530
531       gst_caps_features_add (ret, tmp);
532       g_free (tmp);
533
534       if (c == '\0')
535         break;
536
537       /* Skip to the next value */
538       features++;
539       while (*features == ' ')
540         features++;
541       feature = features;
542     } else {
543       escape = FALSE;
544       features++;
545     }
546   }
547
548   return ret;
549 }
550
551 /**
552  * gst_caps_features_get_size:
553  * @features: a #GstCapsFeatures.
554  *
555  * Returns the number of features in @features.
556  *
557  * Returns: The number of features in @features.
558  *
559  * Since: 1.2
560  */
561 guint
562 gst_caps_features_get_size (const GstCapsFeatures * features)
563 {
564   g_return_val_if_fail (features != NULL, 0);
565
566   return features->array->len;
567 }
568
569 /**
570  * gst_caps_features_get_nth:
571  * @features: a #GstCapsFeatures.
572  * @i: index of the feature
573  *
574  * Returns the @i-th feature of @features.
575  *
576  * Returns: The @i-th feature of @features.
577  *
578  * Since: 1.2
579  */
580 const gchar *
581 gst_caps_features_get_nth (const GstCapsFeatures * features, guint i)
582 {
583   const gchar *feature;
584   GQuark quark;
585
586   g_return_val_if_fail (features != NULL, NULL);
587
588   quark = gst_caps_features_get_nth_id (features, i);
589   if (!quark)
590     return NULL;
591
592   feature = g_quark_to_string (quark);
593   return feature;
594 }
595
596 /**
597  * gst_caps_features_get_nth_id:
598  * @features: a #GstCapsFeatures.
599  * @i: index of the feature
600  *
601  * Returns the @i-th feature of @features.
602  *
603  * Returns: The @i-th feature of @features.
604  *
605  * Since: 1.2
606  */
607 GQuark
608 gst_caps_features_get_nth_id (const GstCapsFeatures * features, guint i)
609 {
610   GQuark *quark;
611
612   g_return_val_if_fail (features != NULL, 0);
613   g_return_val_if_fail (i < features->array->len, 0);
614
615   quark = &g_array_index (features->array, GQuark, i);
616
617   return *quark;
618 }
619
620 /**
621  * gst_caps_features_contains:
622  * @features: a #GstCapsFeatures.
623  * @feature: a feature
624  *
625  * Check if @features contains @feature.
626  *
627  * Returns: %TRUE if @features contains @feature.
628  *
629  * Since: 1.2
630  */
631 gboolean
632 gst_caps_features_contains (const GstCapsFeatures * features,
633     const gchar * feature)
634 {
635   g_return_val_if_fail (features != NULL, FALSE);
636   g_return_val_if_fail (feature != NULL, FALSE);
637
638   return gst_caps_features_contains_id (features,
639       g_quark_from_string (feature));
640 }
641
642 /**
643  * gst_caps_features_contains_id:
644  * @features: a #GstCapsFeatures.
645  * @feature: a feature
646  *
647  * Check if @features contains @feature.
648  *
649  * Returns: %TRUE if @features contains @feature.
650  *
651  * Since: 1.2
652  */
653 gboolean
654 gst_caps_features_contains_id (const GstCapsFeatures * features, GQuark feature)
655 {
656   guint i, n;
657
658   g_return_val_if_fail (features != NULL, FALSE);
659   g_return_val_if_fail (feature != 0, FALSE);
660
661   if (features->is_any)
662     return TRUE;
663
664   n = features->array->len;
665   if (n == 0)
666     return feature == _gst_caps_feature_memory_system_memory;
667
668   for (i = 0; i < n; i++) {
669     if (gst_caps_features_get_nth_id (features, i) == feature)
670       return TRUE;
671   }
672
673   return FALSE;
674 }
675
676 /**
677  * gst_caps_features_is_equal:
678  * @features1: a #GstCapsFeatures.
679  * @features2: a #GstCapsFeatures.
680  *
681  * Check if @features1 and @features2 are equal.
682  *
683  * Returns: %TRUE if @features1 and @features2 are equal.
684  *
685  * Since: 1.2
686  */
687 gboolean
688 gst_caps_features_is_equal (const GstCapsFeatures * features1,
689     const GstCapsFeatures * features2)
690 {
691   guint i, n;
692
693   g_return_val_if_fail (features1 != NULL, FALSE);
694   g_return_val_if_fail (features2 != NULL, FALSE);
695
696   if (features1->is_any || features2->is_any)
697     return TRUE;
698
699   /* Check for the sysmem==empty case */
700   if (features1->array->len == 0 && features2->array->len == 0)
701     return TRUE;
702   if (features1->array->len == 0 && features2->array->len == 1
703       && gst_caps_features_contains_id (features2,
704           _gst_caps_feature_memory_system_memory))
705     return TRUE;
706   if (features2->array->len == 0 && features1->array->len == 1
707       && gst_caps_features_contains_id (features1,
708           _gst_caps_feature_memory_system_memory))
709     return TRUE;
710
711   if (features1->array->len != features2->array->len)
712     return FALSE;
713
714   n = features1->array->len;
715   for (i = 0; i < n; i++)
716     if (!gst_caps_features_contains_id (features2,
717             gst_caps_features_get_nth_id (features1, i)))
718       return FALSE;
719
720   return TRUE;
721 }
722
723 /**
724  * gst_caps_features_is_any:
725  * @features: a #GstCapsFeatures.
726  *
727  * Check if @features is %GST_CAPS_FEATURES_ANY.
728  *
729  * Returns: %TRUE if @features is %GST_CAPS_FEATURES_ANY.
730  *
731  * Since: 1.2
732  */
733 gboolean
734 gst_caps_features_is_any (const GstCapsFeatures * features)
735 {
736   g_return_val_if_fail (features != NULL, FALSE);
737
738   return features->is_any;
739 }
740
741 /**
742  * gst_caps_features_add:
743  * @features: a #GstCapsFeatures.
744  * @feature: a feature.
745  *
746  * Adds @feature to @features.
747  *
748  * Since: 1.2
749  */
750 void
751 gst_caps_features_add (GstCapsFeatures * features, const gchar * feature)
752 {
753   g_return_if_fail (features != NULL);
754   g_return_if_fail (IS_MUTABLE (features));
755   g_return_if_fail (feature != NULL);
756   g_return_if_fail (!features->is_any);
757
758   gst_caps_features_add_id (features, g_quark_from_string (feature));
759 }
760
761 /**
762  * gst_caps_features_add_id:
763  * @features: a #GstCapsFeatures.
764  * @feature: a feature.
765  *
766  * Adds @feature to @features.
767  *
768  * Since: 1.2
769  */
770 void
771 gst_caps_features_add_id (GstCapsFeatures * features, GQuark feature)
772 {
773   g_return_if_fail (features != NULL);
774   g_return_if_fail (IS_MUTABLE (features));
775   g_return_if_fail (feature != 0);
776   g_return_if_fail (!features->is_any);
777
778   if (!gst_caps_feature_name_is_valid (g_quark_to_string (feature))) {
779     g_warning ("Invalid caps feature name: %s", g_quark_to_string (feature));
780     return;
781   }
782
783   /* If features is empty it will contain sysmem, however
784    * we want to add it explicitely if it is tried to be
785    * added as first features
786    */
787   if (features->array->len > 0
788       && gst_caps_features_contains_id (features, feature))
789     return;
790
791   g_array_append_val (features->array, feature);
792 }
793
794 /**
795  * gst_caps_features_remove:
796  * @features: a #GstCapsFeatures.
797  * @feature: a feature.
798  *
799  * Removes @feature from @features.
800  *
801  * Since: 1.2
802  */
803 void
804 gst_caps_features_remove (GstCapsFeatures * features, const gchar * feature)
805 {
806   g_return_if_fail (features != NULL);
807   g_return_if_fail (IS_MUTABLE (features));
808   g_return_if_fail (feature != NULL);
809
810   gst_caps_features_remove_id (features, g_quark_from_string (feature));
811 }
812
813 /**
814  * gst_caps_features_remove_id:
815  * @features: a #GstCapsFeatures.
816  * @feature: a feature.
817  *
818  * Removes @feature from @features.
819  *
820  * Since: 1.2
821  */
822 void
823 gst_caps_features_remove_id (GstCapsFeatures * features, GQuark feature)
824 {
825   guint i, n;
826
827   g_return_if_fail (features != NULL);
828   g_return_if_fail (IS_MUTABLE (features));
829   g_return_if_fail (feature != 0);
830
831   n = features->array->len;
832   for (i = 0; i < n; i++) {
833     GQuark quark = gst_caps_features_get_nth_id (features, i);
834
835     if (quark == feature) {
836       g_array_remove_index_fast (features->array, i);
837       return;
838     }
839   }
840 }
841
842 static void
843 gst_caps_features_transform_to_string (const GValue * src_value,
844     GValue * dest_value)
845 {
846   g_return_if_fail (src_value != NULL);
847   g_return_if_fail (dest_value != NULL);
848
849   dest_value->data[0].v_pointer =
850       gst_caps_features_to_string (src_value->data[0].v_pointer);
851 }