Now to push my luck. If I want to send the call to an AGI instead of directly dialing the remote extension, is it possible to set up a pre-dial handler without the Dial command but with something else like the Set command?
I don’t understand what you mean. A pre-dial handler is invoked by Dial() and is meant to be a quick dialplan application run. Are you saying you want to dial something and send it elsewhere? Like an Originate from dialplan? If so there’s an application for that…
Sorry to break in on your thread but I’m a little stuck.
Jades, could you post your working configuration so I can duplicate?
I have FreePBX 14 / Asterisk 13, ulaw is the first codec in Admin / Advanced SIP Settings / Codec order.
To get G722 between extensions, I have the following config giving partially good results (my extensions start with 4…) in:
/etc/asterisk/extensions_override_freepbx.conf
[from-internal-custom]
exten => _4XXX,1,Set(PJSIP_MEDIA_OFFER(audio)=!all,g722)
same => n,Set(PJSIP_SEND_SESSION_REFRESH()=invite)
same => n,Dial(PJSIP/${EXTEN},b(callee-pre-dial^${EXTEN}^1))
same => n,Dial(PJSIP/${EXTEN},30)
[callee-pre-dial]
exten => _4XXX,1,Set(PJSIP_MEDIA_OFFER(audio)=!all,g722)
same => n,Return()
I get good call quality on both ends of the call (Grandstream Wave on Android talking to Jitsi Desktop on Windows). Both ends report they are using G722.
However, 2 issues:
‘pjsip show channelstats’ shows the caller with ulaw and callee with g722. As if the destination is switched to G722 but the calling extension remains at ulaw.
The CPU on the Asterisk server jumps, indicating it is doing transcoding for some reason. If I temporarily move G722 to the top of my SIP Codecs in FreePBX, calls between extensions are not transcoded and CPU utilization stays low. So Asterisk is transcoding and I want to avoid this.
I don’t understand what is going on - or what I am doing wrong. As I said, it looks like the 2 extensions are talking G722 to each other but Asterisk still thinks the caller is on ulaw.
Your code looks right, and I also have the same issue where asterisk shows the wrong codec. I just assumed it was a bug or design and just left it as is. I am able to differentiate how g711 vs g722 sounds like, plus both endpoints are confirming that the in-use codec is g722, so I am confident that it what you are seeing in the CLI doesn’t even matter. I also noticed the same behavior in chan_sip btw, which is what eased my concerned even more so.
Thanks for getting back to me and confirming the code snippet looks good.
I am getting good call quality with g722 but I am also seeing increased CPU utilization on the Asterisk server which indicates it is doing transcoding.
If I force all communication to g722 by changing the preferred codec in FreePBX / Advanced SIP Settings / General SIP Settings and move g722 to the top, I get the g722 call quality but without the increased CPU utilization i.e. no transcoding.
I’m concerned with CPU load on the server if I have a lot of extensions talking to each other and Asterisk is doing (unnecessary) transcoding on each channel.
Are you also seeing increased CPU utilization with g722 between extensions using the /etc/asterisk/extensions_override_freepbx.conf customization?
I see almost exactly the same amount of CPU usage when making a call with the above script vs making an outside call where no script is involved and g711 is automatically negotiated.
Also, I highly doubt any transcoding is done. You’d be able to tell in the quality of the phone call if transcoding is being performed. I could be wrong about this statement, but I know what a transcoded call would sound like, so I’m pretty confident about my response.