Choosing Codecs

Home » Asterisk Users » Choosing Codecs
Asterisk Users 10 Comments

Hi list!

I noticed that when the phone of my wife calls the gsm codec will be used, but if someone calls the phone, alaw will be used:

00493511111111 calls 00493512222222:
OpenWrt*CLI> sip show channels Peer User/ANR Call ID Format Hold Last Message Expiry Peer 00493512222222 5305ad0e07977dd 0x4 (ulaw) No Init: INVITE 0049351222 00493511111111 1481837b-c0a801 0x4 (ulaw) No Rx: INVITE 0049351111

00493512222222 calls 00493511111111:
OpenWrt*CLI> sip show channels Peer User/ANR Call ID Format Hold Last Message Expiry Peer 00493511111111 5e21076a01b9483 0x8 (alaw) No Tx: ACK 0049351111 00493512222222 MCBsoNI2Cj266BB 0x2 (gsm) No Rx: ACK 0049351222

Could someone explain me why?
Second question: I think, ulaw/alaw are better then gsm, isn’t it?
If so, how can I change it?

Thanks Luca Bertoncello

10 thoughts on - Choosing Codecs

  • Hi Luca Y need to check your wifes codec priority list -seems to be GSM on the first place.

    Luca Bertoncello wrote:

  • GSM is the native codec used for calls to mobile phones; it uses lossy compression to achieve a low bit rate.

    A-law is the native codec used by physical exchanges on the land line network
    (PSTN and ISDN). It is non-lossy. It works by arranging the “steps” closer together near the zero line, and further apart away from it; so the difference between the actual signal and the nearest digital representation is small in proportion to the signal.

    To force the use of a-law, you need something like

    disallow=all allow=alaw

    at the top of the configuration file for the calling technology in question
    (sip.conf for SIP, chan_dahdi.conf for DAHDI, &c.). If you want to force a specific device to use a specific codec, then put an allow in the section for that device.

  • Zitat von A J Stiles :


    Well, but for voice quality, which codec is better?
    alaw or gsm?

    Thanks Luca Bertoncello

  • A-law is better for voice quality (sorry, thought my original explanation was obvious). But note that if the destination is a mobile phone, GSM will be used anyway, at least for the link between the final cell tower and the handset.

  • Zitat von A J Stiles :

    OK, thank you… Maybe will be your explanation other day but mondays obvious… 😀

    So, I think, I should try to force the using of alaw for this phone,
    is it right?
    Usually we don’t call mobile phones from our landline…

    Thanks Luca Bertoncello

  • Yes. You should definitely be using A-law for calls to the Outside World.

    If you use a different codec, then your telephone company will either transcode it for you (if it is one they understand) or just block the call (if not).
    Even if you are trying to use A-law to call a mobile phone, the transcoding to GSM for the final leg to and from the handset will be taken care of by the mobile company’s equipment.

  • Zitat von A J Stiles :

    OK, I’ll change the settings!

    Thanks Luca Bertoncello

  • Zitat von A J Stiles :

    Well, I wanted to change these settings, but I’m not sure, where I
    have to do that… I think in the users.conf, but I think, the “allow” keywords is for
    the network…

    How can I change this setting?

    Thanks Luca Bertoncello

  • It will be in the /etc/asterisk/*.conf file for the appropriate calling technology. So if the calls are going over a SIP trunk, it will be in sip.conf . You want

    disallow=all allow=alaw

    There probably will be some other allow= lines; just stick a semicolon in front of the ones you do *not* want, to comment them out. Then issue

    core reload

    in Asterisk CLI, and all your calls should be A-law from now on.

  • Zitat von A J Stiles :

    OK, thanks a lot!

    Luca Bertoncello