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