2 * Copyright (C) <2003> David A. Schleef <ds@schleef.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
22 * @short_description: Structure describing sets of media formats
23 * @see_also: #GstStructure
25 * Caps (capabilities) are lighweight refcounted objects describing media types.
26 * They are composed of an array of #GstStructure.
28 * Caps are exposed on #GstPadTemplate to describe all possible types a
29 * given pad can handle. They are also stored in the #GstRegistry along with
30 * a description of the #GstElement.
32 * Caps are exposed on the element pads using the gst_pad_get_caps() pad
33 * function. This function describes the possible types that the pad can
34 * handle or produce at runtime.
36 * Caps are also attached to buffers to describe to content of the data
37 * pointed to by the buffer with gst_buffer_set_caps(). Caps attached to
38 * a #GstBuffer allow for format negotiation upstream and downstream.
40 * A #GstCaps can be constructed with the following code fragment:
43 * <title>Creating caps</title>
46 * caps = gst_caps_new_simple ("video/x-raw-yuv",
47 * "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
48 * "framerate", GST_TYPE_FRACTION, 25, 1,
49 * "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
50 * "width", G_TYPE_INT, 320,
51 * "height", G_TYPE_INT, 240,
56 * A #GstCaps is fixed when it has no properties with ranges or lists. Use
57 * gst_caps_is_fixed() to test for fixed caps. Only fixed caps can be
58 * set on a #GstPad or #GstBuffer.
60 * Various methods exist to work with the media types such as subtracting
63 * Last reviewed on 2007-02-13 (0.10.10)
72 #include "gst_private.h"
75 #define DEBUG_REFCOUNT
77 #define CAPS_POISON(caps) G_STMT_START{ \
79 GstCaps *_newcaps = gst_caps_copy (caps); \
80 gst_caps_unref(caps); \
84 #define STRUCTURE_POISON(structure) G_STMT_START{ \
86 GstStructure *_newstruct = gst_structure_copy (structure); \
87 gst_structure_free(structure); \
88 structure = _newstruct; \
91 #define IS_WRITABLE(caps) \
92 (g_atomic_int_get (&(caps)->refcount) == 1)
94 /* quick way to get a caps structure at an index without doing a type or array
96 #define gst_caps_get_structure_unchecked(caps, index) \
97 ((GstStructure *)g_ptr_array_index ((caps)->structs, (index)))
100 /* lock to protect multiple invocations of static caps to caps conversion */
101 G_LOCK_DEFINE_STATIC (static_caps_lock);
103 static void gst_caps_transform_to_string (const GValue * src_value,
104 GValue * dest_value);
105 static gboolean gst_caps_from_string_inplace (GstCaps * caps,
106 const gchar * string);
107 static GstCaps *gst_caps_copy_conditional (GstCaps * src);
110 gst_caps_get_type (void)
112 static GType gst_caps_type = 0;
114 if (G_UNLIKELY (gst_caps_type == 0)) {
115 gst_caps_type = g_boxed_type_register_static ("GstCaps",
116 (GBoxedCopyFunc) gst_caps_copy_conditional,
117 (GBoxedFreeFunc) gst_caps_unref);
119 g_value_register_transform_func (gst_caps_type,
120 G_TYPE_STRING, gst_caps_transform_to_string);
123 return gst_caps_type;
126 /* creation/deletion */
129 * gst_caps_new_empty:
131 * Creates a new #GstCaps that is empty. That is, the returned
132 * #GstCaps contains no media formats.
133 * Caller is responsible for unreffing the returned caps.
135 * Returns: the new #GstCaps
138 gst_caps_new_empty (void)
140 GstCaps *caps = g_slice_new (GstCaps);
142 caps->type = GST_TYPE_CAPS;
145 caps->structs = g_ptr_array_new ();
147 #ifdef DEBUG_REFCOUNT
148 GST_CAT_LOG (GST_CAT_CAPS, "created caps %p", caps);
157 * Creates a new #GstCaps that indicates that it is compatible with
160 * Returns: the new #GstCaps
163 gst_caps_new_any (void)
165 GstCaps *caps = gst_caps_new_empty ();
167 caps->flags = GST_CAPS_FLAGS_ANY;
173 * gst_caps_new_simple:
174 * @media_type: the media type of the structure
175 * @fieldname: first field to set
176 * @...: additional arguments
178 * Creates a new #GstCaps that contains one #GstStructure. The
179 * structure is defined by the arguments, which have the same format
180 * as gst_structure_new().
181 * Caller is responsible for unreffing the returned caps.
183 * Returns: the new #GstCaps
186 gst_caps_new_simple (const char *media_type, const char *fieldname, ...)
189 GstStructure *structure;
192 caps = gst_caps_new_empty ();
194 va_start (var_args, fieldname);
195 structure = gst_structure_new_valist (media_type, fieldname, var_args);
198 gst_caps_append_structure (caps, structure);
205 * @struct1: the first structure to add
206 * @...: additional structures to add
208 * Creates a new #GstCaps and adds all the structures listed as
209 * arguments. The list must be NULL-terminated. The structures
210 * are not copied; the returned #GstCaps owns the structures.
212 * Returns: the new #GstCaps
215 gst_caps_new_full (GstStructure * struct1, ...)
220 va_start (var_args, struct1);
221 caps = gst_caps_new_full_valist (struct1, var_args);
228 * gst_caps_new_full_valist:
229 * @structure: the first structure to add
230 * @var_args: additional structures to add
232 * Creates a new #GstCaps and adds all the structures listed as
233 * arguments. The list must be NULL-terminated. The structures
234 * are not copied; the returned #GstCaps owns the structures.
236 * Returns: the new #GstCaps
239 gst_caps_new_full_valist (GstStructure * structure, va_list var_args)
243 caps = gst_caps_new_empty ();
246 gst_caps_append_structure (caps, structure);
247 structure = va_arg (var_args, GstStructure *);
255 * @caps: the #GstCaps to copy
257 * Creates a new #GstCaps as a copy of the old @caps. The new caps will have a
258 * refcount of 1, owned by the caller. The structures are copied as well.
260 * Note that this function is the semantic equivalent of a gst_caps_ref()
261 * followed by a gst_caps_make_writable(). If you only want to hold on to a
262 * reference to the data, you should use gst_caps_ref().
264 * When you are finished with the caps, call gst_caps_unref() on it.
266 * Returns: the new #GstCaps
269 gst_caps_copy (const GstCaps * caps)
272 GstStructure *structure;
275 g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
277 newcaps = gst_caps_new_empty ();
278 newcaps->flags = caps->flags;
280 for (i = 0; i < caps->structs->len; i++) {
281 structure = gst_caps_get_structure_unchecked (caps, i);
282 gst_caps_append_structure (newcaps, gst_structure_copy (structure));
289 _gst_caps_free (GstCaps * caps)
291 GstStructure *structure;
294 /* The refcount must be 0, but since we're only called by gst_caps_unref,
295 * don't bother testing. */
297 for (i = 0; i < caps->structs->len; i++) {
298 structure = (GstStructure *) gst_caps_get_structure_unchecked (caps, i);
299 gst_structure_set_parent_refcount (structure, NULL);
300 gst_structure_free (structure);
302 g_ptr_array_free (caps->structs, TRUE);
304 memset (caps, 0xff, sizeof (GstCaps));
307 #ifdef DEBUG_REFCOUNT
308 GST_CAT_LOG (GST_CAT_CAPS, "freeing caps %p", caps);
310 g_slice_free (GstCaps, caps);
314 * gst_caps_make_writable:
315 * @caps: the #GstCaps to make writable
317 * Returns a writable copy of @caps.
319 * If there is only one reference count on @caps, the caller must be the owner,
320 * and so this function will return the caps object unchanged. If on the other
321 * hand there is more than one reference on the object, a new caps object will
322 * be returned. The caller's reference on @caps will be removed, and instead the
323 * caller will own a reference to the returned object.
325 * In short, this function unrefs the caps in the argument and refs the caps
326 * that it returns. Don't access the argument after calling this function. See
327 * also: gst_caps_ref().
329 * Returns: the same #GstCaps object.
332 gst_caps_make_writable (GstCaps * caps)
336 g_return_val_if_fail (caps != NULL, NULL);
338 /* we are the only instance reffing this caps */
339 if (g_atomic_int_get (&caps->refcount) == 1)
343 copy = gst_caps_copy (caps);
344 gst_caps_unref (caps);
351 * @caps: the #GstCaps to reference
353 * Add a reference to a #GstCaps object.
355 * From this point on, until the caller calls gst_caps_unref() or
356 * gst_caps_make_writable(), it is guaranteed that the caps object will not
357 * change. This means its structures won't change, etc. To use a #GstCaps
358 * object, you must always have a refcount on it -- either the one made
359 * implicitly by gst_caps_new(), or via taking one explicitly with this
362 * Returns: the same #GstCaps object.
365 gst_caps_ref (GstCaps * caps)
367 g_return_val_if_fail (caps != NULL, NULL);
369 #ifdef DEBUG_REFCOUNT
370 GST_CAT_LOG (GST_CAT_REFCOUNTING, "%p %d->%d", caps,
371 GST_CAPS_REFCOUNT_VALUE (caps), GST_CAPS_REFCOUNT_VALUE (caps) + 1);
373 g_return_val_if_fail (GST_CAPS_REFCOUNT_VALUE (caps) > 0, NULL);
375 g_atomic_int_inc (&caps->refcount);
382 * @caps: the #GstCaps to unref
384 * Unref a #GstCaps and and free all its structures and the
385 * structures' values when the refcount reaches 0.
388 gst_caps_unref (GstCaps * caps)
390 g_return_if_fail (caps != NULL);
392 #ifdef DEBUG_REFCOUNT
393 GST_CAT_LOG (GST_CAT_REFCOUNTING, "%p %d->%d", caps,
394 GST_CAPS_REFCOUNT_VALUE (caps), GST_CAPS_REFCOUNT_VALUE (caps) - 1);
397 g_return_if_fail (GST_CAPS_REFCOUNT_VALUE (caps) > 0);
399 /* if we ended up with the refcount at zero, free the caps */
400 if (G_UNLIKELY (g_atomic_int_dec_and_test (&caps->refcount)))
401 _gst_caps_free (caps);
405 gst_static_caps_get_type (void)
407 static GType staticcaps_type = 0;
409 if (G_UNLIKELY (staticcaps_type == 0)) {
410 staticcaps_type = g_pointer_type_register_static ("GstStaticCaps");
412 return staticcaps_type;
417 * gst_static_caps_get:
418 * @static_caps: the #GstStaticCaps to convert
420 * Converts a #GstStaticCaps to a #GstCaps.
422 * Returns: A pointer to the #GstCaps. Unref after usage. Since the
423 * core holds an additional ref to the returned caps,
424 * use gst_caps_make_writable() on the returned caps to modify it.
427 gst_static_caps_get (GstStaticCaps * static_caps)
431 g_return_val_if_fail (static_caps != NULL, NULL);
433 caps = (GstCaps *) static_caps;
435 /* refcount is 0 when we need to convert */
436 if (G_UNLIKELY (g_atomic_int_get (&caps->refcount) == 0)) {
440 G_LOCK (static_caps_lock);
441 /* check if other thread already updated */
442 if (G_UNLIKELY (g_atomic_int_get (&caps->refcount) > 0))
445 string = static_caps->string;
447 if (G_UNLIKELY (string == NULL))
450 GST_CAT_LOG (GST_CAT_CAPS, "creating %p", static_caps);
452 /* we construct the caps on the stack, then copy over the struct into our
453 * real caps, refcount last. We do this because we must leave the refcount
454 * of the result caps to 0 so that other threads don't run away with the
455 * caps while we are constructing it. */
456 temp.type = GST_TYPE_CAPS;
458 temp.structs = g_ptr_array_new ();
460 /* initialize the caps to a refcount of 1 so the caps can be writable for
461 * the next statement */
464 /* convert to string */
465 if (G_UNLIKELY (!gst_caps_from_string_inplace (&temp, string)))
466 g_critical ("Could not convert static caps \"%s\"", string);
468 /* now copy stuff over to the real caps. */
469 caps->type = temp.type;
470 caps->flags = temp.flags;
471 caps->structs = temp.structs;
472 /* and bump the refcount so other threads can now read */
473 g_atomic_int_set (&caps->refcount, 1);
475 GST_CAT_LOG (GST_CAT_CAPS, "created %p", static_caps);
477 G_UNLOCK (static_caps_lock);
479 /* ref the caps, makes it not writable */
487 G_UNLOCK (static_caps_lock);
488 g_warning ("static caps %p string is NULL", static_caps);
494 static GstStructure *
495 gst_caps_remove_and_get_structure (GstCaps * caps, guint idx)
497 /* don't use index_fast, gst_caps_do_simplify relies on the order */
498 GstStructure *s = g_ptr_array_remove_index (caps->structs, idx);
500 gst_structure_set_parent_refcount (s, NULL);
505 gst_structure_is_equal_foreach (GQuark field_id, const GValue * val2,
508 GstStructure *struct1 = (GstStructure *) data;
509 const GValue *val1 = gst_structure_id_get_value (struct1, field_id);
513 if (gst_value_compare (val1, val2) == GST_VALUE_EQUAL) {
521 gst_caps_structure_is_subset_field (GQuark field_id, const GValue * value,
524 GstStructure *subtract_from = user_data;
525 GValue subtraction = { 0, };
528 if (!(other = gst_structure_id_get_value (subtract_from, field_id)))
529 /* field is missing in one set */
532 /* equal values are subset */
533 if (gst_value_compare (other, value) == GST_VALUE_EQUAL)
541 * -> 1 - [1,2] = empty
545 * -> [1,2] - [1,3] = empty
549 * -> {1,3} - {1,2} = 3
552 * First caps subtraction needs to return a non-empty set, second
553 * subtractions needs to give en empty set.
555 if (gst_value_subtract (&subtraction, other, value)) {
556 g_value_unset (&subtraction);
557 /* !empty result, swapping must be empty */
558 if (!gst_value_subtract (&subtraction, value, other))
561 g_value_unset (&subtraction);
567 gst_caps_structure_is_subset (const GstStructure * minuend,
568 const GstStructure * subtrahend)
570 if ((minuend->name != subtrahend->name) ||
571 (gst_structure_n_fields (minuend) !=
572 gst_structure_n_fields (subtrahend))) {
576 return gst_structure_foreach ((GstStructure *) subtrahend,
577 gst_caps_structure_is_subset_field, (gpointer) minuend);
582 * @caps1: the #GstCaps that will be appended to
583 * @caps2: the #GstCaps to append
585 * Appends the structures contained in @caps2 to @caps1. The structures in
586 * @caps2 are not copied -- they are transferred to @caps1, and then @caps2 is
587 * freed. If either caps is ANY, the resulting caps will be ANY.
590 gst_caps_append (GstCaps * caps1, GstCaps * caps2)
592 GstStructure *structure;
595 g_return_if_fail (GST_IS_CAPS (caps1));
596 g_return_if_fail (GST_IS_CAPS (caps2));
597 g_return_if_fail (IS_WRITABLE (caps1));
598 g_return_if_fail (IS_WRITABLE (caps2));
603 if (gst_caps_is_any (caps1) || gst_caps_is_any (caps2)) {
604 /* FIXME: this leaks */
605 caps1->flags |= GST_CAPS_FLAGS_ANY;
606 for (i = caps2->structs->len - 1; i >= 0; i--) {
607 structure = gst_caps_remove_and_get_structure (caps2, i);
608 gst_structure_free (structure);
611 int len = caps2->structs->len;
613 for (i = 0; i < len; i++) {
614 structure = gst_caps_remove_and_get_structure (caps2, 0);
615 gst_caps_append_structure (caps1, structure);
618 gst_caps_unref (caps2); /* guaranteed to free it */
623 * @caps1: the #GstCaps that will take the new entries
624 * @caps2: the #GstCaps to merge in
626 * Appends the structures contained in @caps2 to @caps1 if they are not yet
627 * expressed by @caps1. The structures in @caps2 are not copied -- they are
628 * transferred to @caps1, and then @caps2 is freed.
629 * If either caps is ANY, the resulting caps will be ANY.
634 gst_caps_merge (GstCaps * caps1, GstCaps * caps2)
636 GstStructure *structure;
639 g_return_if_fail (GST_IS_CAPS (caps1));
640 g_return_if_fail (GST_IS_CAPS (caps2));
641 g_return_if_fail (IS_WRITABLE (caps1));
642 g_return_if_fail (IS_WRITABLE (caps2));
647 if (gst_caps_is_any (caps1)) {
648 for (i = caps2->structs->len - 1; i >= 0; i--) {
649 structure = gst_caps_remove_and_get_structure (caps2, i);
650 gst_structure_free (structure);
652 } else if (gst_caps_is_any (caps2)) {
653 caps1->flags |= GST_CAPS_FLAGS_ANY;
654 for (i = caps1->structs->len - 1; i >= 0; i--) {
655 structure = gst_caps_remove_and_get_structure (caps1, i);
656 gst_structure_free (structure);
659 int len = caps2->structs->len;
661 for (i = 0; i < len; i++) {
662 structure = gst_caps_remove_and_get_structure (caps2, 0);
663 gst_caps_merge_structure (caps1, structure);
666 GstCaps *com = gst_caps_intersect (caps1, caps2);
667 GstCaps *add = gst_caps_subtract (caps2, com);
669 GST_DEBUG ("common : %d", gst_caps_get_size (com));
670 GST_DEBUG ("adding : %d", gst_caps_get_size (add));
671 gst_caps_append (caps1, add);
672 gst_caps_unref (com);
675 gst_caps_unref (caps2); /* guaranteed to free it */
679 * gst_caps_append_structure:
680 * @caps: the #GstCaps that will be appended to
681 * @structure: the #GstStructure to append
683 * Appends @structure to @caps. The structure is not copied; @caps
684 * becomes the owner of @structure.
687 gst_caps_append_structure (GstCaps * caps, GstStructure * structure)
689 g_return_if_fail (GST_IS_CAPS (caps));
690 g_return_if_fail (IS_WRITABLE (caps));
692 if (G_LIKELY (structure)) {
693 g_return_if_fail (structure->parent_refcount == NULL);
696 STRUCTURE_POISON (structure);
699 gst_structure_set_parent_refcount (structure, &caps->refcount);
700 g_ptr_array_add (caps->structs, structure);
705 * gst_caps_remove_structure:
706 * @caps: the #GstCaps to remove from
707 * @idx: Index of the structure to remove
709 * removes the stucture with the given index from the list of structures
710 * contained in @caps.
713 gst_caps_remove_structure (GstCaps * caps, guint idx)
715 GstStructure *structure;
717 g_return_if_fail (caps != NULL);
718 g_return_if_fail (idx <= gst_caps_get_size (caps));
719 g_return_if_fail (IS_WRITABLE (caps));
721 structure = gst_caps_remove_and_get_structure (caps, idx);
722 gst_structure_free (structure);
726 * gst_caps_merge_structure:
727 * @caps: the #GstCaps that will the the new structure
728 * @structure: the #GstStructure to merge
730 * Appends @structure to @caps if its not already expressed by @caps. The
731 * structure is not copied; @caps becomes the owner of @structure.
734 gst_caps_merge_structure (GstCaps * caps, GstStructure * structure)
736 g_return_if_fail (GST_IS_CAPS (caps));
737 g_return_if_fail (IS_WRITABLE (caps));
739 if (G_LIKELY (structure)) {
740 GstStructure *structure1;
742 gboolean unique = TRUE;
744 g_return_if_fail (structure->parent_refcount == NULL);
747 STRUCTURE_POISON (structure);
750 /* check each structure */
751 for (i = caps->structs->len - 1; i >= 0; i--) {
752 structure1 = gst_caps_get_structure_unchecked (caps, i);
753 /* if structure is a subset of structure1, then skip it */
754 if (gst_caps_structure_is_subset (structure1, structure)) {
760 gst_structure_set_parent_refcount (structure, &caps->refcount);
761 g_ptr_array_add (caps->structs, structure);
763 gst_structure_free (structure);
773 * Gets the number of structures contained in @caps.
775 * Returns: the number of structures that @caps contains
778 gst_caps_get_size (const GstCaps * caps)
780 g_return_val_if_fail (GST_IS_CAPS (caps), 0);
782 return caps->structs->len;
786 * gst_caps_get_structure:
788 * @index: the index of the structure
790 * Finds the structure in @caps that has the index @index, and
793 * WARNING: This function takes a const GstCaps *, but returns a
794 * non-const GstStructure *. This is for programming convenience --
795 * the caller should be aware that structures inside a constant
796 * #GstCaps should not be modified.
798 * Returns: a pointer to the #GstStructure corresponding to @index
801 gst_caps_get_structure (const GstCaps * caps, guint index)
803 g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
804 g_return_val_if_fail (index < caps->structs->len, NULL);
806 return gst_caps_get_structure_unchecked (caps, index);
811 * @caps: the #GstCaps to copy
812 * @nth: the nth structure to copy
814 * Creates a new #GstCaps and appends a copy of the nth structure
815 * contained in @caps.
817 * Returns: the new #GstCaps
820 gst_caps_copy_nth (const GstCaps * caps, guint nth)
823 GstStructure *structure;
825 g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
827 newcaps = gst_caps_new_empty ();
828 newcaps->flags = caps->flags;
830 if (caps->structs->len > nth) {
831 structure = gst_caps_get_structure_unchecked (caps, nth);
832 gst_caps_append_structure (newcaps, gst_structure_copy (structure));
840 * @caps: the #GstCaps to truncate
842 * Destructively discard all but the first structure from @caps. Useful when
843 * fixating. @caps must be writable.
846 gst_caps_truncate (GstCaps * caps)
850 g_return_if_fail (GST_IS_CAPS (caps));
851 g_return_if_fail (IS_WRITABLE (caps));
853 i = caps->structs->len - 1;
856 gst_caps_remove_structure (caps, i--);
860 * gst_caps_set_simple:
861 * @caps: the #GstCaps to set
862 * @field: first field to set
863 * @...: additional parameters
865 * Sets fields in a simple #GstCaps. A simple #GstCaps is one that
866 * only has one structure. The arguments must be passed in the same
867 * manner as gst_structure_set(), and be NULL-terminated.
870 gst_caps_set_simple (GstCaps * caps, const char *field, ...)
872 GstStructure *structure;
875 g_return_if_fail (GST_IS_CAPS (caps));
876 g_return_if_fail (caps->structs->len == 1);
877 g_return_if_fail (IS_WRITABLE (caps));
879 structure = gst_caps_get_structure_unchecked (caps, 0);
881 va_start (var_args, field);
882 gst_structure_set_valist (structure, field, var_args);
887 * gst_caps_set_simple_valist:
888 * @caps: the #GstCaps to copy
889 * @field: first field to set
890 * @varargs: additional parameters
892 * Sets fields in a simple #GstCaps. A simple #GstCaps is one that
893 * only has one structure. The arguments must be passed in the same
894 * manner as gst_structure_set(), and be NULL-terminated.
897 gst_caps_set_simple_valist (GstCaps * caps, const char *field, va_list varargs)
899 GstStructure *structure;
901 g_return_if_fail (GST_IS_CAPS (caps));
902 g_return_if_fail (caps->structs->len == 1);
903 g_return_if_fail (IS_WRITABLE (caps));
905 structure = gst_caps_get_structure_unchecked (caps, 0);
907 gst_structure_set_valist (structure, field, varargs);
914 * @caps: the #GstCaps to test
916 * Determines if @caps represents any media format.
918 * Returns: TRUE if @caps represents any format.
921 gst_caps_is_any (const GstCaps * caps)
923 g_return_val_if_fail (GST_IS_CAPS (caps), FALSE);
925 return (caps->flags & GST_CAPS_FLAGS_ANY);
930 * @caps: the #GstCaps to test
932 * Determines if @caps represents no media formats.
934 * Returns: TRUE if @caps represents no formats.
937 gst_caps_is_empty (const GstCaps * caps)
939 g_return_val_if_fail (GST_IS_CAPS (caps), FALSE);
941 if (caps->flags & GST_CAPS_FLAGS_ANY)
944 return (caps->structs == NULL) || (caps->structs->len == 0);
948 gst_caps_is_fixed_foreach (GQuark field_id, const GValue * value,
951 return gst_value_is_fixed (value);
956 * @caps: the #GstCaps to test
958 * Fixed #GstCaps describe exactly one format, that is, they have exactly
959 * one structure, and each field in the structure describes a fixed type.
960 * Examples of non-fixed types are GST_TYPE_INT_RANGE and GST_TYPE_LIST.
962 * Returns: TRUE if @caps is fixed
965 gst_caps_is_fixed (const GstCaps * caps)
967 GstStructure *structure;
969 g_return_val_if_fail (GST_IS_CAPS (caps), FALSE);
971 if (caps->structs->len != 1)
974 structure = gst_caps_get_structure_unchecked (caps, 0);
976 return gst_structure_foreach (structure, gst_caps_is_fixed_foreach, NULL);
980 * gst_caps_is_equal_fixed:
981 * @caps1: the #GstCaps to test
982 * @caps2: the #GstCaps to test
984 * Tests if two #GstCaps are equal. This function only works on fixed
987 * Returns: TRUE if the arguments represent the same format
990 gst_caps_is_equal_fixed (const GstCaps * caps1, const GstCaps * caps2)
992 GstStructure *struct1, *struct2;
994 g_return_val_if_fail (gst_caps_is_fixed (caps1), FALSE);
995 g_return_val_if_fail (gst_caps_is_fixed (caps2), FALSE);
997 struct1 = gst_caps_get_structure_unchecked (caps1, 0);
998 struct2 = gst_caps_get_structure_unchecked (caps2, 0);
1000 if (struct1->name != struct2->name) {
1003 if (struct1->fields->len != struct2->fields->len) {
1007 return gst_structure_foreach (struct1, gst_structure_is_equal_foreach,
1012 * gst_caps_is_always_compatible:
1013 * @caps1: the #GstCaps to test
1014 * @caps2: the #GstCaps to test
1016 * A given #GstCaps structure is always compatible with another if
1017 * every media format that is in the first is also contained in the
1018 * second. That is, @caps1 is a subset of @caps2.
1020 * Returns: TRUE if @caps1 is a subset of @caps2.
1023 gst_caps_is_always_compatible (const GstCaps * caps1, const GstCaps * caps2)
1025 g_return_val_if_fail (GST_IS_CAPS (caps1), FALSE);
1026 g_return_val_if_fail (GST_IS_CAPS (caps2), FALSE);
1028 return gst_caps_is_subset (caps1, caps2);
1032 * gst_caps_is_subset:
1033 * @subset: a #GstCaps
1034 * @superset: a potentially greater #GstCaps
1036 * Checks if all caps represented by @subset are also represented by @superset.
1037 * <note>This function does not work reliably if optional properties for caps
1038 * are included on one caps and omitted on the other.</note>
1040 * Returns: %TRUE if @subset is a subset of @superset
1043 gst_caps_is_subset (const GstCaps * subset, const GstCaps * superset)
1048 g_return_val_if_fail (subset != NULL, FALSE);
1049 g_return_val_if_fail (superset != NULL, FALSE);
1051 if (gst_caps_is_empty (subset) || gst_caps_is_any (superset))
1053 if (gst_caps_is_any (subset) || gst_caps_is_empty (superset))
1056 caps = gst_caps_subtract (subset, superset);
1057 ret = gst_caps_is_empty (caps);
1058 gst_caps_unref (caps);
1063 * gst_caps_is_equal:
1064 * @caps1: a #GstCaps
1065 * @caps2: another #GstCaps
1067 * Checks if the given caps represent the same set of caps.
1068 * <note>This function does not work reliably if optional properties for caps
1069 * are included on one caps and omitted on the other.</note>
1071 * This function deals correctly with passing NULL for any of the caps.
1073 * Returns: TRUE if both caps are equal.
1076 gst_caps_is_equal (const GstCaps * caps1, const GstCaps * caps2)
1078 /* FIXME 0.11: NULL pointers are no valid Caps but indicate an error
1079 * So there should be an assertion that caps1 and caps2 != NULL */
1081 /* NULL <-> NULL is allowed here */
1085 /* one of them NULL => they are different (can't be both NULL because
1086 * we checked that above) */
1087 if (caps1 == NULL || caps2 == NULL)
1090 if (gst_caps_is_fixed (caps1) && gst_caps_is_fixed (caps2))
1091 return gst_caps_is_equal_fixed (caps1, caps2);
1093 return gst_caps_is_subset (caps1, caps2) && gst_caps_is_subset (caps2, caps1);
1099 const GstStructure *intersect;
1105 gst_caps_structure_intersect_field (GQuark id, const GValue * val1,
1108 IntersectData *idata = (IntersectData *) data;
1109 GValue dest_value = { 0 };
1110 const GValue *val2 = gst_structure_id_get_value (idata->intersect, id);
1113 gst_structure_id_set_value (idata->dest, id, val1);
1114 } else if (idata->first_run) {
1115 if (gst_value_intersect (&dest_value, val1, val2)) {
1116 gst_structure_id_set_value (idata->dest, id, &dest_value);
1117 g_value_unset (&dest_value);
1126 static GstStructure *
1127 gst_caps_structure_intersect (const GstStructure * struct1,
1128 const GstStructure * struct2)
1132 g_return_val_if_fail (struct1 != NULL, NULL);
1133 g_return_val_if_fail (struct2 != NULL, NULL);
1135 if (struct1->name != struct2->name)
1138 data.dest = gst_structure_id_empty_new (struct1->name);
1139 data.intersect = struct2;
1140 data.first_run = TRUE;
1141 if (!gst_structure_foreach ((GstStructure *) struct1,
1142 gst_caps_structure_intersect_field, &data))
1145 data.intersect = struct1;
1146 data.first_run = FALSE;
1147 if (!gst_structure_foreach ((GstStructure *) struct2,
1148 gst_caps_structure_intersect_field, &data))
1154 gst_structure_free (data.dest);
1159 static GstStructure *
1160 gst_caps_structure_union (const GstStructure * struct1,
1161 const GstStructure * struct2)
1165 const GstStructureField *field1;
1166 const GstStructureField *field2;
1169 /* FIXME this doesn't actually work */
1171 if (struct1->name != struct2->name)
1174 dest = gst_structure_id_empty_new (struct1->name);
1176 for (i = 0; i < struct1->fields->len; i++) {
1177 GValue dest_value = { 0 };
1179 field1 = GST_STRUCTURE_FIELD (struct1, i);
1180 field2 = gst_structure_id_get_field (struct2, field1->name);
1182 if (field2 == NULL) {
1185 if (gst_value_union (&dest_value, &field1->value, &field2->value)) {
1186 gst_structure_set_value (dest, g_quark_to_string (field1->name),
1189 ret = gst_value_compare (&field1->value, &field2->value);
1201 * gst_caps_intersect:
1202 * @caps1: a #GstCaps to intersect
1203 * @caps2: a #GstCaps to intersect
1205 * Creates a new #GstCaps that contains all the formats that are common
1206 * to both @caps1 and @caps2.
1208 * Returns: the new #GstCaps
1211 gst_caps_intersect (const GstCaps * caps1, const GstCaps * caps2)
1213 guint64 i; /* index can be up to 2 * G_MAX_UINT */
1216 GstStructure *struct1;
1217 GstStructure *struct2;
1219 GstStructure *istruct;
1221 g_return_val_if_fail (GST_IS_CAPS (caps1), NULL);
1222 g_return_val_if_fail (GST_IS_CAPS (caps2), NULL);
1224 /* caps are exactly the same pointers, just copy one caps */
1226 return gst_caps_copy (caps1);
1228 /* empty caps on either side, return empty */
1229 if (gst_caps_is_empty (caps1) || gst_caps_is_empty (caps2))
1230 return gst_caps_new_empty ();
1232 /* one of the caps is any, just copy the other caps */
1233 if (gst_caps_is_any (caps1))
1234 return gst_caps_copy (caps2);
1235 if (gst_caps_is_any (caps2))
1236 return gst_caps_copy (caps1);
1238 dest = gst_caps_new_empty ();
1240 /* run zigzag on top line then right line, this preserves the caps order
1241 * much better than a simple loop.
1243 * This algorithm zigzags over the caps structures as demonstrated in
1244 * the folowing matrix:
1252 * First we iterate over the caps1 structures (top line) intersecting
1253 * the structures diagonally down, then we iterate over the caps2
1256 for (i = 0; i < caps1->structs->len + caps2->structs->len - 1; i++) {
1257 /* caps1 index goes from 0 to caps1->structs->len-1 */
1258 j = MIN (i, caps1->structs->len - 1);
1259 /* caps2 index stays 0 until i reaches caps1->structs->len, then it counts
1260 * up from 1 to caps2->structs->len - 1 */
1263 /* now run the diagonal line, end condition is the left or bottom
1265 while (k < caps2->structs->len) {
1266 struct1 = gst_caps_get_structure_unchecked (caps1, j);
1267 struct2 = gst_caps_get_structure_unchecked (caps2, k);
1269 istruct = gst_caps_structure_intersect (struct1, struct2);
1271 gst_caps_append_structure (dest, istruct);
1272 /* move down left */
1275 break; /* so we don't roll back to G_MAXUINT */
1284 const GstStructure *subtract_from;
1291 gst_caps_structure_subtract_field (GQuark field_id, const GValue * value,
1294 SubtractionEntry *e = user_data;
1295 GValue subtraction = { 0, };
1296 const GValue *other;
1297 GstStructure *structure;
1299 other = gst_structure_id_get_value (e->subtract_from, field_id);
1303 if (!gst_value_subtract (&subtraction, other, value))
1305 if (gst_value_compare (&subtraction, other) == GST_VALUE_EQUAL) {
1306 g_value_unset (&subtraction);
1309 structure = gst_structure_copy (e->subtract_from);
1310 gst_structure_id_set_value (structure, field_id, &subtraction);
1311 g_value_unset (&subtraction);
1312 e->put_into = g_slist_prepend (e->put_into, structure);
1318 gst_caps_structure_subtract (GSList ** into, const GstStructure * minuend,
1319 const GstStructure * subtrahend)
1324 e.subtract_from = minuend;
1327 ret = gst_structure_foreach ((GstStructure *) subtrahend,
1328 gst_caps_structure_subtract_field, &e);
1334 for (walk = e.put_into; walk; walk = g_slist_next (walk)) {
1335 gst_structure_free (walk->data);
1337 g_slist_free (e.put_into);
1343 * gst_caps_subtract:
1344 * @minuend: #GstCaps to substract from
1345 * @subtrahend: #GstCaps to substract
1347 * Subtracts the @subtrahend from the @minuend.
1348 * <note>This function does not work reliably if optional properties for caps
1349 * are included on one caps and omitted on the other.</note>
1351 * Returns: the resulting caps
1354 gst_caps_subtract (const GstCaps * minuend, const GstCaps * subtrahend)
1359 GstCaps *dest = NULL, *src;
1361 g_return_val_if_fail (minuend != NULL, NULL);
1362 g_return_val_if_fail (subtrahend != NULL, NULL);
1364 if (gst_caps_is_empty (minuend) || gst_caps_is_any (subtrahend)) {
1365 return gst_caps_new_empty ();
1367 if (gst_caps_is_empty (subtrahend))
1368 return gst_caps_copy (minuend);
1370 /* FIXME: Do we want this here or above?
1371 The reason we need this is that there is no definition about what
1372 ANY means for specific types, so it's not possible to reduce ANY partially
1373 You can only remove everything or nothing and that is done above.
1374 Note: there's a test that checks this behaviour. */
1375 g_return_val_if_fail (!gst_caps_is_any (minuend), NULL);
1376 g_assert (subtrahend->structs->len > 0);
1378 src = gst_caps_copy (minuend);
1379 for (i = 0; i < subtrahend->structs->len; i++) {
1380 sub = gst_caps_get_structure_unchecked (subtrahend, i);
1382 gst_caps_unref (src);
1385 dest = gst_caps_new_empty ();
1386 for (j = 0; j < src->structs->len; j++) {
1387 min = gst_caps_get_structure_unchecked (src, j);
1388 if (gst_structure_get_name_id (min) == gst_structure_get_name_id (sub)) {
1391 if (gst_caps_structure_subtract (&list, min, sub)) {
1394 for (walk = list; walk; walk = g_slist_next (walk)) {
1395 gst_caps_append_structure (dest, (GstStructure *) walk->data);
1397 g_slist_free (list);
1399 gst_caps_append_structure (dest, gst_structure_copy (min));
1402 gst_caps_append_structure (dest, gst_structure_copy (min));
1405 if (gst_caps_is_empty (dest)) {
1406 gst_caps_unref (src);
1411 gst_caps_unref (src);
1412 gst_caps_do_simplify (dest);
1418 * @caps1: a #GstCaps to union
1419 * @caps2: a #GstCaps to union
1421 * Creates a new #GstCaps that contains all the formats that are in
1422 * either @caps1 and @caps2.
1424 * Returns: the new #GstCaps
1427 gst_caps_union (const GstCaps * caps1, const GstCaps * caps2)
1432 /* NULL pointers are no correct GstCaps */
1433 g_return_val_if_fail (caps1 != NULL, NULL);
1434 g_return_val_if_fail (caps2 != NULL, NULL);
1436 if (gst_caps_is_empty (caps1))
1437 return gst_caps_copy (caps2);
1439 if (gst_caps_is_empty (caps2))
1440 return gst_caps_copy (caps1);
1442 if (gst_caps_is_any (caps1) || gst_caps_is_any (caps2))
1443 return gst_caps_new_any ();
1445 dest1 = gst_caps_copy (caps1);
1446 dest2 = gst_caps_copy (caps2);
1447 gst_caps_append (dest1, dest2);
1449 gst_caps_do_simplify (dest1);
1453 typedef struct _NormalizeForeach
1456 GstStructure *structure;
1461 gst_caps_normalize_foreach (GQuark field_id, const GValue * value, gpointer ptr)
1463 NormalizeForeach *nf = (NormalizeForeach *) ptr;
1467 if (G_VALUE_TYPE (value) == GST_TYPE_LIST) {
1468 for (i = 1; i < gst_value_list_get_size (value); i++) {
1469 const GValue *v = gst_value_list_get_value (value, i);
1470 GstStructure *structure = gst_structure_copy (nf->structure);
1472 gst_structure_id_set_value (structure, field_id, v);
1473 gst_caps_append_structure (nf->caps, structure);
1476 gst_value_init_and_copy (&val, gst_value_list_get_value (value, 0));
1477 gst_structure_id_set_value (nf->structure, field_id, &val);
1478 g_value_unset (&val);
1486 * gst_caps_normalize:
1487 * @caps: a #GstCaps to normalize
1489 * Creates a new #GstCaps that represents the same set of formats as
1490 * @caps, but contains no lists. Each list is expanded into separate
1493 * Returns: the new #GstCaps
1496 gst_caps_normalize (const GstCaps * caps)
1498 NormalizeForeach nf;
1502 g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
1504 newcaps = gst_caps_copy (caps);
1507 for (i = 0; i < newcaps->structs->len; i++) {
1508 nf.structure = gst_caps_get_structure_unchecked (newcaps, i);
1510 while (!gst_structure_foreach (nf.structure,
1511 gst_caps_normalize_foreach, &nf));
1518 gst_caps_compare_structures (gconstpointer one, gconstpointer two)
1521 const GstStructure *struct1 = *((const GstStructure **) one);
1522 const GstStructure *struct2 = *((const GstStructure **) two);
1524 /* FIXME: this orders alphabetically, but ordering the quarks might be faster
1525 So what's the best way? */
1526 ret = strcmp (gst_structure_get_name (struct1),
1527 gst_structure_get_name (struct2));
1531 return gst_structure_n_fields (struct2) - gst_structure_n_fields (struct1);
1538 GstStructure *compare;
1543 gst_caps_structure_figure_out_union (GQuark field_id, const GValue * value,
1546 UnionField *u = user_data;
1547 const GValue *val = gst_structure_id_get_value (u->compare, field_id);
1551 g_value_unset (&u->value);
1554 if (gst_value_compare (val, value) == GST_VALUE_EQUAL)
1557 g_value_unset (&u->value);
1561 gst_value_union (&u->value, val, value);
1566 gst_caps_structure_simplify (GstStructure ** result,
1567 const GstStructure * simplify, GstStructure * compare)
1570 UnionField field = { 0, {0,}, NULL };
1572 /* try to subtract to get a real subset */
1573 if (gst_caps_structure_subtract (&list, simplify, compare)) {
1574 switch (g_slist_length (list)) {
1579 *result = list->data;
1580 g_slist_free (list);
1586 for (walk = list; walk; walk = g_slist_next (walk)) {
1587 gst_structure_free (walk->data);
1589 g_slist_free (list);
1595 /* try to union both structs */
1596 field.compare = compare;
1597 if (gst_structure_foreach ((GstStructure *) simplify,
1598 gst_caps_structure_figure_out_union, &field)) {
1599 gboolean ret = FALSE;
1601 /* now we know all of simplify's fields are the same in compare
1602 * but at most one field: field.name */
1603 if (G_IS_VALUE (&field.value)) {
1604 if (gst_structure_n_fields (simplify) == gst_structure_n_fields (compare)) {
1605 gst_structure_id_set_value (compare, field.name, &field.value);
1609 g_value_unset (&field.value);
1610 } else if (gst_structure_n_fields (simplify) <=
1611 gst_structure_n_fields (compare)) {
1612 /* compare is just more specific, will be optimized away later */
1613 /* FIXME: do this here? */
1614 GST_LOG ("found a case that will be optimized later.");
1616 gchar *one = gst_structure_to_string (simplify);
1617 gchar *two = gst_structure_to_string (compare);
1620 ("caps mismatch: structures %s and %s claim to be possible to unify, but aren't",
1632 gst_caps_switch_structures (GstCaps * caps, GstStructure * old,
1633 GstStructure * new, gint i)
1635 gst_structure_set_parent_refcount (old, NULL);
1636 gst_structure_free (old);
1637 gst_structure_set_parent_refcount (new, &caps->refcount);
1638 g_ptr_array_index (caps->structs, i) = new;
1642 * gst_caps_do_simplify:
1643 * @caps: a #GstCaps to simplify
1645 * Modifies the given @caps inplace into a representation that represents the
1646 * same set of formats, but in a simpler form. Component structures that are
1647 * identical are merged. Component structures that have values that can be
1648 * merged are also merged.
1650 * Returns: TRUE, if the caps could be simplified
1653 gst_caps_do_simplify (GstCaps * caps)
1655 GstStructure *simplify, *compare, *result = NULL;
1657 gboolean changed = FALSE;
1659 g_return_val_if_fail (caps != NULL, FALSE);
1660 g_return_val_if_fail (IS_WRITABLE (caps), FALSE);
1662 if (gst_caps_get_size (caps) < 2)
1665 g_ptr_array_sort (caps->structs, gst_caps_compare_structures);
1667 start = caps->structs->len - 1;
1668 for (i = caps->structs->len - 1; i >= 0; i--) {
1669 simplify = gst_caps_get_structure_unchecked (caps, i);
1670 if (gst_structure_get_name_id (simplify) !=
1671 gst_structure_get_name_id (gst_caps_get_structure_unchecked (caps,
1674 for (j = start; j >= 0; j--) {
1677 compare = gst_caps_get_structure_unchecked (caps, j);
1678 if (gst_structure_get_name_id (simplify) !=
1679 gst_structure_get_name_id (compare)) {
1682 if (gst_caps_structure_simplify (&result, simplify, compare)) {
1684 gst_caps_switch_structures (caps, simplify, result, i);
1687 gst_caps_remove_structure (caps, i);
1699 /* gst_caps_do_simplify (caps); */
1703 #ifndef GST_DISABLE_LOADSAVE
1705 * gst_caps_save_thyself:
1706 * @caps: a #GstCaps structure
1707 * @parent: a XML parent node
1709 * Serializes a #GstCaps to XML and adds it as a child node of @parent.
1711 * Returns: a XML node pointer
1714 gst_caps_save_thyself (const GstCaps * caps, xmlNodePtr parent)
1716 char *s = gst_caps_to_string (caps);
1718 xmlNewChild (parent, NULL, (xmlChar *) "caps", (xmlChar *) s);
1724 * gst_caps_load_thyself:
1725 * @parent: a XML node
1727 * Creates a #GstCaps from its XML serialization.
1729 * Returns: a new #GstCaps structure
1732 gst_caps_load_thyself (xmlNodePtr parent)
1734 if (strcmp ("caps", (char *) parent->name) == 0) {
1735 return gst_caps_from_string ((gchar *) xmlNodeGetContent (parent));
1746 * @caps: a pointer to #GstCaps
1747 * @newcaps: a #GstCaps to replace *caps
1749 * Replaces *caps with @newcaps. Unrefs the #GstCaps in the location
1750 * pointed to by @caps, if applicable, then modifies @caps to point to
1751 * @newcaps. An additional ref on @newcaps is taken.
1753 * This function does not take any locks so you might want to lock
1754 * the object owning @caps pointer.
1757 gst_caps_replace (GstCaps ** caps, GstCaps * newcaps)
1761 g_return_if_fail (caps != NULL);
1765 if (newcaps != oldcaps) {
1767 gst_caps_ref (newcaps);
1772 gst_caps_unref (oldcaps);
1777 * gst_caps_to_string:
1780 * Converts @caps to a string representation. This string representation
1781 * can be converted back to a #GstCaps by gst_caps_from_string().
1783 * For debugging purposes its easier to do something like this:
1785 * GST_LOG ("caps are %" GST_PTR_FORMAT, caps);
1787 * This prints the caps in human readble form.
1789 * Returns: a newly allocated string representing @caps.
1792 gst_caps_to_string (const GstCaps * caps)
1797 /* NOTE: This function is potentially called by the debug system,
1798 * so any calls to gst_log() (and GST_DEBUG(), GST_LOG(), etc.)
1799 * should be careful to avoid recursion. This includes any functions
1800 * called by gst_caps_to_string. In particular, calls should
1801 * not use the GST_PTR_FORMAT extension. */
1804 return g_strdup ("NULL");
1806 if (gst_caps_is_any (caps)) {
1807 return g_strdup ("ANY");
1809 if (gst_caps_is_empty (caps)) {
1810 return g_strdup ("EMPTY");
1813 /* estimate a rough string length to avoid unnecessary reallocs in GString */
1815 for (i = 0; i < caps->structs->len; i++) {
1817 STRUCTURE_ESTIMATED_STRING_LEN (gst_caps_get_structure_unchecked (caps,
1821 s = g_string_sized_new (slen);
1822 for (i = 0; i < caps->structs->len; i++) {
1823 GstStructure *structure;
1826 /* ';' is now added by gst_structure_to_string */
1827 g_string_append_c (s, ' ');
1830 structure = gst_caps_get_structure_unchecked (caps, i);
1831 priv_gst_structure_append_to_gstring (structure, s);
1833 if (s->len && s->str[s->len - 1] == ';') {
1834 /* remove latest ';' */
1835 s->str[--s->len] = '\0';
1837 return g_string_free (s, FALSE);
1841 gst_caps_from_string_inplace (GstCaps * caps, const gchar * string)
1843 GstStructure *structure;
1846 g_return_val_if_fail (string, FALSE);
1847 if (strcmp ("ANY", string) == 0) {
1848 caps->flags = GST_CAPS_FLAGS_ANY;
1851 if (strcmp ("EMPTY", string) == 0) {
1855 structure = gst_structure_from_string (string, &s);
1856 if (structure == NULL) {
1859 gst_caps_append_structure (caps, structure);
1863 while (g_ascii_isspace (*s))
1868 structure = gst_structure_from_string (s, &s);
1869 if (structure == NULL) {
1872 gst_caps_append_structure (caps, structure);
1880 * gst_caps_from_string:
1881 * @string: a string to convert to #GstCaps
1883 * Converts @caps from a string representation.
1885 * Returns: a newly allocated #GstCaps
1888 gst_caps_from_string (const gchar * string)
1892 caps = gst_caps_new_empty ();
1893 if (gst_caps_from_string_inplace (caps, string)) {
1896 gst_caps_unref (caps);
1902 gst_caps_transform_to_string (const GValue * src_value, GValue * dest_value)
1904 g_return_if_fail (G_IS_VALUE (src_value));
1905 g_return_if_fail (G_IS_VALUE (dest_value));
1906 g_return_if_fail (G_VALUE_HOLDS (src_value, GST_TYPE_CAPS));
1907 g_return_if_fail (G_VALUE_HOLDS (dest_value, G_TYPE_STRING)
1908 || G_VALUE_HOLDS (dest_value, G_TYPE_POINTER));
1910 dest_value->data[0].v_pointer =
1911 gst_caps_to_string (src_value->data[0].v_pointer);
1915 gst_caps_copy_conditional (GstCaps * src)
1918 return gst_caps_ref (src);