:right-sidebar: True ByteWriter =================================================================== .. currentmodule:: gi.repository.GstBase .. class:: ByteWriter(*args, **kwargs) :no-contents-entry: :obj:`~gi.repository.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. Methods ------- .. rst-class:: interim-class .. class:: ByteWriter :no-index: .. method:: ensure_free_space(size: int) -> bool Checks if enough free space from the current write cursor is available and reallocates if necessary. :param size: Number of bytes that should be available .. method:: fill(value: int, size: int) -> bool Writes ``size`` bytes containing ``value`` to ``writer``\. :param value: Value to be written :param size: Number of bytes to be written .. method:: free() -> None Frees ``writer`` and all memory allocated by it. .. method:: free_and_get_buffer() -> ~gi.repository.Gst.Buffer Frees ``writer`` and all memory allocated by it except the current data, which is returned as :obj:`~gi.repository.Gst.Buffer`\. Free-function: gst_buffer_unref .. method:: free_and_get_data() -> int Frees ``writer`` and all memory allocated by it except the current data, which is returned. Free-function: g_free .. method:: get_remaining() -> 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. .. method:: init() -> None Initializes ``writer`` to an empty instance .. method:: init_with_data(data: list[int], initialized: bool) -> None Initializes ``writer`` with the given memory area. If ``initialized`` is :const:`True` it is possible to read ``size`` bytes from the :obj:`~gi.repository.GstBase.ByteWriter` from the beginning. :param data: Memory area for writing :param initialized: If :const:`True` the complete data can be read from the beginning .. method:: init_with_size(size: int, fixed: bool) -> None Initializes ``writer`` with the given initial data size. :param size: Initial size of data :param fixed: If :const:`True` the data can't be reallocated .. method:: put_buffer(buffer: ~gi.repository.Gst.Buffer, offset: int, size: int) -> bool Writes ``size`` bytes of ``data`` to ``writer``\. :param buffer: source :obj:`~gi.repository.Gst.Buffer` :param offset: offset to copy from :param size: total size to copy. If -1, all data is copied .. method:: put_data(data: list[int]) -> bool Writes ``size`` bytes of ``data`` to ``writer``\. :param data: Data to write .. method:: put_float32_be(val: float) -> bool Writes a big endian 32 bit float to ``writer``\. :param val: Value to write .. method:: put_float32_le(val: float) -> bool Writes a little endian 32 bit float to ``writer``\. :param val: Value to write .. method:: put_float64_be(val: float) -> bool Writes a big endian 64 bit float to ``writer``\. :param val: Value to write .. method:: put_float64_le(val: float) -> bool Writes a little endian 64 bit float to ``writer``\. :param val: Value to write .. method:: put_int16_be(val: int) -> bool Writes a signed big endian 16 bit integer to ``writer``\. :param val: Value to write .. method:: put_int16_le(val: int) -> bool Writes a signed little endian 16 bit integer to ``writer``\. :param val: Value to write .. method:: put_int24_be(val: int) -> bool Writes a signed big endian 24 bit integer to ``writer``\. :param val: Value to write .. method:: put_int24_le(val: int) -> bool Writes a signed little endian 24 bit integer to ``writer``\. :param val: Value to write .. method:: put_int32_be(val: int) -> bool Writes a signed big endian 32 bit integer to ``writer``\. :param val: Value to write .. method:: put_int32_le(val: int) -> bool Writes a signed little endian 32 bit integer to ``writer``\. :param val: Value to write .. method:: put_int64_be(val: int) -> bool Writes a signed big endian 64 bit integer to ``writer``\. :param val: Value to write .. method:: put_int64_le(val: int) -> bool Writes a signed little endian 64 bit integer to ``writer``\. :param val: Value to write .. method:: put_int8(val: int) -> bool Writes a signed 8 bit integer to ``writer``\. :param val: Value to write .. method:: put_string_utf16(data: list[int]) -> bool Writes a NUL-terminated UTF16 string to ``writer`` (including the terminator). :param data: UTF16 string to write .. method:: put_string_utf32(data: list[int]) -> bool Writes a NUL-terminated UTF32 string to ``writer`` (including the terminator). :param data: UTF32 string to write .. method:: put_string_utf8(data: str) -> bool Writes a NUL-terminated UTF8 string to ``writer`` (including the terminator). :param data: UTF8 string to write .. method:: put_uint16_be(val: int) -> bool Writes a unsigned big endian 16 bit integer to ``writer``\. :param val: Value to write .. method:: put_uint16_le(val: int) -> bool Writes a unsigned little endian 16 bit integer to ``writer``\. :param val: Value to write .. method:: put_uint24_be(val: int) -> bool Writes a unsigned big endian 24 bit integer to ``writer``\. :param val: Value to write .. method:: put_uint24_le(val: int) -> bool Writes a unsigned little endian 24 bit integer to ``writer``\. :param val: Value to write .. method:: put_uint32_be(val: int) -> bool Writes a unsigned big endian 32 bit integer to ``writer``\. :param val: Value to write .. method:: put_uint32_le(val: int) -> bool Writes a unsigned little endian 32 bit integer to ``writer``\. :param val: Value to write .. method:: put_uint64_be(val: int) -> bool Writes a unsigned big endian 64 bit integer to ``writer``\. :param val: Value to write .. method:: put_uint64_le(val: int) -> bool Writes a unsigned little endian 64 bit integer to ``writer``\. :param val: Value to write .. method:: put_uint8(val: int) -> bool Writes a unsigned 8 bit integer to ``writer``\. :param val: Value to write .. method:: reset() -> None Resets ``writer`` and frees the data if it's owned by ``writer``\. .. method:: reset_and_get_buffer() -> ~gi.repository.Gst.Buffer Resets ``writer`` and returns the current data as buffer. Free-function: gst_buffer_unref .. method:: reset_and_get_data() -> list[int] Resets ``writer`` and returns the current data. Free-function: g_free Fields ------ .. rst-class:: interim-class .. class:: ByteWriter :no-index: .. attribute:: alloc_size Allocation size of the data .. attribute:: fixed If :const:`True` no reallocations are allowed .. attribute:: owned If :const:`False` no reallocations are allowed and copies of data are returned .. attribute:: parent :obj:`~gi.repository.GstBase.ByteReader` parent