Membrane.Matroska.Parser.EBML (Membrane Matroska plugin v0.6.1)

View Source

Helper functions for decoding and encoding EBML elements.

EBML RFC: https://datatracker.ietf.org/doc/html/rfc8794

Note that this module does not support parsing Master Elements with unknown data size https://datatracker.ietf.org/doc/html/rfc8794#name-unknown-data-size

Summary

Functions

Returns an EBML element's name, type, and data

Returns the name associated with the EBML ELEMENT_ID of the first Element in the input binary.

Returns the number encoded in the VINT_DATA field of the first VINT in the input binary

Types

element_type_t()

@type element_type_t() ::
  :integer | :uint | :float | :string | :utf_8 | :date | :master | :binary

Functions

decode_element(bytes)

@spec decode_element(binary()) ::
  {:ok, {name :: atom(), data :: binary(), rest :: binary()}}
  | {:error, :need_more_bytes}

Returns an EBML element's name, type, and data

decode_element_name(element)

@spec decode_element_name(binary()) ::
  {:ok, {atom(), binary()}} | {:error, :need_more_bytes}

Returns the name associated with the EBML ELEMENT_ID of the first Element in the input binary.

EMBL elements are identified by the hexadecimal representation of the entire leading VINT including WIDTH, MARKER and DATA

decode_vint(bytes)

@spec decode_vint(binary()) ::
  {:ok, {non_neg_integer(), binary()}} | {:error, :need_more_bytes}

Returns the number encoded in the VINT_DATA field of the first VINT in the input binary

parse_binary(bytes)

@spec parse_binary(binary()) :: binary()

parse_date(arg)

@spec parse_date(binary()) :: :calendar.datetime()

parse_float(arg)

@spec parse_float(binary()) :: float()

parse_integer(bytes)

@spec parse_integer(binary()) :: integer()

parse_master(bytes, schema)

@spec parse_master(binary(), function()) :: list()

parse_string(bytes)

@spec parse_string(binary()) :: binary()

parse_uint(bytes)

@spec parse_uint(binary()) :: non_neg_integer()

parse_utf8(bytes)

@spec parse_utf8(binary()) :: binary()