Tuesday, May 13, 2014

OPUS codec with transcoding on Asterisk 11.5.x (or higher, 11.6,11.7,11.8,11.9) with(out) FreePBX

Hi all, this is just a quick and dirty guide to get OPUS and VP8 running on Asterisk 11.9.0 on your Debian box.

  • All credits for the Asterisk patch to meetecho and forked by netaskd for Asterisk 11.5.x or higher support.
  • This guide is intended for Debian 6 - 64bit platform only. Of course, with a little research, you could do it for other platforms as well.
  • Want to know more about why i am so gung-ho about OPUS, see here.
  • If you want a quick and easy access to a fully running Asterisk 11.5.x. From this image, follow the guide below to get it update to Asterisk 11.9 and get OPUS/VP8 enabled and running
  • IMPORTANT: There are some legal implications using OPUS on Asterisk code, read all about it here. REMEMBER, this is for educational use only.

Ok, let’s get down to business.

  1. Get “autoconf”, “automake” “pkg-config”
    # apt-get install autoconf automake pkg-config
  2. Get the latest libopus
    # cd /usr/src
    # wget http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz && tar –zxvf opus-1.1.tar.gz && cd opus-1.1
    # ./configure
    # make all && make install
  3. That should get your opus ready for asterisk installation. Since vp8 is merely passthru, it will not require and libraries.
  4. Now, go to the asterisk source installation directory (if you don’t have it, simply download it from here). If you are running my image, you could overwrite the 11.5 by simply follow the guide below.
  5. Now, lets get started on asterisk side
    # cd /usr/src/asterisk-11.9.0
    # wget https://raw.githubusercontent.com/netaskd/asterisk-opus/master/asterisk-11.5.0_opus+vp8.diff -O asterisk_opus+vp8.diff --no-check-certificate
    # patch –p1 –u < asterisk_opus+vp8.diff
    You should see everything working well so far like below.
    image
    # ./bootstrap.sh
    # make clean && ./configure --with-crypto --with-ssl --with-srtp=/usr/local/lib --prefix=/usr
    IMPORTANT: If you do not have libsrtp, leave only with “--prefix=/usr”, remove the rest in that line. Libcryto and ssl are used for SRTP (for WebRTC mainly)
    # make menuselect
    IMPORANT: Please be sure to select 1) Codec Opus in Codec Translations, 2) Format VP8 in Format Interpreters and for best compatibility, 3) all sounds that’s SLIN16 (not selected by default) in Core Sound Packages, MOH Packages and Extra Sound..
    IMPORANT: If you can’t select Opus something went wrong in your libopus installation!, otherwise it should be preselected for you, but do check nontheless
    FREEPBX USERS! IMPORTANT: FreePBX users, be sure to select format_mp3, res_config_mysql, app_mysql, app_saycountpl and cdr_mysql in Add-ons
    # save and exit
    FREEPBX USERS! IMPORTANT: Run this # contrib/scripts/get_mp3_source.sh
    # make && make install
  6. Now if you use freepbx, simple run #amportal kill && amportal start
  7. Otherwise, simply kill and start back Asterisk
  8. You should see opus in the translation list
    # asterisk -rx "core show translation"
  9. Also, if you go into asterisk cli, you could type opus <tab> and set debug…that all means the patch worked great, now to test!
  10. Be sure to set allow=opus in your sip general setting or per peer/user. For FreePBX users, go to FPBX UX and select Asterisk SIP settings, set allow opus/vp8 like below right at the bottom of that page.
     image
  11. Use a phone that supports OPUS (on Windows you’ve got Phoner, MicroSIP, on mobile you’ve got CCIPSimple or BRIA) and dial away to test
  12. Here’s my BRIA on my Android with Opus at 48Khz, dialing the echo test on FreePBX *43
    ss

Next, i am going to try this on WebRTC with passthru support for VP8 and full transcoding with OPUS!

Cheers and have a good week ahead, do send your feedbacks to sanjay---at@---astiostech.com

Thursday, May 1, 2014

The personal & secret telephone menu – with Asterisk/FreePBX

Have you ever wanted to do some crazy telephony stuff such as call a long distant number using your office PaBX, or call you back and bridge an open channel (so you can call anywhere) or do just about anything with your own Direct Inward Number (or PSTN number) that only you know how to activate?

Here’s in summary what i wanted to achieve

  1. Use back my existing number, e.g. my own DID
  2. Let it do the same thing as before, i.e. ring my extension, forward to my mobile
  3. BUT, enable a “secret” menu option that only i know that can execute different functions of the PaBX such as dial a long distance number

I wanted to do something like this without affecting my existing number when everyone else dials. But the trick is to not let anyone know its an IVR that’s actually “answering” the call. So, its essentially, my own private little menu system that when i dial my own number, i can activate by activating (dialing) the IVR option!

I believe this is a cool feature to enable users to do a multitude of stuff within their Asterisk/FreePBX system;

In an organization, this could be use to;

  1. Check your voicemail from a pstn number
  2. Check calendar appointments (using ICS/Exchange module)
  3. Initiate a call back
  4. Initiate another call (bridging)
  5. Send a voiceblast, …etc.etc.etc

The real trick isn’t a big mystery actually, its actually pretty trivial, here are the steps

  1. Create an IVR, use a ring-ring dialtone as the announcement (like as though it is really ringing but actually its playing an “ivr” message giving you time to key in your “secret” code for different functions”). Use this file here if you don’t have one. Fake ringtone http://goo.gl/AnHpPI
  2. Set different destinations as ivr menu responses using the beautiful web UI brought to you by FreePBX to do loads of stuff. See sample below;
    Be sure to:
    a) Set the announcement to the fake ringtone you just uploaded (using Admin/System Recordings)
    b) Set direct dial to disable
    c) Set timeout to however long you need to dial your secret codes (ensure its no longer than the fakeringtone)
    d) Set both invalid and timeout destination to your actual extension without a retry recording i.e. none
    e) Set invalid and timeout retries to zero
    f) In conclusion, follow like below verbatim, except for relevant changes for you
    image
  3. Create an inbound route to go to that IVR you just created! 
    image
  4. Save and apply configs!
  5. Do two tests, 1 dial and enter 2020 and it will “DialGirlFriend”
  6. Second test, dial without pressing anything…it will sound like a normal ring and eventually call your extension

And there you go, thanks to the intuitive design of FreePBX and of course the backend Asterisk super engine, you can do so much of fun stuff, with just one number :)

Happy Labor Day Folks!

 

Sanjay@astiostech