videocalling
SDP (Session Description Protocol)

SDP (Session Description Protocol)

Protocol

Standard format for describing media streaming parameters during connection establishment

What is SDP?

Session Description Protocol (SDP) is a format for describing the multimedia communication sessions for the purposes of session announcement and session invitation. In WebRTC, it is the key data payload exchanged during the signaling process to establish a peer-to-peer connection.

Think of SDP as a business card that devices exchange. It tells the other peer: "This is who I am, these are the audio and video codecs I support, this is my IP address and port (candidates), and this is the encryption I use."

Role in the Offer/Answer Model

WebRTC uses an Offer/Answer model to set up calls, and SDP is the language used for both:

  • Offer: One peer generates an SDP blob describing their capabilities and intent to start a session.
  • Answer: The receiving peer accepts the offer and generates their own SDP blob in response, confirming what they can support.

Once both sides have exchanged and set these SDPs (using setLocalDescription and setRemoteDescription), media can begin to flow.

Structure of an SDP Packet

SDP is text-based and consists of a series of lines in the format <type>=<value>. Here are common lines you might see:

  • v=0: Protocol version.
  • o=...: Originator and session identifier.
  • s=...: Session name.
  • c=...: Connection information (IP address).
  • m=...: Media Descriptions (e.g., m=audio 54312 RTP/SAVPF 111). This line defines the media type, port, protocol, and codec payload types.
  • a=...: Attributes (e.g., a=rtpmap:111 opus/48000/2). These provide details about the media lines, such as codec names and candidate information.

Why is SDP Important?

Without SDP, two devices wouldn't know how to talk to each other. One might speak "VP8" video while the other expects "H.264". One might be listening on port 5000 while the other sends to port 6000. SDP resolves all these discrepancies before the call starts.

SDP also carries the critical ICE candidates (IP addresses and ports) gathered by the ICE agent, which are necessary for traversing NATs and firewalls.