Class Meta
- All Implemented Interfaces:
Proxy
GstMeta structure should be included as the first member of a GstBuffer
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 gst_meta_api_type_register() which takes a name for the metadata API and some tags associated with the metadata. With gst_meta_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, gst_meta_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 GstMetaInfo
structure that contains the information for the implementation of the API.
A specific implementation can be retrieved by name with gst_meta_get_info().
See GstBuffer for how the metadata can be added, retrieved and removed from
buffers.
-
Constructor Summary
ConstructorsConstructorDescriptionMeta()Allocate a new Meta.Allocate a new Meta.Meta(MemorySegment address) Create a Meta proxy instance for the provided memory address.Allocate a new Meta with the fields set to the provided values.Allocate a new Meta with the fields set to the provided values. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanapiTypeAggregateParams(Type api, Structure[] aggregatedParams, Structure params0, Structure params1) When a element liketeedecides the allocation, each downstream element may fill different parameters and pass them to gst_query_add_allocation_meta().static String[]apiTypeGetTags(Type api) static booleanapiTypeHasTag(Type api, Quark tag) Check ifapiwas registered withtag.static TypeapiTypeRegister(String api, @Nullable String @Nullable [] tags) Register and return a GType for theapiand associate it withtags.static voidapiTypeSetParamsAggregator(Type api, @Nullable AllocationMetaParamsAggregator aggregator) This function sets the aggregator function for a specific API type.intcompareSeqnum(Meta meta2) Meta sequence number compare function.static @Nullable Metadeserialize(Buffer buffer, MemorySegment data, long size, Out<Integer> consumed) Recreate aGstMetafrom serialized data returned by gst_meta_serialize() and add it tobuffer.static @Nullable MetaInfoLookup a previously registered meta info structure by its implementation nameimpl.static MemoryLayoutThe memory layout of the native struct.longGets seqnum for this meta.Read the value of the fieldflags.readInfo()Read the value of the fieldinfo.static MetaInforegister(Type api, String impl, long size, @Nullable MetaInitFunction initFunc, @Nullable MetaFreeFunction freeFunc, @Nullable MetaTransformFunction transformFunc) Register a newGstMetaimplementation.static MetaInforegisterCustom(String name, @Nullable String @Nullable [] tags, @Nullable CustomMetaTransformFunction transformFunc) Register a new customGstMetaimplementation, backed by an opaque structure holding aGstStructure.static MetaInforegisterCustomSimple(String name) Simplified version of gst_meta_register_custom(), with no tags and no transform function.booleanserialize(ByteArrayInterface data) Serialize this Meta into a format that can be stored or transmitted and later deserialized by gst_meta_deserialize().booleanserializeSimple(@org.jspecify.annotations.Nullable byte @Nullable [] data) Same as gst_meta_serialize() but with aGByteArrayinstead ofGstByteArrayInterface.voidwriteFlags(Set<MetaFlags> flags) Write a value in the fieldflags.voidWrite a value in the fieldinfo.Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Meta
Create a Meta proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Meta
Allocate a new Meta.- Parameters:
arena- to control the memory allocation scope
-
Meta
public Meta()Allocate a new Meta. The memory is allocated withArena.ofAuto(). -
Meta
-
Meta
Allocate a new Meta with the fields set to the provided values. The memory is allocated withArena.ofAuto().- Parameters:
flags- value for the fieldflagsinfo- value for the fieldinfo
-
-
Method Details
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readFlags
-
writeFlags
-
readInfo
-
writeInfo
Write a value in the fieldinfo.- Parameters:
info- The new value for the fieldinfo
-
apiTypeAggregateParams
public static boolean apiTypeAggregateParams(Type api, Structure[] aggregatedParams, Structure params0, Structure params1) When a element liketeedecides the allocation, each downstream element may fill different parameters and pass them to gst_query_add_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 intoaggregatedParams.- Parameters:
api- the GType of the API for which the parameters are being aggregated.aggregatedParams- This structure will be updated with the combined parameters from bothparams0andparams1.params0- aGstStructurecontaining the new parameters to be aggregated.params1- aGstStructurecontaining the new parameters to be aggregated.- Returns:
trueif the parameters were successfully aggregated,falseotherwise.- Since:
- 1.26
-
apiTypeGetTags
-
apiTypeHasTag
-
apiTypeRegister
-
apiTypeSetParamsAggregator
public static void apiTypeSetParamsAggregator(Type api, @Nullable AllocationMetaParamsAggregator aggregator) This function sets the aggregator function for a specific API type.- Parameters:
api- theGTypeof the API for which the aggregator function is being set.aggregator- the aggregator function to be associated with the given API type.- Since:
- 1.26
-
deserialize
public static @Nullable Meta deserialize(Buffer buffer, MemorySegment data, long size, Out<Integer> consumed) Recreate aGstMetafrom serialized data returned by gst_meta_serialize() 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.- Parameters:
buffer- aGstBufferdata- serialization data obtained from gst_meta_serialize()size- size ofdataconsumed- total size used by this meta, could be less thansize- Returns:
- the metadata owned by
buffer,ornull. - Since:
- 1.24
-
getInfo
-
register
public static MetaInfo register(Type api, String impl, long size, @Nullable MetaInitFunction initFunc, @Nullable MetaFreeFunction freeFunc, @Nullable MetaTransformFunction transformFunc) Register a newGstMetaimplementation.The same
infocan be retrieved later with gst_meta_get_info() by usingimplas the key.- Parameters:
api- the type of theGstMetaAPIimpl- the name of theGstMetaimplementationsize- the size of theGstMetastructureinitFunc- aGstMetaInitFunctionfreeFunc- aGstMetaFreeFunctiontransformFunc- aGstMetaTransformFunction- Returns:
- a
GstMetaInfothat can be used to access metadata.
-
registerCustom
public static MetaInfo registerCustom(String name, @Nullable String @Nullable [] tags, @Nullable CustomMetaTransformFunction transformFunc) Register a new customGstMetaimplementation, backed by an opaque structure holding aGstStructure.The registered info can be retrieved later with gst_meta_get_info() by using
nameas the key.The backing
GstStructurecan be retrieved with gst_custom_meta_get_structure(), its mutability is conditioned by the writability of the buffer the meta is attached to.When
transformFuncisnull, the meta and its backingGstStructurewill always be copied when the transform operation is copy, other operations are discarded, copy regions are ignored.- Parameters:
name- the name of theGstMetaimplementationtags- tags forapitransformFunc- aGstMetaTransformFunction- Returns:
- a
GstMetaInfothat can be used to access metadata. - Since:
- 1.20
-
registerCustomSimple
-
compareSeqnum
Meta sequence number compare function. Can be used asGCompareFuncor aGCompareDataFunc.- Parameters:
meta2- aGstMeta- Returns:
- a negative number if this Meta comes before
meta2,0 if both metas have an equal sequence number, or a positive integer if this Meta comes aftermeta2. - Since:
- 1.16
-
getSeqnum
public long getSeqnum()Gets seqnum for this meta.- Since:
- 1.16
-
serialize
Serialize this Meta into a format that can be stored or transmitted and later deserialized by gst_meta_deserialize().This is only supported for meta that implements
GstMetaInfo.serialize_func,falseis returned otherwise.Upon failure,
data>datapointer could have been reallocated, butdata>lenwon'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.
- Parameters:
data-GstByteArrayInterfaceto append serialization data- Returns:
trueon success,falseotherwise.- Since:
- 1.24
-
serializeSimple
public boolean serializeSimple(@org.jspecify.annotations.Nullable byte @Nullable [] data) Same as gst_meta_serialize() but with aGByteArrayinstead ofGstByteArrayInterface.- Parameters:
data-GByteArrayto append serialization data- Returns:
trueon success,falseotherwise.- Since:
- 1.24
-