Package org.freedesktop.gstreamer.gst
Class TypeFind
java.lang.Object
io.github.jwharm.javagi.base.ProxyInstance
org.freedesktop.gstreamer.gst.TypeFind
- All Implemented Interfaces:
Proxy
The following functions allow you to detect the media type of an unknown
stream.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Functional interface declaration of theGetLengthCallback
callback.static interface
Functional interface declaration of thePeekCallback
callback.static interface
Functional interface declaration of theSuggestCallback
callback. -
Constructor Summary
ConstructorDescriptionTypeFind()
Allocate a new TypeFind.Allocate a new TypeFind.TypeFind
(MemorySegment address) Create a TypeFind proxy instance for the provided memory address.TypeFind
(TypeFind.PeekCallback peek, TypeFind.SuggestCallback suggest, MemorySegment data, TypeFind.GetLengthCallback getLength) Allocate a new TypeFind with the fields set to the provided values.TypeFind
(TypeFind.PeekCallback peek, TypeFind.SuggestCallback suggest, MemorySegment data, TypeFind.GetLengthCallback getLength, Arena arena) Allocate a new TypeFind with the fields set to the provided values. -
Method Summary
Modifier and TypeMethodDescriptionlong
Get the length of the data stream.static MemoryLayout
The memory layout of the native struct.static Type
getType()
Get the GType of the TypeFind classvoid
overrideGetLength
(TypeFind.GetLengthCallback getLength, Arena _arena) Write a value in the fieldget_length
.void
overridePeek
(TypeFind.PeekCallback peek, Arena _arena) Write a value in the fieldpeek
.void
overrideSuggest
(TypeFind.SuggestCallback suggest, Arena _arena) Write a value in the fieldsuggest
.peek
(long offset, int size) Returns thesize
bytes of the stream to identify beginning at offset.readData()
Read the value of the fielddata
.static boolean
register
(@Nullable Plugin plugin, String name, int rank, TypeFindFunction func, @Nullable String extensions, @Nullable Caps possibleCaps) Registers a new typefind function to be used for typefinding.void
If aGstTypeFindFunction
calls this function it suggests the caps with the given probability.void
suggestEmptySimple
(int probability, String mediaType) If aGstTypeFindFunction
calls this function it suggests caps of the givenmediaType
with the givenprobability
.void
suggestSimple
(int probability, String mediaType, @Nullable String fieldname, Object... varargs) If aGstTypeFindFunction
calls this function it suggests the caps with the given probability.void
writeData
(MemorySegment data) Write a value in the fielddata
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
TypeFind
Create a TypeFind proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
TypeFind
Allocate a new TypeFind.- Parameters:
arena
- to control the memory allocation scope
-
TypeFind
public TypeFind()Allocate a new TypeFind. The memory is allocated withArena.ofAuto()
. -
TypeFind
public TypeFind(TypeFind.PeekCallback peek, TypeFind.SuggestCallback suggest, MemorySegment data, TypeFind.GetLengthCallback getLength, Arena arena) Allocate a new TypeFind with the fields set to the provided values.- Parameters:
peek
- callback function for the fieldpeek
suggest
- callback function for the fieldsuggest
data
- value for the fielddata
getLength
- callback function for the fieldgetLength
arena
- to control the memory allocation scope
-
TypeFind
public TypeFind(TypeFind.PeekCallback peek, TypeFind.SuggestCallback suggest, MemorySegment data, TypeFind.GetLengthCallback getLength) Allocate a new TypeFind with the fields set to the provided values. The memory is allocated withArena.ofAuto()
.- Parameters:
peek
- callback function for the fieldpeek
suggest
- callback function for the fieldsuggest
data
- value for the fielddata
getLength
- callback function for the fieldgetLength
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
overridePeek
Write a value in the fieldpeek
.- Parameters:
peek
- The new value for the fieldpeek
_arena
- to control the memory allocation scope
-
overrideSuggest
Write a value in the fieldsuggest
.- Parameters:
suggest
- The new value for the fieldsuggest
_arena
- to control the memory allocation scope
-
readData
Read the value of the fielddata
.- Returns:
- The value of the field
data
-
writeData
Write a value in the fielddata
.- Parameters:
data
- The new value for the fielddata
-
overrideGetLength
Write a value in the fieldget_length
.- Parameters:
getLength
- The new value for the fieldget_length
_arena
- to control the memory allocation scope
-
register
public static boolean register(@Nullable @Nullable Plugin plugin, String name, int rank, TypeFindFunction func, @Nullable @Nullable String extensions, @Nullable @Nullable Caps possibleCaps) Registers a new typefind function to be used for typefinding. After registering this function will be available for typefinding. This function is typically called during an element's plugin initialization.- Parameters:
plugin
- AGstPlugin
, ornull
for a static typefind functionname
- The name for registeringrank
- The rank (or importance) of this typefind functionfunc
- TheGstTypeFindFunction
to useextensions
- Optional comma-separated list of extensions that could belong to this typepossibleCaps
- Optionally the caps that could be returned when typefinding succeeds- Returns:
true
on success,false
otherwise
-
getLength
public long getLength()Get the length of the data stream.- Returns:
- The length of the data stream, or 0 if it is not available.
-
peek
Returns thesize
bytes of the stream to identify beginning at offset. If offset is a positive number, the offset is relative to the beginning of the stream, if offset is a negative number the offset is relative to the end of the stream. The returned memory is valid until the typefinding function returns and must not be freed.- Parameters:
offset
- The offsetsize
- The number of bytes to return- Returns:
- the
requested data, or
null
if that data is not available.
-
suggest
If aGstTypeFindFunction
calls this function it suggests the caps with the given probability. AGstTypeFindFunction
may supply different suggestions in one call. It is up to the caller of theGstTypeFindFunction
to interpret these values.- Parameters:
probability
- The probability in percent that the suggestion is rightcaps
- The fixedGstCaps
to suggest
-
suggestEmptySimple
If aGstTypeFindFunction
calls this function it suggests caps of the givenmediaType
with the givenprobability
.This function is similar to gst_type_find_suggest_simple(), but uses a
GstCaps
with no fields.- Parameters:
probability
- The probability in percent that the suggestion is rightmediaType
- the media type of the suggested caps
-
suggestSimple
public void suggestSimple(int probability, String mediaType, @Nullable @Nullable String fieldname, Object... varargs) If aGstTypeFindFunction
calls this function it suggests the caps with the given probability. AGstTypeFindFunction
may supply different suggestions in one call. It is up to the caller of theGstTypeFindFunction
to interpret these values.This function is similar to gst_type_find_suggest(), only that instead of passing a
GstCaps
argument you can create the caps on the fly in the same way as you can with gst_caps_new_simple().Make sure you terminate the list of arguments with a
null
argument and that the values passed have the correct type (in terms of width in bytes when passed to the vararg function - this applies particularly to gdouble and guint64 arguments).- Parameters:
probability
- The probability in percent that the suggestion is rightmediaType
- the media type of the suggested capsfieldname
- first field of the suggested caps, ornull
varargs
- additional arguments to the suggested caps in the same format as the arguments passed to gst_structure_new() (ie. triplets of field name, field GType and field value). Iffieldname
isnull
, this list must be exactly onenull
.
-