Package org.freedesktop.gstreamer.base
Class BitReader
java.lang.Object
io.github.jwharm.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
ConstructorDescriptionAllocate 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 TypeMethodDescriptionvoid
free()
Frees aGstBitReader
instance, which was previously allocated by gst_bit_reader_new().boolean
getBitsUint16
(Out<Short> val, int nbits) Readnbits
bits intoval
and update the current position.boolean
getBitsUint32
(Out<Integer> val, int nbits) Readnbits
bits intoval
and update the current position.boolean
getBitsUint64
(Out<Long> val, int nbits) Readnbits
bits intoval
and update the current position.boolean
getBitsUint8
(Out<Byte> val, int nbits) Readnbits
bits intoval
and update the current position.static MemoryLayout
The memory layout of the native struct.int
getPos()
Returns the current position of aGstBitReader
instance in bits.int
Returns the remaining number of bits of aGstBitReader
instance.int
getSize()
Returns the total number of bits of aGstBitReader
instance.void
init
(byte[] data) Initializes aGstBitReader
instance to read fromdata
.static BitReader
new_
(byte[] data) Create a newGstBitReader
instance, which will read fromdata
.boolean
peekBitsUint16
(Out<Short> val, int nbits) Readnbits
bits intoval
but keep the current position.boolean
peekBitsUint32
(Out<Integer> val, int nbits) Readnbits
bits intoval
but keep the current position.boolean
peekBitsUint64
(Out<Long> val, int nbits) Readnbits
bits intoval
but keep the current position.boolean
peekBitsUint8
(Out<Byte> val, int nbits) Readnbits
bits intoval
but keep the current position.int
readBit()
Read the value of the fieldbit
.int
readByte()
Read the value of the fieldbyte
.byte[]
readData()
Read the value of the fielddata
.int
readSize()
Read the value of the fieldsize
.boolean
setPos
(int pos) Sets the new position of aGstBitReader
instance topos
in bits.boolean
skip
(int nbits) Skipsnbits
bits of theGstBitReader
instance.boolean
Skips until the next byte.void
writeBit
(int bit) Write a value in the fieldbit
.void
writeByte
(int byte_) Write a value in the fieldbyte
.void
Write a value in the fielddata
.void
writeSize
(int size) Write a value in the fieldsize
.Methods inherited from class io.github.jwharm.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 fielddata
size
- value for the fieldsize
byte_
- value for the fieldbyte_
bit
- value for the fieldbit
arena
- 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 fielddata
size
- value for the fieldsize
byte_
- 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 byte[] 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 newGstBitReader
instance, which will read fromdata
.Free-function: gst_bit_reader_free
- Parameters:
data
- Data from which theGstBitReader
should read- Returns:
- a new
GstBitReader
instance
-
free
public void free()Frees aGstBitReader
instance, which was previously allocated by gst_bit_reader_new(). -
getBitsUint16
-
getBitsUint32
-
getBitsUint64
-
getBitsUint8
-
getPos
public int getPos()Returns the current position of aGstBitReader
instance in bits.- Returns:
- The current position of this BitReader in bits.
-
getRemaining
public int getRemaining()Returns the remaining number of bits of aGstBitReader
instance.- Returns:
- The remaining number of bits of this BitReader instance.
-
getSize
public int getSize()Returns the total number of bits of aGstBitReader
instance.- Returns:
- The total number of bits of this BitReader instance.
-
init
public void init(byte[] data) Initializes aGstBitReader
instance 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 aGstBitReader
instance topos
in bits.- Parameters:
pos
- The new position in bits- Returns:
true
if the position could be set successfully,false
otherwise.
-
skip
public boolean skip(int nbits) Skipsnbits
bits of theGstBitReader
instance.- Parameters:
nbits
- the number of bits to skip- Returns:
true
ifnbits
bits could be skipped,false
otherwise.
-
skipToByte
public boolean skipToByte()Skips until the next byte.- Returns:
true
if successful,false
otherwise.
-