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
44 * - gst_caps_save_thyself
45 * - gst_caps_load_thyself
49 * - gstreamer.Structure
52 * - GstStructure* -> Structure
57 module gstreamer
.Caps
;
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
;
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
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,
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
106 * Last reviewed on 2007-02-13 (0.10.10)
111 /** the main Gtk struct */
112 protected GstCaps
* gstCaps
;
115 public GstCaps
* getCapsStruct()
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;
135 Stdout("Yup. This is the noAssert version.").newline;
136 if ( gstCaps is null )
141 Stdout("struct gstCaps is null on constructor").newline;
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;
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
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.
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.
207 * the media type of the structure
211 * additional arguments
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.
226 * the first structure to add
228 * additional structures to add
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.
243 * the first structure to add
245 * additional structures to add
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.
263 * the GstCaps to 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
277 * the GstCaps to copy
279 * the nth structure to copy
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.
292 * the GstStaticCaps to convert
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.
309 * the GstCaps that will be appended to
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.
325 * the GstCaps that will take the new entries
327 * the GstCaps to merge in
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.
340 * the GstCaps that will be appended to
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
354 * the GstCaps to remove from
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.
368 * the GstCaps that will the the new 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.
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
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.
401 * the index of the structure
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.
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.
433 * the GstCaps to copy
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.
448 * the GstCaps to test
450 * TRUE if caps represents any format.
454 // gboolean gst_caps_is_any (const GstCaps *caps);
455 return gst_caps_is_any(gstCaps
);
459 * Determines if caps represents no media formats.
461 * the GstCaps to test
463 * TRUE if caps represents no formats.
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.
476 * the GstCaps to test
478 * TRUE if caps is fixed
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.
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.
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
509 * the GstCaps to test
511 * the GstCaps to test
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.
526 * the GstCaps to test
528 * the GstCaps to test
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.
541 * This function does not work reliably if optional properties for caps
542 * are included on one caps and omitted on the other.
546 * a potentially greater GstCaps
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.
560 * a GstCaps to intersect
562 * a GstCaps to intersect
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.
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
593 * a GstCaps to normalize
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.
609 * a GstCaps to simplify
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.
628 * a pointer to GstCaps
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.
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.
658 * a string to convert to GstCaps
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.
671 * This function does not work reliably if optional properties for caps
672 * are included on one caps and omitted on the other.
674 * GstCaps to substract from
676 * GstCaps to substract
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().
697 * the GstCaps to make writable
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
716 * the GstCaps to reference
718 * the same GstCaps object.
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.
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.
742 * the GstCaps to unref
748 // void gst_caps_unref (GstCaps *caps);
749 gst_caps_unref(gstCaps
);