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

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

Callbacks

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 message incomes from an element

Callback invoked when pipeline receives a message that is not recognized as an internal membrane message

Callback invoked when pipeline is in :playing state, i.e. all its elements are in this state

Callback invoked when pipeline is in :prepared state, i.e. all its elements are in this state. It receives the previous playback state (:stopped or :playing)

Callback invoked when Membrane.Pipeline.Spec is linked and in the same playback state as pipeline

Callback invoked when pipeline is in :playing state, i.e. all its elements are in this state

Enables to check whether module is membrane pipeline

Link to this section Types

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.

Link to this type callback_return_t() View Source
callback_return_t() ::
  Membrane.Mixins.CallbackHandler.callback_return_t(
    action_t(),
    Membrane.Pipeline.State.internal_state_t()
  )

Type that defines all valid return values from most callbacks.

Link to this type forward_action_t() View Source
forward_action_t() ::
  {:forward, {Membrane.Element.name_t(), Membrane.Message.t()}}

Action that sends a message to element identified by name.

Link to this type pipeline_options_t() View Source
pipeline_options_t() :: any()

Defines options that can be passed to start/3 / start_link/3 and received in handle_init/1 callback.

Link to this type remove_child_action_t() View Source
remove_child_action_t() ::
  {:remove_child, Membrane.Element.name_t() | [Membrane.Element.name_t()]}

Action that stops, unlinks and removes specified child/children from pipeline.

Link to this type spec_action_t() View Source
spec_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 happes.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function pipeline?(module) View Source
pipeline?(module()) :: boolean()

Checks whether module is a pipeline.

Link to this function playback_warn_error(message, reason, state) View Source

Callback implementation for Membrane.Mixins.Playback.playback_warn_error/3.

Link to this function start(module, pipeline_options \\ nil, process_options \\ []) View Source
start(
  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.

Link to this function start_link(module, pipeline_options \\ nil, process_options \\ []) View Source
start_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.

Link to this function stop_and_terminate(pipeline) View Source
stop_and_terminate(pipeline :: module()) :: :ok

Link to this section Callbacks

Link to this callback handle_init(options) View Source
handle_init(options :: pipeline_options_t()) ::
  {{:ok, Membrane.Pipeline.Spec.t()},
   Membrane.Pipeline.State.internal_state_t()}
  | {:error, any()}

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.

Link to this callback handle_message(message, element, state) View Source
handle_message(
  message :: Membrane.Message.t(),
  element :: Membrane.Element.name_t(),
  state :: Membrane.Pipeline.State.internal_state_t()
) :: callback_return_t()

Callback invoked when message incomes from an element.

Link to this callback handle_other(message, state) View Source
handle_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.

Link to this callback handle_play(state) View Source
handle_play(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.

Link to this callback handle_prepare(previous_playback_state, state) View Source
handle_prepare(
  previous_playback_state :: Membrane.Mixins.Playback.state_t(),
  state :: Membrane.Pipeline.State.internal_state_t()
) :: callback_return_t()

Callback invoked when pipeline is in :prepared state, i.e. all its elements are in this state. It receives the previous playback state (:stopped or :playing).

Link to this callback handle_spec_started(elements, state) View Source
handle_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.

Link to this callback handle_stop(state) View Source
handle_stop(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.

Link to this callback membrane_pipeline?() View Source
membrane_pipeline?() :: true

Enables to check whether module is membrane pipeline