Meta#
- class Meta(*args, **kwargs)#
The Meta structure should be included as the first member of a Buffer
metadata structure. The structure defines the API of the metadata and should
be accessible to all elements using the metadata.
A metadata API is registered with api_type_register() which takes a
name for the metadata API and some tags associated with the metadata.
With api_type_has_tag() one can check if a certain metadata API
contains a given tag.
Multiple implementations of a metadata API can be registered.
To implement a metadata API, register() should be used. This
function takes all parameters needed to create, free and transform metadata
along with the size of the metadata. The function returns a MetaInfo
structure that contains the information for the implementation of the API.
A specific implementation can be retrieved by name with get_info().
See Buffer for how the metadata can be added, retrieved and removed from
buffers.
Methods#
- class Meta
- classmethod api_type_aggregate_params(api: GType, aggregated_params: Structure, params0: Structure, params1: Structure) bool#
When a element like
teedecides the allocation, each downstream element may fill different parameters and pass them toadd_allocation_meta(). In order to keep these parameters, a merge operation is needed. This aggregate function can combine the parameters fromparams0andparam1, and write the result back intoaggregated_params.Added in version 1.26.
- Parameters:
api – the GType of the API for which the parameters are being aggregated.
aggregated_params – This structure will be updated with the combined parameters from both
params0andparams1.params0 – a
Structurecontaining the new parameters to be aggregated.params1 – a
Structurecontaining the new parameters to be aggregated.
- classmethod api_type_has_tag(api: GType, tag: int) bool#
Check if
apiwas registered withtag.- Parameters:
api – an API
tag – the tag to check
- classmethod api_type_register(api: str, tags: list[str]) GType#
Register and return a GType for the
apiand associate it withtags.- Parameters:
api – an API to register
tags – tags for
api
- classmethod api_type_set_params_aggregator(api: GType, aggregator: Callable[[Structure, Structure, Structure], bool]) None#
This function sets the aggregator function for a specific API type.
Added in version 1.26.
- Parameters:
api – the
Typeof the API for which the aggregator function is being set.aggregator – the aggregator function to be associated with the given API type.
- classmethod api_type_tags_contain_only(api: GType, valid_tags: list[str]) bool#
Added in version 1.28.
- Parameters:
api – an API
valid_tags – a list of valid tags
- compare_seqnum(meta2: Meta) int#
Meta sequence number compare function. Can be used as
CompareFuncor aCompareDataFunc.Added in version 1.16.
- Parameters:
meta2 – a
Meta
- classmethod deserialize(buffer: Buffer, data: list[int]) tuple[Meta | None, int]#
Recreate a
Metafrom serialized data returned byserialize()and add it tobuffer.Note that the meta must have been previously registered by calling one of
gst_*_meta_get_info ()functions.consumedis set to the number of bytes that can be skipped fromdatato find the next meta serialization, if any. In case of parsing error that does not allow to determine that size,consumedis set to 0.Added in version 1.24.
- Parameters:
buffer – a
Bufferdata – serialization data obtained from
serialize()
- classmethod get_info(impl: str) MetaInfo | None#
Lookup a previously registered meta info structure by its implementation name
impl.- Parameters:
impl – the name
- classmethod register_custom(name: str, tags: list[str], transform_func: Callable[[Buffer, CustomMeta, Buffer, int, Any, Any], bool] | None = None, user_data: Any = None) MetaInfo#
Register a new custom
Metaimplementation, backed by an opaque structure holding aStructure.The registered info can be retrieved later with
get_info()by usingnameas the key.The backing
Structurecan be retrieved withget_structure(), its mutability is conditioned by the writability of the buffer the meta is attached to.When
transform_funcisNone, the meta and its backingStructurewill always be copied when the transform operation is copy, other operations are discarded, copy regions are ignored.Added in version 1.20.
- Parameters:
name – the name of the
Metaimplementationtags – tags for
apitransform_func – a
MetaTransformFunctionuser_data – user data passed to
transform_func
- classmethod register_custom_simple(name: str) MetaInfo#
Simplified version of
register_custom(), with no tags and no transform function.Added in version 1.24.
- Parameters:
name – the name of the
Metaimplementation
- serialize(data: ByteArrayInterface) bool#
Serialize
metainto a format that can be stored or transmitted and later deserialized bydeserialize().This is only supported for meta that implements
MetaInfo.serialize_func,Falseis returned otherwise.Upon failure,
data->data pointer could have been reallocated, butdata->len won’t be modified. This is intended to be able to append multiple metas into the sameGByteArray.Since serialization size is often the same for every buffer, caller may want to remember the size of previous data to preallocate the next.
Added in version 1.24.
- Parameters:
data –
ByteArrayInterfaceto append serialization data
- serialize_simple(data: list[int]) bool#
Same as
serialize()but with aGByteArrayinstead ofByteArrayInterface.Added in version 1.24.
- Parameters:
data –
GByteArrayto append serialization data