Membrane.Caps.Matcher (Membrane Core v0.7.0) View Source

Module that allows to specify valid caps and verify that they match specification.

Caps specifications (specs) should be in one of the formats:

  • simply module name of the desired caps (e.g. Membrane.Caps.Audio.Raw or Raw with proper alias)
  • tuple with module name and keyword list of specs for specific caps fields (e.g. {Raw, format: :s24le})
  • list of the formats described above

Field values can be specified in following ways:

  • By a raw value for the field (e.g. :s24le)
  • Using range/2 for values comparable with Kernel.<=/2 and Kernel.>=/2 (e.g. Matcher.range(0, 255))
  • With one_of/1 and a list of valid values (e.g Matcher.one_of([:u8, :s16le, :s32le])) Checks on the values from list are performed recursively i.e. it can contain another range/2, for example Matcher.one_of([0, Matcher.range(2, 4), Matcher.range(10, 20)])

If the specs are defined inside of Membrane.Element.WithInputPads.def_input_pad/2 and Membrane.Element.WithOutputPads.def_output_pad/2 module name can be omitted from range/2 and one_of/1 calls.

Example

Below is a pad definition with an example of specs for caps matcher:

alias Membrane.Caps.Video.Raw

def_input_pad :input,
  demand_unit: :buffers,
  caps: {Raw, format: one_of([:I420, :I422]), aligned: true}

Link to this section Summary

Functions

Function determining whether the caps match provided specs.

Returns opaque specification of list of valid values for caps field.

Returns opaque specification of range of valid values for caps field.

Function used to make sure caps specs are valid.

Link to this section Types

Specs

caps_spec_t() :: module() | {module(), keyword()}

Specs

caps_specs_t() :: :any | caps_spec_t() | [caps_spec_t()]

Specs

one_of_t()

Specs

range_t()

Link to this section Functions

Specs

match?(caps_specs_t(), struct() | any()) :: boolean()

Function determining whether the caps match provided specs.

When :any is used as specs, caps can by anything (i.e. they can be invalid)

Specs

one_of(list()) :: one_of_t()

Returns opaque specification of list of valid values for caps field.

Specs

range(any(), any()) :: range_t()

Returns opaque specification of range of valid values for caps field.

Link to this function

validate_specs(specs_list)

View Source

Specs

validate_specs(caps_specs_t() | any()) :: :ok | {:error, reason :: tuple()}

Function used to make sure caps specs are valid.

In particular, valid caps:

  • Have shape described by caps_specs_t/0 type
  • If they contain keyword list, the keys are present in requested caps type

It returns :ok when caps are valid and {:error, reason} otherwise