This document details the flow of incoming (receive) RTP packets across the WebRTC codebase, tracing the path from the network socket to the video receive stream.
Packets arrive from the network via UDP or TCP sockets. Platform-specific socket implementations trigger an event when bytes are ready to be read.
AsyncUDPSocket / PhysicalSocketOnReadEventThe bytes move up through the ICE/STUN/TURN connection channels and DTLS layer.
P2PTransportChannel -> OnReadPacketConnection::OnReadPacketDtlsTransport -> OnReadPacketThe raw bytes reach the RTP core structures where they are parsed into proper C++ WebRTC objects.
RtpTransport::OnRtpPacketReceived(const ReceivedIpPacket&)RtpPacketReceived.RtpHeaderExtensionMap.RtpTransport::DemuxPacketRtpDemuxer::OnRtpPacket(const RtpPacketReceived&)RtpPacketSinkInterface (usually a BaseChannel).BaseChannel::OnRtpPacket(const RtpPacketReceived&)RtpPacketSinkInterface. Serves as the base conduit for specific Media Channels (audio or video).WebRtcVideoReceiveChannel::OnPacketReceived(RtpPacketReceived)Call interface: call_->Receiver()->DeliverRtpPacket(...)Call::DeliverRtpPacketRtpStreamReceiverController to resolve the sink for the SSRC.RtpVideoStreamReceiver2::OnRtpPacket(const RtpPacketReceived&)PacketBuffer (Jitter Buffer) to wait for frame completion.[Network] | v +-----------------------+ | AsyncUDPSocket / | (Network Thread) | PhysicalSocket | +-----------------------+ | v +-----------------------+ | P2PTransportChannel | (Network Thread) | / DtlsTransport | +-----------------------+ | v +-----------------------+ | RtpTransport | (Network Thread) +-----------------------+ | v +-----------------------+ | RtpDemuxer | (Network Thread) +-----------------------+ | v +-----------------------+ | BaseChannel | (Network Thread) | & MediaReceiveChannel| +-----------------------+ | v +-----------------------+ | Call::DeliverRtpPacket| (Network Thread) +-----------------------+ | v +-----------------------+ | Stream Receiver | (Network Thread) | (e.g., RtpVideo- | | StreamReceiver2) | +-----------------------+ | v [Decoder]