Audio codecs 🎚️
Define a tradeoff between audio quality and consumed bandwidth
Last updated
Define a tradeoff between audio quality and consumed bandwidth
Last updated
Audio codecs and fluctuations in network (jitter, packet loss) are 2 main factors that impact audio quality on a VoIP call. Although the possibilities to control quality of a network are usually limited, you can always configure codecs
👨🔧 For example one may select HD codecs only (like G722
) on calls running through a particular AI Agent / Trunk preventing lower quality calls completely
👨🔧 Or they may wish to sacrifice quality in a tradeoff for a reduction in audio bitrate (and thus consumed network bandwidth) by enabling PCMA
, PCMU
Codecs negotiation process may be a bit convoluted, so we provide examples to make it simpler!
This will help you in understanding how and when to set codecs on the inbound leg (A leg), outbound leg (B leg), and when to force them on both
When call gets set up there is 4 sets of codecs involved . This may seem excessive but let's have a look
Calling party codecs (A)
A caller will call with a set of codec supported by their device (calling party codecs)
Called party codecs (B)
A callee will have their own set of supported codecs (called party codecs)
VoIP Number outbound codecs for calling party (VN-A)
These codecs will negotiate media against calling party codecs on the A leg
VoIP Number inbound codecs for called party (VN-B)
These codecs will negotiate media against called party codecs on the B leg
2 sets (A, B) are controlled by the end points (caller / callee) and 2 (VN-A, VN-B) by VoIP Number in order to setup a media on both legs of a call. What you can always configure on VoIP Number is these 2 sets of codecs to be applied by VoIP Number on a caller and callee (VN-A, VN-B). If you control the endpoints then you can also configure codecs on them (A, B)
Caller (PSTN or external SIP) dials in with (A) OPUS, G722 and PCMA
VoIP Number looks up the Connection and sees that it has inbound codecs configured to G722, PCMU, PCMA (VN-B). It sets these codecs on a B leg to Connection and rings it. Connection supports OPUS, G722, AMR-WB, PCMU, PCMA (B). G722 is the first codec present on both lists on the B leg (B, VN-B) and gets selected
Coming back to the A leg, because Connection did not enforce inbound codecs on a caller, a full set of codecs available on VoIP Number is offered to the caller (VN-A): OPUS, G722, AMR-WB, PCMU, PCMA. The first codec in common between A and VN-A is OPUS, so it gets selected
Caller (PSTN or external SIP) dials in with (A) OPUS, G722 and PCMA
VoIP Number looks up the Connection and sees that it has inbound codecs configured to G722, PCMU, PCMA (VN-B). It sets these codecs on a B leg to Connection and rings it. Connection supports OPUS, G722, AMR-WB, PCMU, PCMA (B). G722 is the first codec present on both lists on the B leg (B, VN-B) and gets selected
Coming back to the A leg, because Connection has Force selected codecs on the caller
enabled - this same list (VN-B) is offered to the caller (VN-A): G722, PCMU, PCMA. The first codec in common between A and VN-A is G722, so it gets selected
Caller (PSTN or external SIP) dials in with (A) OPUS, G722 and PCMA
VoIP Number looks up the Connection and sees that it has inbound codecs configured to G722, PCMU, PCMA (VN-B). It sets these codecs on a B leg to Connection and rings it. Connection supports OPUS, G722, AMR-WB, PCMU, PCMA (B). G722 is the first codec present on both lists on the B leg (B, VN-B) and gets selected
Coming back to the A leg, because Connection B has Force selected codecs on the caller
enabled - this same list (VN-B) is offered to the caller (VN-A): G722, PCMU, PCMA. There is no codec in common between A (OPUS) and VN-A (G722, PCMU, PCMA) , so call is declined
This type of codec enforcement may be a deliberate strategy enforcing calls coming through a given Trunk or Connection are always in high audio quality or with a low bitrate
Connection A (SIP endpoint registered on VoIP Number) dials in with (A) OPUS, G722 and PCMA
VoIP Number looks up dialed Connection B and sees that it has inbound codecs configured to G722, PCMU, PCMA (VN-B). It sets these codecs on a B leg to Connection B and rings it. Connection B supports OPUS, G722, AMR-WB, PCMU, PCMA (B). G722 is the first codec present on both lists on the B leg (B, VN-B) and gets selected
Coming back to the A leg, VoIP Number sees that Connection A has outbound codecs configured to OPUS, G722. Because Connection B did not enforce inbound codecs on a caller, this list of codecs is offered to the caller (VN-A): OPUS, G722. The first codec in common between A and VN-A is OPUS, so it gets selected
Connection A (SIP endpoint registered on VoIP Number) dials in with (A) OPUS, G722 and PCMA
VoIP Number looks up dialed Connection B and sees that it has inbound codecs configured to G722, PCMU, PCMA (VN-B). It sets these codecs on a B leg to Connection B and rings it. Connection B supports OPUS, G722, AMR-WB, PCMU, PCMA (B). G722 is the first codec present on both lists on the B leg (B, VN-B) and gets selected
Coming back to the A leg, VoIP Number sees that Connection A has outbound codecs configured to OPUS, G722. Because Connection B has Force selected codecs on the caller
enabled - this same list (VN-B) is offered to the caller (VN-A): G722, PCMU, PCMA. The first codec in common between A and VN-A is G722, so it gets selected
With a Trunk things are simpler. TRUNK IN
codecs are offered on the A leg to caller (become VN-A list). TRUNK OUT
codecs are offered on a B leg to called party (become VN-B list)
Caller dials in with (A) OPUS, G722 and PCMA
VoIP Number looks up the Trunk and sees that it has outbound codecs (TRUNK OUT
) configured to G722, PCMU, PCMA (VN-B). It sets these codecs on a B leg to called party and rings it. Called party supports OPUS, G722, AMR-WB, PCMU, PCMA (B). G722 is the first codec present on both lists on the B leg (B, VN-B) and gets selected
Coming back to the A leg, VoIP Number sees that Trunk has inbound codecs (TRUNK IN
) configured to G722, PCMU, PCMA. This list of codecs is offered to the caller (VN-A): G722, PCMU, PCMA. The first codec in common between A and VN-A is G722, so it gets selected
Open inbound / outbound settings of your Connection or Trunk
You will find there a list of Available
and Selected
codecs
Move codecs between lists to build a list of selected codecs that is prioritised from the top to bottom (the top most entry on a list has highest priority). This means that when codecs are negotiated they are considered starting from the top most entry to the bottom
Only a codec that is present on your Selected
list may be chosen on a call
Click on arrows to move codecs between Available
and Selected
lists
Drag and drop them to rearrange position on a list
Save your settings once done
✅ You have now configured codecs and defined acceptable audio quality and network bandwidth consumed