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
;
59 private import gstreamerc
.gstreamertypes
;
61 private import gstreamerc
.gstreamer
;
63 private import glib
.Str
;
64 private import gstreamer
.Structure
;
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
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,
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
96 * Last reviewed on 2007-02-13 (0.10.10)
101 /** the main Gtk struct */
102 protected GstCaps
* gstCaps
;
105 public GstCaps
* getCapsStruct()
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
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.
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.
172 * the media type of the structure
176 * additional arguments
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.
191 * the first structure to add
193 * additional structures to add
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.
208 * the first structure to add
210 * additional structures to add
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.
228 * the GstCaps to 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
242 * the GstCaps to copy
244 * the nth structure to copy
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.
257 * the GstStaticCaps to convert
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.
274 * the GstCaps that will be appended to
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.
290 * the GstCaps that will take the new entries
292 * the GstCaps to merge in
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.
305 * the GstCaps that will be appended to
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
319 * the GstCaps to remove from
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.
333 * the GstCaps that will the the new 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.
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
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.
366 * the index of the structure
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.
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.
398 * the GstCaps to copy
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.
413 * the GstCaps to test
415 * TRUE if caps represents any format.
419 // gboolean gst_caps_is_any (const GstCaps *caps);
420 return gst_caps_is_any(gstCaps
);
424 * Determines if caps represents no media formats.
426 * the GstCaps to test
428 * TRUE if caps represents no formats.
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.
441 * the GstCaps to test
443 * TRUE if caps is fixed
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.
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.
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
474 * the GstCaps to test
476 * the GstCaps to test
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.
491 * the GstCaps to test
493 * the GstCaps to test
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.
506 * This function does not work reliably if optional properties for caps
507 * are included on one caps and omitted on the other.
511 * a potentially greater GstCaps
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.
525 * a GstCaps to intersect
527 * a GstCaps to intersect
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.
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
558 * a GstCaps to normalize
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.
574 * a GstCaps to simplify
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.
593 * a pointer to GstCaps
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.
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.
623 * a string to convert to GstCaps
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.
636 * This function does not work reliably if optional properties for caps
637 * are included on one caps and omitted on the other.
639 * GstCaps to substract from
641 * GstCaps to substract
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().
662 * the GstCaps to make writable
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
681 * the GstCaps to reference
683 * the same GstCaps object.
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.
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.
707 * the GstCaps to unref
713 // void gst_caps_unref (GstCaps *caps);
714 gst_caps_unref(gstCaps
);