[asterisk-users] PJSIP - Forcing codec preference?

David Herselman dhe at syrex.co
Fri Sep 25 10:40:05 CDT 2020


We're holding ourselves back from moving to PJSIP as we don't appear to have figured out how to force codec preference in a dial plan. The 'PJSIP Advanced Codec Negotiation' document (https://wiki.asterisk.org/wiki/display/AST/PJSIP+Advanced+Codec+Negotiation) appears to ultimately be what we're after, but we're not comfortable running Asterisk 18 in production just yet. Is there no way to mimic functionality we previously had in chan_sip?

I don't appear to be able to set an inheritable variable for the subsequent PJSIP leg of the call, to exclusively only offer the codec we negotiated for the first leg of the call. If for example we have chan_iax2 incoming that we wish to send out via pjsip.

With chan_sip, this works:
 exten => s,n,Set(_SIP_CODEC_OUTBOUND=${CHANNEL(audioreadformat)})

With pjsip, this gives an error:
  exten => s,n,Set(_PJSIP_MEDIA_OFFER(audio)=!all,${CHANNEL(audioreadformat)})

  ERROR[26925][C-00020b9c] pbx_functions.c: Function _PJSIP_MEDIA_OFFER not registered

I'd image things haven't changed since 2018 where this appears to have been discussed in the following thread:
  Re: Pjsip migration - SIP_CODEC and SIP_CODEC_OUTBOUND
  URL: https://community.asterisk.org/t/pjsip-migration-sip-codec-and-sip-codec-outbound/73342/7

No way besides learning whatever code the AGI's written in, temporarily passing it up as a temporary variable and then calling a pre-dial handler?

I presume incoming shouldn't have this problem as the channel would be pjsip, right? With chan_sip we simply set SIP_CODEC as one of the first inbound context dial plan rules, before the channel is answered:
  exten => s,n,Set(SIP_CODEC=alaw)

I presume the following would work with pjsip:
  exten => s,n,Set(PJSIP_MEDIA_OFFER(audio)=!all,alaw)

PS: I can't find the reference again but recall a recommendation to call Progress() due to nuances with some systems, is this still relevant?

David Herselman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20200925/d9643433/attachment.html>

More information about the asterisk-users mailing list