Package org.freedesktop.gstreamer.base
Class BitReader
java.lang.Object
org.javagi.base.ProxyInstance
org.freedesktop.gstreamer.base.BitReader
- All Implemented Interfaces:
Proxy
GstBitReader provides a bit reader that can read any number of bits
from a memory buffer. It provides functions for reading any number of bits
into 8, 16, 32 and 64 bit variables.-
Constructor Summary
ConstructorsConstructorDescriptionAllocate a new BitReader.BitReader(byte[] data, int size, int byte_, int bit) Allocate a new BitReader with the fields set to the provided values.Allocate a new BitReader with the fields set to the provided values.Allocate a new BitReader.BitReader(MemorySegment address) Create a BitReader proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoidfree()Frees aGstBitReaderinstance, which was previously allocated by gst_bit_reader_new().booleangetBitsUint16(Out<Short> val, int nbits) Readnbitsbits intovaland update the current position.booleangetBitsUint32(Out<Integer> val, int nbits) Readnbitsbits intovaland update the current position.booleangetBitsUint64(Out<Long> val, int nbits) Readnbitsbits intovaland update the current position.booleangetBitsUint8(Out<Byte> val, int nbits) Readnbitsbits intovaland update the current position.static MemoryLayoutThe memory layout of the native struct.intgetPos()Returns the current position of aGstBitReaderinstance in bits.intReturns the remaining number of bits of aGstBitReaderinstance.intgetSize()Returns the total number of bits of aGstBitReaderinstance.voidinit(@org.jspecify.annotations.Nullable byte @Nullable [] data) Initializes aGstBitReaderinstance to read fromdata.This function can be called on already initialized instances.static BitReadernew_(@org.jspecify.annotations.Nullable byte @Nullable [] data) Create a newGstBitReaderinstance, which will read fromdata.booleanpeekBitsUint16(Out<Short> val, int nbits) Readnbitsbits intovalbut keep the current position.booleanpeekBitsUint32(Out<Integer> val, int nbits) Readnbitsbits intovalbut keep the current position.booleanpeekBitsUint64(Out<Long> val, int nbits) Readnbitsbits intovalbut keep the current position.booleanpeekBitsUint8(Out<Byte> val, int nbits) Readnbitsbits intovalbut keep the current position.intreadBit()Read the value of the fieldbit.intreadByte()Read the value of the fieldbyte.@org.jspecify.annotations.Nullable byte @Nullable []readData()Read the value of the fielddata.intreadSize()Read the value of the fieldsize.booleansetPos(int pos) Sets the new position of aGstBitReaderinstance toposin bits.booleanskip(int nbits) Skipsnbitsbits of theGstBitReaderinstance.booleanSkips until the next byte.voidwriteBit(int bit) Write a value in the fieldbit.voidwriteByte(int byte_) Write a value in the fieldbyte.voidWrite a value in the fielddata.voidwriteSize(int size) Write a value in the fieldsize.Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
BitReader
Create a BitReader proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
BitReader
Allocate a new BitReader.- Parameters:
arena- to control the memory allocation scope
-
BitReader
public BitReader()Allocate a new BitReader. The memory is allocated withArena.ofAuto(). -
BitReader
Allocate a new BitReader with the fields set to the provided values.- Parameters:
data- value for the fielddatasize- value for the fieldsizebyte_- value for the fieldbyte_bit- value for the fieldbitarena- to control the memory allocation scope
-
BitReader
public BitReader(byte[] data, int size, int byte_, int bit) Allocate a new BitReader with the fields set to the provided values. The memory is allocated withArena.ofAuto().- Parameters:
data- value for the fielddatasize- value for the fieldsizebyte_- value for the fieldbyte_bit- value for the fieldbit
-
-
Method Details
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readData
public @org.jspecify.annotations.Nullable byte @Nullable [] 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_arena- to control the memory allocation scope
-
readSize
public int readSize()Read the value of the fieldsize.- Returns:
- The value of the field
size
-
writeSize
public void writeSize(int size) Write a value in the fieldsize.- Parameters:
size- The new value for the fieldsize
-
readByte
public int readByte()Read the value of the fieldbyte.- Returns:
- The value of the field
byte
-
writeByte
public void writeByte(int byte_) Write a value in the fieldbyte.- Parameters:
byte_- The new value for the fieldbyte
-
readBit
public int readBit()Read the value of the fieldbit.- Returns:
- The value of the field
bit
-
writeBit
public void writeBit(int bit) Write a value in the fieldbit.- Parameters:
bit- The new value for the fieldbit
-
new_
Create a newGstBitReaderinstance, which will read fromdata.Free-function: gst_bit_reader_free
- Parameters:
data- Data from which theGstBitReadershould read- Returns:
- a new
GstBitReaderinstance
-
free
public void free()Frees aGstBitReaderinstance, which was previously allocated by gst_bit_reader_new(). -
getBitsUint16
-
getBitsUint32
-
getBitsUint64
-
getBitsUint8
-
getPos
public int getPos()Returns the current position of aGstBitReaderinstance in bits.- Returns:
- The current position of this BitReader in bits.
-
getRemaining
public int getRemaining()Returns the remaining number of bits of aGstBitReaderinstance.- Returns:
- The remaining number of bits of this BitReader instance.
-
getSize
public int getSize()Returns the total number of bits of aGstBitReaderinstance.- Returns:
- The total number of bits of this BitReader instance.
-
init
public void init(@org.jspecify.annotations.Nullable byte @Nullable [] data) Initializes aGstBitReaderinstance to read fromdata.This function can be called on already initialized instances.- Parameters:
data- data from which the bit reader should read
-
peekBitsUint16
-
peekBitsUint32
-
peekBitsUint64
-
peekBitsUint8
-
setPos
public boolean setPos(int pos) Sets the new position of aGstBitReaderinstance toposin bits.- Parameters:
pos- The new position in bits- Returns:
trueif the position could be set successfully,falseotherwise.
-
skip
public boolean skip(int nbits) Skipsnbitsbits of theGstBitReaderinstance.- Parameters:
nbits- the number of bits to skip- Returns:
trueifnbitsbits could be skipped,falseotherwise.
-
skipToByte
public boolean skipToByte()Skips until the next byte.- Returns:
trueif successful,falseotherwise.
-