Class BitWriter

java.lang.Object
org.javagi.base.ProxyInstance
org.freedesktop.gstreamer.base.BitWriter
All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class BitWriter extends ProxyInstance
GstBitWriter provides a bit writer that can write any number of bits into a memory buffer. It provides functions for writing any number of bits into 8, 16, 32 and 64 bit variables.
Since:
1.16
  • Constructor Summary

    Constructors
    Constructor
    Description
    Allocate a new BitWriter.
    Allocate a new BitWriter.
    Create a BitWriter proxy instance for the provided memory address.
    BitWriter(MemorySegment data, int bitSize, int bitCapacity, boolean autoGrow, boolean owned)
    Allocate a new BitWriter with the fields set to the provided values.
    BitWriter(MemorySegment data, int bitSize, int bitCapacity, boolean autoGrow, boolean owned, Arena arena)
    Allocate a new BitWriter with the fields set to the provided values.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    alignBytes(byte trailingBit)
    Write trailing bit to align last byte of data. trailingBit can only be 1 or 0.
    void
    Frees this BitWriter and the allocated data inside.
    Frees this BitWriter without destroying the internal data, which is returned as GstBuffer.
    byte[]
    Frees this BitWriter without destroying the internal data, which is returned.
    byte[]
    Get written data pointer
    The memory layout of the native struct.
    int
     
    int
    Get size of written data
    void
    Initializes this BitWriter to an empty instance.
    void
    initWithData(@Nullable byte @Nullable [] data, boolean initialized)
    Initializes this BitWriter with the given memory area data. IF initialized is true it is possible to read size bits from the GstBitWriter from the beginning.
    void
    initWithSize(int size, boolean fixed)
    Initializes a GstBitWriter instance and allocates the given data size.
    static BitWriter
    Creates a new, empty GstBitWriter instance.
    static BitWriter
    newWithData(@Nullable byte @Nullable [] data, boolean initialized)
    Creates a new GstBitWriter instance with the given memory area.
    static BitWriter
    newWithSize(int size, boolean fixed)
    Creates a GstBitWriter instance with the given initial data size.
    boolean
    putBitsUint16(short value, int nbits)
    Write nbits bits of value to GstBitWriter.
    boolean
    putBitsUint32(int value, int nbits)
    Write nbits bits of value to GstBitWriter.
    boolean
    putBitsUint64(long value, int nbits)
    Write nbits bits of value to GstBitWriter.
    boolean
    putBitsUint8(byte value, int nbits)
    Write nbits bits of value to GstBitWriter.
    boolean
    putBytes(@Nullable byte @Nullable [] data, int nbytes)
    Write nbytes bytes of data to GstBitWriter.
    boolean
    Read the value of the field auto_grow.
    int
    Read the value of the field bit_capacity.
    int
    Read the value of the field bit_size.
    Read the value of the field data.
    boolean
    Read the value of the field owned.
    void
    Resets this BitWriter and frees the data if it's owned by bitwriter.
    Resets this BitWriter and returns the current data as GstBuffer.
    byte[]
    Resets this BitWriter and returns the current data.
    boolean
    setPos(int pos)
     
    void
    writeAutoGrow(boolean autoGrow)
    Write a value in the field auto_grow.
    void
    writeBitCapacity(int bitCapacity)
    Write a value in the field bit_capacity.
    void
    writeBitSize(int bitSize)
    Write a value in the field bit_size.
    void
    Write a value in the field data.
    void
    writeOwned(boolean owned)
    Write a value in the field owned.

    Methods inherited from class ProxyInstance

    equals, handle, hashCode

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BitWriter

      public BitWriter(MemorySegment address)
      Create a BitWriter proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • BitWriter

      public BitWriter(Arena arena)
      Allocate a new BitWriter.
      Parameters:
      arena - to control the memory allocation scope
    • BitWriter

      public BitWriter()
      Allocate a new BitWriter. The memory is allocated with Arena.ofAuto().
    • BitWriter

      public BitWriter(MemorySegment data, int bitSize, int bitCapacity, boolean autoGrow, boolean owned, Arena arena)
      Allocate a new BitWriter with the fields set to the provided values.
      Parameters:
      data - value for the field data
      bitSize - value for the field bitSize
      bitCapacity - value for the field bitCapacity
      autoGrow - value for the field autoGrow
      owned - value for the field owned
      arena - to control the memory allocation scope
    • BitWriter

      public BitWriter(MemorySegment data, int bitSize, int bitCapacity, boolean autoGrow, boolean owned)
      Allocate a new BitWriter with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      data - value for the field data
      bitSize - value for the field bitSize
      bitCapacity - value for the field bitCapacity
      autoGrow - value for the field autoGrow
      owned - value for the field owned
  • Method Details

    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readData

      public MemorySegment readData()
      Read the value of the field data.
      Returns:
      The value of the field data
    • writeData

      public void writeData(MemorySegment data)
      Write a value in the field data.
      Parameters:
      data - The new value for the field data
    • readBitSize

      public int readBitSize()
      Read the value of the field bit_size.
      Returns:
      The value of the field bit_size
    • writeBitSize

      public void writeBitSize(int bitSize)
      Write a value in the field bit_size.
      Parameters:
      bitSize - The new value for the field bit_size
    • readBitCapacity

      public int readBitCapacity()
      Read the value of the field bit_capacity.
      Returns:
      The value of the field bit_capacity
    • writeBitCapacity

      public void writeBitCapacity(int bitCapacity)
      Write a value in the field bit_capacity.
      Parameters:
      bitCapacity - The new value for the field bit_capacity
    • readAutoGrow

      public boolean readAutoGrow()
      Read the value of the field auto_grow.
      Returns:
      The value of the field auto_grow
    • writeAutoGrow

      public void writeAutoGrow(boolean autoGrow)
      Write a value in the field auto_grow.
      Parameters:
      autoGrow - The new value for the field auto_grow
    • readOwned

      public boolean readOwned()
      Read the value of the field owned.
      Returns:
      The value of the field owned
    • writeOwned

      public void writeOwned(boolean owned)
      Write a value in the field owned.
      Parameters:
      owned - The new value for the field owned
    • new_

      public static BitWriter new_()

      Creates a new, empty GstBitWriter instance.

      Free-function: gst_bit_writer_free

      Returns:
      a new, empty GstByteWriter instance
    • newWithData

      public static BitWriter newWithData(@Nullable byte @Nullable [] data, boolean initialized)

      Creates a new GstBitWriter instance with the given memory area. If initialized is true it is possible to read size bits from the GstBitWriter from the beginning.

      Free-function: gst_bit_writer_free

      Parameters:
      data - Memory area for writing
      initialized - if true the complete data can be read from the beginning
      Returns:
      a new GstBitWriter instance
    • newWithSize

      public static BitWriter newWithSize(int size, boolean fixed)

      Creates a GstBitWriter instance with the given initial data size.

      Free-function: gst_bit_writer_free

      Parameters:
      size - Initial size of data in bytes
      fixed - If true the data can't be reallocated
      Returns:
      a new GstBitWriter instance
    • alignBytes

      public boolean alignBytes(byte trailingBit)
      Write trailing bit to align last byte of data. trailingBit can only be 1 or 0.
      Parameters:
      trailingBit - trailing bits of last byte, 0 or 1
      Returns:
      true if successful, false otherwise.
    • free

      public void free()
      Frees this BitWriter and the allocated data inside.
    • freeAndGetBuffer

      public Buffer freeAndGetBuffer()

      Frees this BitWriter without destroying the internal data, which is returned as GstBuffer.

      Free-function: gst_buffer_unref

      Returns:
      a new allocated GstBuffer wrapping the data inside. gst_buffer_unref() after usage.
    • freeAndGetData

      public byte[] freeAndGetData()

      Frees this BitWriter without destroying the internal data, which is returned.

      Free-function: g_free

      Returns:
      the current data. g_free() after usage.
    • getData

      public byte[] getData()
      Get written data pointer
      Returns:
      data pointer
    • getRemaining

      public int getRemaining()
    • getSize

      public int getSize()
      Get size of written data
      Returns:
      size of bits written in data
    • init

      public void init()
      Initializes this BitWriter to an empty instance.
    • initWithData

      public void initWithData(@Nullable byte @Nullable [] data, boolean initialized)
      Initializes this BitWriter with the given memory area data. IF initialized is true it is possible to read size bits from the GstBitWriter from the beginning.
      Parameters:
      data - Memory area for writing
      initialized - If true the complete data can be read from the beginning
    • initWithSize

      public void initWithSize(int size, boolean fixed)
      Initializes a GstBitWriter instance and allocates the given data size.
      Parameters:
      size - the size on bytes to allocate for data
      fixed - If true the data can't be reallocated
    • putBitsUint16

      public boolean putBitsUint16(short value, int nbits)
      Write nbits bits of value to GstBitWriter.
      Parameters:
      value - value of guint16 to write
      nbits - number of bits to write
      Returns:
      true if successful, false otherwise.
    • putBitsUint32

      public boolean putBitsUint32(int value, int nbits)
      Write nbits bits of value to GstBitWriter.
      Parameters:
      value - value of guint32 to write
      nbits - number of bits to write
      Returns:
      true if successful, false otherwise.
    • putBitsUint64

      public boolean putBitsUint64(long value, int nbits)
      Write nbits bits of value to GstBitWriter.
      Parameters:
      value - value of guint64 to write
      nbits - number of bits to write
      Returns:
      true if successful, false otherwise.
    • putBitsUint8

      public boolean putBitsUint8(byte value, int nbits)
      Write nbits bits of value to GstBitWriter.
      Parameters:
      value - value of guint8 to write
      nbits - number of bits to write
      Returns:
      true if successful, false otherwise.
    • putBytes

      public boolean putBytes(@Nullable byte @Nullable [] data, int nbytes)
      Write nbytes bytes of data to GstBitWriter.
      Parameters:
      data - pointer of data to write
      nbytes - number of bytes to write
      Returns:
      true if successful, false otherwise.
    • reset

      public void reset()
      Resets this BitWriter and frees the data if it's owned by bitwriter.
    • resetAndGetBuffer

      public Buffer resetAndGetBuffer()

      Resets this BitWriter and returns the current data as GstBuffer.

      Free-function: gst_buffer_unref

      Returns:
      a new allocated GstBuffer wrapping the current data. gst_buffer_unref() after usage.
    • resetAndGetData

      public byte[] resetAndGetData()

      Resets this BitWriter and returns the current data.

      Free-function: g_free

      Returns:
      the current data. g_free() after usage.
    • setPos

      public boolean setPos(int pos)