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 wrapssrs_netfd_tand exposes aSrsTcpConnectionas the accepted server-side TCP socket (not an outbound “client” in naming) -
→ that has-a
ISrsProtocolReadWriterbehavior 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+SrsProtocolfor 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::cyclerather than a separate OS thread.