Class ByteWriter

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

@Generated("org.javagi.JavaGI") public class ByteWriter extends ProxyInstance
GstByteWriter provides a byte writer and reader that can write/read different integer and floating point types to/from a memory buffer. It provides functions for writing/reading signed/unsigned, little/big endian integers of 8, 16, 24, 32 and 64 bits and functions for reading little/big endian floating points numbers of 32 and 64 bits. It also provides functions to write/read NUL-terminated strings in various character encodings.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Allocate a new ByteWriter.
    Allocate a new ByteWriter.
    Create a ByteWriter proxy instance for the provided memory address.
    ByteWriter(ByteReader parent, int allocSize, boolean fixed, boolean owned)
    Allocate a new ByteWriter with the fields set to the provided values.
    ByteWriter(ByteReader parent, int allocSize, boolean fixed, boolean owned, Arena arena)
    Allocate a new ByteWriter with the fields set to the provided values.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    ensureFreeSpace(int size)
    Checks if enough free space from the current write cursor is available and reallocates if necessary.
    boolean
    fill(byte value, int size)
    Writes size bytes containing value to writer.
    void
    Frees this ByteWriter and all memory allocated by it.
    Frees this ByteWriter and all memory allocated by it except the current data, which is returned as GstBuffer.
    Frees this ByteWriter and all memory allocated by it except the current data, which is returned.
    The memory layout of the native struct.
    int
    Returns the remaining size of data that can still be written.
    void
    Initializes this ByteWriter to an empty instance
    void
    initWithData(@Nullable byte @Nullable [] data, boolean initialized)
    Initializes this ByteWriter with the given memory area.
    void
    initWithSize(int size, boolean fixed)
    Initializes this ByteWriter with the given initial data size.
    static ByteWriter
    Creates a new, empty GstByteWriter instance
    static ByteWriter
    newWithData(MemorySegment data, int size, boolean initialized)
    Creates a new GstByteWriter instance with the given memory area.
    static ByteWriter
    newWithSize(int size, boolean fixed)
    Creates a new GstByteWriter instance with the given initial data size.
    boolean
    putBuffer(Buffer buffer, long offset, long size)
    Writes size bytes of data to writer.
    boolean
    putData(@Nullable byte @Nullable [] data)
    Writes size bytes of data to writer.
    boolean
    putFloat32Be(float val)
    Writes a big endian 32 bit float to writer.
    boolean
    putFloat32Le(float val)
    Writes a little endian 32 bit float to writer.
    boolean
    putFloat64Be(double val)
    Writes a big endian 64 bit float to writer.
    boolean
    putFloat64Le(double val)
    Writes a little endian 64 bit float to writer.
    boolean
    putInt16Be(short val)
    Writes a signed big endian 16 bit integer to writer.
    boolean
    putInt16Le(short val)
    Writes a signed little endian 16 bit integer to writer.
    boolean
    putInt24Be(int val)
    Writes a signed big endian 24 bit integer to writer.
    boolean
    putInt24Le(int val)
    Writes a signed little endian 24 bit integer to writer.
    boolean
    putInt32Be(int val)
    Writes a signed big endian 32 bit integer to writer.
    boolean
    putInt32Le(int val)
    Writes a signed little endian 32 bit integer to writer.
    boolean
    putInt64Be(long val)
    Writes a signed big endian 64 bit integer to writer.
    boolean
    putInt64Le(long val)
    Writes a signed little endian 64 bit integer to writer.
    boolean
    putInt8(byte val)
    Writes a signed 8 bit integer to writer.
    boolean
    putStringUtf16(@Nullable short @Nullable [] data)
    Writes a NUL-terminated UTF16 string to this ByteWriter (including the terminator).
    boolean
    putStringUtf32(@Nullable int @Nullable [] data)
    Writes a NUL-terminated UTF32 string to this ByteWriter (including the terminator).
    boolean
    Writes a NUL-terminated UTF8 string to this ByteWriter (including the terminator).
    boolean
    putUint16Be(short val)
    Writes a unsigned big endian 16 bit integer to writer.
    boolean
    putUint16Le(short val)
    Writes a unsigned little endian 16 bit integer to writer.
    boolean
    putUint24Be(int val)
    Writes a unsigned big endian 24 bit integer to writer.
    boolean
    putUint24Le(int val)
    Writes a unsigned little endian 24 bit integer to writer.
    boolean
    putUint32Be(int val)
    Writes a unsigned big endian 32 bit integer to writer.
    boolean
    putUint32Le(int val)
    Writes a unsigned little endian 32 bit integer to writer.
    boolean
    putUint64Be(long val)
    Writes a unsigned big endian 64 bit integer to writer.
    boolean
    putUint64Le(long val)
    Writes a unsigned little endian 64 bit integer to writer.
    boolean
    putUint8(byte val)
    Writes a unsigned 8 bit integer to writer.
    int
    Read the value of the field alloc_size.
    boolean
    Read the value of the field fixed.
    boolean
    Read the value of the field owned.
    @Nullable ByteReader
    Read the value of the field parent.
    void
    Resets this ByteWriter and frees the data if it's owned by writer.
    Resets this ByteWriter and returns the current data as buffer.
    byte[]
    Resets this ByteWriter and returns the current data.
    void
    writeAllocSize(int allocSize)
    Write a value in the field alloc_size.
    void
    writeFixed(boolean fixed)
    Write a value in the field fixed.
    void
    writeOwned(boolean owned)
    Write a value in the field owned.
    void
    writeParent(@Nullable ByteReader parent)
    Write a value in the field parent.

    Methods inherited from class ProxyInstance

    equals, handle, hashCode

    Methods inherited from class Object

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

    • ByteWriter

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

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

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

      public ByteWriter(ByteReader parent, int allocSize, boolean fixed, boolean owned, Arena arena)
      Allocate a new ByteWriter with the fields set to the provided values.
      Parameters:
      parent - value for the field parent
      allocSize - value for the field allocSize
      fixed - value for the field fixed
      owned - value for the field owned
      arena - to control the memory allocation scope
    • ByteWriter

      public ByteWriter(ByteReader parent, int allocSize, boolean fixed, boolean owned)
      Allocate a new ByteWriter with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      parent - value for the field parent
      allocSize - value for the field allocSize
      fixed - value for the field fixed
      owned - value for the field owned
  • Method Details

    • getMemoryLayout

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

      public @Nullable ByteReader readParent()
      Read the value of the field parent.
      Returns:
      The value of the field parent
    • writeParent

      public void writeParent(@Nullable ByteReader parent)
      Write a value in the field parent.
      Parameters:
      parent - The new value for the field parent
    • readAllocSize

      public int readAllocSize()
      Read the value of the field alloc_size.
      Returns:
      The value of the field alloc_size
    • writeAllocSize

      public void writeAllocSize(int allocSize)
      Write a value in the field alloc_size.
      Parameters:
      allocSize - The new value for the field alloc_size
    • readFixed

      public boolean readFixed()
      Read the value of the field fixed.
      Returns:
      The value of the field fixed
    • writeFixed

      public void writeFixed(boolean fixed)
      Write a value in the field fixed.
      Parameters:
      fixed - The new value for the field fixed
    • 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 ByteWriter new_()

      Creates a new, empty GstByteWriter instance

      Free-function: gst_byte_writer_free

      Returns:
      a new, empty GstByteWriter instance
    • newWithData

      public static ByteWriter newWithData(MemorySegment data, int size, boolean initialized)

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

      Free-function: gst_byte_writer_free

      Parameters:
      data - Memory area for writing
      size - Size of data in bytes
      initialized - If true the complete data can be read from the beginning
      Returns:
      a new GstByteWriter instance
    • newWithSize

      public static ByteWriter newWithSize(int size, boolean fixed)

      Creates a new GstByteWriter instance with the given initial data size.

      Free-function: gst_byte_writer_free

      Parameters:
      size - Initial size of data
      fixed - If true the data can't be reallocated
      Returns:
      a new GstByteWriter instance
    • ensureFreeSpace

      public boolean ensureFreeSpace(int size)
      Checks if enough free space from the current write cursor is available and reallocates if necessary.
      Parameters:
      size - Number of bytes that should be available
      Returns:
      true if at least size bytes are still available
    • fill

      public boolean fill(byte value, int size)
      Writes size bytes containing value to writer.
      Parameters:
      value - Value to be written
      size - Number of bytes to be written
      Returns:
      true if the value could be written
    • free

      public void free()
      Frees this ByteWriter and all memory allocated by it.
    • freeAndGetBuffer

      public Buffer freeAndGetBuffer()

      Frees this ByteWriter and all memory allocated by it except the current data, which is returned as GstBuffer.

      Free-function: gst_buffer_unref

      Returns:
      the current data as buffer. gst_buffer_unref() after usage.
    • freeAndGetData

      public MemorySegment freeAndGetData()

      Frees this ByteWriter and all memory allocated by it except the current data, which is returned.

      Free-function: g_free

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

      public int getRemaining()
      Returns the remaining size of data that can still be written. If -1 is returned the remaining size is only limited by system resources.
      Returns:
      the remaining size of data that can still be written
    • init

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

      public void initWithData(@Nullable byte @Nullable [] data, boolean initialized)
      Initializes this ByteWriter with the given memory area. If initialized is true it is possible to read size bytes from the GstByteWriter 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 this ByteWriter with the given initial data size.
      Parameters:
      size - Initial size of data
      fixed - If true the data can't be reallocated
    • putBuffer

      public boolean putBuffer(Buffer buffer, long offset, long size)
      Writes size bytes of data to writer.
      Parameters:
      buffer - source GstBuffer
      offset - offset to copy from
      size - total size to copy. If -1, all data is copied
      Returns:
      true if the data could be written
    • putData

      public boolean putData(@Nullable byte @Nullable [] data)
      Writes size bytes of data to writer.
      Parameters:
      data - Data to write
      Returns:
      true if the value could be written
    • putFloat32Be

      public boolean putFloat32Be(float val)
      Writes a big endian 32 bit float to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putFloat32Le

      public boolean putFloat32Le(float val)
      Writes a little endian 32 bit float to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putFloat64Be

      public boolean putFloat64Be(double val)
      Writes a big endian 64 bit float to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putFloat64Le

      public boolean putFloat64Le(double val)
      Writes a little endian 64 bit float to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putInt16Be

      public boolean putInt16Be(short val)
      Writes a signed big endian 16 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putInt16Le

      public boolean putInt16Le(short val)
      Writes a signed little endian 16 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putInt24Be

      public boolean putInt24Be(int val)
      Writes a signed big endian 24 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putInt24Le

      public boolean putInt24Le(int val)
      Writes a signed little endian 24 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putInt32Be

      public boolean putInt32Be(int val)
      Writes a signed big endian 32 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putInt32Le

      public boolean putInt32Le(int val)
      Writes a signed little endian 32 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putInt64Be

      public boolean putInt64Be(long val)
      Writes a signed big endian 64 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putInt64Le

      public boolean putInt64Le(long val)
      Writes a signed little endian 64 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putInt8

      public boolean putInt8(byte val)
      Writes a signed 8 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putStringUtf16

      public boolean putStringUtf16(@Nullable short @Nullable [] data)
      Writes a NUL-terminated UTF16 string to this ByteWriter (including the terminator).
      Parameters:
      data - UTF16 string to write
      Returns:
      true if the value could be written
    • putStringUtf32

      public boolean putStringUtf32(@Nullable int @Nullable [] data)
      Writes a NUL-terminated UTF32 string to this ByteWriter (including the terminator).
      Parameters:
      data - UTF32 string to write
      Returns:
      true if the value could be written
    • putStringUtf8

      public boolean putStringUtf8(String data)
      Writes a NUL-terminated UTF8 string to this ByteWriter (including the terminator).
      Parameters:
      data - UTF8 string to write
      Returns:
      true if the value could be written
    • putUint16Be

      public boolean putUint16Be(short val)
      Writes a unsigned big endian 16 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putUint16Le

      public boolean putUint16Le(short val)
      Writes a unsigned little endian 16 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putUint24Be

      public boolean putUint24Be(int val)
      Writes a unsigned big endian 24 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putUint24Le

      public boolean putUint24Le(int val)
      Writes a unsigned little endian 24 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putUint32Be

      public boolean putUint32Be(int val)
      Writes a unsigned big endian 32 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putUint32Le

      public boolean putUint32Le(int val)
      Writes a unsigned little endian 32 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putUint64Be

      public boolean putUint64Be(long val)
      Writes a unsigned big endian 64 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putUint64Le

      public boolean putUint64Le(long val)
      Writes a unsigned little endian 64 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • putUint8

      public boolean putUint8(byte val)
      Writes a unsigned 8 bit integer to writer.
      Parameters:
      val - Value to write
      Returns:
      true if the value could be written
    • reset

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

      public Buffer resetAndGetBuffer()

      Resets this ByteWriter and returns the current data as buffer.

      Free-function: gst_buffer_unref

      Returns:
      the current data as buffer. gst_buffer_unref() after usage.
    • resetAndGetData

      public byte[] resetAndGetData()

      Resets this ByteWriter and returns the current data.

      Free-function: g_free

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