Media Formats within Session Description Protocol

I was asked a question recently on SIP codec negotiation between voice devices where the devices can support multiple codecs and how this is accomplished during call setup.

The Session Description Protocol (SDP) is used within the SIP message bodies to agree session information and announces Media Formats that the originating device will support for the session. The SDP also provides other important information, but we’ll focus on the voice Media Formats.

Below is an example packet capture of SIP INVITE message with the SDP payload and Media Description fields expanded:

Media Description, name and address (m): audio 40376 RTP/AVP 8 18 4 0
Media Type: audio
Media Port: 40376
Media Protocol: RTP/AVP
Media Format: ITU-T G.711 PCMA
Media Format: ITU-T G.729
Media Format: ITU-T G.723
Media Format: ITU-T G.711 PCMU

We can see in the above that the rtpmap attributes are laid out (8, 18, 4, 0) which are in the order of preference for this session. The subsequent Media Attributes fields relate the rtpmap values to the Media Formats:

Media Attribute (a): rtpmap:8 PCMA/8000
Media Attribute Fieldname: rtpmap
Media Format: 8
MIME Type: PCMA
Sample Rate: 8000
Media Attribute (a): rtpmap:18 G729/8000
Media Attribute Fieldname: rtpmap
Media Format: 18
MIME Type: G729
Sample Rate: 8000
Media Attribute (a): rtpmap:4 G723/8000
Media Attribute Fieldname: rtpmap
Media Format: 4
MIME Type: G723
Sample Rate: 8000
Media Attribute (a): rtpmap:0 PCMU/8000
Media Attribute Fieldname: rtpmap
Media Format: 0
MIME Type: PCMU
Sample Rate: 8000

In this example we can see that the device initiating the session prefers to use G.711A @ 8 kHz. The far end device will respond with a 200 OK message to confirm its own acceptable media formats.

Far End Device:

Media Description, name and address (m): audio 8000 RTP/AVP 8 0 3 98 97 101
Media Type: audio
Media Port: 8000
Media Protocol: RTP/AVP
Media Format: ITU-T G.711 PCMA
Media Format: ITU-T G.711 PCMU
Media Format: GSM 06.10
Media Format: DynamicRTP-Type-98
Media Format: DynamicRTP-Type-97
Media Format: DynamicRTP-Type-101
Media Attribute (a): rtpmap:0 pcmu/8000
Media Attribute Fieldname: rtpmap
Media Format: 0
MIME Type: pcmu
Sample Rate: 8000
Media Attribute (a): rtpmap:8 pcma/8000
Media Attribute Fieldname: rtpmap
Media Format: 8
MIME Type: pcma
Sample Rate: 8000
Media Attribute (a): rtpmap:3 gsm/8000
Media Attribute Fieldname: rtpmap
Media Format: 3
MIME Type: gsm
Sample Rate: 8000
Media Attribute (a): rtpmap:98 iLBC/8000
Media Attribute Fieldname: rtpmap
Media Format: 98
MIME Type: iLBC
Sample Rate: 8000
Media Attribute (a): rtpmap:97 speex/8000
Media Attribute Fieldname: rtpmap
Media Format: 97
MIME Type: speex
Sample Rate: 8000
Media Attribute (a): rtpmap:101 telephone-event/8000
Media Attribute Fieldname: rtpmap
Media Format: 101
MIME Type: telephone-event
Sample Rate: 8000
Media Attribute (a): fmtp:101 0-15
Media Attribute Fieldname: fmtp
Media Format: 101 [telephone-event]
Media format specific parameters: 0-15

In this case both devices can use a preferred Media Format of G.711A for the session and the call can proceed.

Should the far end device not support any of the available Media Formats offered by the originating device, a 415 “Unsupported Media Type” message is returned.

Links:

IETF RFC2327 SDP

Leave a Reply