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

Helper functions for decoding and encoding EBML elements.

EBML RFC: https://www.rfc-editor.org/rfc/rfc8794.html

Note that this module does not support parsing Master Elements with unknown data size https://www.rfc-editor.org/rfc/rfc8794.html#section-6.2

Link to this section 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

Link to this section Types

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

Link to this section 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()