Membrane Core v0.1.0 Membrane.Element.Base.Mixin.SourceBehaviour behaviour View Source
Module defining behaviour for source and filter elements.
When used declares behaviour implementation, provides default callback definitions and imports macros.
For more information on implementing elements, see Membrane.Element.Base
.
Link to this section Summary
Functions
Macro that defines known source pads for the element type
Callbacks
Callback that is called when buffers should be emitted by the source or filter
Callback that defines what source pads may be ever available for this element type
Link to this section Types
known_source_pads_t() :: [ {Membrane.Element.Pad.name_t(), {Membrane.Element.Pad.availability_t(), :push | :pull, Membrane.Caps.Matcher.caps_specs_t()}} ]
Link to this section Functions
Macro that defines known source pads for the element type.
Allows to use one_of/1
and range/2
functions from Membrane.Caps.Matcher
without module prefix.
It automatically generates documentation from the given definition and adds compile-time caps specs validation.
Link to this section Callbacks
handle_demand( pad :: Membrane.Element.Pad.name_t(), size :: non_neg_integer(), unit :: Membrane.Buffer.Metric.unit_t(), context :: Membrane.Context.Demand.t(), state :: Membrane.Element.Base.Mixin.CommonBehaviour.internal_state_t() ) :: Membrane.Element.Base.Mixin.CommonBehaviour.callback_return_t()
Callback that is called when buffers should be emitted by the source or filter.
It will be called only for source pads in the pull mode, as in their case demand is triggered by the sinks of the subsequent elements.
In source elements, appropriate amount of data should be sent here. If it happens not to be yet available, element should store unsupplied demand and supply it when possible.
In filter elements, this callback should usually return :demand
action with
size sufficient (at least approximately) for supplying incoming demand. This
will result with calling Membrane.Element.Base.Filter.handle_process/4
or
Membrane.Element.Base.Sink.handle_write/4
, which is to supply
the demand. If it does not, or does only partially,
Membrane.Element.Base.Mixin.SourceBehaviour.handle_demand/5
is called
again, until there is any data available on the sink pad.
For sources in the push mode, element should generate buffers without this callback.
Callback that defines what source pads may be ever available for this element type.
The default name for generic source pad, in elements that just produce some
buffers is :source
.