Membrane Core v0.1.0 Membrane.Caps.Matcher 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 recursivly 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.Base.Mixin.SinkBehaviour.def_known_sink_pads/1 and Membrane.Element.Base.Mixin.SourceBehaviour.def_known_source_pads/1 module name can be ommitted from range/2 and one_of/1 calls.

Link to this section Summary

Functions

Function determining whether the caps match provided specs

Returns opaque list_spec_t/0 that specifies list of valid values for caps field

Returns opaque range_spec_t/0 that specifies range of valid values for caps field

Function used to make sure caps specs are valid

Link to this section Types

Link to this type caps_spec_t() View Source
caps_spec_t() :: module() | {module(), keyword()}
Link to this type caps_specs_t() View Source
caps_specs_t() :: :any | caps_spec_t() | [caps_spec_t()]

Link to this section Functions

Link to this function match?(specs, caps) View Source
match?(:any, any()) :: true
match?(caps_specs_t(), struct()) :: 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)

Returns opaque list_spec_t/0 that specifies list of valid values for caps field

Returns opaque range_spec_t/0 that specifies range of valid values for caps field

Link to this function validate_specs(specs_list) View Source
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