alternative to assert
[gtkD.git] / gtkD / srcgstreamer / gstreamer / Caps.d
blobe96ca0a75084bc771f45e7c06f7509d8a51b41a9
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 private import gstreamerc.gstreamertypes;
61 private import gstreamerc.gstreamer;
63 private import glib.Str;
64 private import gstreamer.Structure;
68 /**
69 * Description
70 * Caps (capabilities) are lighweight refcounted objects describing media types.
71 * They are composed of an array of GstStructure.
72 * Caps are exposed on GstPadTemplate to describe all possible types a
73 * given pad can handle. They are also stored in the GstRegistry along with
74 * a description of the GstElement.
75 * Caps are exposed on the element pads using the gst_pad_get_caps() pad
76 * function. This function describes the possible types that the pad can
77 * handle or produce at runtime.
78 * Caps are also attached to buffers to describe to content of the data
79 * pointed to by the buffer with gst_buffer_set_caps(). Caps attached to
80 * a GstBuffer allow for format negotiation upstream and downstream.
81 * A GstCaps can be constructed with the following code fragment:
82 * Example4.Creating caps
83 * GstCaps *caps;
84 * caps = gst_caps_new_simple ("video/x-raw-yuv",
85 * "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
86 * "framerate", GST_TYPE_FRACTION, 25, 1,
87 * "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
88 * "width", G_TYPE_INT, 320,
89 * "height", G_TYPE_INT, 240,
90 * NULL);
91 * A GstCaps is fixed when it has no properties with ranges or lists. Use
92 * gst_caps_is_fixed() to test for fixed caps. Only fixed caps can be
93 * set on a GstPad or GstBuffer.
94 * Various methods exist to work with the media types such as subtracting
95 * or intersecting.
96 * Last reviewed on 2007-02-13 (0.10.10)
98 public class Caps
101 /** the main Gtk struct */
102 protected GstCaps* gstCaps;
105 public GstCaps* getCapsStruct()
107 return gstCaps;
111 /** the main Gtk struct as a void* */
112 protected void* getStruct()
114 return cast(void*)gstCaps;
118 * Sets our main struct and passes it to the parent class
120 public this (GstCaps* gstCaps)
122 this.gstCaps = gstCaps;
126 * Creates a new GstCaps that indicates that it is compatible with
127 * any media format.
128 * Returns:
129 * the new GstCaps
131 public static Caps newAny()
133 // GstCaps* gst_caps_new_any (void);
134 return new Caps(cast(GstCaps*)gst_caps_new_any() );
153 * Creates a new GstCaps that is empty. That is, the returned
154 * GstCaps contains no media formats.
155 * Caller is responsible for unreffing the returned caps.
156 * Returns:
157 * the new GstCaps
159 public this ()
161 // GstCaps* gst_caps_new_empty (void);
162 this(cast(GstCaps*)gst_caps_new_empty() );
167 * Creates a new GstCaps that contains one GstStructure. The
168 * structure is defined by the arguments, which have the same format
169 * as gst_structure_new().
170 * Caller is responsible for unreffing the returned caps.
171 * media_type:
172 * the media type of the structure
173 * fieldname:
174 * first field to set
175 * ...:
176 * additional arguments
177 * Returns:
178 * the new GstCaps
180 public this (char[] mediaType, char[] fieldname, ... )
182 // GstCaps* gst_caps_new_simple (const char *media_type, const char *fieldname, ...);
183 this(cast(GstCaps*)gst_caps_new_simple(Str.toStringz(mediaType), Str.toStringz(fieldname)) );
187 * Creates a new GstCaps and adds all the structures listed as
188 * arguments. The list must be NULL-terminated. The structures
189 * are not copied; the returned GstCaps owns the structures.
190 * struct1:
191 * the first structure to add
192 * ...:
193 * additional structures to add
194 * Returns:
195 * the new GstCaps
197 public this (Structure struct1, ... )
199 // GstCaps* gst_caps_new_full (GstStructure *struct1, ...);
200 this(cast(GstCaps*)gst_caps_new_full((struct1 is null) ? null : struct1.getStructureStruct()) );
204 * Creates a new GstCaps and adds all the structures listed as
205 * arguments. The list must be NULL-terminated. The structures
206 * are not copied; the returned GstCaps owns the structures.
207 * structure:
208 * the first structure to add
209 * var_args:
210 * additional structures to add
211 * Returns:
212 * the new GstCaps
214 public this (Structure structure, void* varArgs)
216 // GstCaps* gst_caps_new_full_valist (GstStructure *structure, va_list var_args);
217 this(cast(GstCaps*)gst_caps_new_full_valist((structure is null) ? null : structure.getStructureStruct(), varArgs) );
221 * Creates a new GstCaps as a copy of the old caps. The new caps will have a
222 * refcount of 1, owned by the caller. The structures are copied as well.
223 * Note that this function is the semantic equivalent of a gst_caps_ref()
224 * followed by a gst_caps_make_writable(). If you only want to hold on to a
225 * reference to the data, you should use gst_caps_ref().
226 * When you are finished with the caps, call gst_caps_unref() on it.
227 * caps:
228 * the GstCaps to copy
229 * Returns:
230 * the new GstCaps
232 public Caps copy()
234 // GstCaps* gst_caps_copy (const GstCaps *caps);
235 return new Caps( gst_caps_copy(gstCaps) );
239 * Creates a new GstCaps and appends a copy of the nth structure
240 * contained in caps.
241 * caps:
242 * the GstCaps to copy
243 * nth:
244 * the nth structure to copy
245 * Returns:
246 * the new GstCaps
248 public Caps copyNth(uint nth)
250 // GstCaps* gst_caps_copy_nth (const GstCaps *caps, guint nth);
251 return new Caps( gst_caps_copy_nth(gstCaps, nth) );
255 * Converts a GstStaticCaps to a GstCaps.
256 * static_caps:
257 * the GstStaticCaps to convert
258 * Returns:
259 * A pointer to the GstCaps. Unref after usage. Since the
260 * core holds an additional ref to the returned caps,
261 * use gst_caps_make_writable() on the returned caps to modify it.
263 public static Caps staticCapsGet(GstStaticCaps* staticCaps)
265 // GstCaps* gst_static_caps_get (GstStaticCaps *static_caps);
266 return new Caps( gst_static_caps_get(staticCaps) );
270 * Appends the structures contained in caps2 to caps1. The structures in
271 * caps2 are not copied -- they are transferred to caps1, and then caps2 is
272 * freed. If either caps is ANY, the resulting caps will be ANY.
273 * caps1:
274 * the GstCaps that will be appended to
275 * caps2:
276 * the GstCaps to append
278 public void append(Caps caps2)
280 // void gst_caps_append (GstCaps *caps1, GstCaps *caps2);
281 gst_caps_append(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct());
285 * Appends the structures contained in caps2 to caps1 if they are not yet
286 * expressed by caps1. The structures in caps2 are not copied -- they are
287 * transferred to caps1, and then caps2 is freed.
288 * If either caps is ANY, the resulting caps will be ANY.
289 * caps1:
290 * the GstCaps that will take the new entries
291 * caps2:
292 * the GstCaps to merge in
293 * Since 0.10.10
295 public void merge(Caps caps2)
297 // void gst_caps_merge (GstCaps *caps1, GstCaps *caps2);
298 gst_caps_merge(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct());
302 * Appends structure to caps. The structure is not copied; caps
303 * becomes the owner of structure.
304 * caps:
305 * the GstCaps that will be appended to
306 * structure:
307 * the GstStructure to append
309 public void appendStructure(Structure structure)
311 // void gst_caps_append_structure (GstCaps *caps, GstStructure *structure);
312 gst_caps_append_structure(gstCaps, (structure is null) ? null : structure.getStructureStruct());
316 * removes the stucture with the given index from the list of structures
317 * contained in caps.
318 * caps:
319 * the GstCaps to remove from
320 * idx:
321 * Index of the structure to remove
323 public void removeStructure(uint idx)
325 // void gst_caps_remove_structure (GstCaps *caps, guint idx);
326 gst_caps_remove_structure(gstCaps, idx);
330 * Appends structure to caps if its not already expressed by caps. The
331 * structure is not copied; caps becomes the owner of structure.
332 * caps:
333 * the GstCaps that will the the new structure
334 * structure:
335 * the GstStructure to merge
337 public void mergeStructure(Structure structure)
339 // void gst_caps_merge_structure (GstCaps *caps, GstStructure *structure);
340 gst_caps_merge_structure(gstCaps, (structure is null) ? null : structure.getStructureStruct());
344 * Gets the number of structures contained in caps.
345 * caps:
346 * a GstCaps
347 * Returns:
348 * the number of structures that caps contains
350 public uint getSize()
352 // guint gst_caps_get_size (const GstCaps *caps);
353 return gst_caps_get_size(gstCaps);
357 * Finds the structure in caps that has the index index, and
358 * returns it.
359 * WARNING: This function takes a const GstCaps *, but returns a
360 * non-const GstStructure *. This is for programming convenience --
361 * the caller should be aware that structures inside a constant
362 * GstCaps should not be modified.
363 * caps:
364 * a GstCaps
365 * index:
366 * the index of the structure
367 * Returns:
368 * a pointer to the GstStructure corresponding to index
370 public Structure getStructure(uint index)
372 // GstStructure* gst_caps_get_structure (const GstCaps *caps, guint index);
373 return new Structure( gst_caps_get_structure(gstCaps, index) );
377 * Sets fields in a simple GstCaps. A simple GstCaps is one that
378 * only has one structure. The arguments must be passed in the same
379 * manner as gst_structure_set(), and be NULL-terminated.
380 * caps:
381 * the GstCaps to set
382 * field:
383 * first field to set
384 * ...:
385 * additional parameters
387 public void setSimple(char[] field, ... )
389 // void gst_caps_set_simple (GstCaps *caps, char *field, ...);
390 gst_caps_set_simple(gstCaps, Str.toStringz(field));
394 * Sets fields in a simple GstCaps. A simple GstCaps is one that
395 * only has one structure. The arguments must be passed in the same
396 * manner as gst_structure_set(), and be NULL-terminated.
397 * caps:
398 * the GstCaps to copy
399 * field:
400 * first field to set
401 * varargs:
402 * additional parameters
404 public void setSimpleValist(char[] field, void* varargs)
406 // void gst_caps_set_simple_valist (GstCaps *caps, char *field, va_list varargs);
407 gst_caps_set_simple_valist(gstCaps, Str.toStringz(field), varargs);
411 * Determines if caps represents any media format.
412 * caps:
413 * the GstCaps to test
414 * Returns:
415 * TRUE if caps represents any format.
417 public int isAny()
419 // gboolean gst_caps_is_any (const GstCaps *caps);
420 return gst_caps_is_any(gstCaps);
424 * Determines if caps represents no media formats.
425 * caps:
426 * the GstCaps to test
427 * Returns:
428 * TRUE if caps represents no formats.
430 public int isEmpty()
432 // gboolean gst_caps_is_empty (const GstCaps *caps);
433 return gst_caps_is_empty(gstCaps);
437 * Fixed GstCaps describe exactly one format, that is, they have exactly
438 * one structure, and each field in the structure describes a fixed type.
439 * Examples of non-fixed types are GST_TYPE_INT_RANGE and GST_TYPE_LIST.
440 * caps:
441 * the GstCaps to test
442 * Returns:
443 * TRUE if caps is fixed
445 public int isFixed()
447 // gboolean gst_caps_is_fixed (const GstCaps *caps);
448 return gst_caps_is_fixed(gstCaps);
452 * Checks if the given caps represent the same set of caps.
453 * Note
454 * This function does not work reliably if optional properties for caps
455 * are included on one caps and omitted on the other.
456 * This function deals correctly with passing NULL for any of the caps.
457 * caps1:
458 * a GstCaps
459 * caps2:
460 * another GstCaps
461 * Returns:
462 * TRUE if both caps are equal.
464 public int isEqual(Caps caps2)
466 // gboolean gst_caps_is_equal (const GstCaps *caps1, const GstCaps *caps2);
467 return gst_caps_is_equal(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct());
471 * Tests if two GstCaps are equal. This function only works on fixed
472 * GstCaps.
473 * caps1:
474 * the GstCaps to test
475 * caps2:
476 * the GstCaps to test
477 * Returns:
478 * TRUE if the arguments represent the same format
480 public int isEqualFixed(Caps caps2)
482 // gboolean gst_caps_is_equal_fixed (const GstCaps *caps1, const GstCaps *caps2);
483 return gst_caps_is_equal_fixed(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct());
487 * A given GstCaps structure is always compatible with another if
488 * every media format that is in the first is also contained in the
489 * second. That is, caps1 is a subset of caps2.
490 * caps1:
491 * the GstCaps to test
492 * caps2:
493 * the GstCaps to test
494 * Returns:
495 * TRUE if caps1 is a subset of caps2.
497 public int isAlwaysCompatible(Caps caps2)
499 // gboolean gst_caps_is_always_compatible (const GstCaps *caps1, const GstCaps *caps2);
500 return gst_caps_is_always_compatible(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct());
504 * Checks if all caps represented by subset are also represented by superset.
505 * Note
506 * This function does not work reliably if optional properties for caps
507 * are included on one caps and omitted on the other.
508 * subset:
509 * a GstCaps
510 * superset:
511 * a potentially greater GstCaps
512 * Returns:
513 * TRUE if subset is a subset of superset
515 public int isSubset(Caps superset)
517 // gboolean gst_caps_is_subset (const GstCaps *subset, const GstCaps *superset);
518 return gst_caps_is_subset(gstCaps, (superset is null) ? null : superset.getCapsStruct());
522 * Creates a new GstCaps that contains all the formats that are common
523 * to both caps1 and caps2.
524 * caps1:
525 * a GstCaps to intersect
526 * caps2:
527 * a GstCaps to intersect
528 * Returns:
529 * the new GstCaps
531 public Caps intersect(Caps caps2)
533 // GstCaps* gst_caps_intersect (const GstCaps *caps1, const GstCaps *caps2);
534 return new Caps( gst_caps_intersect(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) );
538 * Creates a new GstCaps that contains all the formats that are in
539 * either caps1 and caps2.
540 * caps1:
541 * a GstCaps to union
542 * caps2:
543 * a GstCaps to union
544 * Returns:
545 * the new GstCaps
547 public Caps unio(Caps caps2)
549 // GstCaps* gst_caps_union (const GstCaps *caps1, const GstCaps *caps2);
550 return new Caps( gst_caps_union(gstCaps, (caps2 is null) ? null : caps2.getCapsStruct()) );
554 * Creates a new GstCaps that represents the same set of formats as
555 * caps, but contains no lists. Each list is expanded into separate
556 * GstStructures.
557 * caps:
558 * a GstCaps to normalize
559 * Returns:
560 * the new GstCaps
562 public Caps normalize()
564 // GstCaps* gst_caps_normalize (const GstCaps *caps);
565 return new Caps( gst_caps_normalize(gstCaps) );
569 * Modifies the given caps inplace into a representation that represents the
570 * same set of formats, but in a simpler form. Component structures that are
571 * identical are merged. Component structures that have values that can be
572 * merged are also merged.
573 * caps:
574 * a GstCaps to simplify
575 * Returns:
576 * TRUE, if the caps could be simplified
578 public int doSimplify()
580 // gboolean gst_caps_do_simplify (GstCaps *caps);
581 return gst_caps_do_simplify(gstCaps);
587 * Replaces *caps with newcaps. Unrefs the GstCaps in the location
588 * pointed to by caps, if applicable, then modifies caps to point to
589 * newcaps. An additional ref on newcaps is taken.
590 * This function does not take any locks so you might want to lock
591 * the object owning caps pointer.
592 * caps:
593 * a pointer to GstCaps
594 * newcaps:
595 * a GstCaps to replace *caps
597 public static void replace(GstCaps** caps, Caps newcaps)
599 // void gst_caps_replace (GstCaps **caps, GstCaps *newcaps);
600 gst_caps_replace(caps, (newcaps is null) ? null : newcaps.getCapsStruct());
604 * Converts caps to a string representation. This string representation
605 * can be converted back to a GstCaps by gst_caps_from_string().
606 * For debugging purposes its easier to do something like this:
607 * GST_LOG ("caps are %" GST_PTR_FORMAT, caps);
608 * This prints the caps in human readble form.
609 * caps:
610 * a GstCaps
611 * Returns:
612 * a newly allocated string representing caps.
614 public char[] toString()
616 // gchar* gst_caps_to_string (const GstCaps *caps);
617 return Str.toString(gst_caps_to_string(gstCaps) );
621 * Converts caps from a string representation.
622 * string:
623 * a string to convert to GstCaps
624 * Returns:
625 * a newly allocated GstCaps
627 public static Caps fromString(char[] string)
629 // GstCaps* gst_caps_from_string (const gchar *string);
630 return new Caps( gst_caps_from_string(Str.toStringz(string)) );
634 * Subtracts the subtrahend from the minuend.
635 * Note
636 * This function does not work reliably if optional properties for caps
637 * are included on one caps and omitted on the other.
638 * minuend:
639 * GstCaps to substract from
640 * subtrahend:
641 * GstCaps to substract
642 * Returns:
643 * the resulting caps
645 public Caps subtract(Caps subtrahend)
647 // GstCaps* gst_caps_subtract (const GstCaps *minuend, const GstCaps *subtrahend);
648 return new Caps( gst_caps_subtract(gstCaps, (subtrahend is null) ? null : subtrahend.getCapsStruct()) );
652 * Returns a writable copy of caps.
653 * If there is only one reference count on caps, the caller must be the owner,
654 * and so this function will return the caps object unchanged. If on the other
655 * hand there is more than one reference on the object, a new caps object will
656 * be returned. The caller's reference on caps will be removed, and instead the
657 * caller will own a reference to the returned object.
658 * In short, this function unrefs the caps in the argument and refs the caps
659 * that it returns. Don't access the argument after calling this function. See
660 * also: gst_caps_ref().
661 * caps:
662 * the GstCaps to make writable
663 * Returns:
664 * the same GstCaps object.
666 public Caps makeWritable()
668 // GstCaps* gst_caps_make_writable (GstCaps *caps);
669 return new Caps( gst_caps_make_writable(gstCaps) );
673 * Add a reference to a GstCaps object.
674 * From this point on, until the caller calls gst_caps_unref() or
675 * gst_caps_make_writable(), it is guaranteed that the caps object will not
676 * change. This means its structures won't change, etc. To use a GstCaps
677 * object, you must always have a refcount on it -- either the one made
678 * implicitly by gst_caps_new(), or via taking one explicitly with this
679 * function.
680 * caps:
681 * the GstCaps to reference
682 * Returns:
683 * the same GstCaps object.
685 public Caps doref()
687 // GstCaps* gst_caps_ref (GstCaps *caps);
688 return new Caps( gst_caps_ref(gstCaps) );
692 * Destructively discard all but the first structure from caps. Useful when
693 * fixating. caps must be writable.
694 * caps:
695 * the GstCaps to truncate
697 public void truncate()
699 // void gst_caps_truncate (GstCaps *caps);
700 gst_caps_truncate(gstCaps);
704 * Unref a GstCaps and and free all its structures and the
705 * structures' values when the refcount reaches 0.
706 * caps:
707 * the GstCaps to unref
708 * See Also
709 * GstStructure
711 public void unref()
713 // void gst_caps_unref (GstCaps *caps);
714 gst_caps_unref(gstCaps);