RTMP.Listener (rtmp v0.1.0)

Copy Markdown View Source

Starts an RTMP server.

Add it to your supervision tree:

children = [
  {RTMP.Listener, port: 1935, handler: MyApp.RTMPHandler}
]

Options

  • :handler (required) — a module implementing RTMP.Handler.
  • :handler_options — passed to RTMP.Handler.init/2 for every connection. Default [].
  • :port — TCP port. Default 1935. Use 0 for a random free port (see port/1).
  • :acceptors — number of acceptor processes. Default 10.
  • :max_connections — concurrent connections before new ones are refused. Default 16_384.
  • :limits — per-connection limits, a keyword list or RTMP.Limits struct. See RTMP.Limits for options and defaults.
  • :transport_options — passed to :gen_tcp via ThousandIsland, e.g. [ip: {127, 0, 0, 1}] to bind to localhost only.
  • :name — registered name for the listener's supervisor.

Each connection runs in its own process; a failure in one never affects the listener or any other connection.

Summary

Functions

The port the listener is bound to — useful after starting with port: 0.

Starts the listener. See the module docs for options.

Stops the listener, waiting up to timeout ms for connections to finish. Open connections get RTMP.Handler.handle_disconnect/2 with :shutdown.

Functions

port(listener)

@spec port(Supervisor.supervisor()) :: {:ok, :inet.port_number()} | :error

The port the listener is bound to — useful after starting with port: 0.

start_link(opts)

@spec start_link(keyword()) :: Supervisor.on_start()

Starts the listener. See the module docs for options.

stop(listener, timeout \\ 15000)

@spec stop(Supervisor.supervisor(), timeout()) :: :ok

Stops the listener, waiting up to timeout ms for connections to finish. Open connections get RTMP.Handler.handle_disconnect/2 with :shutdown.