You can’t. An endpoint is generally not going to send a re-INVITE to change the codecs mid-call, and if it does or exposes that in some fashion, it will be a device specific attribute.
Technically, ConfBridge always transcodes, since it has to mix the audio from all the participants. In its case, it transcodes the audio to signed linear, mixes it, then transcodes it back to the write format of each particular participant. It maintains a special set of transcoders in
bridge_softmix for this purpose.
That doesn’t really help you, however, since it doesn’t force the participants to all use a particular format, e.g., g722.
The notion of having ‘on-the-fly switching to different formats’ has been discussed a few times at AstriDevCons. If I were going to go about doing something like this, I’d use the PJSIP stack in Asterisk, as it will be far easier than attempting to do it
chan_sip (in fact, I wouldn’t even bother trying in
chan_sip, given its structure).
res_pjsip_session already exposes a function to initiate a media session refresh via an
UPDATE or re-
res_pjsip_session_refresh - which will do the job we need. Furthermore, we already have a dialplan function
PJSIP_MEDIA_OFFER that allows you to change the formats we’d offer in a session refresh. There really just needs to be a new dialplan function - say
PJSIP_SEND_SESSION_REFRESH - that invokes
res_pjsip_session_refresh. Then you could do something like this to change the formats on the fly:
same => n,Set(PJSIP_MEDIA_OFFER(audio)=!all,g722)
same => n,Set(PJSIP_SEND_SESSION_REFRESH()=invite)
Note that I’m glossing over some details, as I’m pretty sure you’d have to update the formats on the channel if the refresh succeeded, but it shouldn’t be a lot of code thanks to the APIs the PJSIP stack in Asterisk exposes.