Caps

Caps (capabilities) are lightweight 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_query_caps() pad function. This function describes the possible types that the pad can handle or produce at runtime.

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. Fixed caps can be used in a caps event to notify downstream elements of the current media type.

Various methods exist to work with the media types such as subtracting or intersecting.

Last reviewed on 2011-03-28 (0.11.3)

class Caps {}

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. The GstCaps is guaranteed to be writable. Caller is responsible for unreffing the returned caps.

this
this(string mediaType)

Creates a new GstCaps that contains one GstStructure with name media_type. 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.

appendStructureFull
void appendStructureFull(Structure structure, CapsFeatures features)

Appends structure with features to caps. The structure is not copied; caps becomes the owner of structure. Since 1.2

canIntersect
int canIntersect(Caps caps2)

Tries intersecting caps1 and caps2 and reports whether the result would not be empty

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.

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 e.g. gst_caps_new_simple(), or via taking one explicitly with this function.

fixate
Caps fixate()

Modifies the given caps into a representation with only fixed values. First the caps will be truncated and then the first structure will be fixated with gst_structure_fixate().

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

Finds the features in caps that has the index index, and returns it. WARNING: This function takes a const GstCaps *, but returns a non-const GstCapsFeatures *. This is for programming convenience -- the caller should be aware that structures inside a constant GstCaps should not be modified. However, if you know the caps are writable, either because you have just copied them or made them writable with gst_caps_make_writable(), you may modify the features returned in the usual way, e.g. with functions like gst_caps_features_add(). You do not need to free or unref the structure returned, it belongs to the GstCaps. Since 1.2

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. However, if you know the caps are writable, either because you have just copied them or made them writable with gst_caps_make_writable(), you may modify the structure returned in the usual way, e.g. with functions like gst_structure_set(). You do not need to free or unref the structure returned, it belongs to the GstCaps.

intersect
Caps intersect(Caps caps2)

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

intersectFull
Caps intersectFull(Caps caps2, GstCapsIntersectMode mode)

Creates a new GstCaps that contains all the formats that are common to both caps1 and caps2, the order is defined by the GstCapsIntersectMode used.

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.

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.

isStrictlyEqual
int isStrictlyEqual(Caps caps2)

Checks if the given caps are exactly the same set of caps.

isSubset
int isSubset(Caps superset)

Checks if all caps represented by subset are also represented by superset.

isSubsetStructure
int isSubsetStructure(Structure structure)

Checks if structure is a subset of caps. See gst_caps_is_subset() for more information.

isSubsetStructureFull
int isSubsetStructureFull(Structure structure, CapsFeatures features)

Checks if structure is a subset of caps. See gst_caps_is_subset() for more information. Since 1.2

merge
Caps 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 a writable copy of caps1, and then caps2 is freed. If either caps is ANY, the resulting caps will be ANY.

mergeStructure
Caps mergeStructure(Structure structure)

Appends structure to caps if its not already expressed by caps.

mergeStructureFull
Caps mergeStructureFull(Structure structure, CapsFeatures features)

Appends structure with features to caps if its not already expressed by caps. Since 1.2

normalize
Caps normalize()

Returns a GstCaps that represents the same set of formats as caps, but contains no lists. Each list is expanded into separate GstStructures. This function takes ownership of caps.

removeStructure
void removeStructure(uint idx)

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

setFeatures
void setFeatures(uint index, CapsFeatures features)

Sets the GstCapsFeatures features for the structure at index. Since 1.2

setSimpleValist
void setSimpleValist(string field, void* varargs)

Sets fields in a GstCaps. The arguments must be passed in the same manner as gst_structure_set(), and be NULL-terminated.

setValue
void setValue(string field, Value value)

Sets the given field on all structures of caps to the given value. This is a convenience function for calling gst_structure_set_value() on all structures of caps.

simplify
Caps simplify()

Converts the given caps 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. This method does not preserve the original order of caps.

stealStructure
Structure stealStructure(uint index)

Retrieves the structure with the given index from the list of structures contained in caps. The caller becomes the owner of the returned structure.

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
Caps truncate()

Discard all but the first structure from caps. Useful when fixating.

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
int replace(GstCaps** oldCaps, Caps newCaps)

Modifies a pointer to a GstCaps to point to a different GstCaps. The modification is done atomically (so this is useful for ensuring thread safety in some cases), and the reference counts are updated appropriately (the old caps is unreffed, the new is reffed). Either ncaps or the GstCaps pointed to by ocaps may be NULL.

staticCapsCleanup
void staticCapsCleanup(GstStaticCaps* staticCaps)

Clean up the cached caps contained in static_caps.

staticCapsGet
Caps staticCapsGet(GstStaticCaps* staticCaps)

Converts a GstStaticCaps to a GstCaps.

take
int take(GstCaps** oldCaps, Caps newCaps)

Modifies a pointer to a GstCaps to point to a different GstCaps. This function is similar to gst_caps_replace() except that it takes ownership of new_caps.

Variables

gstCaps
GstCaps* gstCaps;

the main Gtk struct

Meta