Membrane Core v0.5.0 Membrane.Bin behaviour View Source
Bins, similarly to pipelines, are containers for elements. However, at the same time, they can be placed and linked within pipelines. Although bin is a separate Membrane entity, it can be perceived as a pipeline within an element. Bins can also be nested within one another.
There are two main reasons why bins are useful:
- they enable creating reusable element groups
- they allow managing their children, for instance by dynamically spawning or replacing them as the stream changes.
In order to create bin use Membrane.Bin
in your callback module.
Link to this section Summary
Types
Type that defines a bin name by which it is identified.
Defines options that can be passed to start_link/3
and received
in handle_init/1
callback.
Functions
Brings all the stuff necessary to implement a pipeline.
Checks whether module is a bin.
Returns a specification to start this module under a supervisor.
Defines that bin exposes a clock which is a proxy to one of its children.
Macro that defines input pad for the bin.
Macro that defines output pad for the bin.
Starts the Bin based on given module and links it to the current process.
Changes bin's playback state to :stopped
and terminates its process
Callbacks
Callback invoked on initialization of bin process. It should parse options
and initialize bin's internal state. Internally it is invoked inside
GenServer.init/1
callback.
Callback that is called when new pad has beed added to bin. Executed ONLY for dynamic pads.
Callback that is called when some pad of the bin has beed removed. Executed ONLY for dynamic pads.
Enables to check whether module is membrane bin.
Automatically implemented callback used to determine whether bin exports clock.
Link to this section Types
callback_return_t()
View Sourcecallback_return_t() :: {:ok | {:ok, [Membrane.Parent.Action.t()]} | {:error, any()}, state_t()} | {:error, any()}
Type that defines a bin name by which it is identified.
Defines options that can be passed to start_link/3
and received
in handle_init/1
callback.
Link to this section Functions
Brings all the stuff necessary to implement a pipeline.
Options:
:bring_spec?
- if true (default) imports and aliasesMembrane.ParentSpec
:bring_pad?
- if true (default) requires and aliasesMembrane.Pad
Checks whether module is a bin.
Returns a specification to start this module under a supervisor.
See Supervisor
.
Defines that bin exposes a clock which is a proxy to one of its children.
If this macro is not called, no ticks will be forwarded to parent, regardless of clock definitions in its children.
Macro that defines input pad for the bin.
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.
The type Membrane.Pad.bin_spec_t/0
describes how the definition of pads should look.
Macro that defines output pad for the bin.
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.
The type Membrane.Pad.bin_spec_t/0
describes how the definition of pads should look.
start_link(my_name, module, bin_options \\ nil, process_options \\ [])
View Sourcestart_link( atom(), module(), bin_options :: options_t(), process_options :: GenServer.options() ) :: GenServer.on_start()
Starts the Bin based on given module and links it to the current process.
Bin options are passed to module's handle_init/1
callback.
Process options are internally passed to GenServer.start_link/3
.
Returns the same values as GenServer.start_link/3
.
Changes bin's playback state to :stopped
and terminates its process
Link to this section Callbacks
handle_init(options)
View Sourcehandle_init(options :: options_t()) :: {{:ok, Membrane.ParentSpec.t()}, Membrane.Core.Bin.State.internal_state_t()} | {:error, any()}
Callback invoked on initialization of bin process. It should parse options
and initialize bin's internal state. Internally it is invoked inside
GenServer.init/1
callback.
handle_pad_added(pad, context, state)
View Sourcehandle_pad_added( pad :: Membrane.Pad.ref_t(), context :: Membrane.Bin.CallbackContext.PadAdded.t(), state :: Membrane.Core.Bin.State.internal_state_t() ) :: callback_return_t()
Callback that is called when new pad has beed added to bin. Executed ONLY for dynamic pads.
handle_pad_removed(pad, context, state)
View Sourcehandle_pad_removed( pad :: Membrane.Pad.ref_t(), context :: Membrane.Bin.CallbackContext.PadRemoved.t(), state :: Membrane.Core.Bin.State.internal_state_t() ) :: callback_return_t()
Callback that is called when some pad of the bin has beed removed. Executed ONLY for dynamic pads.
Enables to check whether module is membrane bin.
Automatically implemented callback used to determine whether bin exports clock.