Gjsify LogoGjsify Logo

#GstByteReader provides a byte reader that can read different integer and floating point types from a memory buffer. It provides functions for 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 read NUL-terminated strings in various character encodings.

record

Hierarchy

  • ByteReader

Index

Constructors

Properties

byte: number

Current byte position

field
data: Uint8Array

Data from which the bit reader will read

field
size: number

Size of data in bytes

field
name: string

Methods

  • dup_data(): [boolean, Uint8Array]
  • 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 g_free() when no longer needed.

    Returns [boolean, Uint8Array]

  • dup_string_utf16(): [boolean, number[]]
  • 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.

    Returns [boolean, number[]]

  • dup_string_utf32(): [boolean, number[]]
  • 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.

    Returns [boolean, number[]]

  • dup_string_utf8(): [boolean, string[]]
  • Free-function: g_free

    FIXME:Reads (copies) a NUL-terminated string in the #GstByteReader 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.

    Returns [boolean, string[]]

  • free(): void
  • get_data(): [boolean, Uint8Array]
  • Returns a constant pointer to the current data position if at least size bytes are left and updates the current position.

    Returns [boolean, Uint8Array]

  • get_float32_be(): [boolean, number]
  • get_float32_le(): [boolean, number]
  • Read a 32 bit little endian floating point value into val and update the current position.

    Returns [boolean, number]

  • get_float64_be(): [boolean, number]
  • get_float64_le(): [boolean, number]
  • Read a 64 bit little endian floating point value into val and update the current position.

    Returns [boolean, number]

  • get_int16_be(): [boolean, number]
  • get_int16_le(): [boolean, number]
  • get_int24_be(): [boolean, number]
  • get_int24_le(): [boolean, number]
  • get_int32_be(): [boolean, number]
  • get_int32_le(): [boolean, number]
  • get_int64_be(): [boolean, number]
  • get_int64_le(): [boolean, number]
  • get_int8(): [boolean, number]
  • get_pos(): number
  • get_remaining(): number
  • get_size(): number
  • get_string_utf8(): [boolean, string[]]
  • 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.

    Returns [boolean, string[]]

  • get_uint16_be(): [boolean, number]
  • get_uint16_le(): [boolean, number]
  • get_uint24_be(): [boolean, number]
  • get_uint24_le(): [boolean, number]
  • get_uint32_be(): [boolean, number]
  • get_uint32_le(): [boolean, number]
  • get_uint64_be(): [boolean, number]
  • get_uint64_le(): [boolean, number]
  • get_uint8(): [boolean, number]
  • init(data: Uint8Array): void
  • Initializes a #GstByteReader instance to read from data. This function can be called on already initialized instances.

    Parameters

    • data: Uint8Array

      data from which the #GstByteReader should read

    Returns void

  • masked_scan_uint32(mask: number, pattern: number, offset: number, size: number): number
  • 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.

    Parameters

    • mask: number

      mask to apply to data before matching against pattern

    • pattern: number

      pattern to match (after mask is applied)

    • offset: number

      offset from which to start scanning, relative to the current position

    • size: number

      number of bytes to scan from offset

    Returns number

  • masked_scan_uint32_peek(mask: number, pattern: number, offset: number, size: number): [number, number]
  • 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.

    Parameters

    • mask: number

      mask to apply to data before matching against pattern

    • pattern: number

      pattern to match (after mask is applied)

    • offset: number

      offset from which to start scanning, relative to the current position

    • size: number

      number of bytes to scan from offset

    Returns [number, number]

  • peek_data(): [boolean, Uint8Array]
  • Returns a constant pointer to the current data position if at least size bytes are left and keeps the current position.

    Returns [boolean, Uint8Array]

  • peek_float32_be(): [boolean, number]
  • peek_float32_le(): [boolean, number]
  • peek_float64_be(): [boolean, number]
  • peek_float64_le(): [boolean, number]
  • peek_int16_be(): [boolean, number]
  • peek_int16_le(): [boolean, number]
  • peek_int24_be(): [boolean, number]
  • peek_int24_le(): [boolean, number]
  • peek_int32_be(): [boolean, number]
  • peek_int32_le(): [boolean, number]
  • peek_int64_be(): [boolean, number]
  • peek_int64_le(): [boolean, number]
  • peek_int8(): [boolean, number]
  • peek_string_utf8(): [boolean, string[]]
  • 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.

    Returns [boolean, string[]]

  • peek_uint16_be(): [boolean, number]
  • peek_uint16_le(): [boolean, number]
  • peek_uint24_be(): [boolean, number]
  • peek_uint24_le(): [boolean, number]
  • peek_uint32_be(): [boolean, number]
  • peek_uint32_le(): [boolean, number]
  • peek_uint64_be(): [boolean, number]
  • peek_uint64_le(): [boolean, number]
  • peek_uint8(): [boolean, number]
  • set_pos(pos: number): boolean
  • Sets the new position of a #GstByteReader instance to pos in bytes.

    Parameters

    • pos: number

      The new position in bytes

    Returns boolean

  • skip(nbytes: number): boolean
  • Skips nbytes bytes of the #GstByteReader instance.

    Parameters

    • nbytes: number

      the number of bytes to skip

    Returns boolean

  • skip_string_utf16(): boolean
  • Skips a NUL-terminated UTF-16 string in the #GstByteReader 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.

    Returns boolean

  • skip_string_utf32(): boolean
  • Skips a NUL-terminated UTF-32 string in the #GstByteReader 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.

    Returns boolean

  • skip_string_utf8(): boolean
  • Skips a NUL-terminated string in the #GstByteReader 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.

    Returns boolean

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method