[asterisk-dev] Codec Negotiation in Asterisk

Ravi Shankar rbalakri at netd.com
Wed Feb 8 08:11:12 MST 2006


Hi,
    I was playing around with the Asterisk 1.2.1 and I found out this 
interesting problem. I've the following topology,

Phone A ---SIP--- Asterisk --SIP--- Phone B

* Phone A supports G711 and GSM (in that order of priority)
* Asterisk is configured to allow only G711 and GSM
* Phone B supports only GSM

When Phone B calls Phone A the following sequence of things happen. 
Phone B sends INVITE with GSM and Asterisk sends INVITE to Phone A with 
(G711, GSM). Since on Phone A G711 is the first preferred codec, between 
Phone A and Asterisk, G711 is used and between Asterisk and Phone B GSM 
is used. So Asterisk does transcoding between G711 and GSM.

But if the phone A had chosen GSM then there is no transcoding required. 
So I guess if Asterisk on its invite message to Phone A had put GSM as 
its first priority then there wouldn't have been a need for transcoding.

This is just one instance and there are many scenarios for e.g. instead 
of GSM in the above scenario if we have G729 and if I don't have the 
license to transcode between G711 and G729 the call would fail but if 
the Phone A had chosen G729 the call could have gone fine.

I am new to Asterisk development and I'm not sure on what basis asterisk 
decides to send all the configured codec instead of filtering it out 
based on the incoming SDP. Can somebody let me know why it is designed 
this way ? If not I would like to work on it and find out a better way 
to do codec negotiation.

Also it will be great if somebody can give me some pointers on the code 
on where I should start looking to solve this problem.

thanks,
Ravi



More information about the asterisk-dev mailing list