1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD 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
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gstreamer.Caps;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gobject.Value;
31 private import gstreamer.CapsFeatures;
32 private import gstreamer.Structure;
33 private import gstreamer.c.functions;
34 public  import gstreamer.c.types;
35 public  import gstreamerc.gstreamertypes;
36 
37 
38 /**
39  * Caps (capabilities) are lightweight refcounted objects describing media types.
40  * They are composed of an array of #GstStructure.
41  * 
42  * Caps are exposed on #GstPadTemplate to describe all possible types a
43  * given pad can handle. They are also stored in the #GstRegistry along with
44  * a description of the #GstElement.
45  * 
46  * Caps are exposed on the element pads using the gst_pad_query_caps() pad
47  * function. This function describes the possible types that the pad can
48  * handle or produce at runtime.
49  * 
50  * A #GstCaps can be constructed with the following code fragment:
51  * |[<!-- language="C" -->
52  * GstCaps *caps = gst_caps_new_simple ("video/x-raw",
53  * "format", G_TYPE_STRING, "I420",
54  * "framerate", GST_TYPE_FRACTION, 25, 1,
55  * "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
56  * "width", G_TYPE_INT, 320,
57  * "height", G_TYPE_INT, 240,
58  * NULL);
59  * ]|
60  * 
61  * A #GstCaps is fixed when it has no properties with ranges or lists. Use
62  * gst_caps_is_fixed() to test for fixed caps. Fixed caps can be used in a
63  * caps event to notify downstream elements of the current media type.
64  * 
65  * Various methods exist to work with the media types such as subtracting
66  * or intersecting.
67  * 
68  * Be aware that the current #GstCaps / #GstStructure serialization into string
69  * has limited support for nested #GstCaps / #GstStructure fields. It can only
70  * support one level of nesting. Using more levels will lead to unexpected
71  * behavior when using serialization features, such as gst_caps_to_string() or
72  * gst_value_serialize() and their counterparts.
73  */
74 public class Caps
75 {
76 	/** the main Gtk struct */
77 	protected GstCaps* gstCaps;
78 	protected bool ownedRef;
79 
80 	/** Get the main Gtk struct */
81 	public GstCaps* getCapsStruct(bool transferOwnership = false)
82 	{
83 		if (transferOwnership)
84 			ownedRef = false;
85 		return gstCaps;
86 	}
87 
88 	/** the main Gtk struct as a void* */
89 	protected void* getStruct()
90 	{
91 		return cast(void*)gstCaps;
92 	}
93 
94 	/**
95 	 * Sets our main struct and passes it to the parent class.
96 	 */
97 	public this (GstCaps* gstCaps, bool ownedRef = false)
98 	{
99 		this.gstCaps = gstCaps;
100 		this.ownedRef = ownedRef;
101 	}
102 
103 	/**
104 	 * Creates a new GstCaps that indicates that it is compatible with
105 	 * any media format.
106 	 * Returns:
107 	 *  the new GstCaps
108 	 */
109 	public static Caps newAny()
110 	{
111 		// GstCaps* gst_caps_new_any (void);
112 		auto p = cast(GstCaps*)gst_caps_new_any();
113 
114 		if(p is null)
115 		{
116 			throw new ConstructionException("null returned by gst_caps_new_any");
117 		}
118 
119 		return new Caps(cast(GstCaps*)p); //, true);
120 	}
121 
122 	/**
123 	 */
124 
125 	/** */
126 	public static GType getType()
127 	{
128 		return gst_caps_get_type();
129 	}
130 
131 	/**
132 	 * Creates a new #GstCaps that is empty.  That is, the returned
133 	 * #GstCaps contains no media formats.
134 	 * The #GstCaps is guaranteed to be writable.
135 	 * Caller is responsible for unreffing the returned caps.
136 	 *
137 	 * Returns: the new #GstCaps
138 	 *
139 	 * Throws: ConstructionException GTK+ fails to create the object.
140 	 */
141 	public this()
142 	{
143 		auto p = gst_caps_new_empty();
144 
145 		if(p is null)
146 		{
147 			throw new ConstructionException("null returned by new_empty");
148 		}
149 
150 		this(cast(GstCaps*) p);
151 	}
152 
153 	/**
154 	 * Creates a new #GstCaps that contains one #GstStructure with name
155 	 * @media_type.
156 	 * Caller is responsible for unreffing the returned caps.
157 	 *
158 	 * Params:
159 	 *     mediaType = the media type of the structure
160 	 *
161 	 * Returns: the new #GstCaps
162 	 *
163 	 * Throws: ConstructionException GTK+ fails to create the object.
164 	 */
165 	public this(string mediaType)
166 	{
167 		auto p = gst_caps_new_empty_simple(Str.toStringz(mediaType));
168 
169 		if(p is null)
170 		{
171 			throw new ConstructionException("null returned by new_empty_simple");
172 		}
173 
174 		this(cast(GstCaps*) p);
175 	}
176 
177 	/**
178 	 * Creates a new #GstCaps and adds all the structures listed as
179 	 * arguments.  The list must be %NULL-terminated.  The structures
180 	 * are not copied; the returned #GstCaps owns the structures.
181 	 *
182 	 * Params:
183 	 *     structure = the first structure to add
184 	 *     varArgs = additional structures to add
185 	 *
186 	 * Returns: the new #GstCaps
187 	 *
188 	 * Throws: ConstructionException GTK+ fails to create the object.
189 	 */
190 	public this(Structure structure, void* varArgs)
191 	{
192 		auto p = gst_caps_new_full_valist((structure is null) ? null : structure.getStructureStruct(), varArgs);
193 
194 		if(p is null)
195 		{
196 			throw new ConstructionException("null returned by new_full_valist");
197 		}
198 
199 		this(cast(GstCaps*) p);
200 	}
201 
202 	/**
203 	 * Appends the structures contained in @caps2 to @caps1. The structures in
204 	 * @caps2 are not copied -- they are transferred to @caps1, and then @caps2 is
205 	 * freed. If either caps is ANY, the resulting caps will be ANY.
206 	 *
207 	 * Params:
208 	 *     caps2 = the #GstCaps to append
209 	 */
210 	public void append(Caps caps2)
211 	{
212 		gst_caps_append(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct());
213 	}
214 
215 	/**
216 	 * Appends @structure to @caps.  The structure is not copied; @caps
217 	 * becomes the owner of @structure.
218 	 *
219 	 * Params:
220 	 *     structure = the #GstStructure to append
221 	 */
222 	public void appendStructure(Structure structure)
223 	{
224 		gst_caps_append_structure(gstCaps, (structure is null) ? null : structure.getStructureStruct(true));
225 	}
226 
227 	/**
228 	 * Appends @structure with @features to @caps.  The structure is not copied; @caps
229 	 * becomes the owner of @structure.
230 	 *
231 	 * Params:
232 	 *     structure = the #GstStructure to append
233 	 *     features = the #GstCapsFeatures to append
234 	 *
235 	 * Since: 1.2
236 	 */
237 	public void appendStructureFull(Structure structure, CapsFeatures features)
238 	{
239 		gst_caps_append_structure_full(gstCaps, (structure is null) ? null : structure.getStructureStruct(true), (features is null) ? null : features.getCapsFeaturesStruct(true));
240 	}
241 
242 	/**
243 	 * Tries intersecting @caps1 and @caps2 and reports whether the result would not
244 	 * be empty
245 	 *
246 	 * Params:
247 	 *     caps2 = a #GstCaps to intersect
248 	 *
249 	 * Returns: %TRUE if intersection would be not empty
250 	 */
251 	public bool canIntersect(Caps caps2)
252 	{
253 		return gst_caps_can_intersect(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) != 0;
254 	}
255 
256 	/**
257 	 * Creates a new #GstCaps and appends a copy of the nth structure
258 	 * contained in @caps.
259 	 *
260 	 * Params:
261 	 *     nth = the nth structure to copy
262 	 *
263 	 * Returns: the new #GstCaps
264 	 */
265 	public Caps copyNth(uint nth)
266 	{
267 		auto p = gst_caps_copy_nth(gstCaps, nth);
268 
269 		if(p is null)
270 		{
271 			return null;
272 		}
273 
274 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
275 	}
276 
277 	/**
278 	 * Calls the provided function once for each structure and caps feature in the
279 	 * #GstCaps. In contrast to gst_caps_foreach(), the function may modify the
280 	 * structure and features. In contrast to gst_caps_filter_and_map_in_place(),
281 	 * the structure and features are removed from the caps if %FALSE is returned
282 	 * from the function.
283 	 * The caps must be mutable.
284 	 *
285 	 * Params:
286 	 *     func = a function to call for each field
287 	 *     userData = private data
288 	 *
289 	 * Since: 1.6
290 	 */
291 	public void filterAndMapInPlace(GstCapsFilterMapFunc func, void* userData)
292 	{
293 		gst_caps_filter_and_map_in_place(gstCaps, func, userData);
294 	}
295 
296 	/**
297 	 * Modifies the given @caps into a representation with only fixed
298 	 * values. First the caps will be truncated and then the first structure will be
299 	 * fixated with gst_structure_fixate().
300 	 *
301 	 * This function takes ownership of @caps and will call gst_caps_make_writable()
302 	 * on it so you must not use @caps afterwards unless you keep an additional
303 	 * reference to it with gst_caps_ref().
304 	 *
305 	 * Returns: the fixated caps
306 	 */
307 	public Caps fixate()
308 	{
309 		auto p = gst_caps_fixate(gstCaps);
310 
311 		if(p is null)
312 		{
313 			return null;
314 		}
315 
316 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
317 	}
318 
319 	alias foreac = foreach_;
320 	/**
321 	 * Calls the provided function once for each structure and caps feature in the
322 	 * #GstCaps. The function must not modify the fields.
323 	 * Also see gst_caps_map_in_place() and gst_caps_filter_and_map_in_place().
324 	 *
325 	 * Params:
326 	 *     func = a function to call for each field
327 	 *     userData = private data
328 	 *
329 	 * Returns: %TRUE if the supplied function returns %TRUE for each call,
330 	 *     %FALSE otherwise.
331 	 *
332 	 * Since: 1.6
333 	 */
334 	public bool foreach_(GstCapsForeachFunc func, void* userData)
335 	{
336 		return gst_caps_foreach(gstCaps, func, userData) != 0;
337 	}
338 
339 	/**
340 	 * Finds the features in @caps that has the index @index, and
341 	 * returns it.
342 	 *
343 	 * WARNING: This function takes a const GstCaps *, but returns a
344 	 * non-const GstCapsFeatures *.  This is for programming convenience --
345 	 * the caller should be aware that structures inside a constant
346 	 * #GstCaps should not be modified. However, if you know the caps
347 	 * are writable, either because you have just copied them or made
348 	 * them writable with gst_caps_make_writable(), you may modify the
349 	 * features returned in the usual way, e.g. with functions like
350 	 * gst_caps_features_add().
351 	 *
352 	 * You do not need to free or unref the structure returned, it
353 	 * belongs to the #GstCaps.
354 	 *
355 	 * Params:
356 	 *     index = the index of the structure
357 	 *
358 	 * Returns: a pointer to the #GstCapsFeatures
359 	 *     corresponding to @index
360 	 *
361 	 * Since: 1.2
362 	 */
363 	public CapsFeatures getFeatures(uint index)
364 	{
365 		auto p = gst_caps_get_features(gstCaps, index);
366 
367 		if(p is null)
368 		{
369 			return null;
370 		}
371 
372 		return ObjectG.getDObject!(CapsFeatures)(cast(GstCapsFeatures*) p);
373 	}
374 
375 	/**
376 	 * Gets the number of structures contained in @caps.
377 	 *
378 	 * Returns: the number of structures that @caps contains
379 	 */
380 	public uint getSize()
381 	{
382 		return gst_caps_get_size(gstCaps);
383 	}
384 
385 	/**
386 	 * Finds the structure in @caps that has the index @index, and
387 	 * returns it.
388 	 *
389 	 * WARNING: This function takes a const GstCaps *, but returns a
390 	 * non-const GstStructure *.  This is for programming convenience --
391 	 * the caller should be aware that structures inside a constant
392 	 * #GstCaps should not be modified. However, if you know the caps
393 	 * are writable, either because you have just copied them or made
394 	 * them writable with gst_caps_make_writable(), you may modify the
395 	 * structure returned in the usual way, e.g. with functions like
396 	 * gst_structure_set().
397 	 *
398 	 * You do not need to free or unref the structure returned, it
399 	 * belongs to the #GstCaps.
400 	 *
401 	 * Params:
402 	 *     index = the index of the structure
403 	 *
404 	 * Returns: a pointer to the #GstStructure corresponding
405 	 *     to @index
406 	 */
407 	public Structure getStructure(uint index)
408 	{
409 		auto p = gst_caps_get_structure(gstCaps, index);
410 
411 		if(p is null)
412 		{
413 			return null;
414 		}
415 
416 		return ObjectG.getDObject!(Structure)(cast(GstStructure*) p);
417 	}
418 
419 	/**
420 	 * Creates a new #GstCaps that contains all the formats that are common
421 	 * to both @caps1 and @caps2. Defaults to %GST_CAPS_INTERSECT_ZIG_ZAG mode.
422 	 *
423 	 * Params:
424 	 *     caps2 = a #GstCaps to intersect
425 	 *
426 	 * Returns: the new #GstCaps
427 	 */
428 	public Caps intersect(Caps caps2)
429 	{
430 		auto p = gst_caps_intersect(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct());
431 
432 		if(p is null)
433 		{
434 			return null;
435 		}
436 
437 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
438 	}
439 
440 	/**
441 	 * Creates a new #GstCaps that contains all the formats that are common
442 	 * to both @caps1 and @caps2, the order is defined by the #GstCapsIntersectMode
443 	 * used.
444 	 *
445 	 * Params:
446 	 *     caps2 = a #GstCaps to intersect
447 	 *     mode = The intersection algorithm/mode to use
448 	 *
449 	 * Returns: the new #GstCaps
450 	 */
451 	public Caps intersectFull(Caps caps2, GstCapsIntersectMode mode)
452 	{
453 		auto p = gst_caps_intersect_full(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct(), mode);
454 
455 		if(p is null)
456 		{
457 			return null;
458 		}
459 
460 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
461 	}
462 
463 	/**
464 	 * A given #GstCaps structure is always compatible with another if
465 	 * every media format that is in the first is also contained in the
466 	 * second.  That is, @caps1 is a subset of @caps2.
467 	 *
468 	 * Params:
469 	 *     caps2 = the #GstCaps to test
470 	 *
471 	 * Returns: %TRUE if @caps1 is a subset of @caps2.
472 	 */
473 	public bool isAlwaysCompatible(Caps caps2)
474 	{
475 		return gst_caps_is_always_compatible(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) != 0;
476 	}
477 
478 	/**
479 	 * Determines if @caps represents any media format.
480 	 *
481 	 * Returns: %TRUE if @caps represents any format.
482 	 */
483 	public bool isAny()
484 	{
485 		return gst_caps_is_any(gstCaps) != 0;
486 	}
487 
488 	/**
489 	 * Determines if @caps represents no media formats.
490 	 *
491 	 * Returns: %TRUE if @caps represents no formats.
492 	 */
493 	public bool isEmpty()
494 	{
495 		return gst_caps_is_empty(gstCaps) != 0;
496 	}
497 
498 	/**
499 	 * Checks if the given caps represent the same set of caps.
500 	 *
501 	 * Params:
502 	 *     caps2 = another #GstCaps
503 	 *
504 	 * Returns: %TRUE if both caps are equal.
505 	 */
506 	public bool isEqual(Caps caps2)
507 	{
508 		return gst_caps_is_equal(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) != 0;
509 	}
510 
511 	/**
512 	 * Tests if two #GstCaps are equal.  This function only works on fixed
513 	 * #GstCaps.
514 	 *
515 	 * Params:
516 	 *     caps2 = the #GstCaps to test
517 	 *
518 	 * Returns: %TRUE if the arguments represent the same format
519 	 */
520 	public bool isEqualFixed(Caps caps2)
521 	{
522 		return gst_caps_is_equal_fixed(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) != 0;
523 	}
524 
525 	/**
526 	 * Fixed #GstCaps describe exactly one format, that is, they have exactly
527 	 * one structure, and each field in the structure describes a fixed type.
528 	 * Examples of non-fixed types are GST_TYPE_INT_RANGE and GST_TYPE_LIST.
529 	 *
530 	 * Returns: %TRUE if @caps is fixed
531 	 */
532 	public bool isFixed()
533 	{
534 		return gst_caps_is_fixed(gstCaps) != 0;
535 	}
536 
537 	/**
538 	 * Checks if the given caps are exactly the same set of caps.
539 	 *
540 	 * Params:
541 	 *     caps2 = another #GstCaps
542 	 *
543 	 * Returns: %TRUE if both caps are strictly equal.
544 	 */
545 	public bool isStrictlyEqual(Caps caps2)
546 	{
547 		return gst_caps_is_strictly_equal(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) != 0;
548 	}
549 
550 	/**
551 	 * Checks if all caps represented by @subset are also represented by @superset.
552 	 *
553 	 * Params:
554 	 *     superset = a potentially greater #GstCaps
555 	 *
556 	 * Returns: %TRUE if @subset is a subset of @superset
557 	 */
558 	public bool isSubset(Caps superset)
559 	{
560 		return gst_caps_is_subset(gstCaps, (superset is null) ? null : superset.getCapsStruct()) != 0;
561 	}
562 
563 	/**
564 	 * Checks if @structure is a subset of @caps. See gst_caps_is_subset()
565 	 * for more information.
566 	 *
567 	 * Params:
568 	 *     structure = a potential #GstStructure subset of @caps
569 	 *
570 	 * Returns: %TRUE if @structure is a subset of @caps
571 	 */
572 	public bool isSubsetStructure(Structure structure)
573 	{
574 		return gst_caps_is_subset_structure(gstCaps, (structure is null) ? null : structure.getStructureStruct()) != 0;
575 	}
576 
577 	/**
578 	 * Checks if @structure is a subset of @caps. See gst_caps_is_subset()
579 	 * for more information.
580 	 *
581 	 * Params:
582 	 *     structure = a potential #GstStructure subset of @caps
583 	 *     features = a #GstCapsFeatures for @structure
584 	 *
585 	 * Returns: %TRUE if @structure is a subset of @caps
586 	 *
587 	 * Since: 1.2
588 	 */
589 	public bool isSubsetStructureFull(Structure structure, CapsFeatures features)
590 	{
591 		return gst_caps_is_subset_structure_full(gstCaps, (structure is null) ? null : structure.getStructureStruct(), (features is null) ? null : features.getCapsFeaturesStruct()) != 0;
592 	}
593 
594 	/**
595 	 * Calls the provided function once for each structure and caps feature in the
596 	 * #GstCaps. In contrast to gst_caps_foreach(), the function may modify but not
597 	 * delete the structures and features. The caps must be mutable.
598 	 *
599 	 * Params:
600 	 *     func = a function to call for each field
601 	 *     userData = private data
602 	 *
603 	 * Returns: %TRUE if the supplied function returns %TRUE for each call,
604 	 *     %FALSE otherwise.
605 	 *
606 	 * Since: 1.6
607 	 */
608 	public bool mapInPlace(GstCapsMapFunc func, void* userData)
609 	{
610 		return gst_caps_map_in_place(gstCaps, func, userData) != 0;
611 	}
612 
613 	/**
614 	 * Appends the structures contained in @caps2 to @caps1 if they are not yet
615 	 * expressed by @caps1. The structures in @caps2 are not copied -- they are
616 	 * transferred to a writable copy of @caps1, and then @caps2 is freed.
617 	 * If either caps is ANY, the resulting caps will be ANY.
618 	 *
619 	 * Params:
620 	 *     caps2 = the #GstCaps to merge in
621 	 *
622 	 * Returns: the merged caps.
623 	 */
624 	public Caps merge(Caps caps2)
625 	{
626 		auto p = gst_caps_merge(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct());
627 
628 		if(p is null)
629 		{
630 			return null;
631 		}
632 
633 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
634 	}
635 
636 	/**
637 	 * Appends @structure to @caps if its not already expressed by @caps.
638 	 *
639 	 * Params:
640 	 *     structure = the #GstStructure to merge
641 	 *
642 	 * Returns: the merged caps.
643 	 */
644 	public Caps mergeStructure(Structure structure)
645 	{
646 		auto p = gst_caps_merge_structure(gstCaps, (structure is null) ? null : structure.getStructureStruct(true));
647 
648 		if(p is null)
649 		{
650 			return null;
651 		}
652 
653 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
654 	}
655 
656 	/**
657 	 * Appends @structure with @features to @caps if its not already expressed by @caps.
658 	 *
659 	 * Params:
660 	 *     structure = the #GstStructure to merge
661 	 *     features = the #GstCapsFeatures to merge
662 	 *
663 	 * Returns: the merged caps.
664 	 *
665 	 * Since: 1.2
666 	 */
667 	public Caps mergeStructureFull(Structure structure, CapsFeatures features)
668 	{
669 		auto p = gst_caps_merge_structure_full(gstCaps, (structure is null) ? null : structure.getStructureStruct(true), (features is null) ? null : features.getCapsFeaturesStruct(true));
670 
671 		if(p is null)
672 		{
673 			return null;
674 		}
675 
676 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
677 	}
678 
679 	/**
680 	 * Returns a #GstCaps that represents the same set of formats as
681 	 * @caps, but contains no lists.  Each list is expanded into separate
682 	 * @GstStructures.
683 	 *
684 	 * This function takes ownership of @caps and will call gst_caps_make_writable()
685 	 * on it so you must not use @caps afterwards unless you keep an additional
686 	 * reference to it with gst_caps_ref().
687 	 *
688 	 * Returns: the normalized #GstCaps
689 	 */
690 	public Caps normalize()
691 	{
692 		auto p = gst_caps_normalize(gstCaps);
693 
694 		if(p is null)
695 		{
696 			return null;
697 		}
698 
699 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
700 	}
701 
702 	/**
703 	 * removes the structure with the given index from the list of structures
704 	 * contained in @caps.
705 	 *
706 	 * Params:
707 	 *     idx = Index of the structure to remove
708 	 */
709 	public void removeStructure(uint idx)
710 	{
711 		gst_caps_remove_structure(gstCaps, idx);
712 	}
713 
714 	/**
715 	 * Sets the #GstCapsFeatures @features for the structure at @index.
716 	 *
717 	 * Params:
718 	 *     index = the index of the structure
719 	 *     features = the #GstCapsFeatures to set
720 	 *
721 	 * Since: 1.2
722 	 */
723 	public void setFeatures(uint index, CapsFeatures features)
724 	{
725 		gst_caps_set_features(gstCaps, index, (features is null) ? null : features.getCapsFeaturesStruct(true));
726 	}
727 
728 	/**
729 	 * Sets fields in a #GstCaps.  The arguments must be passed in the same
730 	 * manner as gst_structure_set(), and be %NULL-terminated.
731 	 *
732 	 * Params:
733 	 *     field = first field to set
734 	 *     varargs = additional parameters
735 	 */
736 	public void setSimpleValist(string field, void* varargs)
737 	{
738 		gst_caps_set_simple_valist(gstCaps, Str.toStringz(field), varargs);
739 	}
740 
741 	/**
742 	 * Sets the given @field on all structures of @caps to the given @value.
743 	 * This is a convenience function for calling gst_structure_set_value() on
744 	 * all structures of @caps.
745 	 *
746 	 * Params:
747 	 *     field = name of the field to set
748 	 *     value = value to set the field to
749 	 */
750 	public void setValue(string field, Value value)
751 	{
752 		gst_caps_set_value(gstCaps, Str.toStringz(field), (value is null) ? null : value.getValueStruct());
753 	}
754 
755 	/**
756 	 * Converts the given @caps into a representation that represents the
757 	 * same set of formats, but in a simpler form.  Component structures that are
758 	 * identical are merged.  Component structures that have values that can be
759 	 * merged are also merged.
760 	 *
761 	 * This function takes ownership of @caps and will call gst_caps_make_writable()
762 	 * on it if necessary, so you must not use @caps afterwards unless you keep an
763 	 * additional reference to it with gst_caps_ref().
764 	 *
765 	 * This method does not preserve the original order of @caps.
766 	 *
767 	 * Returns: The simplified caps.
768 	 */
769 	public Caps simplify()
770 	{
771 		auto p = gst_caps_simplify(gstCaps);
772 
773 		if(p is null)
774 		{
775 			return null;
776 		}
777 
778 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
779 	}
780 
781 	/**
782 	 * Retrieves the structure with the given index from the list of structures
783 	 * contained in @caps. The caller becomes the owner of the returned structure.
784 	 *
785 	 * Params:
786 	 *     index = Index of the structure to retrieve
787 	 *
788 	 * Returns: a pointer to the #GstStructure
789 	 *     corresponding to @index.
790 	 */
791 	public Structure stealStructure(uint index)
792 	{
793 		auto p = gst_caps_steal_structure(gstCaps, index);
794 
795 		if(p is null)
796 		{
797 			return null;
798 		}
799 
800 		return ObjectG.getDObject!(Structure)(cast(GstStructure*) p, true);
801 	}
802 
803 	/**
804 	 * Subtracts the @subtrahend from the @minuend.
805 	 * > This function does not work reliably if optional properties for caps
806 	 * > are included on one caps and omitted on the other.
807 	 *
808 	 * Params:
809 	 *     subtrahend = #GstCaps to subtract
810 	 *
811 	 * Returns: the resulting caps
812 	 */
813 	public Caps subtract(Caps subtrahend)
814 	{
815 		auto p = gst_caps_subtract(gstCaps, (subtrahend is null) ? null : subtrahend.getCapsStruct());
816 
817 		if(p is null)
818 		{
819 			return null;
820 		}
821 
822 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
823 	}
824 
825 	/**
826 	 * Converts @caps to a string representation.  This string representation
827 	 * can be converted back to a #GstCaps by gst_caps_from_string().
828 	 *
829 	 * For debugging purposes its easier to do something like this:
830 	 * |[<!-- language="C" -->
831 	 * GST_LOG ("caps are %" GST_PTR_FORMAT, caps);
832 	 * ]|
833 	 * This prints the caps in human readable form.
834 	 *
835 	 * The current implementation of serialization will lead to unexpected results
836 	 * when there are nested #GstCaps / #GstStructure deeper than one level.
837 	 *
838 	 * Returns: a newly allocated string representing @caps.
839 	 */
840 	public override string toString()
841 	{
842 		auto retStr = gst_caps_to_string(gstCaps);
843 
844 		scope(exit) Str.freeString(retStr);
845 		return Str.toString(retStr);
846 	}
847 
848 	/**
849 	 * Discard all but the first structure from @caps. Useful when
850 	 * fixating.
851 	 *
852 	 * This function takes ownership of @caps and will call gst_caps_make_writable()
853 	 * on it if necessary, so you must not use @caps afterwards unless you keep an
854 	 * additional reference to it with gst_caps_ref().
855 	 *
856 	 * Returns: truncated caps
857 	 */
858 	public Caps truncate()
859 	{
860 		auto p = gst_caps_truncate(gstCaps);
861 
862 		if(p is null)
863 		{
864 			return null;
865 		}
866 
867 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
868 	}
869 
870 	/**
871 	 * Converts @caps from a string representation.
872 	 *
873 	 * The current implementation of serialization will lead to unexpected results
874 	 * when there are nested #GstCaps / #GstStructure deeper than one level.
875 	 *
876 	 * Params:
877 	 *     string_ = a string to convert to #GstCaps
878 	 *
879 	 * Returns: a newly allocated #GstCaps
880 	 */
881 	public static Caps fromString(string string_)
882 	{
883 		auto p = gst_caps_from_string(Str.toStringz(string_));
884 
885 		if(p is null)
886 		{
887 			return null;
888 		}
889 
890 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
891 	}
892 }