RTMP.Connection (rtmp v0.1.0)

Copy Markdown View Source

One process per RTMP connection (a ThousandIsland.Handler). Started by RTMP.Listener; you don't use this module directly.

It drives the whole connection: handshake, chunk stream reassembly, protocol control messages, commands, FLV tag parsing, and the calls into your RTMP.Handler.

Design notes

  • Backpressure. Frames are handed to your handler synchronously, inside handle_data/3. ThousandIsland keeps the socket in active: :once mode, so no more data is read until that returns. A slow handler throttles the publisher through TCP flow control instead of filling an internal queue — there isn't one.
  • Failure isolation. Every exit path — protocol error, limit breach, timeout, handler exception, rejection — closes this one connection and reports a reason to RTMP.Handler.handle_disconnect/2. Nothing here can affect the listener or other connections.
  • Output batching. Everything a step needs to send is collected and written to the socket in one call at the end of that step.

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(arg)

@spec start_link({handler_options :: term(), GenServer.options()}) ::
  GenServer.on_start()