Membrane Core v0.4.3 Membrane.Pipeline behaviour View Source
Module containing functions for constructing and supervising pipelines.
Pipelines are units that make it possible to instantiate, link and manage elements in convenient way (actually elements should always be used inside a pipeline). Linking elements together enables them to pass data to one another, and process it in different ways.
Link to this section Summary
Types
Type describing actions that can be returned from pipeline callbacks.
Type that defines all valid return values from most callbacks.
Action that sends a message to element identified by name.
Defines options that can be passed to start/3
/ start_link/3
and received
in handle_init/1
callback.
Action that stops, unlinks and removes specified child/children from pipeline.
Action that instantiates elements and links them according to Membrane.Pipeline.Spec
.
Functions
Returns a specification to start this module under a supervisor.
Checks whether module is a pipeline.
Changes playback state to :playing
.
Changes playback state to :prepared
.
Does the same as start_link/3
but starts process outside of supervision tree.
Starts the Pipeline based on given module and links it to the current process.
Changes playback state to :stopped
.
Changes pipeline's playback state to :stopped
and terminates its process
Callbacks
Callback invoked when pipeline's element receives end_of_stream event.
Callback invoked when pipeline's element receives start_of_stream event.
Callback invoked on initialization of pipeline process. It should parse options
and initialize element internal state. Internally it is invoked inside
GenServer.init/1
callback.
Callback invoked when a notification comes in from an element.
Callback invoked when pipeline receives a message that is not recognized as an internal membrane message.
Callback invoked when pipeline transition from :playing
to :prepared
state has finished,
that is all of its elements are prepared to be stopped.
Callback invoked when pipeline is in :playing
state, i.e. all its elements
are in this state.
Callback invoked when pipeline is in :playing
state, i.e. all its elements
are in this state.
Callback invoked when pipeline is shutting down.
Internally called in GenServer.terminate/2
callback.
Callback invoked when Membrane.Pipeline.Spec
is linked and in the same playback
state as pipeline.
Callback invoked when pipeline transition from :stopped
to :prepared
state has finished,
that is all of its elements are prepared to enter :playing
state.
Enables to check whether module is membrane pipeline
Link to this section Types
action_t()
View Sourceaction_t() :: forward_action_t() | spec_action_t() | remove_child_action_t()
Type describing actions that can be returned from pipeline callbacks.
Returning actions is a way of pipeline interaction with its elements and other parts of framework.
Type that defines all valid return values from most callbacks.
In case of error, a callback is supposed to return {:error, any}
if it is not
passed state, and {{:error, any}, state}
otherwise.
forward_action_t()
View Sourceforward_action_t() :: {:forward, {Membrane.Element.name_t(), Membrane.Notification.t()}}
Action that sends a message to element identified by name.
Defines options that can be passed to start/3
/ start_link/3
and received
in handle_init/1
callback.
remove_child_action_t()
View Sourceremove_child_action_t() :: {:remove_child, Membrane.Element.name_t() | [Membrane.Element.name_t()]}
Action that stops, unlinks and removes specified child/children from pipeline.
spec_action_t()
View Sourcespec_action_t() :: {:spec, Membrane.Pipeline.Spec.t()}
Action that instantiates elements and links them according to Membrane.Pipeline.Spec
.
Elements playback state is changed to the current pipeline state.
c:handle_spec_started
callback is executed once it happens.
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Checks whether module is a pipeline.
Changes playback state to :playing
.
An alias for change_playback_state/2
with proper state.
Changes playback state to :prepared
.
An alias for change_playback_state/2
with proper state.
start(module, pipeline_options \\ nil, process_options \\ [])
View Sourcestart( module(), pipeline_options :: pipeline_options_t(), process_options :: GenServer.options() ) :: GenServer.on_start()
Does the same as start_link/3
but starts process outside of supervision tree.
start_link(module, pipeline_options \\ nil, process_options \\ [])
View Sourcestart_link( module(), pipeline_options :: pipeline_options_t(), process_options :: GenServer.options() ) :: GenServer.on_start()
Starts the Pipeline based on given module and links it to the current process.
Pipeline 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 playback state to :stopped
.
An alias for change_playback_state/2
with proper state.
stop_and_terminate(pipeline)
View Sourcestop_and_terminate(pipeline :: pid()) :: :ok
Changes pipeline's playback state to :stopped
and terminates its process
Link to this section Callbacks
handle_element_end_of_stream({}, state)
View Sourcehandle_element_end_of_stream( {Membrane.Element.name_t(), Membrane.Element.Pad.ref_t()}, state :: Membrane.Pipeline.State.internal_state_t() ) :: callback_return_t()
Callback invoked when pipeline's element receives end_of_stream event.
handle_element_start_of_stream({}, state)
View Sourcehandle_element_start_of_stream( {Membrane.Element.name_t(), Membrane.Element.Pad.ref_t()}, state :: Membrane.Pipeline.State.internal_state_t() ) :: callback_return_t()
Callback invoked when pipeline's element receives start_of_stream event.
handle_init(options)
View Sourcehandle_init(options :: pipeline_options_t()) :: callback_return_t()
Callback invoked on initialization of pipeline process. It should parse options
and initialize element internal state. Internally it is invoked inside
GenServer.init/1
callback.
handle_notification(notification, element, state)
View Sourcehandle_notification( notification :: Membrane.Notification.t(), element :: Membrane.Element.name_t(), state :: Membrane.Pipeline.State.internal_state_t() ) :: callback_return_t()
Callback invoked when a notification comes in from an element.
handle_other(message, state)
View Sourcehandle_other( message :: any(), state :: Membrane.Pipeline.State.internal_state_t() ) :: callback_return_t()
Callback invoked when pipeline receives a message that is not recognized as an internal membrane message.
Useful for receiving ticks from timer, data sent from NIFs or other stuff.
handle_playing_to_prepared(state)
View Sourcehandle_playing_to_prepared(state :: Membrane.Pipeline.State.internal_state_t()) :: callback_return_t()
Callback invoked when pipeline transition from :playing
to :prepared
state has finished,
that is all of its elements are prepared to be stopped.
handle_prepared_to_playing(state)
View Sourcehandle_prepared_to_playing(state :: Membrane.Pipeline.State.internal_state_t()) :: callback_return_t()
Callback invoked when pipeline is in :playing
state, i.e. all its elements
are in this state.
handle_prepared_to_stopped(state)
View Sourcehandle_prepared_to_stopped(state :: Membrane.Pipeline.State.internal_state_t()) :: callback_return_t()
Callback invoked when pipeline is in :playing
state, i.e. all its elements
are in this state.
handle_shutdown(reason, state)
View Sourcehandle_shutdown(reason, state :: Membrane.Pipeline.State.internal_state_t()) :: :ok when reason: :normal | :shutdown | {:shutdown, any()}
Callback invoked when pipeline is shutting down.
Internally called in GenServer.terminate/2
callback.
Useful for any cleanup required.
handle_spec_started(elements, state)
View Sourcehandle_spec_started( elements :: [Membrane.Element.name_t()], state :: Membrane.Pipeline.State.internal_state_t() ) :: callback_return_t()
Callback invoked when Membrane.Pipeline.Spec
is linked and in the same playback
state as pipeline.
Spec can be started from handle_init/1
callback or as spec_action_t/0
action.
handle_stopped_to_prepared(state)
View Sourcehandle_stopped_to_prepared(state :: Membrane.Pipeline.State.internal_state_t()) :: callback_return_t()
Callback invoked when pipeline transition from :stopped
to :prepared
state has finished,
that is all of its elements are prepared to enter :playing
state.
Enables to check whether module is membrane pipeline