Imagine my setup - 2 trunks, each trunk allows only one codec, trunk 1 - alaw, trunk 2 - g722. My extension allows both alaw and g722. When I am calling from extension through trunk 1, asterisk sets up g722 channel to my extension and it has to transcode audio back and forth to/from alaw. Why asterisk does not issue reinvite with alaw codec in order to avoid transcoding or select alaw from the beginning ?
There is a patch from Sippy developers to avoid unnecessary transcoding:
It only supports 1.4 though