:right-sidebar: True ByteReader =================================================================== .. currentmodule:: gi.repository.GstBase .. class:: ByteReader(*args, **kwargs) :no-contents-entry: :Constructors: :: ByteReader() Methods ------- .. rst-class:: interim-class .. class:: ByteReader :no-index: .. method:: dup_data() -> tuple[bool, bytes] Free-function: g_free Returns a newly-allocated copy of the current data position if at least ``size`` bytes are left and updates the current position. Free with :func:`~gi.repository.GLib.free` when no longer needed. .. method:: dup_string_utf16() -> tuple[bool, list[int]] Free-function: g_free Returns a newly-allocated copy of the current data position if there is a NUL-terminated UTF-16 string in the data (this could be an empty string as well), and advances the current position. No input checking for valid UTF-16 is done. This function is endianness agnostic - you should not assume the UTF-16 characters are in host endianness. This function will fail if no NUL-terminator was found in in the data. Note: there is no peek or get variant of this function to ensure correct byte alignment of the UTF-16 string. .. method:: dup_string_utf32() -> tuple[bool, list[int]] Free-function: g_free Returns a newly-allocated copy of the current data position if there is a NUL-terminated UTF-32 string in the data (this could be an empty string as well), and advances the current position. No input checking for valid UTF-32 is done. This function is endianness agnostic - you should not assume the UTF-32 characters are in host endianness. This function will fail if no NUL-terminator was found in in the data. Note: there is no peek or get variant of this function to ensure correct byte alignment of the UTF-32 string. .. method:: dup_string_utf8() -> tuple[bool, list[str]] Free-function: g_free FIXME:Reads (copies) a NUL-terminated string in the :obj:`~gi.repository.GstBase.ByteReader` instance, advancing the current position to the byte after the string. This will work for any NUL-terminated string with a character width of 8 bits, so ASCII, UTF-8, ISO-8859-N etc. No input checking for valid UTF-8 is done. This function will fail if no NUL-terminator was found in in the data. .. method:: free() -> None Frees a :obj:`~gi.repository.GstBase.ByteReader` instance, which was previously allocated by :func:`~gi.repository.GstBase.ByteReader.new`. .. method:: get_data() -> tuple[bool, bytes] Returns a constant pointer to the current data position if at least ``size`` bytes are left and updates the current position. .. method:: get_float32_be() -> tuple[bool, float] Read a 32 bit big endian floating point value into ``val`` and update the current position. .. method:: get_float32_le() -> tuple[bool, float] Read a 32 bit little endian floating point value into ``val`` and update the current position. .. method:: get_float64_be() -> tuple[bool, float] Read a 64 bit big endian floating point value into ``val`` and update the current position. .. method:: get_float64_le() -> tuple[bool, float] Read a 64 bit little endian floating point value into ``val`` and update the current position. .. method:: get_int16_be() -> tuple[bool, int] Read a signed 16 bit big endian integer into ``val`` and update the current position. .. method:: get_int16_le() -> tuple[bool, int] Read a signed 16 bit little endian integer into ``val`` and update the current position. .. method:: get_int24_be() -> tuple[bool, int] Read a signed 24 bit big endian integer into ``val`` and update the current position. .. method:: get_int24_le() -> tuple[bool, int] Read a signed 24 bit little endian integer into ``val`` and update the current position. .. method:: get_int32_be() -> tuple[bool, int] Read a signed 32 bit big endian integer into ``val`` and update the current position. .. method:: get_int32_le() -> tuple[bool, int] Read a signed 32 bit little endian integer into ``val`` and update the current position. .. method:: get_int64_be() -> tuple[bool, int] Read a signed 64 bit big endian integer into ``val`` and update the current position. .. method:: get_int64_le() -> tuple[bool, int] Read a signed 64 bit little endian integer into ``val`` and update the current position. .. method:: get_int8() -> tuple[bool, int] Read a signed 8 bit integer into ``val`` and update the current position. .. method:: get_pos() -> int Returns the current position of a :obj:`~gi.repository.GstBase.ByteReader` instance in bytes. .. method:: get_remaining() -> int Returns the remaining number of bytes of a :obj:`~gi.repository.GstBase.ByteReader` instance. .. method:: get_size() -> int Returns the total number of bytes of a :obj:`~gi.repository.GstBase.ByteReader` instance. .. method:: get_string_utf8() -> tuple[bool, list[str]] Returns a constant pointer to the current data position if there is a NUL-terminated string in the data (this could be just a NUL terminator), advancing the current position to the byte after the string. This will work for any NUL-terminated string with a character width of 8 bits, so ASCII, UTF-8, ISO-8859-N etc. No input checking for valid UTF-8 is done. This function will fail if no NUL-terminator was found in in the data. .. method:: get_uint16_be() -> tuple[bool, int] Read an unsigned 16 bit big endian integer into ``val`` and update the current position. .. method:: get_uint16_le() -> tuple[bool, int] Read an unsigned 16 bit little endian integer into ``val`` and update the current position. .. method:: get_uint24_be() -> tuple[bool, int] Read an unsigned 24 bit big endian integer into ``val`` and update the current position. .. method:: get_uint24_le() -> tuple[bool, int] Read an unsigned 24 bit little endian integer into ``val`` and update the current position. .. method:: get_uint32_be() -> tuple[bool, int] Read an unsigned 32 bit big endian integer into ``val`` and update the current position. .. method:: get_uint32_le() -> tuple[bool, int] Read an unsigned 32 bit little endian integer into ``val`` and update the current position. .. method:: get_uint64_be() -> tuple[bool, int] Read an unsigned 64 bit big endian integer into ``val`` and update the current position. .. method:: get_uint64_le() -> tuple[bool, int] Read an unsigned 64 bit little endian integer into ``val`` and update the current position. .. method:: get_uint8() -> tuple[bool, int] Read an unsigned 8 bit integer into ``val`` and update the current position. .. method:: init(data: ~typing.Sequence[int]) -> None Initializes a :obj:`~gi.repository.GstBase.ByteReader` instance to read from ``data``. This function can be called on already initialized instances. :param data: data from which the :obj:`~gi.repository.GstBase.ByteReader` should read .. method:: masked_scan_uint32(mask: int, pattern: int, offset: int, size: int) -> int Scan for pattern ``pattern`` with applied mask ``mask`` in the byte reader data, starting from offset ``offset`` relative to the current position. The bytes in ``pattern`` and ``mask`` are interpreted left-to-right, regardless of endianness. All four bytes of the pattern must be present in the byte reader data for it to match, even if the first or last bytes are masked out. It is an error to call this function without making sure that there is enough data (offset+size bytes) in the byte reader. :param mask: mask to apply to data before matching against ``pattern`` :param pattern: pattern to match (after mask is applied) :param offset: offset from which to start scanning, relative to the current position :param size: number of bytes to scan from offset .. method:: masked_scan_uint32_peek(mask: int, pattern: int, offset: int, size: int) -> tuple[int, int] Scan for pattern ``pattern`` with applied mask ``mask`` in the byte reader data, starting from offset ``offset`` relative to the current position. The bytes in ``pattern`` and ``mask`` are interpreted left-to-right, regardless of endianness. All four bytes of the pattern must be present in the byte reader data for it to match, even if the first or last bytes are masked out. It is an error to call this function without making sure that there is enough data (offset+size bytes) in the byte reader. .. versionadded:: 1.6 :param mask: mask to apply to data before matching against ``pattern`` :param pattern: pattern to match (after mask is applied) :param offset: offset from which to start scanning, relative to the current position :param size: number of bytes to scan from offset .. method:: peek_data() -> tuple[bool, bytes] Returns a constant pointer to the current data position if at least ``size`` bytes are left and keeps the current position. .. method:: peek_float32_be() -> tuple[bool, float] Read a 32 bit big endian floating point value into ``val`` but keep the current position. .. method:: peek_float32_le() -> tuple[bool, float] Read a 32 bit little endian floating point value into ``val`` but keep the current position. .. method:: peek_float64_be() -> tuple[bool, float] Read a 64 bit big endian floating point value into ``val`` but keep the current position. .. method:: peek_float64_le() -> tuple[bool, float] Read a 64 bit little endian floating point value into ``val`` but keep the current position. .. method:: peek_int16_be() -> tuple[bool, int] Read a signed 16 bit big endian integer into ``val`` but keep the current position. .. method:: peek_int16_le() -> tuple[bool, int] Read a signed 16 bit little endian integer into ``val`` but keep the current position. .. method:: peek_int24_be() -> tuple[bool, int] Read a signed 24 bit big endian integer into ``val`` but keep the current position. .. method:: peek_int24_le() -> tuple[bool, int] Read a signed 24 bit little endian integer into ``val`` but keep the current position. .. method:: peek_int32_be() -> tuple[bool, int] Read a signed 32 bit big endian integer into ``val`` but keep the current position. .. method:: peek_int32_le() -> tuple[bool, int] Read a signed 32 bit little endian integer into ``val`` but keep the current position. .. method:: peek_int64_be() -> tuple[bool, int] Read a signed 64 bit big endian integer into ``val`` but keep the current position. .. method:: peek_int64_le() -> tuple[bool, int] Read a signed 64 bit little endian integer into ``val`` but keep the current position. .. method:: peek_int8() -> tuple[bool, int] Read a signed 8 bit integer into ``val`` but keep the current position. .. method:: peek_string_utf8() -> tuple[bool, list[str]] Returns a constant pointer to the current data position if there is a NUL-terminated string in the data (this could be just a NUL terminator). The current position will be maintained. This will work for any NUL-terminated string with a character width of 8 bits, so ASCII, UTF-8, ISO-8859-N etc. No input checking for valid UTF-8 is done. This function will fail if no NUL-terminator was found in in the data. .. method:: peek_uint16_be() -> tuple[bool, int] Read an unsigned 16 bit big endian integer into ``val`` but keep the current position. .. method:: peek_uint16_le() -> tuple[bool, int] Read an unsigned 16 bit little endian integer into ``val`` but keep the current position. .. method:: peek_uint24_be() -> tuple[bool, int] Read an unsigned 24 bit big endian integer into ``val`` but keep the current position. .. method:: peek_uint24_le() -> tuple[bool, int] Read an unsigned 24 bit little endian integer into ``val`` but keep the current position. .. method:: peek_uint32_be() -> tuple[bool, int] Read an unsigned 32 bit big endian integer into ``val`` but keep the current position. .. method:: peek_uint32_le() -> tuple[bool, int] Read an unsigned 32 bit little endian integer into ``val`` but keep the current position. .. method:: peek_uint64_be() -> tuple[bool, int] Read an unsigned 64 bit big endian integer into ``val`` but keep the current position. .. method:: peek_uint64_le() -> tuple[bool, int] Read an unsigned 64 bit little endian integer into ``val`` but keep the current position. .. method:: peek_uint8() -> tuple[bool, int] Read an unsigned 8 bit integer into ``val`` but keep the current position. .. method:: set_pos(pos: int) -> bool Sets the new position of a :obj:`~gi.repository.GstBase.ByteReader` instance to ``pos`` in bytes. :param pos: The new position in bytes .. method:: skip(nbytes: int) -> bool Skips ``nbytes`` bytes of the :obj:`~gi.repository.GstBase.ByteReader` instance. :param nbytes: the number of bytes to skip .. method:: skip_string_utf16() -> bool Skips a NUL-terminated UTF-16 string in the :obj:`~gi.repository.GstBase.ByteReader` instance, advancing the current position to the byte after the string. No input checking for valid UTF-16 is done. This function will fail if no NUL-terminator was found in in the data. .. method:: skip_string_utf32() -> bool Skips a NUL-terminated UTF-32 string in the :obj:`~gi.repository.GstBase.ByteReader` instance, advancing the current position to the byte after the string. No input checking for valid UTF-32 is done. This function will fail if no NUL-terminator was found in in the data. .. method:: skip_string_utf8() -> bool Skips a NUL-terminated string in the :obj:`~gi.repository.GstBase.ByteReader` instance, advancing the current position to the byte after the string. This will work for any NUL-terminated string with a character width of 8 bits, so ASCII, UTF-8, ISO-8859-N etc. No input checking for valid UTF-8 is done. This function will fail if no NUL-terminator was found in in the data. Fields ------ .. rst-class:: interim-class .. class:: ByteReader :no-index: .. attribute:: byte Current byte position .. attribute:: data Data from which the bit reader will read .. attribute:: size Size of ``data`` in bytes