View Source Membrane.RTMPServer (Membrane RTMP plugin v0.28.1)

A simple RTMP server, which handles each new incoming connection. When a new client connects, the handle_new_client is invoked. New connections remain in an incomplete RTMP handshake state, until another process makes demand for their data. If no data is demanded within the client_timeout period, TCP socket is closed.

Options:

  • handle_new_client: An anonymous function called when a new client connects. It receives the client reference, app and stream_key, allowing custom processing, like sending the reference to another process. The function should return a Membrane.RTMPServer.client_behaviour_spec/0 which defines how the client should behave.
  • port: Port on which RTMP server will listen. Defaults to 1935.
  • use_ssl?: If true, SSL socket (for RTMPS) will be used. Othwerwise, TCP socket (for RTMP) will be used. Defaults to false.
  • client_timeout: Time after which an unused client connection is automatically closed, expressed in Membrane.Time.t() units. Defaults to 5 seconds.
  • name: If not nil, value of this field will be used as a name under which the server's process will be registered. Defaults to nil.

Summary

Types

A type representing how a client handler should behave. If just a tuple is passed, the second element of that tuple is used as an input argument of the Membrane.RTMPServer.ClientHandler.handle_init/1. Otherwise, an empty map is passed to the Membrane.RTMPServer.ClientHandler.handle_init/1.

t()

Defines options for the RTMP server.

Functions

Returns a specification to start this module under a supervisor.

Returns the port on which the server listens for connection.

Extracts ssl, port, app and stream_key from url.

Starts the RTMP server.

Types

Link to this type

client_behaviour_spec()

View Source
@type client_behaviour_spec() ::
  Membrane.RTMPServer.ClientHandler.t()
  | {Membrane.RTMPServer.ClientHandler.t(), opts :: any()}

A type representing how a client handler should behave. If just a tuple is passed, the second element of that tuple is used as an input argument of the Membrane.RTMPServer.ClientHandler.handle_init/1. Otherwise, an empty map is passed to the Membrane.RTMPServer.ClientHandler.handle_init/1.

@type server_identifier() :: pid() | atom()
@type t() :: [
  port: :inet.port_number(),
  use_ssl?: boolean(),
  name: atom() | nil,
  handle_new_client: (client_ref :: pid(),
                      app :: String.t(),
                      stream_key :: String.t() ->
                        client_behaviour_spec()),
  client_timeout: Membrane.Time.t()
]

Defines options for the RTMP server.

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

get_port(server_identifier)

View Source
@spec get_port(server_identifier()) :: :inet.port_number()

Returns the port on which the server listens for connection.

@spec parse_url(url :: String.t()) :: {boolean(), integer(), String.t(), String.t()}

Extracts ssl, port, app and stream_key from url.

Link to this function

start_link(server_options)

View Source
@spec start_link(server_options :: t()) :: GenServer.on_start()

Starts the RTMP server.