Codec selection

What if sip.conf doesnt have codec set? what will be the default codec that will be used?



If you do not specify what codecs to use in sip.conf, either in the global settings or on a per user basis, then I believe that the choice is left up to the client. So any format that Asterisk supports and the Client supports that the client would like to use.



But what about the preference if not specified in sip.conf per extension? random?

Asterisk won’t prefer anything. The client will choose which codec it wants to use and tell Asterisk to use that codec. The only preference that Asterisk has is what you specify in sip.conf. If you choose not to put anything in sip.conf, then the decision will be left up to the client.


I start a call to my Asterisk machine from my SIP phone. My SIP phone supports ulaw, alaw, and gsm. Asterisk supports all of those codecs, and since we are not specifying any settings about which codec to use in sip.conf it leaves the choice up to the client. My SIP phone will then make the choice, depending on your sip phone and how you have configured it, as to which codec to use. The SIP phone I use, will choose ulaw by default because of the best sound quality.



What is the recommended/preferred codec order?

It depends on what you are trying to do. Each codec is good for different things.

The most common are ulaw and gsm. ulaw sounds the best, but takes the most bandwidth. Most voip providers use this. gsm is great for linking offices together as it takes much less bandwidth per call (1/3 - 1/4 the size) than ulaw, but still sounds ok.

There are many other codecs you just have to find one that works good for your goals.


balance for bandwidth and quality.