Summary:ASTERISK-18892: CLONE -Asterisk doesn't respect the codec order - alaw always first in realtime.
Reporter:Maciej Krajewski (jamicque)Labels:
Date Opened:2011-11-18 15:29:13.000-0600Date Closed:2011-11-18 15:35:03.000-0600
Versions:Frequency of
is a clone ofASTERISK-18887 Asterisk doesn't respect the codec order - alaw always first in realtime.
Description:This is the old bug from 2008 - as a reply to that bug it was told that it won't be changed it that moment. Has anything changed? Problem still exists in

I receive calls from a E1 in Europe (so audio is encoded in PCMA). Then Asterisk does a Dial to a SIP proxy defined as:

type = peer
host = xxxxxxxx
allow = g729   ; <--- FIRST
allow = alaw
allow = ulaw
context = from-proxy

But the INVITE generated by Asterisk has the following SDP:
o=root 5394 5394 IN IP4
c=IN IP4
t=0 0
m=audio 14868 RTP/AVP 8 18 0 3 101
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:0 PCMU/8000
a=rtpmap:3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -

As you can see, the preferred codec is PCMA instead of G729.
I've also tryed adding in the dialplan:
 exten => _XXXXX.,n,Set(__SIP_CODEC=g729)
but it does nothing.

Well, I can understand that in order to avoid transcoding Asterisk chooses PCMA (since it's the same codification as the audio coming from the E1), but it should be possible to respect the codec order set in the peer configuration.

Of course this is very important for a SIP provider.

So I wonder why there is not a way to get it, and also why this is the default behaviour (non respecting the codec order set in sip.conf).

the originating call does not have to come from E1 it can be originated by SIP UA.
What i have noticed that in no mater what configuration in sip.conf for peer/friend/user alaw is always the first codec in SDP (despite the order of configuration),
rest of the codes are in order as configured in sip.conf. Deleting alaw from configuration causes codec to placed in proper order so the issue seems to be concerning alaw being always first in SDP no matter what.

If any more information is required please let me know.
Comments:By: Matt Jordan (mjordan) 2011-11-18 15:34:54.459-0600

Clone :-(