I've no idea here...
[gtkD.git] / gtkD / srcgstreamer / gstreamer / Caps.d
blob0de3fbbf595c2731728cdc87c9b06f53f9435cd9
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD 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
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gstreamer-GstCaps.html
26 * outPack = gstreamer
27 * outFile = Caps
28 * strct = GstCaps
29 * realStrct=
30 * ctorStrct=
31 * clss = Caps
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gst_caps_
40 * - gst_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * - gst_caps_save_thyself
45 * - gst_caps_load_thyself
46 * - gst_caps_new_any
47 * imports:
48 * - glib.Str
49 * - gstreamer.Structure
50 * structWrap:
51 * - GstCaps* -> Caps
52 * - GstStructure* -> Structure
53 * module aliases:
54 * local aliases:
57 module gstreamer.Caps;
59 version(noAssert)
61 version(Tango)
63 import tango.io.Stdout; // use the tango loging?
67 private import gstreamerc.gstreamertypes;
69 private import gstreamerc.gstreamer;
72 private import glib.Str;
73 private import gstreamer.Structure;
78 /**
79 * Description
80 * Caps (capabilities) are lighweight refcounted objects describing media types.
81 * They are composed of an array of GstStructure.
82 * Caps are exposed on GstPadTemplate to describe all possible types a
83 * given pad can handle. They are also stored in the GstRegistry along with
84 * a description of the GstElement.
85 * Caps are exposed on the element pads using the gst_pad_get_caps() pad
86 * function. This function describes the possible types that the pad can
87 * handle or produce at runtime.
88 * Caps are also attached to buffers to describe to content of the data
89 * pointed to by the buffer with gst_buffer_set_caps(). Caps attached to
90 * a GstBuffer allow for format negotiation upstream and downstream.
91 * A GstCaps can be constructed with the following code fragment:
92 * Example4.Creating caps
93 * GstCaps *caps;
94 * caps = gst_caps_new_simple ("video/x-raw-yuv",
95 * "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
96 * "framerate", GST_TYPE_FRACTION, 25, 1,
97 * "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
98 * "width", G_TYPE_INT, 320,
99 * "height", G_TYPE_INT, 240,
100 * NULL);
101 * A GstCaps is fixed when it has no properties with ranges or lists. Use
102 * gst_caps_is_fixed() to test for fixed caps. Only fixed caps can be
103 * set on a GstPad or GstBuffer.
104 * Various methods exist to work with the media types such as subtracting
105 * or intersecting.
106 * Last reviewed on 2007-02-13 (0.10.10)
108 public class Caps
111 /** the main Gtk struct */
112 protected GstCaps* gstCaps;
115 public GstCaps* getCapsStruct()
117 return gstCaps;
121 /** the main Gtk struct as a void* */
122 protected void* getStruct()
124 return cast(void*)gstCaps;
128 * Sets our main struct and passes it to the parent class
130 public this (GstCaps* gstCaps)
132 /*Stdout("Here we are, at the Caps this().").newline;
133 version(noAssert)
135 Stdout("Yup. This is the noAssert version.").newline;
136 if ( gstCaps is null )
138 int zero = 0;
139 version(Tango)
141 Stdout("struct gstCaps is null on constructor").newline;
143 else
145 printf("struct gstCaps is null on constructor");
147 Stdout("Let's divide by zero. It'll be fun. The program will crash! Great feedback.").newline;
148 zero = zero / zero;
151 else
153 Stdout("Hey, this wasn't supposed to get called!!!!!!!!!!!!!!").newline;
155 assert(gstCaps !is null, "struct gstCaps is null on constructor");
157 this.gstCaps = gstCaps;
161 * Creates a new GstCaps that indicates that it is compatible with
162 * any media format.
163 * Returns:
164 * the new GstCaps
166 public static Caps newAny()
168 // GstCaps* gst_caps_new_any (void);
169 return new Caps(cast(GstCaps*)gst_caps_new_any() );
188 * Creates a new GstCaps that is empty. That is, the returned
189 * GstCaps contains no media formats.
190 * Caller is responsible for unreffing the returned caps.
191 * Returns:
192 * the new GstCaps
194 public this ()
196 // GstCaps* gst_caps_new_empty (void);
197 this(cast(GstCaps*)gst_caps_new_empty() );
202 * Creates a new GstCaps that contains one GstStructure. The
203 * structure is defined by the arguments, which have the same format
204 * as gst_structure_new().
205 * Caller is responsible for unreffing the returned caps.
206 * media_type:
207 * the media type of the structure
208 * fieldname:
209 * first field to set
210 * ...:
211 * additional arguments
212 * Returns:
213 * the new GstCaps
215 public this (char[] mediaType, char[] fieldname, ... )
217 // GstCaps* gst_caps_new_simple (const char *media_type, const char *fieldname, ...);
218 this(cast(GstCaps*)gst_caps_new_simple(Str.toStringz(mediaType), Str.toStringz(fieldname)) );
222 * Creates a new GstCaps and adds all the structures listed as
223 * arguments. The list must be NULL-terminated. The structures
224 * are not copied; the returned GstCaps owns the structures.
225 * struct1:
226 * the first structure to add
227 * ...:
228 * additional structures to add
229 * Returns:
230 * the new GstCaps
232 public this (Structure struct1, ... )
234 // GstCaps* gst_caps_new_full (GstStructure *struct1, ...);
235 this(cast(GstCaps*)gst_caps_new_full((struct1 is null) ? null : struct1.getStructureStruct()) );
239 * Creates a new GstCaps and adds all the structures listed as
240 * arguments. The list must be NULL-terminated. The structures
241 * are not copied; the returned GstCaps owns the structures.
242 * structure:
243 * the first structure to add
244 * var_args:
245 * additional structures to add
246 * Returns:
247 * the new GstCaps
249 public this (Structure structure, void* varArgs)
251 // GstCaps* gst_caps_new_full_valist (GstStructure *structure, va_list var_args);
252 this(cast(GstCaps*)gst_caps_new_full_valist((structure is null) ? null : structure.getStructureStruct(), varArgs) );
256 * Creates a new GstCaps as a copy of the old caps. The new caps will have a
257 * refcount of 1, owned by the caller. The structures are copied as well.
258 * Note that this function is the semantic equivalent of a gst_caps_ref()
259 * followed by a gst_caps_make_writable(). If you only want to hold on to a
260 * reference to the data, you should use gst_caps_ref().
261 * When you are finished with the caps, call gst_caps_unref() on it.
262 * caps:
263 * the GstCaps to copy
264 * Returns:
265 * the new GstCaps
267 public Caps copy()
269 // GstCaps* gst_caps_copy (const GstCaps *caps);
270 return new Caps( gst_caps_copy(gstCaps) );
274 * Creates a new GstCaps and appends a copy of the nth structure
275 * contained in caps.
276 * caps:
277 * the GstCaps to copy
278 * nth:
279 * the nth structure to copy
280 * Returns:
281 * the new GstCaps
283 public Caps copyNth(uint nth)
285 // GstCaps* gst_caps_copy_nth (const GstCaps *caps, guint nth);
286 return new Caps( gst_caps_copy_nth(gstCaps, nth) );
290 * Converts a GstStaticCaps to a GstCaps.
291 * static_caps:
292 * the GstStaticCaps to convert
293 * Returns:
294 * A pointer to the GstCaps. Unref after usage. Since the
295 * core holds an additional ref to the returned caps,
296 * use gst_caps_make_writable() on the returned caps to modify it.
298 public static Caps staticCapsGet(GstStaticCaps* staticCaps)
300 // GstCaps* gst_static_caps_get (GstStaticCaps *static_caps);
301 return new Caps( gst_static_caps_get(staticCaps) );
305 * Appends the structures contained in caps2 to caps1. The structures in
306 * caps2 are not copied -- they are transferred to caps1, and then caps2 is
307 * freed. If either caps is ANY, the resulting caps will be ANY.
308 * caps1:
309 * the GstCaps that will be appended to
310 * caps2:
311 * the GstCaps to append
313 public void append(Caps caps2)
315 // void gst_caps_append (GstCaps *caps1, GstCaps *caps2);
316 gst_caps_append(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct());
320 * Appends the structures contained in caps2 to caps1 if they are not yet
321 * expressed by caps1. The structures in caps2 are not copied -- they are
322 * transferred to caps1, and then caps2 is freed.
323 * If either caps is ANY, the resulting caps will be ANY.
324 * caps1:
325 * the GstCaps that will take the new entries
326 * caps2:
327 * the GstCaps to merge in
328 * Since 0.10.10
330 public void merge(Caps caps2)
332 // void gst_caps_merge (GstCaps *caps1, GstCaps *caps2);
333 gst_caps_merge(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct());
337 * Appends structure to caps. The structure is not copied; caps
338 * becomes the owner of structure.
339 * caps:
340 * the GstCaps that will be appended to
341 * structure:
342 * the GstStructure to append
344 public void appendStructure(Structure structure)
346 // void gst_caps_append_structure (GstCaps *caps, GstStructure *structure);
347 gst_caps_append_structure(gstCaps, (structure is null) ? null : structure.getStructureStruct());
351 * removes the stucture with the given index from the list of structures
352 * contained in caps.
353 * caps:
354 * the GstCaps to remove from
355 * idx:
356 * Index of the structure to remove
358 public void removeStructure(uint idx)
360 // void gst_caps_remove_structure (GstCaps *caps, guint idx);
361 gst_caps_remove_structure(gstCaps, idx);
365 * Appends structure to caps if its not already expressed by caps. The
366 * structure is not copied; caps becomes the owner of structure.
367 * caps:
368 * the GstCaps that will the the new structure
369 * structure:
370 * the GstStructure to merge
372 public void mergeStructure(Structure structure)
374 // void gst_caps_merge_structure (GstCaps *caps, GstStructure *structure);
375 gst_caps_merge_structure(gstCaps, (structure is null) ? null : structure.getStructureStruct());
379 * Gets the number of structures contained in caps.
380 * caps:
381 * a GstCaps
382 * Returns:
383 * the number of structures that caps contains
385 public uint getSize()
387 // guint gst_caps_get_size (const GstCaps *caps);
388 return gst_caps_get_size(gstCaps);
392 * Finds the structure in caps that has the index index, and
393 * returns it.
394 * WARNING: This function takes a const GstCaps *, but returns a
395 * non-const GstStructure *. This is for programming convenience --
396 * the caller should be aware that structures inside a constant
397 * GstCaps should not be modified.
398 * caps:
399 * a GstCaps
400 * index:
401 * the index of the structure
402 * Returns:
403 * a pointer to the GstStructure corresponding to index
405 public Structure getStructure(uint index)
407 // GstStructure* gst_caps_get_structure (const GstCaps *caps, guint index);
408 return new Structure( gst_caps_get_structure(gstCaps, index) );
412 * Sets fields in a simple GstCaps. A simple GstCaps is one that
413 * only has one structure. The arguments must be passed in the same
414 * manner as gst_structure_set(), and be NULL-terminated.
415 * caps:
416 * the GstCaps to set
417 * field:
418 * first field to set
419 * ...:
420 * additional parameters
422 public void setSimple(char[] field, ... )
424 // void gst_caps_set_simple (GstCaps *caps, char *field, ...);
425 gst_caps_set_simple(gstCaps, Str.toStringz(field));
429 * Sets fields in a simple GstCaps. A simple GstCaps is one that
430 * only has one structure. The arguments must be passed in the same
431 * manner as gst_structure_set(), and be NULL-terminated.
432 * caps:
433 * the GstCaps to copy
434 * field:
435 * first field to set
436 * varargs:
437 * additional parameters
439 public void setSimpleValist(char[] field, void* varargs)
441 // void gst_caps_set_simple_valist (GstCaps *caps, char *field, va_list varargs);
442 gst_caps_set_simple_valist(gstCaps, Str.toStringz(field), varargs);
446 * Determines if caps represents any media format.
447 * caps:
448 * the GstCaps to test
449 * Returns:
450 * TRUE if caps represents any format.
452 public int isAny()
454 // gboolean gst_caps_is_any (const GstCaps *caps);
455 return gst_caps_is_any(gstCaps);
459 * Determines if caps represents no media formats.
460 * caps:
461 * the GstCaps to test
462 * Returns:
463 * TRUE if caps represents no formats.
465 public int isEmpty()
467 // gboolean gst_caps_is_empty (const GstCaps *caps);
468 return gst_caps_is_empty(gstCaps);
472 * Fixed GstCaps describe exactly one format, that is, they have exactly
473 * one structure, and each field in the structure describes a fixed type.
474 * Examples of non-fixed types are GST_TYPE_INT_RANGE and GST_TYPE_LIST.
475 * caps:
476 * the GstCaps to test
477 * Returns:
478 * TRUE if caps is fixed
480 public int isFixed()
482 // gboolean gst_caps_is_fixed (const GstCaps *caps);
483 return gst_caps_is_fixed(gstCaps);
487 * Checks if the given caps represent the same set of caps.
488 * Note
489 * This function does not work reliably if optional properties for caps
490 * are included on one caps and omitted on the other.
491 * This function deals correctly with passing NULL for any of the caps.
492 * caps1:
493 * a GstCaps
494 * caps2:
495 * another GstCaps
496 * Returns:
497 * TRUE if both caps are equal.
499 public int isEqual(Caps caps2)
501 // gboolean gst_caps_is_equal (const GstCaps *caps1, const GstCaps *caps2);
502 return gst_caps_is_equal(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct());
506 * Tests if two GstCaps are equal. This function only works on fixed
507 * GstCaps.
508 * caps1:
509 * the GstCaps to test
510 * caps2:
511 * the GstCaps to test
512 * Returns:
513 * TRUE if the arguments represent the same format
515 public int isEqualFixed(Caps caps2)
517 // gboolean gst_caps_is_equal_fixed (const GstCaps *caps1, const GstCaps *caps2);
518 return gst_caps_is_equal_fixed(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct());
522 * A given GstCaps structure is always compatible with another if
523 * every media format that is in the first is also contained in the
524 * second. That is, caps1 is a subset of caps2.
525 * caps1:
526 * the GstCaps to test
527 * caps2:
528 * the GstCaps to test
529 * Returns:
530 * TRUE if caps1 is a subset of caps2.
532 public int isAlwaysCompatible(Caps caps2)
534 // gboolean gst_caps_is_always_compatible (const GstCaps *caps1, const GstCaps *caps2);
535 return gst_caps_is_always_compatible(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct());
539 * Checks if all caps represented by subset are also represented by superset.
540 * Note
541 * This function does not work reliably if optional properties for caps
542 * are included on one caps and omitted on the other.
543 * subset:
544 * a GstCaps
545 * superset:
546 * a potentially greater GstCaps
547 * Returns:
548 * TRUE if subset is a subset of superset
550 public int isSubset(Caps superset)
552 // gboolean gst_caps_is_subset (const GstCaps *subset, const GstCaps *superset);
553 return gst_caps_is_subset(gstCaps, (superset is null) ? null : superset.getCapsStruct());
557 * Creates a new GstCaps that contains all the formats that are common
558 * to both caps1 and caps2.
559 * caps1:
560 * a GstCaps to intersect
561 * caps2:
562 * a GstCaps to intersect
563 * Returns:
564 * the new GstCaps
566 public Caps intersect(Caps caps2)
568 // GstCaps* gst_caps_intersect (const GstCaps *caps1, const GstCaps *caps2);
569 return new Caps( gst_caps_intersect(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) );
573 * Creates a new GstCaps that contains all the formats that are in
574 * either caps1 and caps2.
575 * caps1:
576 * a GstCaps to union
577 * caps2:
578 * a GstCaps to union
579 * Returns:
580 * the new GstCaps
582 public Caps unio(Caps caps2)
584 // GstCaps* gst_caps_union (const GstCaps *caps1, const GstCaps *caps2);
585 return new Caps( gst_caps_union(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) );
589 * Creates a new GstCaps that represents the same set of formats as
590 * caps, but contains no lists. Each list is expanded into separate
591 * GstStructures.
592 * caps:
593 * a GstCaps to normalize
594 * Returns:
595 * the new GstCaps
597 public Caps normalize()
599 // GstCaps* gst_caps_normalize (const GstCaps *caps);
600 return new Caps( gst_caps_normalize(gstCaps) );
604 * Modifies the given caps inplace into a representation that represents the
605 * same set of formats, but in a simpler form. Component structures that are
606 * identical are merged. Component structures that have values that can be
607 * merged are also merged.
608 * caps:
609 * a GstCaps to simplify
610 * Returns:
611 * TRUE, if the caps could be simplified
613 public int doSimplify()
615 // gboolean gst_caps_do_simplify (GstCaps *caps);
616 return gst_caps_do_simplify(gstCaps);
622 * Replaces *caps with newcaps. Unrefs the GstCaps in the location
623 * pointed to by caps, if applicable, then modifies caps to point to
624 * newcaps. An additional ref on newcaps is taken.
625 * This function does not take any locks so you might want to lock
626 * the object owning caps pointer.
627 * caps:
628 * a pointer to GstCaps
629 * newcaps:
630 * a GstCaps to replace *caps
632 public static void replace(GstCaps** caps, Caps newcaps)
634 // void gst_caps_replace (GstCaps **caps, GstCaps *newcaps);
635 gst_caps_replace(caps, (newcaps is null) ? null : newcaps.getCapsStruct());
639 * Converts caps to a string representation. This string representation
640 * can be converted back to a GstCaps by gst_caps_from_string().
641 * For debugging purposes its easier to do something like this:
642 * GST_LOG ("caps are %" GST_PTR_FORMAT, caps);
643 * This prints the caps in human readble form.
644 * caps:
645 * a GstCaps
646 * Returns:
647 * a newly allocated string representing caps.
649 public char[] toString()
651 // gchar* gst_caps_to_string (const GstCaps *caps);
652 return Str.toString(gst_caps_to_string(gstCaps) );
656 * Converts caps from a string representation.
657 * string:
658 * a string to convert to GstCaps
659 * Returns:
660 * a newly allocated GstCaps
662 public static Caps fromString(char[] string)
664 // GstCaps* gst_caps_from_string (const gchar *string);
665 return new Caps( gst_caps_from_string(Str.toStringz(string)) );
669 * Subtracts the subtrahend from the minuend.
670 * Note
671 * This function does not work reliably if optional properties for caps
672 * are included on one caps and omitted on the other.
673 * minuend:
674 * GstCaps to substract from
675 * subtrahend:
676 * GstCaps to substract
677 * Returns:
678 * the resulting caps
680 public Caps subtract(Caps subtrahend)
682 // GstCaps* gst_caps_subtract (const GstCaps *minuend, const GstCaps *subtrahend);
683 return new Caps( gst_caps_subtract(gstCaps, (subtrahend is null) ? null : subtrahend.getCapsStruct()) );
687 * Returns a writable copy of caps.
688 * If there is only one reference count on caps, the caller must be the owner,
689 * and so this function will return the caps object unchanged. If on the other
690 * hand there is more than one reference on the object, a new caps object will
691 * be returned. The caller's reference on caps will be removed, and instead the
692 * caller will own a reference to the returned object.
693 * In short, this function unrefs the caps in the argument and refs the caps
694 * that it returns. Don't access the argument after calling this function. See
695 * also: gst_caps_ref().
696 * caps:
697 * the GstCaps to make writable
698 * Returns:
699 * the same GstCaps object.
701 public Caps makeWritable()
703 // GstCaps* gst_caps_make_writable (GstCaps *caps);
704 return new Caps( gst_caps_make_writable(gstCaps) );
708 * Add a reference to a GstCaps object.
709 * From this point on, until the caller calls gst_caps_unref() or
710 * gst_caps_make_writable(), it is guaranteed that the caps object will not
711 * change. This means its structures won't change, etc. To use a GstCaps
712 * object, you must always have a refcount on it -- either the one made
713 * implicitly by gst_caps_new(), or via taking one explicitly with this
714 * function.
715 * caps:
716 * the GstCaps to reference
717 * Returns:
718 * the same GstCaps object.
720 public Caps doref()
722 // GstCaps* gst_caps_ref (GstCaps *caps);
723 return new Caps( gst_caps_ref(gstCaps) );
727 * Destructively discard all but the first structure from caps. Useful when
728 * fixating. caps must be writable.
729 * caps:
730 * the GstCaps to truncate
732 public void truncate()
734 // void gst_caps_truncate (GstCaps *caps);
735 gst_caps_truncate(gstCaps);
739 * Unref a GstCaps and and free all its structures and the
740 * structures' values when the refcount reaches 0.
741 * caps:
742 * the GstCaps to unref
743 * See Also
744 * GstStructure
746 public void unref()
748 // void gst_caps_unref (GstCaps *caps);
749 gst_caps_unref(gstCaps);