Controlling codec listed in INVITE SDP

Dear All,

We are looking for a way to specify at runtime (preferably in an AGI script) the codecs listed in the INVITE/SDP sent from *.

We currently have an AGI script called each time a call comes in, and set there the SIP_CODEC to define in realtime the codec to use with the caller leg.

From what I found, SIP_CODEC does not help when Asterisk sends an INVITE, only when it replies to an INVITE.

Possibly the best way to do this is to have a “SIP_CODEC similar variable” that would tell asterisk which codecs to use in the INVITES it sends.

Can you help me or point me in the right direction ?

Is there a reason why this exists when called not when calling ?

Thank you for your help,