Membrane Core v0.1.1 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

Link to this section Functions

Link to this macro def_known_source_pads(raw_source_pads) View Source (macro)

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

Link to this callback handle_demand(pad, size, unit, context, state) View Source

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.

Link to this callback known_source_pads() View Source
known_source_pads() :: known_source_pads_t()

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.