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 	/**
320 	 * Calls the provided function once for each structure and caps feature in the
321 	 * #GstCaps. The function must not modify the fields.
322 	 * Also see gst_caps_map_in_place() and gst_caps_filter_and_map_in_place().
323 	 *
324 	 * Params:
325 	 *     func = a function to call for each field
326 	 *     userData = private data
327 	 *
328 	 * Returns: %TRUE if the supplied function returns %TRUE for each call,
329 	 *     %FALSE otherwise.
330 	 *
331 	 * Since: 1.6
332 	 */
333 	public bool foreac(GstCapsForeachFunc func, void* userData)
334 	{
335 		return gst_caps_foreach(gstCaps, func, userData) != 0;
336 	}
337 
338 	/**
339 	 * Finds the features in @caps that has the index @index, and
340 	 * returns it.
341 	 *
342 	 * WARNING: This function takes a const GstCaps *, but returns a
343 	 * non-const GstCapsFeatures *.  This is for programming convenience --
344 	 * the caller should be aware that structures inside a constant
345 	 * #GstCaps should not be modified. However, if you know the caps
346 	 * are writable, either because you have just copied them or made
347 	 * them writable with gst_caps_make_writable(), you may modify the
348 	 * features returned in the usual way, e.g. with functions like
349 	 * gst_caps_features_add().
350 	 *
351 	 * You do not need to free or unref the structure returned, it
352 	 * belongs to the #GstCaps.
353 	 *
354 	 * Params:
355 	 *     index = the index of the structure
356 	 *
357 	 * Returns: a pointer to the #GstCapsFeatures corresponding
358 	 *     to @index
359 	 *
360 	 * Since: 1.2
361 	 */
362 	public CapsFeatures getFeatures(uint index)
363 	{
364 		auto p = gst_caps_get_features(gstCaps, index);
365 
366 		if(p is null)
367 		{
368 			return null;
369 		}
370 
371 		return ObjectG.getDObject!(CapsFeatures)(cast(GstCapsFeatures*) p);
372 	}
373 
374 	/**
375 	 * Gets the number of structures contained in @caps.
376 	 *
377 	 * Returns: the number of structures that @caps contains
378 	 */
379 	public uint getSize()
380 	{
381 		return gst_caps_get_size(gstCaps);
382 	}
383 
384 	/**
385 	 * Finds the structure in @caps that has the index @index, and
386 	 * returns it.
387 	 *
388 	 * WARNING: This function takes a const GstCaps *, but returns a
389 	 * non-const GstStructure *.  This is for programming convenience --
390 	 * the caller should be aware that structures inside a constant
391 	 * #GstCaps should not be modified. However, if you know the caps
392 	 * are writable, either because you have just copied them or made
393 	 * them writable with gst_caps_make_writable(), you may modify the
394 	 * structure returned in the usual way, e.g. with functions like
395 	 * gst_structure_set().
396 	 *
397 	 * You do not need to free or unref the structure returned, it
398 	 * belongs to the #GstCaps.
399 	 *
400 	 * Params:
401 	 *     index = the index of the structure
402 	 *
403 	 * Returns: a pointer to the #GstStructure corresponding
404 	 *     to @index
405 	 */
406 	public Structure getStructure(uint index)
407 	{
408 		auto p = gst_caps_get_structure(gstCaps, index);
409 
410 		if(p is null)
411 		{
412 			return null;
413 		}
414 
415 		return ObjectG.getDObject!(Structure)(cast(GstStructure*) p);
416 	}
417 
418 	/**
419 	 * Creates a new #GstCaps that contains all the formats that are common
420 	 * to both @caps1 and @caps2. Defaults to %GST_CAPS_INTERSECT_ZIG_ZAG mode.
421 	 *
422 	 * Params:
423 	 *     caps2 = a #GstCaps to intersect
424 	 *
425 	 * Returns: the new #GstCaps
426 	 */
427 	public Caps intersect(Caps caps2)
428 	{
429 		auto p = gst_caps_intersect(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct());
430 
431 		if(p is null)
432 		{
433 			return null;
434 		}
435 
436 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
437 	}
438 
439 	/**
440 	 * Creates a new #GstCaps that contains all the formats that are common
441 	 * to both @caps1 and @caps2, the order is defined by the #GstCapsIntersectMode
442 	 * used.
443 	 *
444 	 * Params:
445 	 *     caps2 = a #GstCaps to intersect
446 	 *     mode = The intersection algorithm/mode to use
447 	 *
448 	 * Returns: the new #GstCaps
449 	 */
450 	public Caps intersectFull(Caps caps2, GstCapsIntersectMode mode)
451 	{
452 		auto p = gst_caps_intersect_full(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct(), mode);
453 
454 		if(p is null)
455 		{
456 			return null;
457 		}
458 
459 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
460 	}
461 
462 	/**
463 	 * A given #GstCaps structure is always compatible with another if
464 	 * every media format that is in the first is also contained in the
465 	 * second.  That is, @caps1 is a subset of @caps2.
466 	 *
467 	 * Params:
468 	 *     caps2 = the #GstCaps to test
469 	 *
470 	 * Returns: %TRUE if @caps1 is a subset of @caps2.
471 	 */
472 	public bool isAlwaysCompatible(Caps caps2)
473 	{
474 		return gst_caps_is_always_compatible(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) != 0;
475 	}
476 
477 	/**
478 	 * Determines if @caps represents any media format.
479 	 *
480 	 * Returns: %TRUE if @caps represents any format.
481 	 */
482 	public bool isAny()
483 	{
484 		return gst_caps_is_any(gstCaps) != 0;
485 	}
486 
487 	/**
488 	 * Determines if @caps represents no media formats.
489 	 *
490 	 * Returns: %TRUE if @caps represents no formats.
491 	 */
492 	public bool isEmpty()
493 	{
494 		return gst_caps_is_empty(gstCaps) != 0;
495 	}
496 
497 	/**
498 	 * Checks if the given caps represent the same set of caps.
499 	 *
500 	 * Params:
501 	 *     caps2 = another #GstCaps
502 	 *
503 	 * Returns: %TRUE if both caps are equal.
504 	 */
505 	public bool isEqual(Caps caps2)
506 	{
507 		return gst_caps_is_equal(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) != 0;
508 	}
509 
510 	/**
511 	 * Tests if two #GstCaps are equal.  This function only works on fixed
512 	 * #GstCaps.
513 	 *
514 	 * Params:
515 	 *     caps2 = the #GstCaps to test
516 	 *
517 	 * Returns: %TRUE if the arguments represent the same format
518 	 */
519 	public bool isEqualFixed(Caps caps2)
520 	{
521 		return gst_caps_is_equal_fixed(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) != 0;
522 	}
523 
524 	/**
525 	 * Fixed #GstCaps describe exactly one format, that is, they have exactly
526 	 * one structure, and each field in the structure describes a fixed type.
527 	 * Examples of non-fixed types are GST_TYPE_INT_RANGE and GST_TYPE_LIST.
528 	 *
529 	 * Returns: %TRUE if @caps is fixed
530 	 */
531 	public bool isFixed()
532 	{
533 		return gst_caps_is_fixed(gstCaps) != 0;
534 	}
535 
536 	/**
537 	 * Checks if the given caps are exactly the same set of caps.
538 	 *
539 	 * Params:
540 	 *     caps2 = another #GstCaps
541 	 *
542 	 * Returns: %TRUE if both caps are strictly equal.
543 	 */
544 	public bool isStrictlyEqual(Caps caps2)
545 	{
546 		return gst_caps_is_strictly_equal(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) != 0;
547 	}
548 
549 	/**
550 	 * Checks if all caps represented by @subset are also represented by @superset.
551 	 *
552 	 * Params:
553 	 *     superset = a potentially greater #GstCaps
554 	 *
555 	 * Returns: %TRUE if @subset is a subset of @superset
556 	 */
557 	public bool isSubset(Caps superset)
558 	{
559 		return gst_caps_is_subset(gstCaps, (superset is null) ? null : superset.getCapsStruct()) != 0;
560 	}
561 
562 	/**
563 	 * Checks if @structure is a subset of @caps. See gst_caps_is_subset()
564 	 * for more information.
565 	 *
566 	 * Params:
567 	 *     structure = a potential #GstStructure subset of @caps
568 	 *
569 	 * Returns: %TRUE if @structure is a subset of @caps
570 	 */
571 	public bool isSubsetStructure(Structure structure)
572 	{
573 		return gst_caps_is_subset_structure(gstCaps, (structure is null) ? null : structure.getStructureStruct()) != 0;
574 	}
575 
576 	/**
577 	 * Checks if @structure is a subset of @caps. See gst_caps_is_subset()
578 	 * for more information.
579 	 *
580 	 * Params:
581 	 *     structure = a potential #GstStructure subset of @caps
582 	 *     features = a #GstCapsFeatures for @structure
583 	 *
584 	 * Returns: %TRUE if @structure is a subset of @caps
585 	 *
586 	 * Since: 1.2
587 	 */
588 	public bool isSubsetStructureFull(Structure structure, CapsFeatures features)
589 	{
590 		return gst_caps_is_subset_structure_full(gstCaps, (structure is null) ? null : structure.getStructureStruct(), (features is null) ? null : features.getCapsFeaturesStruct()) != 0;
591 	}
592 
593 	/**
594 	 * Calls the provided function once for each structure and caps feature in the
595 	 * #GstCaps. In contrast to gst_caps_foreach(), the function may modify but not
596 	 * delete the structures and features. The caps must be mutable.
597 	 *
598 	 * Params:
599 	 *     func = a function to call for each field
600 	 *     userData = private data
601 	 *
602 	 * Returns: %TRUE if the supplied function returns %TRUE for each call,
603 	 *     %FALSE otherwise.
604 	 *
605 	 * Since: 1.6
606 	 */
607 	public bool mapInPlace(GstCapsMapFunc func, void* userData)
608 	{
609 		return gst_caps_map_in_place(gstCaps, func, userData) != 0;
610 	}
611 
612 	/**
613 	 * Appends the structures contained in @caps2 to @caps1 if they are not yet
614 	 * expressed by @caps1. The structures in @caps2 are not copied -- they are
615 	 * transferred to a writable copy of @caps1, and then @caps2 is freed.
616 	 * If either caps is ANY, the resulting caps will be ANY.
617 	 *
618 	 * Params:
619 	 *     caps2 = the #GstCaps to merge in
620 	 *
621 	 * Returns: the merged caps.
622 	 */
623 	public Caps merge(Caps caps2)
624 	{
625 		auto p = gst_caps_merge(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct());
626 
627 		if(p is null)
628 		{
629 			return null;
630 		}
631 
632 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
633 	}
634 
635 	/**
636 	 * Appends @structure to @caps if its not already expressed by @caps.
637 	 *
638 	 * Params:
639 	 *     structure = the #GstStructure to merge
640 	 *
641 	 * Returns: the merged caps.
642 	 */
643 	public Caps mergeStructure(Structure structure)
644 	{
645 		auto p = gst_caps_merge_structure(gstCaps, (structure is null) ? null : structure.getStructureStruct(true));
646 
647 		if(p is null)
648 		{
649 			return null;
650 		}
651 
652 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
653 	}
654 
655 	/**
656 	 * Appends @structure with @features to @caps if its not already expressed by @caps.
657 	 *
658 	 * Params:
659 	 *     structure = the #GstStructure to merge
660 	 *     features = the #GstCapsFeatures to merge
661 	 *
662 	 * Returns: the merged caps.
663 	 *
664 	 * Since: 1.2
665 	 */
666 	public Caps mergeStructureFull(Structure structure, CapsFeatures features)
667 	{
668 		auto p = gst_caps_merge_structure_full(gstCaps, (structure is null) ? null : structure.getStructureStruct(true), (features is null) ? null : features.getCapsFeaturesStruct(true));
669 
670 		if(p is null)
671 		{
672 			return null;
673 		}
674 
675 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
676 	}
677 
678 	/**
679 	 * Returns a #GstCaps that represents the same set of formats as
680 	 * @caps, but contains no lists.  Each list is expanded into separate
681 	 * @GstStructures.
682 	 *
683 	 * This function takes ownership of @caps and will call gst_caps_make_writable()
684 	 * on it so you must not use @caps afterwards unless you keep an additional
685 	 * reference to it with gst_caps_ref().
686 	 *
687 	 * Returns: the normalized #GstCaps
688 	 */
689 	public Caps normalize()
690 	{
691 		auto p = gst_caps_normalize(gstCaps);
692 
693 		if(p is null)
694 		{
695 			return null;
696 		}
697 
698 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
699 	}
700 
701 	/**
702 	 * removes the structure with the given index from the list of structures
703 	 * contained in @caps.
704 	 *
705 	 * Params:
706 	 *     idx = Index of the structure to remove
707 	 */
708 	public void removeStructure(uint idx)
709 	{
710 		gst_caps_remove_structure(gstCaps, idx);
711 	}
712 
713 	/**
714 	 * Sets the #GstCapsFeatures @features for the structure at @index.
715 	 *
716 	 * Params:
717 	 *     index = the index of the structure
718 	 *     features = the #GstCapsFeatures to set
719 	 *
720 	 * Since: 1.2
721 	 */
722 	public void setFeatures(uint index, CapsFeatures features)
723 	{
724 		gst_caps_set_features(gstCaps, index, (features is null) ? null : features.getCapsFeaturesStruct(true));
725 	}
726 
727 	/**
728 	 * Sets fields in a #GstCaps.  The arguments must be passed in the same
729 	 * manner as gst_structure_set(), and be %NULL-terminated.
730 	 *
731 	 * Params:
732 	 *     field = first field to set
733 	 *     varargs = additional parameters
734 	 */
735 	public void setSimpleValist(string field, void* varargs)
736 	{
737 		gst_caps_set_simple_valist(gstCaps, Str.toStringz(field), varargs);
738 	}
739 
740 	/**
741 	 * Sets the given @field on all structures of @caps to the given @value.
742 	 * This is a convenience function for calling gst_structure_set_value() on
743 	 * all structures of @caps.
744 	 *
745 	 * Params:
746 	 *     field = name of the field to set
747 	 *     value = value to set the field to
748 	 */
749 	public void setValue(string field, Value value)
750 	{
751 		gst_caps_set_value(gstCaps, Str.toStringz(field), (value is null) ? null : value.getValueStruct());
752 	}
753 
754 	/**
755 	 * Converts the given @caps into a representation that represents the
756 	 * same set of formats, but in a simpler form.  Component structures that are
757 	 * identical are merged.  Component structures that have values that can be
758 	 * merged are also merged.
759 	 *
760 	 * This function takes ownership of @caps and will call gst_caps_make_writable()
761 	 * on it if necessary, so you must not use @caps afterwards unless you keep an
762 	 * additional reference to it with gst_caps_ref().
763 	 *
764 	 * This method does not preserve the original order of @caps.
765 	 *
766 	 * Returns: The simplified caps.
767 	 */
768 	public Caps simplify()
769 	{
770 		auto p = gst_caps_simplify(gstCaps);
771 
772 		if(p is null)
773 		{
774 			return null;
775 		}
776 
777 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
778 	}
779 
780 	/**
781 	 * Retrieves the structure with the given index from the list of structures
782 	 * contained in @caps. The caller becomes the owner of the returned structure.
783 	 *
784 	 * Params:
785 	 *     index = Index of the structure to retrieve
786 	 *
787 	 * Returns: a pointer to the #GstStructure corresponding
788 	 *     to @index.
789 	 */
790 	public Structure stealStructure(uint index)
791 	{
792 		auto p = gst_caps_steal_structure(gstCaps, index);
793 
794 		if(p is null)
795 		{
796 			return null;
797 		}
798 
799 		return ObjectG.getDObject!(Structure)(cast(GstStructure*) p, true);
800 	}
801 
802 	/**
803 	 * Subtracts the @subtrahend from the @minuend.
804 	 * > This function does not work reliably if optional properties for caps
805 	 * > are included on one caps and omitted on the other.
806 	 *
807 	 * Params:
808 	 *     subtrahend = #GstCaps to subtract
809 	 *
810 	 * Returns: the resulting caps
811 	 */
812 	public Caps subtract(Caps subtrahend)
813 	{
814 		auto p = gst_caps_subtract(gstCaps, (subtrahend is null) ? null : subtrahend.getCapsStruct());
815 
816 		if(p is null)
817 		{
818 			return null;
819 		}
820 
821 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
822 	}
823 
824 	/**
825 	 * Converts @caps to a string representation.  This string representation
826 	 * can be converted back to a #GstCaps by gst_caps_from_string().
827 	 *
828 	 * For debugging purposes its easier to do something like this:
829 	 * |[<!-- language="C" -->
830 	 * GST_LOG ("caps are %" GST_PTR_FORMAT, caps);
831 	 * ]|
832 	 * This prints the caps in human readable form.
833 	 *
834 	 * The current implementation of serialization will lead to unexpected results
835 	 * when there are nested #GstCaps / #GstStructure deeper than one level.
836 	 *
837 	 * Returns: a newly allocated string representing @caps.
838 	 */
839 	public override string toString()
840 	{
841 		auto retStr = gst_caps_to_string(gstCaps);
842 
843 		scope(exit) Str.freeString(retStr);
844 		return Str.toString(retStr);
845 	}
846 
847 	/**
848 	 * Discard all but the first structure from @caps. Useful when
849 	 * fixating.
850 	 *
851 	 * This function takes ownership of @caps and will call gst_caps_make_writable()
852 	 * on it if necessary, so you must not use @caps afterwards unless you keep an
853 	 * additional reference to it with gst_caps_ref().
854 	 *
855 	 * Returns: truncated caps
856 	 */
857 	public Caps truncate()
858 	{
859 		auto p = gst_caps_truncate(gstCaps);
860 
861 		if(p is null)
862 		{
863 			return null;
864 		}
865 
866 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
867 	}
868 
869 	/**
870 	 * Converts @caps from a string representation.
871 	 *
872 	 * The current implementation of serialization will lead to unexpected results
873 	 * when there are nested #GstCaps / #GstStructure deeper than one level.
874 	 *
875 	 * Params:
876 	 *     str = a string to convert to #GstCaps
877 	 *
878 	 * Returns: a newly allocated #GstCaps
879 	 */
880 	public static Caps fromString(string str)
881 	{
882 		auto p = gst_caps_from_string(Str.toStringz(str));
883 
884 		if(p is null)
885 		{
886 			return null;
887 		}
888 
889 		return ObjectG.getDObject!(Caps)(cast(GstCaps*) p, true);
890 	}
891 }