Adding G.729 For Free

Posted on February 20, 2012 by admin

If you want to use Digium’s official G.729 (low-bandwidth but very decent quality codec, 8KB/sec instead of ulaw’s 64KB/sec), you need to buy a license per channel used. However, there’s an open source version which seems to work really well. I recommend you install it by doing the following when connected to your Asterisk box as root:

cd /usr/lib/asterisk/modules

Then do ONLY ONE of the following, depending which architecture your Asterisk box’s CPU is:

Then connect to the Asterisk console with:
asterisk -r

and type (adjust accordingly):

You should then see something like:
Loaded /usr/lib/asterisk/modules/

(G729/PCM16 (signed linear) Codec Translator, based on IPP) == Registered translator ‘g729tolin’ from format g729 to slin, cost 1 == Registered translator ‘lintog729’ from format slin to g729, cost 6 Exit from the console with:


Then use nano to edit /etc/asterisk/sip.conf and just below:

Then, if you still want to use G.711 (ulaw) between your box and your trunks (and between your box and your phones) for the time being until you have more time to experiment with it, go to your trunk config pages in FreePBX and add the following to the PEER DETAILS section:

On each of your phone extension pages, set disallow to all and set allow to ulaw. This will force them to use only ulaw. Click the red bar and you’re done.
Now you’re set up to use G.729 for free, but only when you’re ready to try it out; to do this, you could go to your trunk config and put a semicolon at the beginning of the disallow line, which would then allow the system-wide settings (in sip.conf) to affect that trunk, which then it would start using. You could alternately change allow=ulaw to allow=g729 to force it to use only that codec.
To verify what codec you’re actually using, while you’re on a call connect to the Asterisk console with:
asterisk -r
and type:
sip show channels

*CLI> sip show peers
*CLI> manager show connected
*CLI> core show translation

*CLI core show codecs
asterisk -rx “core show codecs”

*CLI> core set verbose 99 <- To view more information pertaining to your problem.
Verbosity was 3 and is now 99

You can also -> “tail -f /var/log/asterisk/full” for errors.

If all the steps are right g729 should work.