Membrane Core v0.1.1 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
orRaw
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 withKernel.<=/2
andKernel.>=/2
(e.g.Matcher.range(0, 255)
) - With
one_of/1
and a list of valid values (e.gMatcher.one_of([:u8, :s16le, :s32le])
) Checks on the values from list are performed recursivly i.e. it can contain anotherrange/2
, for exampleMatcher.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
caps_specs_t() :: :any | caps_spec_t() | [caps_spec_t()]
Link to this section Functions
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
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