View Source Membrane.Matroska.Parser.EBML (Membrane Matroska plugin v0.5.1)

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

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

Functions

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

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

Link to this function

decode_element_name(element)

View Source
@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

@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

@spec parse_binary(binary()) :: binary()
@spec parse_date(binary()) :: :calendar.datetime()
@spec parse_float(binary()) :: float()
@spec parse_integer(binary()) :: integer()
Link to this function

parse_master(bytes, schema)

View Source
@spec parse_master(binary(), function()) :: list()
@spec parse_string(binary()) :: binary()
@spec parse_uint(binary()) :: non_neg_integer()
@spec parse_utf8(binary()) :: binary()