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
ConstructorDescriptionMeta()
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 String[]
apiTypeGetTags
(Type api) static boolean
apiTypeHasTag
(Type api, Quark tag) Check ifapi
was registered withtag
.static Type
apiTypeRegister
(String api, String[] tags) Register and return a GType for theapi
and associate it withtags
.int
compareSeqnum
(Meta meta2) Meta sequence number compare function.static Meta
deserialize
(Buffer buffer, MemorySegment data, long size, Out<Integer> consumed) Recreate aGstMeta
from serialized data returned by gst_meta_serialize() and add it tobuffer
.static MetaInfo
Lookup a previously registered meta info structure by its implementation nameimpl
.static MemoryLayout
The memory layout of the native struct.long
Gets seqnum for this meta.Read the value of the fieldflags
.readInfo()
Read the value of the fieldinfo
.static MetaInfo
register
(Type api, String impl, long size, MetaInitFunction initFunc, MetaFreeFunction freeFunc, MetaTransformFunction transformFunc) Register a newGstMeta
implementation.static MetaInfo
registerCustom
(String name, String[] tags, @Nullable CustomMetaTransformFunction transformFunc) Register a new customGstMeta
implementation, backed by an opaque structure holding aGstStructure
.static MetaInfo
registerCustomSimple
(String name) Simplified version of gst_meta_register_custom(), with no tags and no transform function.boolean
serialize
(ByteArrayInterface data) Serialize this Meta into a format that can be stored or transmitted and later deserialized by gst_meta_deserialize().boolean
serializeSimple
(byte[] data) Same as gst_meta_serialize() but with aGByteArray
instead ofGstByteArrayInterface
.void
writeFlags
(Set<MetaFlags> flags) Write a value in the fieldflags
.void
Write a value in the fieldinfo
.Methods inherited from class io.github.jwharm.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 fieldflags
info
- 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
-
apiTypeGetTags
-
apiTypeHasTag
-
apiTypeRegister
-
deserialize
Recreate aGstMeta
from 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.consumed
is set to the number of bytes that can be skipped fromdata
to find the next meta serialization, if any. In case of parsing error that does not allow to determine that size,consumed
is set to 0.- Parameters:
buffer
- aGstBuffer
data
- serialization data obtained from gst_meta_serialize()size
- size ofdata
consumed
- total size used by this meta, could be less thansize
- Returns:
- the metadata owned by
buffer
, ornull
.
-
getInfo
-
register
public static MetaInfo register(Type api, String impl, long size, MetaInitFunction initFunc, MetaFreeFunction freeFunc, MetaTransformFunction transformFunc) Register a newGstMeta
implementation.The same
info
can be retrieved later with gst_meta_get_info() by usingimpl
as the key.- Parameters:
api
- the type of theGstMeta
APIimpl
- the name of theGstMeta
implementationsize
- the size of theGstMeta
structureinitFunc
- aGstMetaInitFunction
freeFunc
- aGstMetaFreeFunction
transformFunc
- aGstMetaTransformFunction
- Returns:
- a
GstMetaInfo
that can be used to access metadata.
-
registerCustom
public static MetaInfo registerCustom(String name, String[] tags, @Nullable @Nullable CustomMetaTransformFunction transformFunc) Register a new customGstMeta
implementation, backed by an opaque structure holding aGstStructure
.The registered info can be retrieved later with gst_meta_get_info() by using
name
as the key.The backing
GstStructure
can be retrieved with gst_custom_meta_get_structure(), its mutability is conditioned by the writability of the buffer the meta is attached to.When
transformFunc
isnull
, the meta and its backingGstStructure
will always be copied when the transform operation is copy, other operations are discarded, copy regions are ignored.- Parameters:
name
- the name of theGstMeta
implementationtags
- tags forapi
transformFunc
- aGstMetaTransformFunction
- Returns:
- a
GstMetaInfo
that can be used to access metadata.
-
registerCustomSimple
-
compareSeqnum
Meta sequence number compare function. Can be used asGCompareFunc
or 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
.
-
getSeqnum
public long getSeqnum()Gets seqnum for this meta. -
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,false
is 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.
- Parameters:
data
-GstByteArrayInterface
to append serialization data- Returns:
true
on success,false
otherwise.
-
serializeSimple
public boolean serializeSimple(byte[] data) Same as gst_meta_serialize() but with aGByteArray
instead ofGstByteArrayInterface
.- Parameters:
data
-GByteArray
to append serialization data- Returns:
true
on success,false
otherwise.
-