Caps

Caps (capabilities) are lightweight refcounted objects describing media types. They are composed of an array of gstreamer.Structure

Caps are exposed on gstreamer.PadTemplate to describe all possible types a given pad can handle. They are also stored in the gstreamer.Registry along with a description of the gstreamer.Element

Caps are exposed on the element pads using the Pad.queryCaps pad function. This function describes the possible types that the pad can handle or produce at runtime.

A gstreamer.Caps can be constructed with the following code fragment:

GstCaps *caps = gst_caps_new_simple ("video/x-raw",
"format", G_TYPE_STRING, "I420",
"framerate", GST_TYPE_FRACTION, 25, 1,
"pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
"width", G_TYPE_INT, 320,
"height", G_TYPE_INT, 240,
NULL);

A gstreamer.Caps is fixed when it has no properties with ranges or lists. Use Caps.isFixed 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.

Be aware that the current gstreamer.Caps / gstreamer.Structure serialization into string has limited support for nested gstreamer.Caps / gstreamer.Structure fields. It can only support one level of nesting. Using more levels will lead to unexpected behavior when using serialization features, such as Caps.toString or Value.serialize and their counterparts.

class Caps {
protected
bool ownedRef;
}

Constructors

this
this(GstCaps* gstCaps, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this()

Creates a new gstreamer.Caps that is empty. That is, the returned gstreamer.Caps contains no media formats. The gstreamer.Caps is guaranteed to be writable. Caller is responsible for unreffing the returned caps.

this
this(string mediaType)

Creates a new gstreamer.Caps that contains one gstreamer.Structure with name media_type. Caller is responsible for unreffing the returned caps.

this
this(Structure structure, void* varArgs)

Creates a new gstreamer.Caps and adds all the structures listed as arguments. The list must be NULL-terminated. The structures are not copied; the returned gstreamer.Caps 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.

canIntersect
bool canIntersect(Caps caps2)

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

copy
Caps copy()

Creates a new gstreamer.Caps 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.

copyNth
Caps copyNth(uint nth)

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

filterAndMapInPlace
void filterAndMapInPlace(GstCapsFilterMapFunc func, void* userData)

Calls the provided function once for each structure and caps feature in the gstreamer.Caps In contrast to Caps.foreach, the function may modify the structure and features. In contrast to Caps.filterAndMapInPlace, the structure and features are removed from the caps if FALSE is returned from the function. The caps must be mutable.

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 Structure.fixate.

foreach_
bool foreach_(GstCapsForeachFunc func, void* userData)

Calls the provided function once for each structure and caps feature in the gstreamer.Caps The function must not modify the fields. Also see Caps.mapInPlace and Caps.filterAndMapInPlace.

getCapsStruct
GstCaps* getCapsStruct(bool transferOwnership)

Get the main Gtk struct

getFeatures
CapsFeatures getFeatures(uint index)

Finds the features in caps that has the index index, and returns 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.

intersect
Caps intersect(Caps caps2)

Creates a new gstreamer.Caps 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 gstreamer.Caps that contains all the formats that are common to both caps1 and caps2, the order is defined by the GstCapsIntersectMode used.

isAlwaysCompatible
bool isAlwaysCompatible(Caps caps2)

A given gstreamer.Caps 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
bool isAny()

Determines if caps represents any media format.

isEmpty
bool isEmpty()

Determines if caps represents no media formats.

isEqual
bool isEqual(Caps caps2)

Checks if the given caps represent the same set of caps.

isEqualFixed
bool isEqualFixed(Caps caps2)

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

isFixed
bool isFixed()

Fixed gstreamer.Caps 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
bool isStrictlyEqual(Caps caps2)

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

isSubset
bool isSubset(Caps superset)

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

isSubsetStructure
bool isSubsetStructure(Structure structure)

Checks if structure is a subset of caps. See Caps.isSubset for more information.

isSubsetStructureFull
bool isSubsetStructureFull(Structure structure, CapsFeatures features)

Checks if structure is a subset of caps. See Caps.isSubset for more information.

mapInPlace
bool mapInPlace(GstCapsMapFunc func, void* userData)

Calls the provided function once for each structure and caps feature in the gstreamer.Caps In contrast to Caps.foreach, the function may modify but not delete the structures and features. The caps must be mutable.

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.

normalize
Caps normalize()

Returns a gstreamer.Caps 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 structure with the given index from the list of structures contained in caps.

setFeatures
void setFeatures(uint index, CapsFeatures features)

Sets the gstreamer.CapsFeatures features for the structure at index.

setFeaturesSimple
void setFeaturesSimple(CapsFeatures features)

Sets the gstreamer.CapsFeatures features for all the structures of caps.

setSimpleValist
void setSimpleValist(string field, void* varargs)

Sets fields in a gstreamer.Caps The arguments must be passed in the same manner as 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 Structure.setValue 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.

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. > 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 gstreamer.Caps by Caps.fromString.

truncate
Caps truncate()

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

Static functions

fromString
Caps fromString(string string_)

Converts caps from a string representation.

getType
GType getType()
newAny
Caps newAny()

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

Variables

gstCaps
GstCaps* gstCaps;

the main Gtk struct