Our office phones are configured to prefer G722 for intercom. Our ITSP completes calls using G711u. Without forcing a codec it will transcode from G722 to G711u when placing an outbound call, this is expected behavior.
To avoid transcoding we have added the following dialplan to the oubound context:
exten => s,n,Set(SIP_CODEC_INBOUND=ulaw) exten => s,n,Set(SIP_CODEC_OUTBOUND=ulaw) ... exten => s,n,Dial(...)
This works for most outbound calls. Resulting in the following output for “core show channel” on both legs:
NativeFormats: (ulaw) WriteFormat: ulaw ReadFormat: ulaw WriteTranscode: No ReadTranscode: No
On some outbound calls, specifically an auto answering join.me conference line (860) 970-0010 we get this output on both legs:
NativeFormats: (ulaw) WriteFormat: slin16 ReadFormat: slin16 WriteTranscode: Yes (slin@16000)->(slin@8000)->(ulaw@8000) ReadTranscode: Yes (ulaw@8000)->(slin@8000)->(slin@16000)
It’s almost as if the bridge itself remained in slin16 mode, while both endpoints switched to G711u.
The call that doesn’t transcode the ITSP indicated “183 Session Progress” and early media in SDP. While the call that does transcode the ITSP only indicated “200 OK” and the actual media for the call in SDP.
I was able to work around this issue by forcing early media to occur locally instead of on the remote side:
exten => s,n,Set(SIP_CODEC_INBOUND=ulaw) exten => s,n,Set(SIP_CODEC_OUTBOUND=ulaw) exten => s,n,Progress() ;force early media ... exten => s,n,Dial(...)
This fixed the issue. Another quirk to note is that Progress() has to be put after the SIP_CODEC statements, putting them before the statements did not help. The media has to change after the statements.
Is this a bug or an inherent limitation?