Difference between revisions of "PJSIP Codec negotiation"
| (2 intermediate revisions by the same user not shown) | |||
| Line 83: | Line 83: | ||
= Enforce LegA codecs to LegB = | = Enforce LegA codecs to LegB = | ||
In LegA Device/Provider, enable all codecs (or only the ones you really want to allow) and set '''Incoming Call Codec preference''' to '''remote'''. This causes Asterisk to select all allowed codecs from '''LegA SDP''' (preferring SDP order) and pass these codecs to Asterisk core.<br/> | In LegA Device/Provider, enable all codecs (or only the ones you really want to allow) and set '''Incoming Call Codec preference''' to '''remote'''. This causes Asterisk to select all allowed codecs from '''LegA SDP''' (preferring SDP order) and pass these codecs to Asterisk core.<br/> | ||
In LegB Device/Provider, enable all codecs (or only the ones you really want to allow) and set '''Outgoing Call Codec preference''' to '''remote'''. This causes Asterisk to select all allowed codecs from '''Asterisk core''' | In LegB Device/Provider, enable all codecs (or only the ones you really want to allow) and set '''Outgoing Call Codec preference''' to '''remote'''. This causes Asterisk to select all allowed codecs from '''Asterisk core'''. At this point, Asterisk core codecs should be from LegA SDP, ordered by legA SDP. These codecs are sent in SDP to '''LegB'''. | ||
= See also = | = See also = | ||
Latest revision as of 04:06, 21 November 2025
PJSIP Devices use advanced codec negotiation.
Both channels - incoming and outgoing - are responsible for how codecs will be handled during a call.
Device/Provider settings Incoming Call Codec preference and Outgoing Call Codec preference handle how codecs are selected.
Concept
When call comes to MOR (Asterisk), incoming SDP is processed according to Incoming Call Codec preference setting and the result is passed to Asterisk core. Then Asterisk creates an outgoing channel and applies Outgoing Call Codec preference setting on codec list received from Asterisk core (processed codecs from incoming channel). The result is sent in SDP to LegB.
LegA -> Asterisk incoming channel -> Asterisk core -> Asterisk outgoing channel -> LegB
The key concepts for Incoming Call Codec preference and Outgoing Call Codec preference are:
- Remote
- Local
In Incoming Call Codec preference, received codecs from LegA SDP are remote.
In Incoming Call Codec preference, GUI configured codecs are local.
In Outgoing Call Codec preference, received codecs from Asterisk core are remote.
In Outgoing Call Codec preference, GUI configured codecs are local.
Incoming Call Codec preference
Based on this setting, a joint list of preferred codecs between those received in an incoming SDP offer (remote), and those configured in the GUI incoming Device/Provider settings (local) is created and is passed to the Asterisk core.
This list will consist of only those codecs found in both lists (SDP and GUI configured codecs).
- Local - include all codecs in the GUI codec list (local) that are also in the incoming SDP (remote), preserving the local order.
- Local first - include only the first codec in the GUI codec list (local) list that is also in the incoming SDP (remote).
- Remote - include all codecs in the incoming SDP (remote) that are also in the GUI codec list (local), preserving the remote order.
- Remote first - include only the first codec in the incoming SDP (remote) that is also in the GUI codec list (local).
Example
LegA sends codecs in SDP: PCMA, PCMU, G729.
LegA Device configured codecs in GUI are: G729, PCMA, GSM, OPUS.
| Setting | Result (sent to Asterisk core) | Commment |
|---|---|---|
| Local | G729, PCMA | Common codecs are G729 and PCMA, order preference is local |
| Local first | G729 | GUI codecs are G729, PCMA, GSM, OPUS, first common codec in GUI configured list is G729, only this one is selected |
| Remote | PCMA, G729 | Common codecs are G729 and PCMA, order preference is remote |
| Remote first | PCMA | LegA SDP codecs are PCMA, PCMU, G729, first common codec in SDP is PCMA, only this one is selected |
Note: codec PCMU is not configured in GUI therefore it is not selected in any case. Codecs OPUS and GSM are configured in GUI but LegA does not include these codecs in SDP therefore they are also not selected in any case.
Outgoing Call Codec preference
Based on this setting, a joint list of preferred codecs between those received from the Asterisk core (remote), and those configured in the GUI outgoing Device/Provider settings (local) is created and is used to create the outgoing SDP offer.
- Local - include all codecs in the GUI codec list (local) that are also in the incoming Asterisk core (remote) preserving the local order.
- Local merge - include all codecs in the GUI codec list (local) preserving the local order.
- Local first - include only the first codec in the GUI codec list (local) that is also in the incoming Asterisk core (remote).
- Remote - include all codecs in the incoming Asterisk core (remote) that are also in the GUI codec list (local) preserving the remote order.
- Remote merge - include all codecs in the GUI codec list (local) preserving the Asterisk core (remote) order.
- Remote first - include only the first codec in the incoming Asterisk core (remote) that is also in the GUI codec list (local).
Example
Asterisk core sends codecs to outgoing channel: G729, PCMA.
LegB Device configured codecs in GUI are: OPUS, PCMA, GSM, G729.
| Setting | Result (sent to LegB) | Commment |
|---|---|---|
| Local | PCMA, G729 | Common codecs are PCMA and G729, order preference is local |
| Local merge | OPUS, PCMA, GSM, G729 | GUI codecs are OPUS, PCMA, GSM, G729, use only these codecs, order preference is local |
| Local first | PCAM | GUI codecs are OPUS, PCMA, GSM, G729, first common codec in GUI configured list is PCMA, only this one is selected |
| Remote | G729, PCMA | Common codecs are G729 and PCMA, order preference is remote |
| Remote merge | G729, PCMA, OPUS, GSM | GUI codecs are OPUS, PCMA, GSM, G729, all these codecs are included but order preference is remote |
| Remote first | G729 | Asterisk core codecs are G729 and PCMA, first common codec in Asterisk core list is G729, only this one is selected |
Enforce LegA codecs to LegB
In LegA Device/Provider, enable all codecs (or only the ones you really want to allow) and set Incoming Call Codec preference to remote. This causes Asterisk to select all allowed codecs from LegA SDP (preferring SDP order) and pass these codecs to Asterisk core.
In LegB Device/Provider, enable all codecs (or only the ones you really want to allow) and set Outgoing Call Codec preference to remote. This causes Asterisk to select all allowed codecs from Asterisk core. At this point, Asterisk core codecs should be from LegA SDP, ordered by legA SDP. These codecs are sent in SDP to LegB.