SDP Format for WebRTC: Media Negotiation Essentials and Its Relationship to SIP INVITE

Protocols Featured Articles 6 minutes |
SDP Format for WebRTC: Media Negotiation Essentials and Its Relationship to SIP INVITE

SDP (Session Description Protocol) is the core session description format used by WebRTC to carry media negotiation and connection parameters. SIP (Session Initiation Protocol) is a signaling protocol. This article focuses on SDP in WebRTC and explains its differences and relationship with SIP INVITE.

SDP fundamentals and positioning

SDP is defined by RFC 4566 as a text-based session description format. It expresses parameters of a multimedia session; it is not a transport/signaling protocol. In WebRTC, SDP conveys media capabilities and negotiation parameters.

SDP quick facts

ItemMeaningExample
Standards docDefines the content format of SDPRFC 4566
Format typeSession description (plain text)key-value / line semantics
Primary useMedia session descriptioncodecs, bandwidth, direction, etc.
WebRTC hostObject that holds SDPRTCSessionDescription (offer/answer)

What SDP describes

Media line cheatsheet

Info typeSDP markerMeaningCommon values
Media linem=Media stream typeaudio, video, application
Connectionc=Network addressIN IP4 0.0.0.0
Attributesa=Media/session attributesrtpmap, ice-ufrag, sendrecv
Session infos=Session name- (often empty)
Timingt=Session time0 0 (permanent)

Common codec mappings

MediaCodecPTClockNotes
audioOpus11148000/2High quality, low latency
audioPCMU08000G.711
audioPCMA88000G.711
videoVP89690000Open
videoVP99890000Efficient
videoH.2649790000Widely supported

Offer/Answer in WebRTC

SDP exchange sequence (WebRTC)

sequenceDiagram
    participant A as Caller
    participant S as Signaling Server
    participant B as Callee

    A->>S: Send Offer (SDP)
    S->>B: Forward Offer (SDP)
    B->>S: Send Answer (SDP)
    S->>A: Forward Answer (SDP)
    Note over A,B: Offer/Answer complete → media starts

SDP state table (WebRTC)

StageCaller stateCallee stateSDP typeDescription
1Create OfferWaitingofferCaller generates local media capability description
2Waiting for AnswerProcess OfferofferCallee sets remote description
3Waiting for AnswerCreate AnsweranswerCallee generates answer description
4Process AnswerWaiting for connectionanswerCaller sets remote description
5ConnectedConnected-Media negotiation completed

SDP and SIP INVITE: differences and relationship

Conclusion first: SDP is the “description”; SIP INVITE is the “signaling carrier”. In a typical SIP call, the INVITE body carries SDP (Offer); the peer returns SDP (Answer) in 200 OK, completing the Offer/Answer model—conceptually the same as in WebRTC.

Concept map

DimensionSDP (description format)SIP INVITE (signaling request)Relationship
PositioningText format describing media/session parametersRequest method to initiate/modify/terminate a sessionINVITE body may carry SDP
FunctionCodecs, media direction, bandwidth, networkCall control and routingSignaling carries description
StandardRFC 4566RFC 3261 (and extensions)Different specs, complementary
NegotiationOffer/Answer (RFC 3264)Driven by INVITE/200 OK/ACKOffer/Answer embedded in SIP

SIP sequence with SDP (maps to Offer/Answer)

sequenceDiagram
    participant UAC as UAC (Caller)
    participant Proxy as SIP Proxy
    participant UAS as UAS (Callee)

    UAC->>Proxy: INVITE (SDP = Offer)
    Proxy->>UAS: INVITE (SDP = Offer)
    UAS-->>Proxy: 180 / 183 (optional, early media)
    UAS->>Proxy: 200 OK (SDP = Answer)
    Proxy->>UAC: 200 OK (SDP = Answer)
    UAC->>Proxy: ACK
    Proxy->>UAS: ACK
    Note over UAC,UAS: Media (RTP/RTCP) can start

SIP INVITE key fields

ElementLocationExample/NotesPurpose
MethodStart-lineINVITE sip:[email protected] SIP/2.0Initiate session
RoutingHeadersVia/Route/Record-RoutePath propagation/recording
IdentityHeadersCall-ID / From / To / CSeqIdentify session and order
CapabilitiesHeadersContact / Allow / SupportedTerminal features
Payload typeHeadersContent-Type: application/sdpDeclare body type
DescriptionBodySDP text (Offer/Answer)Carry media parameters

Mapping to WebRTC signaling

StepSIP worldWebRTC worldCommonality
Offer generatedINVITE with SDPcreateOffer()/setLocalDescriptionLocal capability description
Answer returned200 OK with SDPcreateAnswer()/setLocalDescriptionAnswer capability description
ConfirmationACKsetRemoteDescription(Answer)Agreement reached
TransportSIP signaling (UDP/TCP/TLS)Custom signaling (WS, etc.)Carry SDP, drive negotiation

Common misconceptions

  • SDP is a session description format, not a protocol; it does not transport signaling.
  • SIP is a signaling protocol; it can carry SDP in message bodies. WebRTC uses custom signaling to carry SDP as well.
  • Offer/Answer (RFC 3264) is a negotiation model used in both SIP (INVITE/200 OK/ACK) and WebRTC (createOffer/createAnswer).
  • Media (RTP/RTCP) and signaling (SIP/custom) are layered and separate: media transports streams; signaling orchestrates negotiation/routing.

SIP–WebRTC interop (supplement)

Protocol comparison

FeatureWebRTCSIPCommon
TransportUDP/TLS/RTP/SAVPFRTP/AVPRTP media layer
SecurityDTLS mandatoryOptional TLSEncryption supported
NAT traversalICE requiredOptional STUN/TURNConnectivity
Session descriptionSDP (format)SDP (format)Same content format, different signaling carriers
SignalingCustom (WebSocket, etc.)SIP stackDifferent implementations

Interop architecture

graph TB
    subgraph "WebRTC"
        W1[Browser] --> W2[WebRTC API]
        W2 --> W3[SDP Offer/Answer]
    end
    
    subgraph "Gateway"
        G1[Protocol Gateway]
        G2[SDP Adaptation]
        G3[Media Relay]
    end
    
    subgraph "SIP"
        S1[SIP Client] --> S2[SIP Stack]
        S2 --> S3[SDP Handling]
    end
    
    W3 --> G1
    G1 --> G2
    G2 --> G3
    G3 --> S3

SDP adaptation cheat sheet

WebRTC attrSIP equivalentAction
UDP/TLS/RTP/SAVPFRTP/AVPRename transport profile
a=ice-ufragn/aRemove
a=ice-pwdn/aRemove
a=fingerprintn/aRemove DTLS fingerprint
a=setup:actpassn/aRemove DTLS setup
a=midn/aRemove media ID

Use cases

ScenarioWebRTC strengthsSIP strengthsInterop value
Enterprise UCBrowser-native accessMature PBXUnified platform
Contact centerFast rolloutStabilityHybrid agent
Mobile appsNative integrationCarrier interopEnd-to-end reach
Video meetingsRich mediaStandardsCross-platform

Troubleshooting and optimization

Diagnostic matrix

SymptomLikely causeSDP checkpointFix
No audioCodec mismatcha=rtpmap (audio)Align codec set
No videoVideo negotiation failurea=rtpmap (video)Ensure VP8/H.264
Failed connectICE issuesa=ice-ufrag/pwdCheck STUN/TURN
Poor qualityCodec choicePayload orderReorder codecs
High latencyBandwidth limitb=AS lineTune bitrate

Signaling state (WebRTC)

stateDiagram-v2
    [*] --> stable: initial
    stable --> have_local_offer: createOffer()
    have_local_offer --> stable: setRemoteDescription(answer)
    stable --> have_remote_offer: setRemoteDescription(offer)
    have_remote_offer --> stable: setLocalDescription(answer)
    
    have_local_offer --> have_local_offer: setLocalDescription(offer)
    have_remote_offer --> have_remote_offer: setRemoteDescription(offer)
    
    stable --> closed: close()
    have_local_offer --> closed: close()
    have_remote_offer --> closed: close()

Optimization cheat sheet

GoalSDP tweakExampleWhen
Lower latencyCodec priorityOpus > PCMURealtime calls
Save bandwidthLimit bitrateb=AS:500Mobile networks
Better qualityHigh profileH.264 High ProfileConferences
CompatibilityBaseline codecsPCMU/PCMALegacy interop

Tags

#WebRTC #SDP #Session Description #Media Negotiation #SIP #Signaling #P2P #Codecs

Copyright Notice

This article is created by WebRTC.link and licensed under CC BY-NC-SA 4.0. This site repost articles will cite the source and author. If you need to repost, please cite the source and author.

Comments

Giscus

Comments powered by Giscus, based on GitHub Discussions

Related Articles

Explore more related content to deepen your understanding of WebRTC technology