View Source Membrane.H26x.NALuParser.SchemeParser (Membrane H.264 and H.265 plugin v0.10.0)

The module providing functions to parse the binary, based on the given Scheme.

Summary

Types

A type describing the field types which can be used in NALu scheme definition.

t()

A type defining the state of the scheme parser.

This type defines a value provider which provides values used in further processing of a parser.

Functions

Returns the local part of the state.

Returns a new SchemeParser.State struct instance.

Parses the binary stream representing a NALu, based on the scheme definition.

Types

@type field() ::
  :u1
  | :u2
  | :u3
  | :u4
  | :u5
  | :u8
  | :u16
  | :u16
  | {:uv, value_provider(integer())}
  | :ue
  | :se

A type describing the field types which can be used in NALu scheme definition.

Defined as in: "7.2 Specification of syntax functions, categories, and descriptors" of the "ITU-T Rec. H.264 (01/2012)".

@opaque t()

A type defining the state of the scheme parser.

The parser preserves its state in the map, which consists of two parts:

  • a map under the :__global__ key - it contains information fetched from a NALu, which might be needed during the parsing of the following NALus.
  • a map under the :__local__ key - it holds information valid during a time of a single NALu processing, and it's cleaned after the NALu is completely parsed. All information fetched from binary part is put into the :__local__ map. If some information needs to be available when other binary part is parsed, it needs to be stored in the map under the :__global__ key of the parser's state, which can be done i.e. with the save_as_global_state statements of the scheme syntax.
Link to this type

value_provider(return_type)

View Source
@type value_provider(return_type) :: return_type | {(... -> return_type), [any()]}

This type defines a value provider which provides values used in further processing of a parser.

A value provider can be either a hardcoded value, known at the compilation time, or a tuple consisting of a lambda expression and the list of keys mapping to some values in the parser's state. If the value provider is a tuple, then it's first element - the lambda expression- is invoked with the arguments being the values of the fields which are available in the parser's state under the key names given in the parser's state, and the value used in the further processing is the value returned by that lambda expression.

Functions

@spec get_local_state(t()) :: map()

Returns the local part of the state.

Link to this function

new(old_state \\ %__MODULE__{__global__: %{}, __local__: %{}})

View Source
@spec new(t()) :: t()

Returns a new SchemeParser.State struct instance.

The new state's local state is clear. If the State is provided as an argument, the new state's __global__ state is copied from the argument. Otherwise, it is set to the clear state.

Link to this function

parse_with_scheme(payload, scheme_module, state \\ new(), iterators \\ [])

View Source
@spec parse_with_scheme(binary(), module(), t(), [integer()]) :: {map(), t()}

Parses the binary stream representing a NALu, based on the scheme definition.

Returns the remaining bitstring and the stated updated with the information fetched from the NALu.