TryLearn More

Use SIP trunks, WebRTC & Apps

Slash your Phone Bill by 80%

Codecs & SDP

This section will go over which codecs 3CX supports and how it negotiates codecs on incoming and outgoing calls with SIP Trunk Providers, as well as how the SDP is structured and where 3CX gets the information from.

Supported Codecs

3CX Supports the following codecs:

  • G.711a / 8000Hz / payload type 8
  • G.711u / 8000Hz / payload type 0
  • G.722 / 8000Hz / payload type 9
  • G.729a / 8000Hz / payload type 18
  • GSM-FR / 8000Hz / payload type 3
  • iLBC / 8000Hz / payload type 111
  • Speex / 8000Hz / payload type 97
  • opus / 48000Hz / palyload type 112
  • telephone-event 96-127 / 8000Hz

A special note for G.729a, the Media Attribute “annexb=no” must be accepted. Also G.729a does not accept VAD (Voice Activation Detection).

If any of the above does not apply, negotiation of G.729a will fail.

Codec Negotiation

Codec Order

The codec priority in 3CX can be configured on a per SIP Trunk basis and is done from the “Options” tab in the SIP Trunks settings, in the “Codec Priority” section.

From here, codecs can be removed, added and have their order changed. It is recommended to remove unnecessary codecs to reduce the MTU/packet size of outgoing INVITE messages. How the order of the codecs affects the codec negotiation will be explained in the following sections.

Outgoing Calls

When creating the INVITE message for an outgoing call through a SIP Trunk, 3CX will place the codecs in the SDP in the exact order they have been configured in “Codec Priority” section.

If the provider in the 200 OK responds with one or more codecs, 3CX will use the topmost codec found in the 200 OK.

Apart from the audio codecs, 3CX will also add the telephone-event 101 codec to the SDP for the transmission of DTMF tones over RFC2833. If the SIP Trunks in the 200 OK does not also include this, then DTMF codecs will not be transmitted over RFC2833.

Note that 3CX does not by default send in-band DTMF tones, it relies on the registered endpoint to do so, so if the endpoint does send in-band DTMF tones, 3CX will relay it.

Incoming Calls

Upon receiving an INVITE from SIP Trunk provider, 3CX will analyze the order of the codecs in the INVITE and will use the topmost codec in the received INVITE, as long as it is also listed in the available codecs in the SIP Trunk settings.

This means that the order of codecs in the SIP Trunk settings does not matter.

In regards to DTMF, 3CX accepts all telephone-event from 96-127 for RFC2833. If the provider does not send a telephone-event codec, then 3CX will not accept any RFC2833 DTMF tones, but it will still accept in-band DTMF tones.

If the INVITE from the SIP Trunk provider does not contain any codec that 3CX supports, or there is no common codec between those in the INVITE and the ones listed in Codecs in the SIP Trunk settings, then 3CX will reply with a 200 OK with no codecs listed and with SDP Port 0.

SDP Connection Address & Ports

For the SDP connection address, 3CX will decide which IP to use in the same way it decides the IP address in the “Contact” header for the REGISTER messages as explained in section 3.3.3.

In the INVITE and 200 OK messages, first 3CX will check if in the “Options” tab, there is an IP address entered in the “Select which IP to us in ‘Contact’ and ‘Connection’ fields” option. If so, this will be used.

If this option is set to “Use Default Settings” then 3CX will use the default Public IP address that it has been configured to use. This is set under Settings → Network → “Public IP” tab.

The Local RTP port 3CX will use on each call is a random port in the range of 9000-10999. This cannot be changed. There is no limitation however on which port the SIP Trunk providers Media Servers are using.