[asterisk-dev] SIP codec selection. Can I select a codec and reinvite?

Gregory Boehnlein damin at nacs.net
Mon Nov 19 14:42:09 CST 2007

> On outbound calls every thing works fine. The phone picks the codec and
> asterisk passes it on to the sip trunk.   On inbound calls  (from the
> SIP trunk) the Sip trunks proffered codec is selected.
> Is there any way (in asterisk) that I can select the codec per call?
> i.e.  Call comes in. before answering the call look up the destination
> peers codec, (function SIPPEER?) and set the codec to use and then
> answer?
> Or is there any way to set the codec and do an manual re-invite?
> Thanks
> Doug Gillespie

BJ Wescke wrote a patch for me last year for 1.2 that allowed us to do codec
based routing via a new DialPlan Function called "SIPPrefCodec". I don't
know if it will work for you, but I've attached a link to the patch.


Basically, that would let you define multiple peers ala:



Using the function, you could then build your Dial string to send it to the
specific peer that matched the codec of the inbound call leg.

Hackish, and not clean, but it worked for us at the time.

More information about the asterisk-dev mailing list