How WebRTC Uses SDP in Signaling

WebRTC (Web Real-Time Communication) relies on the Session Description Protocol (SDP) to negotiate media and network capabilities between peers. This article explains how WebRTC utilizes SDP during the signaling phase, detailing the offer/answer model, the metadata exchanged, and how this process establishes a direct peer-to-peer connection.

What is SDP in WebRTC?

Session Description Protocol (SDP) is a standardized format for describing multimedia sessions. It does not transmit the actual audio or video stream. Instead, SDP is a text-based format that lists a peer’s capabilities, including supported video/audio codecs, encryption keys, and network connection candidates.

The Offer/Answer Negotiation Model

WebRTC uses an “Offer/Answer” architecture to exchange SDP information between two peers (typically called Peer A and Peer B). Because WebRTC does not specify a built-in signaling protocol, peers must exchange these SDP messages using an external signaling mechanism, such as WebSockets, gRPC, or HTTP.

The negotiation process follows these steps:

  1. Creating the Offer: Peer A initiates the connection by calling createOffer(). The browser generates an SDP block containing Peer A’s media and network configurations. Peer A then saves this description locally using setLocalDescription(offer).

  2. Sending the Offer: Peer A sends this local SDP offer through the signaling server to Peer B.

  3. Receiving the Offer: Peer B receives the offer via the signaling channel and saves it as its remote configuration using setRemoteDescription(offer).

  4. Creating the Answer: Peer B generates a corresponding response by calling createAnswer(). This step creates a new SDP block containing Peer B’s compatible configurations. Peer B saves this as its local configuration using setLocalDescription(answer).

  5. Sending the Answer: Peer B transmits the SDP answer back to Peer A through the signaling server.

  6. Completing the Handshake: Peer A receives the answer and saves it using setRemoteDescription(answer).

Once both peers have set their local and remote descriptions, the SDP handshake is complete, and they have successfully negotiated their media session parameters.

What Information is Exchanged in the SDP?

The SDP text blocks contain critical metadata grouped into session-level and media-level descriptions. The primary components include:

By using SDP during this signaling phase, WebRTC ensures that both peers agree on how to encode, decode, and transmit the real-time data before any actual media transmission begins.