GstBase.ByteWriter

Fields

Name

Type

Access

Description

alloc_size

int

r/w

Allocation size of the data

fixed

bool

r/w

If True no reallocations are allowed

owned

bool

r/w

If False no reallocations are allowed and copies of data are returned

parent

GstBase.ByteReader

r/w

GstBase.ByteReader parent

Methods

ensure_free_space (size)

fill (value, size)

free ()

free_and_get_buffer ()

free_and_get_data ()

get_remaining ()

init ()

init_with_data (data, initialized)

init_with_size (size, fixed)

put_buffer (buffer, offset, size)

put_data (data)

put_float32_be (val)

put_float32_le (val)

put_float64_be (val)

put_float64_le (val)

put_int16_be (val)

put_int16_le (val)

put_int24_be (val)

put_int24_le (val)

put_int32_be (val)

put_int32_le (val)

put_int64_be (val)

put_int64_le (val)

put_int8 (val)

put_string_utf16 (data)

put_string_utf32 (data)

put_string_utf8 (data)

put_uint16_be (val)

put_uint16_le (val)

put_uint24_be (val)

put_uint24_le (val)

put_uint32_be (val)

put_uint32_le (val)

put_uint64_be (val)

put_uint64_le (val)

put_uint8 (val)

reset ()

reset_and_get_buffer ()

reset_and_get_data ()

Details

class GstBase.ByteWriter

GstBase.ByteWriter 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.

ensure_free_space(size)[source]
Parameters:

size (int) – Number of bytes that should be available

Returns:

True if at least size bytes are still available

Return type:

bool

Checks if enough free space from the current write cursor is available and reallocates if necessary.

fill(value, size)[source]
Parameters:
  • value (int) – Value to be written

  • size (int) – Number of bytes to be written

Returns:

True if the value could be written

Return type:

bool

Writes size bytes containing value to self.

free()[source]

Frees self and all memory allocated by it.

free_and_get_buffer()[source]
Returns:

the current data as buffer. gst_buffer_unref() after usage.

Return type:

Gst.Buffer

Frees self and all memory allocated by it except the current data, which is returned as Gst.Buffer.

Free-function: gst_buffer_unref

free_and_get_data()[source]
Returns:

the current data. GLib.free() after usage.

Return type:

int

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

Free-function: GLib.free

get_remaining()[source]
Returns:

the remaining size of data that can still be written

Return type:

int

Returns the remaining size of data that can still be written. If -1 is returned the remaining size is only limited by system resources.

init()[source]

Initializes self to an empty instance

init_with_data(data, initialized)[source]
Parameters:
  • data (bytes) – Memory area for writing

  • initialized (bool) – If True the complete data can be read from the beginning

Initializes self with the given memory area. If initialized is True it is possible to read size bytes from the GstBase.ByteWriter from the beginning.

init_with_size(size, fixed)[source]
Parameters:
  • size (int) – Initial size of data

  • fixed (bool) – If True the data can’t be reallocated

Initializes self with the given initial data size.

put_buffer(buffer, offset, size)
Parameters:
  • buffer (Gst.Buffer) – source Gst.Buffer

  • offset (int) – offset to copy from

  • size (int) – total size to copy. If -1, all data is copied

Returns:

True if the data could be written

Return type:

bool

Writes size bytes of data to self.

put_data(data)[source]
Parameters:

data (bytes) – Data to write

Returns:

True if the value could be written

Return type:

bool

Writes size bytes of data to self.

put_float32_be(val)[source]
Parameters:

val (float) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a big endian 32 bit float to self.

put_float32_le(val)[source]
Parameters:

val (float) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a little endian 32 bit float to self.

put_float64_be(val)[source]
Parameters:

val (float) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a big endian 64 bit float to self.

put_float64_le(val)[source]
Parameters:

val (float) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a little endian 64 bit float to self.

put_int16_be(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a signed big endian 16 bit integer to self.

put_int16_le(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a signed little endian 16 bit integer to self.

put_int24_be(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a signed big endian 24 bit integer to self.

put_int24_le(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a signed little endian 24 bit integer to self.

put_int32_be(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a signed big endian 32 bit integer to self.

put_int32_le(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a signed little endian 32 bit integer to self.

put_int64_be(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a signed big endian 64 bit integer to self.

put_int64_le(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a signed little endian 64 bit integer to self.

put_int8(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a signed 8 bit integer to self.

put_string_utf16(data)[source]
Parameters:

data ([int]) – UTF16 string to write

Returns:

True if the value could be written

Return type:

bool

Writes a NUL-terminated UTF16 string to self (including the terminator).

put_string_utf32(data)[source]
Parameters:

data ([int]) – UTF32 string to write

Returns:

True if the value could be written

Return type:

bool

Writes a NUL-terminated UTF32 string to self (including the terminator).

put_string_utf8(data)[source]
Parameters:

data (str) – UTF8 string to write

Returns:

True if the value could be written

Return type:

bool

Writes a NUL-terminated UTF8 string to self (including the terminator).

put_uint16_be(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a unsigned big endian 16 bit integer to self.

put_uint16_le(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a unsigned little endian 16 bit integer to self.

put_uint24_be(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a unsigned big endian 24 bit integer to self.

put_uint24_le(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a unsigned little endian 24 bit integer to self.

put_uint32_be(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a unsigned big endian 32 bit integer to self.

put_uint32_le(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a unsigned little endian 32 bit integer to self.

put_uint64_be(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a unsigned big endian 64 bit integer to self.

put_uint64_le(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a unsigned little endian 64 bit integer to self.

put_uint8(val)[source]
Parameters:

val (int) – Value to write

Returns:

True if the value could be written

Return type:

bool

Writes a unsigned 8 bit integer to self.

reset()[source]

Resets self and frees the data if it’s owned by self.

reset_and_get_buffer()[source]
Returns:

the current data as buffer. gst_buffer_unref() after usage.

Return type:

Gst.Buffer

Resets self and returns the current data as buffer.

Free-function: gst_buffer_unref

reset_and_get_data()[source]
Returns:

the current data. GLib.free() after usage.

Return type:

bytes

Resets self and returns the current data.

Free-function: GLib.free