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::DeliverRtpPacketreceive_time_calculator_ directly on the Network Thread to avoid jitter/delay.Call::DeliverRtpPacket_w.Call::DeliverRtpPacket_wRtpVideoStreamReceiver2::OnRtpPacket(const RtpPacketReceived&)PacketBuffer (Jitter Buffer) to wait for frame completion.VideoFrame is decoded by VCMGenericDecoder.[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) +-----------------------+ | | Thread Hop v +-----------------------+ | Call:: | (Worker Thread) | DeliverRtpPacket_w | +-----------------------+ | v +-----------------------+ | Stream Receiver | (Worker Thread) | (e.g., RtpVideo- | | StreamReceiver2) | +-----------------------+ | v [Decoder]