Enforcing codecs to prevent transcoding


I have some problem with codecs that I cant seem to get right.

My setup is a Cisco AS5350 and an Asterisk and then a SER where clients are connected.

I have for each user a codec to use. All “normal” users should use G.729, and for some with high bandwidth I allow G.711A. However, I have a problem with enforcing this codec through the Asterisk.

As B2BUA there are two “legs”, eg. for an incoming call coming from the Cisco and going to a Client Phone.

  1. Cisco —> Asterisk: Here I cant control which codec to use on a per user basis.
  2. Asterisk —> Client-Phone: Here I use different contexts towards the asterisk, eg. ser_alaw + ser_g729, each has its codec enabled.

How do I control the codec between Cisco and Asterisk dynamically to avoid transcoding?


in the cisco’s peer definition, do


the result is that only g729 and ulaw will be allowed, and g729 will be preferred where possible. However if the other side only supports ulaw, it will be used straight thru.

This is however not what I see…

If I use:

Then I get the following:

  1. Incoming from Cisco: Its saying combined codecs are (ulaw|g729)
  2. Reply from phone on SER: Its saying combined codecs are (ulaw)
  3. And finally this:
    Dec 16 18:20:06 WARNING[28312]: channel.c:2752 ast_channel_make_compatible: No path to translate from SIP/xxx.xx.xxx.x-08177550(256) to SIP/ser_ulaw-0817c7e8(8)
    Dec 16 18:20:06 WARNING[28312]: app_dial.c:1602 dial_exec_full: Had to drop call because I couldn’t make SIP/xxx.xx.xxx.x-08177550 compatible with SIP/ser_ulaw-0817c7e8

I’ve tried using SIP_CODEC variable to force it, but its not working as expected. Its working in the way that it selects ulaw if ulaw is the first allowed codec in sip.conf

I am on Asterisk 1.2.13 if that makes any difference.

Uh, I read your answer again. My Cisco is configured as a Friend, not as a Peer (ie. I am receiving calls from it only, not sending calls to it).

if you are sending calls to the CISCO and want the codec enforced that way just use 2 different peers to originate the calls from.

as for inbound calls from the cisco, use a couple of dialpeers w/ different codec prefs. this will adjust how the cisco presents the codecs calls coming in from the PRIs on the AS5000 series devices

Hi SwK,

I dont understand your answer. It would require that the Cisco has knowledge of codec prefs for each number, is that correct?

I dont have access to the Cisco in our setup, so I cant provision each number differently in it. However if its some general setting they can change, then I can ask them to fix that.

I am not sure it fixes my problem though, as I see it, the issue is that:

  1. Asterisk finds capabilities of the Cisco+Asterisk to be: ulaw+g729, however
  2. Later when it matches capabilities with the Client Phone it says that it cant match the channel with the other channel which it says is codec 256 (256 = g729 only, not g729+ulaw).

I dont know why it “forgets” that the Cisco+Asterisk can use both ulaw+g729. Maybe some flags I’m missing to set somewhere? Its like it only sees the first codec I “allow”.


try posting the rest of the debug, something odd is happening here…


is there the possibility to turn transcoding completely off, and force
asterisk to negotiate best same available codec on both call ends ?
Currently I use Asterisk 1.2.14, maybe in 1.4.0 it is implemented ?
Currently asterisk is picking the best match between codecs configured for
peer and codec available on peer on both call ends, and tries to do transcoding (which is failing becouse of missing codec modules).
But there are matching codecs on both sides, and they could be used.

thank you in advance