Tuesday, February 12, 2013

Asterisk/FreePBX Setting up and enabling Speex codec.

Why Speex?

  1. It works like SILK but, see item 2.
  2. Its an old codec thus supported by lots of phones as opposed to SILK

Environments (of course, improvise and modify for your respective OSes, it can run too far away from these)

  • Debian 6 32bit (somehow I messed up my 64bit or it doesn’t work well with 64 bit)
  • Asterisk 11
  • FreePBX

So the steps are simple as outlined here;

  1. # apt-get install speex speex libspeexdsp-dev libspeex-dev
  2. Go to your Asterisk source directory
  3. Do a #make clean && ./configure && make && make install
  4. NOTE: It should automatically notice Speex libraries are already installed and it will auto select, so don’t have to menu select whatnot.
  5. Once done make, restart Asterisk (#amportal kill && amportal start)
  6. Then you should be autoloading the codec, so # asterisk –rx “core show translation”     should show you speex

    speex 15000 15000 15000 15000 15000  9000 15000     -   23000 15000    15000 17250  17000   15000   23000  17000  17000  17000  17000  17000  17000   17000
    speex16 23500 23500 23500 23500 23500 17500 23500 23500       - 23500    23500 15000   9000   23500   23000  17500  17000  17000  17000  17000  17000   17000

  7. Otherwise, manually load #asterisk –rx “module load codec_speex.so”
  8. If you hit errors, lookout for the full log…
  9. Now, if speex is loaded properly, go to the IAX/SIP Setting pages in FreePBX and enable speex codec respectively
  10. That should now allow you to use speex in the extensions/devices you’ve configured

And you guessed, it, here’s the cliché, Enjoy Speex-ing…

More Asterisk related codec.conf configuration on Speex can be found here:

PS> What Codec we really want to consider in future and see it released to support Asterisk?.
OPUS. I believe this one codec will rule them all. Till then, we use bits like SILK and SPEEX and sometimes g729 to get our very cranky networks to play nice with VoIP audio.

Saturday, February 2, 2013

Setting up SILK Codec with Asterisk 10/11

Wikipedia on SILK: http://en.wikipedia.org/wiki/SILK
This guide takes you through the setup of SILK codec with Asterisk 11. It also can be used to setup Asterisk 10.
While it should work for other environments, this particular guide was written for
1) Debian
2) Working Asterisk 11 (try this article if you want a how-to)
Why use Skype’s SILK?
Here’s the quick how-to (Parts of this guide was taken from Asterisk Wiki here )
  1. Download the  benchmark tool based on your processor architecture. In my case I am using 64 bit so I downloaded the x86_64. Browse to http://downloads.digium.com/pub/telephony/codec_silk/benchsilk/ for options. Copy the URL and do the wget like below
    # cd /usr/src
    # wget
    # chmod +x bench*
    # ./benchsilk-1.0.0-x86_64
  2. After this you will see the recommendation made from the benchmarking tool. Since I was running a VM for writing this, my winner was “generic”, so I headed to this http://downloads.digium.com/pub/telephony/codec_silk/ link, selected my Asterisk version, and selected the processor architecture, which was x86_64, then copied the generic codec url to do wget with
    # wget http://downloads.digium.com/pub/telephony/codec_silk/asterisk-11.0/x86-64/codec_silk-11.0_1.0.0-generic_64.tar.gz
    # tar –zxvf codec_silk*
    # cd codec_silk-11.0_1.0.0-generic_64     (or whatever version of yours directory name)
    # cp codec* /usr/lib/asterisk/modules/
  3. Now put up some configs for codecs.conf
    # nano /etc/asterisk/codecs.conf         (create the file if don’t exist). Paste below all variations this codec



  4. Save and exit
  5. Load the codec
    # asterisk -rx "module load codec_silk.so"
    You should see it return as “Loaded….”
  6. Now, check the translations and codecs
    # asterisk –rx “core show translation”
    # asterisk –rx “core show codecs”
  7. Sometimes, you might need to start and stop asterisk for it to show up in the codec translation table (and for it to work)
  8. On both command executions, you should see in those outputs the words SILK8, SILK12, SILK16, SILK24
  9. Be sure to “allow” this codec for each of your extensions, or sip general settings
    And for each extension, be sure to setup like this
    allow=silk8 ;;;
    or whatever silk band you fancy, I use the narrowband as its important to use smallest bandwidth
  10. Connect using phones that support SILK, set those phones to only use SILK in its list of codecs based on the frequency you’ve “allowed”, in the case above, 8Khz. Typically, 8Khz band will only use 5-20kbps :)
  11. Checkout this document on the payload. The codecs.conf gives you the ability to tweak for poor network conditions too like on Wifi roamers….
Phones that support SILK in my tests:
  1. CSIPSimple for Android Mobile
  2. Basically anything using the PJSIP stack (which has become my favorite softphone….), e.g. http://microsip.org.ua/
Lots other phone vendors also do support SILK but it will probably come slower: Anyway, the PJSIP MicroSIP, I was making calls clean and flawlessly over Wifi