Caps

Description Caps (capabilities) are lighweight refcounted objects describing media types. They are composed of an array of GstStructure. Caps are exposed on GstPadTemplate to describe all possible types a given pad can handle. They are also stored in the GstRegistry along with a description of the GstElement. Caps are exposed on the element pads using the gst_pad_get_caps() pad function. This function describes the possible types that the pad can handle or produce at runtime. Caps are also attached to buffers to describe to content of the data pointed to by the buffer with gst_buffer_set_caps(). Caps attached to a GstBuffer allow for format negotiation upstream and downstream. A GstCaps can be constructed with the following code fragment: A GstCaps is fixed when it has no properties with ranges or lists. Use gst_caps_is_fixed() to test for fixed caps. Only fixed caps can be set on a GstPad or GstBuffer. Various methods exist to work with the media types such as subtracting or intersecting. Last reviewed on 2007-02-13 (0.10.10)

Constructors

this
this(GstCaps* gstCaps)

Sets our main struct and passes it to the parent class

this
this()

Creates a new GstCaps that is empty. That is, the returned GstCaps contains no media formats. Caller is responsible for unreffing the returned caps.

this
this(Structure structure, void* varArgs)

Creates a new GstCaps and adds all the structures listed as arguments. The list must be NULL-terminated. The structures are not copied; the returned GstCaps owns the structures.

Members

Functions

append
void append(Caps caps2)

Appends the structures contained in caps2 to caps1. The structures in caps2 are not copied -- they are transferred to caps1, and then caps2 is freed. If either caps is ANY, the resulting caps will be ANY.

appendStructure
void appendStructure(Structure structure)

Appends structure to caps. The structure is not copied; caps becomes the owner of structure.

copy
Caps copy()

Creates a new GstCaps as a copy of the old caps. The new caps will have a refcount of 1, owned by the caller. The structures are copied as well. Note that this function is the semantic equivalent of a gst_caps_ref() followed by a gst_caps_make_writable(). If you only want to hold on to a reference to the data, you should use gst_caps_ref(). When you are finished with the caps, call gst_caps_unref() on it.

copyNth
Caps copyNth(uint nth)

Creates a new GstCaps and appends a copy of the nth structure contained in caps.

doSimplify
int doSimplify()

Modifies the given caps inplace into a representation that represents the same set of formats, but in a simpler form. Component structures that are identical are merged. Component structures that have values that can be merged are also merged.

doref
Caps doref()

Add a reference to a GstCaps object. From this point on, until the caller calls gst_caps_unref() or gst_caps_make_writable(), it is guaranteed that the caps object will not change. This means its structures won't change, etc. To use a GstCaps object, you must always have a refcount on it -- either the one made implicitly by gst_caps_new(), or via taking one explicitly with this function.

getCapsStruct
GstCaps* getCapsStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getSize
uint getSize()

Gets the number of structures contained in caps.

getStruct
void* getStruct()

the main Gtk struct as a void*

getStructure
Structure getStructure(uint index)

Finds the structure in caps that has the index index, and returns it. WARNING: This function takes a const GstCaps *, but returns a non-const GstStructure *. This is for programming convenience -- the caller should be aware that structures inside a constant GstCaps should not be modified.

intersect
Caps intersect(Caps caps2)

Creates a new GstCaps that contains all the formats that are common to both caps1 and caps2.

isAlwaysCompatible
int isAlwaysCompatible(Caps caps2)

A given GstCaps structure is always compatible with another if every media format that is in the first is also contained in the second. That is, caps1 is a subset of caps2.

isAny
int isAny()

Determines if caps represents any media format.

isEmpty
int isEmpty()

Determines if caps represents no media formats.

isEqual
int isEqual(Caps caps2)

Checks if the given caps represent the same set of caps. Note This function does not work reliably if optional properties for caps are included on one caps and omitted on the other. This function deals correctly with passing NULL for any of the caps.

isEqualFixed
int isEqualFixed(Caps caps2)

Tests if two GstCaps are equal. This function only works on fixed GstCaps.

isFixed
int isFixed()

Fixed GstCaps describe exactly one format, that is, they have exactly one structure, and each field in the structure describes a fixed type. Examples of non-fixed types are GST_TYPE_INT_RANGE and GST_TYPE_LIST.

isSubset
int isSubset(Caps superset)

Checks if all caps represented by subset are also represented by superset. Note This function does not work reliably if optional properties for caps are included on one caps and omitted on the other.

makeWritable
Caps makeWritable()

Returns a writable copy of caps. If there is only one reference count on caps, the caller must be the owner, and so this function will return the caps object unchanged. If on the other hand there is more than one reference on the object, a new caps object will be returned. The caller's reference on caps will be removed, and instead the caller will own a reference to the returned object. In short, this function unrefs the caps in the argument and refs the caps that it returns. Don't access the argument after calling this function. See also: gst_caps_ref().

merge
void merge(Caps caps2)

Appends the structures contained in caps2 to caps1 if they are not yet expressed by caps1. The structures in caps2 are not copied -- they are transferred to caps1, and then caps2 is freed. If either caps is ANY, the resulting caps will be ANY.

mergeStructure
void mergeStructure(Structure structure)

Appends structure to caps if its not already expressed by caps. The structure is not copied; caps becomes the owner of structure.

normalize
Caps normalize()

Creates a new GstCaps that represents the same set of formats as caps, but contains no lists. Each list is expanded into separate GstStructures.

removeStructure
void removeStructure(uint idx)

removes the stucture with the given index from the list of structures contained in caps.

setSimpleValist
void setSimpleValist(string field, void* varargs)

Sets fields in a simple GstCaps. A simple GstCaps is one that only has one structure. The arguments must be passed in the same manner as gst_structure_set(), and be NULL-terminated.

subtract
Caps subtract(Caps subtrahend)

Subtracts the subtrahend from the minuend. Note This function does not work reliably if optional properties for caps are included on one caps and omitted on the other.

toString
string toString()

Converts caps to a string representation. This string representation can be converted back to a GstCaps by gst_caps_from_string().

truncate
void truncate()

Destructively discard all but the first structure from caps. Useful when fixating. caps must be writable.

unio
Caps unio(Caps caps2)

Creates a new GstCaps that contains all the formats that are in either caps1 and caps2.

unref
void unref()

Unref a GstCaps and and free all its structures and the structures' values when the refcount reaches 0.

Static functions

fromString
Caps fromString(string string)

Converts caps from a string representation.

newAny
Caps newAny()

Creates a new GstCaps that indicates that it is compatible with any media format.

replace
void replace(Caps caps, Caps newcaps)

Replaces *caps with newcaps. Unrefs the GstCaps in the location pointed to by caps, if applicable, then modifies caps to point to newcaps. An additional ref on newcaps is taken. This function does not take any locks so you might want to lock the object owning caps pointer.

staticCapsGet
Caps staticCapsGet(GstStaticCaps* staticCaps)

Converts a GstStaticCaps to a GstCaps.

Variables

gstCaps
GstCaps* gstCaps;

the main Gtk struct

Meta