View Source Membrane.RemoteControlled.Pipeline (Membrane Core v0.10.2)
Membrane.RemoteControlled.Pipeline
is a basic Membrane.Pipeline
implementation that can be
controlled by a controlling process.
The controlling process can request the execution of arbitrary
valid Membrane.Pipeline.Action
:
children = ...
links = ...
actions = [{:spec, %ParentSpec{children: children, links: links}}]
Pipeline.exec_actions(pipeline, actions)
The controlling process can also subscribe to the messages sent by the pipeline and later on synchroniously await for these messages:
# subscribes to message which is sent when the pipeline enters any playback state
Pipeline.subscribe(pipeline, %Message.PlaybackState{state: _})
...
# awaits for the message sent when the pipeline enters :playing playback state
Pipeline.await_playback_state(pipeline, :playing)
...
# awaits for the message sent when the pipeline enters :stopped playback state
Pipeline.await_playback_state(pipeline, :stopped)
Membrane.RemoteControlled.Pipeline
can be used when there is no need for introducing a custom
logic in the Membrane.Pipeline
callbacks implementation. An example of usage could be running a
pipeline from the elixir script. Membrane.RemoteControlled.Pipeline
sends the following messages:
Membrane.RemoteControlled.Message.PlaybackState.t()
sent when pipeline enters a given playback state,Membrane.RemoteControlled.Message.StartOfStream.t()
sent when one of direct pipeline children informs the pipeline about start of a stream,Membrane.RemoteControlled.Message.EndOfStream.t()
sent when one of direct pipeline children informs the pipeline about end of a stream,Membrane.RemoteControlled.Message.Notification.t()
sent when pipeline receives notification from one of its children,Membrane.RemoteControlled.Message.Terminated.t()
sent when the pipeline gracefully terminates.
Link to this section Summary
Functions
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.EndOfStream()
message
with no further constraints, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.EndOfStream()
message
concerning the given element
, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.EndOfStream()
message
concerning the given element
and the pad
, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.Notification()
message with no further constraints, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.Notification()
message
concerning the given element
, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.PlaybackState()
message with no further constraints, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.PlaybackState()
message with the given state
, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.StartOfStream()
message
with no further constraints, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.StartOfStream()
message
concerning the given element
, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.StartOfStream()
message
concerning the given element
and the pad
, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Awaits for the Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.Terminated
message,
which is send when the pipeline gracefully terminates.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Sends a list of Pipeline.Action.t()
to the given Membrane.RemoteControlled.Pipeline
for execution.
Changes playback state of pipeline to :playing
.
Changes playback state to :prepared
.
Does the same as the start_link/1
but starts the process outside of the supervision tree.
Starts the Membrane.RemoteControlled.Pipeline
and links it to the current process. The process
that makes the call to the start_link/1
automatically become the controller process.
Changes playback state to :stopped
.
Changes pipeline's playback state to :stopped
and terminates its process.
Subscribes to a given subscription_pattern
. The subscription_pattern
should describe some subset
of elements of Membrane.RemoteControlled.Pipeline.message_t()
type. The subscription_pattern
must be a match pattern.
Changes pipeline's playback state to :stopped
and terminates its process.
Link to this section Functions
@spec await_end_of_stream(pid()) :: Membrane.RemoteControlled.Message.EndOfStream.t()
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.EndOfStream()
message
with no further constraints, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Usage example:
- awaiting for the first
end_of_stream
occuring on any pad of any element in the pipeline:Pipeline.await_end_of_stream(pipeline)
@spec await_end_of_stream(pid(), Membrane.Element.name_t()) :: Membrane.RemoteControlled.Message.EndOfStream.t()
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.EndOfStream()
message
concerning the given element
, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Usage example:
- awaiting for the first
end_of_stream
occuring on any pad of the:element_id
element in the pipeline:Pipeline.await_end_of_stream(pipeline, :element_id)
@spec await_end_of_stream(pid(), Membrane.Element.name_t(), Membrane.Pad.name_t()) :: Membrane.RemoteControlled.Message.EndOfStream.t()
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.EndOfStream()
message
concerning the given element
and the pad
, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Usage example:
- awaiting for the first
end_of_stream
occuring on the:pad_id
of the:element_id
element in the pipeline:Pipeline.await_end_of_stream(pipeline, :element_id, :pad_id)
@spec await_notification(pid()) :: Membrane.RemoteControlled.Message.Notification.t()
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.Notification()
message with no further constraints, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Usage example:
- awaiting for the first notification send to any element in the pipeline:
Pipeline.await_notification(pipeline)
@spec await_notification(pid(), Membrane.Notification.t()) :: Membrane.RemoteControlled.Message.Notification.t()
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.Notification()
message
concerning the given element
, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Usage example:
- awaiting for the first notification send to the
:element_id
element in the pipeline:Pipeline.await_notification(pipeline, :element_id)
@spec await_playback_state(pid()) :: Membrane.RemoteControlled.Message.PlaybackState.t()
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.PlaybackState()
message with no further constraints, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Usage example:
- awaiting for any playback state change occuring in the pipeline:
Pipeline.await_playback_state(pipeline)
@spec await_playback_state(pid(), Membrane.PlaybackState.t()) :: Membrane.RemoteControlled.Message.PlaybackState.t()
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.PlaybackState()
message with the given state
, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Usage example:
- awaiting for the pipeline's playback state to change into
:playing
:Pipeline.await_playback_state(pipeline, :playing)
@spec await_start_of_stream(pid()) :: Membrane.RemoteControlled.Message.StartOfStream.t()
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.StartOfStream()
message
with no further constraints, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Usage example:
- awaiting for the first
start_of_stream
occuring on any pad of any element in the pipeline:Pipeline.await_start_of_stream(pipeline)
@spec await_start_of_stream(pid(), Membrane.Element.name_t()) :: Membrane.RemoteControlled.Message.StartOfStream.t()
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.StartOfStream()
message
concerning the given element
, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Usage example:
- awaiting for the first
start_of_stream
occuring on any pad of the:element_id
element in the pipeline:Pipeline.await_start_of_stream(pipeline, :element_id)
@spec await_start_of_stream(pid(), Membrane.Element.name_t(), Membrane.Pad.name_t()) :: Membrane.RemoteControlled.Message.StartOfStream.t()
Awaits for the first Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.StartOfStream()
message
concerning the given element
and the pad
, sent by the process with pipeline
pid.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Usage example:
- awaiting for the first
start_of_stream
occuring on the:pad_id
pad of the:element_id
element in the pipeline:Pipeline.await_start_of_stream(pipeline, :element_id, :pad_id)
@spec await_termination(pid()) :: Membrane.RemoteControlled.Message.Terminated.t()
Awaits for the Membrane.RemoteControlled.Message()
wrapping the Membrane.RemoteControlled.Message.Terminated
message,
which is send when the pipeline gracefully terminates.
It is required to firstly use the subscribe/2
to subscribe to a given message before awaiting
for that message.
Usage example:
- awaiting for the pipeline termination:
Pipeline.await_termination(pipeline)
@spec exec_actions(pid(), [Membrane.Pipeline.Action.t()]) :: :ok
Sends a list of Pipeline.Action.t()
to the given Membrane.RemoteControlled.Pipeline
for execution.
Usage example:
- making the
Membrane.RemoteControlled.Pipeline
start theMembrane.ParentSpec
specified in the action.children = ... links = ... actions = [{:spec, %ParentSpec{children: children, links: links}}] Pipeline.exec_actions(pipeline, actions)
@spec play(pid()) :: :ok
Changes playback state of pipeline to :playing
.
@spec prepare(pid()) :: :ok
Changes playback state to :prepared
.
@spec start(GenServer.options()) :: GenServer.on_start()
Does the same as the start_link/1
but starts the process outside of the supervision tree.
@spec start_link(GenServer.options()) :: GenServer.on_start()
Starts the Membrane.RemoteControlled.Pipeline
and links it to the current process. The process
that makes the call to the start_link/1
automatically become the controller process.
@spec stop(pid()) :: :ok
Changes playback state to :stopped
.
Changes pipeline's playback state to :stopped
and terminates its process.
Subscribes to a given subscription_pattern
. The subscription_pattern
should describe some subset
of elements of Membrane.RemoteControlled.Pipeline.message_t()
type. The subscription_pattern
must be a match pattern.
Usage examples:
- making the
Membrane.RemoteControlled.Pipeline
send to the controlling processMessage.StartOfStream
message when any pad of the:element_id
receives:start_of_stream
event.
subscribe(pipeline, %Message.StartOfStream{element: :element_id, pad: _})
- making the
Membrane.RemoteControlled.Pipeline
send to the controlling processMessage.PlaybackState
message when the pipeline playback state changes to any state (that is - for all the :stopped, :prepared and :playing playback states).
subscribe(pipeline, %Message.PlaybackState{state: _})
Changes pipeline's playback state to :stopped
and terminates its process.