I am embarrassed to say to it took me so long to come to the realization of the importance of codecs with VOIP — I figured that I should stick with the highest bit rate to get the best call quality.  Well that is fine and dandy as long as you don’t have a lot of packet loss or have a low bandwidth connection — my setup falls into both of those contexts.  So as you can imagine there were times when my VOIP calls were basically inaudible.  To make a long story short I was on the phone last night with a network technician from Vonage (troubleshooting some issues with my Dad’s Vonagesystem) and lo-and-behold my network connection started dropping packets like a flower girl at a wedding.  After the transmission re-stabilized the Vonage tech gave me a little pointer, he told me to decrease packet size to 10 milliseconds.  For whatever reason that turned on the light in my head and it made me realize that I needed to look into compression codecs for my VOIP service.
For a little background on the different VOIP codecs reference THIS.

I was using G.711 — the highest bandwidth, uncompressed audio codec.  For a two-way conversation G.711 requires 128 kpbs!  After doing some reading / researching I decided that the best bang for the buck is to use the G.729 codec which only requires 8kbps each way.  128kbps vs 16kbps.  That is an 88% reduction in bandwidth!!  Another bonus to G.729 is the ability to counteract packet loss.  But what about sound quality?  No one wants tin-can audio, low bandwidth or not.   Without trying it out it was hard to say what the end result would be. . .I decided that it was worth a shot.  Because G.729 is a proprietary codec it has a licensing fee of $10 per channel.  IMHO a one-time fee of $10 per channel is nominal compared to the benefits.  Because of my setup and usage patterns I knew that I would need at least two licenses (to allow two concurrent calls).

My SIP server is PBIAF — the following instructions are for G.729 installation on PBIAF.

  1. Install glibc_2.5 utility — login to the console as root and type “yum install glibc”
  2. Check to make sure you have a clean install by typing “ld –version”
  3. Determine your processor type by typing “uname -p”
  4. Determine your PBIAF 32/64 setup by typing “getconf LONG_BIT”

Remember those settings, we will need them in a minute.

  1. Go to Digium’s websiteand download the G.729 codec and the Linux registration tool (**NOTE you want to make sure you choose the correct processor and 32/64 architecture type!!!!)
  2. Unzip the codec and transfer the codec_g729a.so to your PBIAF /usr/lib/asterisk/modules directory and change the ownership of the file to ‘root’ and the permissions to 755
  3. Place the register script into the /tmp directory and change the permission to ‘a+x’
  4. Purchase the correct number of licenses from Digium and wait for license keys to be emailed to you.
  5. From the console type cd into the /tmp directory and then type “./register”
  6. When prompted enter your license key (**NOTE YOU MUST HAVE WORKING INTERNET CONNECTION FOR THE REGISTRATION PROCESS TO COMPLETE SUCCESSFULLY!!)
  7. Restart Asterisk by typing “amportal restart

Now we need to edit your inbound/outbound trunk settings to use the G.729 codec.

  1. Login to the Administration portal for your PBIAF server
  2. Go to Setup –> Trunks
  3. Choose your outbound trunk and in the “PEER DETAILS” section make it say “disallow=all” and then directly underneath it say “allow=g729 (**NOTE this section is dependant on your service provider — my outbound trunk is through Vitelity)
  4. Apply Configuration changes
  5. Choose your inbound trunk and in the “PEER DETAILS” section make it say “disallow=all” and then directly underneath it say “allow=g729 (**NOTE this section is dependant on your service provider — my inbound trunk is through les.net)
  6. Apply Configuration changes

Now adjust your phones to use the codec.  Each phone will be different, please check your user manual.  I have two Grandstream GXP-2000 IP phones that have worked quite well.  They support the G.729 codec so all I do to is choose G.729A/B from the audio configuration menu and save the settings. 

To confirm that you are using G.729, do the following:

  1. From the console of your PBIAF server type “asterisk -rvvv”
  2. From the CLI line type “show g729
  3. It should state how many licenses you have and how many encoder/decoders are currently in use.
  4. Now place a call and type “show g729 again and this time it should indicate that one of your encoder/decoder is being used.

All in all it was a pretty straightforward configuration and seems to be working great!!  Only time will tell how the call quality is with compressed audio and high packet loss.  I will keep you posted.  For additional information on this tutorial please reference the following links:

http://pbxinaflash.com/forum/showthread.php?p=3370&highlight=configure+codec#post3370

http://kb.digium.com/entry/2/5/

http://nerdvittles.com/index.php?p=70