Membrane Core v0.3.0 Membrane.Element View Source

Module containing functions spawning, shutting down, inspecting and controlling playback of elements.

These functions are usually called by Membrane.Pipeline, and can be called from elsewhere only if there is a really good reason for doing so.

Link to this section Summary

Types

Type that defines an element name by which it is identified

Defines options that can be passed to start/5 / start_link/5 and received in Membrane.Element.Base.Mixin.CommonBehaviour.handle_init/1 callback

Type of user-managed state of element

Defines possible element types:

  • source, producing buffers
  • filter, processing buffers
  • sink, consuming buffers

Functions

Changes the playback state to the new_state

Returns a specification to start this module under a supervisor

Checks whether module is an element

Sends synchronous call to element, informing it that linking has finished

Sends synchronous call to element, requesting it to create a new instance of :on_request pad

Checks whether the given term is a valid element name

Sends synchronous calls to two elements, telling them to link with each other

Changes playback state to :playing

Changes playback state to :prepared

Sends synchronous call to the given element requesting it to set controlling pid

Sends synchronous call to the given element requesting it to set watcher

Stops given element process

Works similarly to start_link/3, but does not link to the current process

Works similarly to start_link/5, but does not link to the current process

Works similarly to start_link/5, but passes element struct (with default values) as element options

Starts process for element of given module, initialized with given options and links it to the current process in the supervision tree

Changes playback state to :stopped

Sends synchronous call to element, telling it to unlink all its pads

Link to this section Types

Type that defines an element name by which it is identified.

Link to this type

options_t() View Source
options_t() :: struct() | nil

Defines options that can be passed to start/5 / start_link/5 and received in Membrane.Element.Base.Mixin.CommonBehaviour.handle_init/1 callback.

Link to this type

playback_state_t() View Source
playback_state_t() :: :stopped | :prepared | :playing

Link to this type

state_t() View Source
state_t() :: map() | struct()

Type of user-managed state of element.

Link to this type

type_t() View Source
type_t() :: :source | :filter | :sink

Defines possible element types:

  • source, producing buffers
  • filter, processing buffers
  • sink, consuming buffers

Link to this section Functions

Link to this function

change_playback_state(pid, new_state) View Source
change_playback_state(pid(), playback_state_t()) :: :ok

Changes the playback state to the new_state.

Returns a specification to start this module under a supervisor.

See Supervisor.

Checks whether module is an element.

Link to this function

handle_linking_finished(server, timeout \\ 5000) View Source

Sends synchronous call to element, informing it that linking has finished.

Link to this function

handle_new_pad(server, direction, pad, timeout \\ 5000) View Source

Sends synchronous call to element, requesting it to create a new instance of :on_request pad.

Link to this macro

is_element_name(term) View Source (macro)

Checks whether the given term is a valid element name

Link to this function

link(link) View Source
link(link_spec :: %Membrane.Pipeline.Link{from: term(), to: term()}) ::
  :ok | {:error, any()}

Sends synchronous calls to two elements, telling them to link with each other.

Changes playback state to :playing.

An alias for change_playback_state/2 with proper state.

Link to this function

prepare(pid) View Source
prepare(pid()) :: :ok

Changes playback state to :prepared.

An alias for change_playback_state/2 with proper state.

Link to this function

set_controlling_pid(server, controlling_pid, timeout \\ 5000) View Source
set_controlling_pid(pid(), pid(), timeout()) :: :ok | {:error, any()}

Sends synchronous call to the given element requesting it to set controlling pid.

It will wait for reply for amount of time passed as second argument (in milliseconds).

Link to this function

set_watcher(server, watcher, timeout \\ 5000) View Source
set_watcher(pid(), pid(), timeout()) :: :ok | {:error, any()}

Sends synchronous call to the given element requesting it to set watcher.

It will wait for reply for amount of time passed as second argument (in milliseconds).

Link to this function

shutdown(server, timeout \\ 5000) View Source
shutdown(pid(), timeout()) :: :ok

Stops given element process.

It will wait for reply for amount of time passed as second argument (in milliseconds).

Will trigger calling Membrane.Element.Base.Mixin.CommonBehaviour.handle_shutdown/1 callback.

Link to this function

start(pipeline, module, name) View Source
start(pid(), module(), name_t()) :: GenServer.on_start()

Works similarly to start_link/3, but does not link to the current process.

Link to this function

start(pipeline, module, name, element_options, process_options \\ []) View Source

Works similarly to start_link/5, but does not link to the current process.

Link to this function

start_link(pipeline, module, name) View Source
start_link(pid(), module(), name_t()) :: GenServer.on_start()

Works similarly to start_link/5, but passes element struct (with default values) as element options.

If element does not define struct, nil is passed.

Link to this function

start_link(pipeline, module, name, element_options, process_options \\ []) View Source

Starts process for element of given module, initialized with given options and links it to the current process in the supervision tree.

Calls GenServer.start_link/3 underneath.

Changes playback state to :stopped.

An alias for change_playback_state/2 with proper state.

Link to this function

unlink(server, timeout \\ 5000) View Source

Sends synchronous call to element, telling it to unlink all its pads.