Gst.Caps¶
Fields¶
Name |
Type |
Access |
Description |
---|---|---|---|
mini_object |
r/w |
the parent type |
Methods¶
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class Gst.Caps¶
Caps (capabilities) are lightweight refcounted objects describing media types. They are composed of an array of
Gst.Structure
.Caps are exposed on
Gst.PadTemplate
to describe all possible types a given pad can handle. They are also stored in theGst.Registry
along with a description of theGst.Element
.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
Gst.Caps
can be constructed with the following code fragment:- `` C
- 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
Gst.Caps
is fixed when it has no fields with ranges or lists. UseGst.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.
Be aware that until 1.20 the
Gst.Caps
/Gst.Structure
serialization into string had limited support for nestedGst.Caps
/Gst.Structure
fields. It could only support one level of nesting. Using more levels would lead to unexpected behavior when using serialization features, such asGst.Caps.to_string
() orGst.value_serialize
() and their counterparts.- classmethod from_string(string)[source]¶
- Parameters:
- Returns:
a newly allocated
Gst.Caps
- Return type:
Converts caps from a string representation.
The implementation of serialization up to 1.20 would lead to unexpected results when there were nested
Gst.Caps
/Gst.Structure
deeper than one level.
- classmethod new_any()[source]¶
-
Creates a new
Gst.Caps
that indicates that it is compatible with any media format.
- classmethod new_empty()[source]¶
-
Creates a new
Gst.Caps
that is empty. That is, the returnedGst.Caps
contains no media formats. TheGst.Caps
is guaranteed to be writable.
- classmethod new_empty_simple(media_type)[source]¶
- Parameters:
media_type (
str
) – the media type of the structure- Returns:
the new
Gst.Caps
- Return type:
Creates a new
Gst.Caps
that contains oneGst.Structure
with name media_type.
- append(caps2)[source]¶
-
Appends the structures contained in caps2 to self. The structures in caps2 are not copied – they are transferred to self, and then caps2 is freed. If either caps is ANY, the resulting caps will be ANY.
- append_structure(structure)[source]¶
- Parameters:
structure (
Gst.Structure
) – theGst.Structure
to append
Appends structure to self. The structure is not copied; self becomes the owner of structure.
- append_structure_full(structure, features)[source]¶
- Parameters:
structure (
Gst.Structure
) – theGst.Structure
to appendfeatures (
Gst.CapsFeatures
orNone
) – theGst.CapsFeatures
to append
Appends structure with features to self. The structure is not copied; self becomes the owner of structure.
New in version 1.2.
- can_intersect(caps2)[source]¶
- Parameters:
- Returns:
True
if intersection would be not empty- Return type:
Tries intersecting self and caps2 and reports whether the result would not be empty
- copy()[source]¶
-
Creates a new
Gst.Caps
as a copy of the old self. 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().
- copy_nth(nth)[source]¶
-
Creates a new
Gst.Caps
and appends a copy of the nth structure contained in self.New in version 1.16.
- filter_and_map_in_place(func, *user_data)[source]¶
- Parameters:
func (
Gst.CapsFilterMapFunc
) – a function to call for each field
Calls the provided function once for each structure and caps feature in the
Gst.Caps
. In contrast toGst.Caps.foreach
(), the function may modify the structure and features. In contrast toGst.Caps.map_in_place
(), the structure and features are removed from the caps ifFalse
is returned from the function. The caps must be mutable.New in version 1.6.
- fixate()[source]¶
- Returns:
the fixated caps
- Return type:
Modifies the given self 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
().This function takes ownership of self and will call gst_caps_make_writable() on it so you must not use self afterwards unless you keep an additional reference to it with gst_caps_ref().
Note that it is not guaranteed that the returned caps have exactly one structure. If self are empty caps then the returned caps will be the empty too and contain no structure at all.
Calling this function with ANY caps is not allowed.
- foreach(func, *user_data)[source]¶
- Parameters:
func (
Gst.CapsForeachFunc
) – a function to call for each field
- Returns:
True
if the supplied function returnsTrue
for each call,False
otherwise.- Return type:
Calls the provided function once for each structure and caps feature in the
Gst.Caps
. The function must not modify the fields. Also seeGst.Caps.map_in_place
() andGst.Caps.filter_and_map_in_place
().New in version 1.6.
- get_features(index)[source]¶
- Parameters:
index (
int
) – the index of the structure- Returns:
a pointer to the
Gst.CapsFeatures
corresponding to index- Return type:
Finds the features in self at index, and returns it.
WARNING: This function takes a
const GstCaps *
, but returns a non-constGstCapsFeatures *
. This is for programming convenience – the caller should be aware that features inside a constantGst.Caps
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 likeGst.CapsFeatures.add
().New in version 1.2.
- get_size()[source]¶
- Returns:
the number of structures that self contains
- Return type:
Gets the number of structures contained in self.
- get_structure(index)[source]¶
- Parameters:
index (
int
) – the index of the structure- Returns:
a pointer to the
Gst.Structure
corresponding to index- Return type:
Finds the structure in self at index, and returns it.
WARNING: This function takes a
const GstCaps *
, but returns a non-constGstStructure *
. This is for programming convenience – the caller should be aware that structures inside a constantGst.Caps
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().
- intersect(caps2)[source]¶
- Parameters:
- Returns:
the new
Gst.Caps
- Return type:
Creates a new
Gst.Caps
that contains all the formats that are common to both self and caps2. Defaults toGst.CapsIntersectMode.ZIG_ZAG
mode.
- intersect_full(caps2, mode)[source]¶
- Parameters:
mode (
Gst.CapsIntersectMode
) – The intersection algorithm/mode to use
- Returns:
the new
Gst.Caps
- Return type:
Creates a new
Gst.Caps
that contains all the formats that are common to both self and caps2, the order is defined by theGst.CapsIntersectMode
used.
- is_always_compatible(caps2)[source]¶
- Parameters:
- Returns:
True
if self is a subset of caps2.- Return type:
A given
Gst.Caps
structure is always compatible with another if every media format that is in the first is also contained in the second. That is, self is a subset of caps2.
- is_equal(caps2)[source]¶
- Parameters:
- Returns:
True
if both caps are equal.- Return type:
Checks if the given caps represent the same set of caps.
- is_equal_fixed(caps2)[source]¶
- Parameters:
- Returns:
True
if the arguments represent the same format- Return type:
Tests if two
Gst.Caps
are equal. This function only works on fixedGst.Caps
.
- is_fixed()[source]¶
-
Fixed
Gst.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.
- is_strictly_equal(caps2)[source]¶
- Parameters:
- Returns:
True
if both caps are strictly equal.- Return type:
Checks if the given caps are exactly the same set of caps.
- is_subset(superset)[source]¶
- Parameters:
- Returns:
True
if self is a subset of superset- Return type:
Checks if all caps represented by self are also represented by superset.
- is_subset_structure(structure)[source]¶
- Parameters:
structure (
Gst.Structure
) – a potentialGst.Structure
subset of self- Returns:
True
if structure is a subset of self- Return type:
Checks if structure is a subset of self. See
Gst.Caps.is_subset
() for more information.
- is_subset_structure_full(structure, features)[source]¶
- Parameters:
structure (
Gst.Structure
) – a potentialGst.Structure
subset of selffeatures (
Gst.CapsFeatures
orNone
) – aGst.CapsFeatures
for structure
- Returns:
True
if structure is a subset of self- Return type:
Checks if structure is a subset of self. See
Gst.Caps.is_subset
() for more information.New in version 1.2.
- map_in_place(func, *user_data)[source]¶
- Parameters:
func (
Gst.CapsMapFunc
) – a function to call for each field
- Returns:
True
if the supplied function returnsTrue
for each call,False
otherwise.- Return type:
Calls the provided function once for each structure and caps feature in the
Gst.Caps
. In contrast toGst.Caps.foreach
(), the function may modify but not delete the structures and features. The caps must be mutable.New in version 1.6.
- merge(caps2)[source]¶
- Parameters:
- Returns:
the merged caps.
- Return type:
Appends the structures contained in caps2 to self if they are not yet expressed by self. The structures in caps2 are not copied – they are transferred to a writable copy of self, and then caps2 is freed. If either caps is ANY, the resulting caps will be ANY.
- merge_structure(structure)[source]¶
- Parameters:
structure (
Gst.Structure
) – theGst.Structure
to merge- Returns:
the merged caps.
- Return type:
Appends structure to self if it is not already expressed by self.
- merge_structure_full(structure, features)[source]¶
- Parameters:
structure (
Gst.Structure
) – theGst.Structure
to mergefeatures (
Gst.CapsFeatures
orNone
) – theGst.CapsFeatures
to merge
- Returns:
the merged caps.
- Return type:
Appends structure with features to self if its not already expressed by self.
New in version 1.2.
- normalize()[source]¶
-
Returns a
Gst.Caps
that represents the same set of formats as self, but contains no lists. Each list is expanded into separateGst.Structure
.This function takes ownership of self and will call gst_caps_make_writable() on it so you must not use self afterwards unless you keep an additional reference to it with gst_caps_ref().
- remove_structure(idx)[source]¶
- Parameters:
idx (
int
) – Index of the structure to remove
Removes the structure with the given index from the list of structures contained in self.
- serialize(flags)[source]¶
- Parameters:
flags (
Gst.SerializeFlags
) – aGst.SerializeFlags
- Returns:
a newly allocated string representing self.
- Return type:
Converts self to a string representation. This string representation can be converted back to a
Gst.Caps
byGst.Caps.from_string
().This prints the caps in human readable form.
This version of the caps serialization function introduces support for nested structures and caps but the resulting strings won’t be parsable with GStreamer prior to 1.20 unless
Gst.SerializeFlags.BACKWARD_COMPAT
is passed as flag.New in version 1.20.
- set_features(index, features)[source]¶
- Parameters:
index (
int
) – the index of the structurefeatures (
Gst.CapsFeatures
orNone
) – theGst.CapsFeatures
to set
Sets the features for the structure at index.
New in version 1.2.
- set_features_simple(features)[source]¶
- Parameters:
features (
Gst.CapsFeatures
orNone
) – theGst.CapsFeatures
to set
Sets the features for all the structures of self.
New in version 1.16.
- set_value(field, value)[source]¶
- Parameters:
field (
str
) – name of the field to setvalue (
GObject.Value
) – value to set the field to
Sets the given field on all structures of self to the given value. This is a convenience function for calling
Gst.Structure.set_value
() on all structures of self.
- simplify()[source]¶
- Returns:
The simplified caps.
- Return type:
Converts the given self 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 function takes ownership of self and will call gst_caps_make_writable() on it if necessary, so you must not use self afterwards unless you keep an additional reference to it with gst_caps_ref().
This method does not preserve the original order of self.
- steal_structure(index)[source]¶
- Parameters:
index (
int
) – Index of the structure to retrieve- Returns:
a pointer to the
Gst.Structure
corresponding to index.- Return type:
Retrieves the structure with the given index from the list of structures contained in self. The caller becomes the owner of the returned structure.
- subtract(subtrahend)[source]¶
- Parameters:
- Returns:
the resulting caps
- Return type:
Subtracts the subtrahend from the self.
This function does not work reliably if optional properties for caps are included on one caps and omitted on the other.
- to_string()[source]¶
- Returns:
a newly allocated string representing self.
- Return type:
Converts self to a string representation. This string representation can be converted back to a
Gst.Caps
byGst.Caps.from_string
().For debugging purposes its easier to do something like this:
`` C GST_LOG (“caps are %” GST_PTR_FORMAT, caps); ``
This prints the caps in human readable form.
The implementation of serialization up to 1.20 would lead to unexpected results when there were nested
Gst.Caps
/Gst.Structure
deeper than one level.
- truncate()[source]¶
- Returns:
truncated caps
- Return type:
Discards all but the first structure from self. Useful when fixating.
This function takes ownership of self and will call gst_caps_make_writable() on it if necessary, so you must not use self afterwards unless you keep an additional reference to it with gst_caps_ref().
Note that it is not guaranteed that the returned caps have exactly one structure. If self is any or empty caps then the returned caps will be the same and contain no structure at all.