Mastering WebRTC SDP: A Complete Guide to Analyzing Session Descriptions
This article provides a systematic overview of the SDP (Session Description Protocol) used in WebRTC, covering its historical background, syntax, key fields, media descriptions, Plan B vs Unified Plan styles, and numerous extensions such as codec parameters, ICE candidates, DTLS, and simulcast, with practical examples and code snippets.
0. Introduction
SDP (Session Description Protocol) is a historic format used in 20th‑century conferencing systems to exchange connection and media attributes between peers. Although JSON is now more common for RPC, SDP remains widely supported in traditional streaming devices, and understanding it is valuable for development and debugging.
1. SDP Specification Overview
SDP consists of a session‑level section followed by zero or more media‑level sections.
The session level starts with a v= line and ends before the first media line.
Each media section starts with an m= line and continues until the next media line or the end of the description.
Session‑level values serve as defaults for all media unless overridden.
An SDP description is a series of lines in the form <type>=<value>. The type is case‑sensitive; the value’s format depends on the type. Fields are separated by spaces, and complex lines may use semicolons ( ;) to separate parameters.
Key SDP fields include:
v= (protocol version)
o= (originator)
s= (session name)
t= (timing)
m= (media description)
c= (connection address)
b= (bandwidth)
a= (attributes)
k= (encryption key)
The fields must appear in a specific order: session description, time description, then media description.
2. WebRTC SDP Content Analysis
In WebRTC, the SDP is relatively flexible; it must contain at least the lines v o s t m c b a. A full example is shown below:
v=0<br/>o=mozilla...THIS_IS_SDPARTA-82.0.3 485627351772987711 0 IN IP4 0.0.0.0<br/>s=-<br/>t=0 0<br/>m=video 9 UDP/TLS/RTP/SAVPF 120 124 121 125 126 127 97 98<br/>c=IN IP4 0.0.0.0<br/>b=AS:1000<br/>a=sendrecv<br/>...Media description example:
m=audio 9 UDP/TLS/RTP/SAVPF 111<br/>a=mid:audio<br/>a=rtpmap:111 opus/48000/2<br/>a=rtcp-fb:111 transport-cc<br/>a=fmtp:111 minptime=10;useinbandfec=1<br/><br/>m=video 9 UDP/TLS/RTP/SAVPF 96 97<br/>a=mid:video<br/>a=rtpmap:96 VP8/90000<br/>a=rtcp-fb:96 goog-remb<br/>a=rtcp-fb:96 transport-cc<br/>a=rtcp-fb:96 ccm fir<br/>a=rtcp-fb:96 nack<br/>a=rtcp-fb:96 nack pli<br/>a=rtpmap:97 rtx/90000<br/>a=fmtp:97 apt=96Important format fields:
c=<nettype> <addrtype> <connection-address>– connection info (IP address). m=<media> <port> <proto> <fmt> … – media type, transport protocol, and payload formats.
Other fields such as t= (start/stop time), s= (session name), and o= (originator) follow RFC definitions.
2.1 WebRTC‑SDP Introduction
WebRTC requires the lines v o s t m c b a. A complete example is provided above.
2.2 Plan B and Unified Plan
WebRTC SDP can follow two styles:
Plan B : Multiple audio/video streams are described within a single m= line.
Unified Plan : Each media track gets its own m= line, simplifying parsing.
With simulcast, a third level (track) is added, resulting in a three‑level hierarchy: session → media → track.
2.3 SDP Extension Information
The a= lines carry most of the detailed information, divided into media information (RTP parameters) and connection information (ICE, DTLS, etc.).
2.3.1 Codec Parameters
Examples:
a=rtpmap:108 H264/90000 a=fmtp:125 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f a=rtcp-fb:108 goog-rembThe a=rtpmap line defines the payload type and codec; a=fmtp provides codec‑specific parameters; a=rtcp-fb lists supported RTCP feedback mechanisms (e.g., nack, pli, ccm‑fir, goog‑remb, transport‑cc).
2.3.2 Header Extension Parameters
Example:
a=extmap:14 urn:ietf:params:rtp-hdrext:toffset2.3.3 Encoding Parameters
SSRC lines describe RTP streams:
a=ssrc:3245189021 cname:Cx4i/VTR51etgjT7<br/>a=ssrc:3245189021 msid:...<br/>a=ssrc:3245189021 mslabel:...<br/>a=ssrc:3245189021 label:...Firefox typically uses a single a=ssrc line with a CNAME.
2.3.4 RTCP Parameters
a=rtcp:<port> IN IP4 <address>– RTCP address (rare in WebRTC). a=rtcp-mux – RTP and RTCP share the same transport (RFC 5761). a=rtcp-rsize – reduced‑size RTCP packets (RFC 5506).
2.3.5 ICE Candidate
Examples:
a=candidate:0 1 UDP 2122252543 192.168.0.111 56774 typ host<br/>a=end-of-candidatesCandidate types include host, server‑reflexive (srflx), peer‑reflexive (prflx), and relay (TURN).
2.3.6 ICE Parameters
a=ice-options:trickle– Trickle ICE. a=ice-lite – ICE lite mode. a=ice-ufrag:<value> and a=ice-pwd:<value> – ICE credentials.
2.3.7 DTLS Parameters
a=setup:actpass– role negotiation (actpass/active/passive). a=fingerprint:sha-256 … – DTLS certificate fingerprint.
2.3.8 Miscellaneous
a=sendrecv, a=sendonly, a=recvonly, a=inactive – media direction. a=group:BUNDLE 0 1 – bundle multiple media on one transport. a=mid:<id> – media identifier (RFC 5888). a=rid:<id> … – RTP stream identifier (draft‑rid). a=simulcast:send hi;mid;lo – simulcast configuration. a=bundle-only – indicates BUNDLE usage in answers. a=msid-semantic:WMS * – MediaStream identifier semantics.
References
[1] 2006, RFC4566 – SDP [2] WebRTC RTP Header Extension analysis [3] RFC5576 – SSRC Group [4] RFC5761 – RTCP‑Mux [5] RFC5506 – Reduced‑size RTCP [6] RFC8445 – ICE UDP [7] RFC6544 – ICE TCP [8] RFC5763 – DTLS‑SRTP [9] RFC5888 – Media Identification
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Douyu Streaming
Official account of Douyu Streaming Development Department, sharing audio and video technology best practices.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
