View Source Membrane.RTSP.Server (Membrane RTSP v0.10.1)

Implementation of an RTSP server.

Usage

To use the RTSP server, you should start it and provide some configuration. To start a new server under a supervision tree:

children = [
  {Membrane.RTSP.Server, [port: 8554, handler: MyRequestHandler]}
]

Supervisor.start_link(children, strategy: :one_for_one)

Or start it directly by calling start_link/1 or start/1.

{:ok, server} = Membrane.RTSP.Server.start_link(config)

For the available configuration options refer to start_link/1

Summary

Functions

Returns a specification to start this module under a supervisor.

Get the port number of the server.

Start an instance of the RTSP server.

Start and link an instance of the RTSP server.

Stops the RTSP server.

Types

@type server_config() :: [server_option()]
@type server_option() ::
  {:handler, module()}
  | {:handler_config, term()}
  | {:name, term()}
  | {:port, :inet.port_number()}
  | {:address, :inet.ip_address()}
  | {:udp_rtp_port, :inet.port_number()}
  | {:udp_rtcp_port, :inet.port_number()}
  | {:session_timeout, non_neg_integer()}

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

@spec port_number(pid() | GenServer.name()) ::
  {:ok, :inet.port_number()} | {:error, any()}

Get the port number of the server.

If the server started with port number 0, the os will choose an available port to assign to the server.

@spec start(server_config()) :: GenServer.on_start()

Start an instance of the RTSP server.

Refer to start_link/1 for the available configuration.

@spec start_link(server_config()) :: GenServer.on_start()

Start and link an instance of the RTSP server.

Options

  • handler - An implementation of the behaviour Membrane.RTSP.Server.Handler. Refer to the module documentation for more details. This field is required.
  • handler_config - Term that will be passed as an argument to init/1 callback of the handler. Defaults to nil.
  • name - Used for name registration of the server. Defaults to nil.
  • port - The port where the server will listen for client connections. Defaults to: 554
  • address - Specify the address where the tcp and udp sockets will be bound. Defaults to :any.
  • udp_rtp_port - The port number of the UDP socket that will be opened to send RTP packets.
  • udp_rtcp_port - The port number of the UDP socket that will be opened to send RTCP packets.
  • session_timeout - if the server does not receive any request from the client within the specified timeframe (in seconds), the connection will be closed. Defaults to 60 seconds.

Server UDP support

Both udp_rtp_port and udp_rtcp_port must be provided for the server to support UDP transport.

Link to this function

stop(server, opts \\ [])

View Source
@spec stop(pid(), [{:timeout, timeout()}]) :: :ok

Stops the RTSP server.

Options