Looking for help on avoiding transcoding whilst transitioning to PJSIP. We’re running Asterisk 18.14.0 with FreePBX 16.
I would essentially like to be able to duplicating what we have working with chan_sip and chan_iax2, so that we can migrate to PJSIP for the upstream VoIP trunks. We’re essentially after the promises of ACN but disappointed that work on this appears to have stalled in the last 2 years.
I’m unfortunately not a developer and whilst I’ve been able to hack together most of what we need using the dial plan I’m in no position to meaningfully contribute to the source code. I am however very grateful for the contributions of skill and time for those that are able to contribute though!
What we have working
We use chan_sip for upstream trunks and a mixture of PJSIP and IAX2 for downstream extensions. Our dial plan currently sets an inheritable variable (‘_’ prefix) that the outgoing call uses to restrict the codec selection of what the current (inbound) channel is making use of.
Upstream (chan_sip) trunk is configured for both alaw and g729 with a custom context:
context=custom-force-codec
allow=alaw,g729
Incoming calls (from upstream SIP trunk towards extensions):
This is very manual, in that we set nearly all extensions to only support g729, with some allowing both g729 and alaw. We then update the custom context that incoming calls from the upstream provider flow in via to force alaw for those.
[custom-force-codec]
exten => _0115551111,1,Set(SIP_CODEC=alaw)
exten => _0116662222,1,Set(SIP_CODEC=alaw)
exten => _.,1,Set(SIP_CODEC=g729)
exten => _.,n,Goto(from-pstn,${EXTEN},1)
exten => s,1,Goto(from-pstn,s,1)
Incoming calls subsequently work relatively well, herewith an example:
pbx.c: Executing [0115551111@custom-force-codec:1] Set("SIP/AAA-00009e8b", "SIP_CODEC=alaw") in new stack
pbx.c: Executing [0115551111@custom-force-codec:2] Goto("SIP/AAA-00009e8b", "from-pstn,5551111,1") in new stack
pbx_builtins.c: Goto (from-pstn,0115551111,1)
Outgoing calls (from extensions through upstream SIP trunks): We have a custom 'macro-dialout-trunk-predial-hook' context which simply contains: ``` exten => s,n,Set(_SIP_CODEC_OUTBOUND=${CHANNEL(audioreadformat)}) ```
Question time
I’m looking for anything that could provide a bridge gap before ACN becomes a reality. I’m also not sure if ACN will ever support codec negotiation between IAX2 and PJSIP.