Skip to content

Object Integration for Handling RTMP in SRS

Object Integration for Handling RTMP in SRS

Today I spent some time exploring the code to understand how the components interact (taking RTMP/RTMPS as an example; other protocols are expected to follow the same pattern, I think). I’m not digging into the RTMP protocol itself, since I focus more on system software than media server engineering. My priority is identifying where each component resides and how they integrate to form a server-level object, so I can build a clear mental map while navigating the codebase.

The component ntegration

The server dispatches the connection resource based on the type of listener:

  • → that has-a SrsServer::do_on_tcp_client(listener, stfd)
    that branches on which listener object (e.g. rtmp_listener_)

  • → that has-a a newly created SrsRtmpConn
    (mind: the listener only accepts and callbacks; the real conn object is owned/created here, not inside the listener)

  • → that has-a ISrsRtmpTransport / SrsRtmpTransport (RTMPS: SrsRtmpsTransport)
    that wraps srs_netfd_t and exposes a SrsTcpConnection as the accepted server-side TCP socket (not an outbound “client” in naming)

  • → that has-a ISrsProtocolReadWriter behavior for raw bytes

  • → that has-a a path through srs_netfd + state-threads (ST) down to kernel socket syscalls

Upper layer — above that byte stream is not yet RTMP semantics, so SrsRtmpConn:

  • has-a SrsRtmpServer + SrsProtocol for RTMP handshake + chunk/message decode/encode (recv_message / do_decode_message / send_and_free_message)

  • → and the conn logic runs as a coroutine via SrsRtmpConn::cycle rather than a separate OS thread.

Share this page:

LinkedIn Twitter Facebook

Comments