Membrane.RTMPServer (Membrane RTMP plugin v0.29.1)
View SourceA 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,
appandstream_key, allowing custom processing, like sending the reference to another process. The function should return aMembrane.RTMPServer.client_behaviour_spec/0which 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. Otherwise, TCP socket (for RTMP) will be used. Defaults to false.
- ssl_options: SSL options to configure the SSL socket.
- 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.
SSL Configuration
SSL options can be configured at the application level or passed as runtime options.
Application Configuration
config :membrane_rtmp_plugin, :ssl,
certfile: "/path/to/cert.pem",
keyfile: "/path/to/key.pem",
verify: :verify_none,
fail_if_no_peer_cert: false,
versions: [:"tlsv1.2", :"tlsv1.3"]Runtime Options
Membrane.RTMPServer.start_link(
port: 1935,
use_ssl?: true,
ssl_options: [
certfile: "/path/to/cert.pem",
keyfile: "/path/to/key.pem"
],
handle_new_client: &my_handler/3
)
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.
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
@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 t() :: [ port: :inet.port_number(), use_ssl?: boolean(), ssl_options: keyword() | nil, 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.
@spec get_port(server_identifier()) :: :inet.port_number()
Returns the port on which the server listens for connection.
Extracts ssl, port, app and stream_key from url.
@spec start_link(server_options :: t()) :: GenServer.on_start()
Starts the RTMP server.