Using g.729 codec with Asterisk on Raspberry Pi (or other ARM device)

I decided to build home PBX based on Asterisk VoIP server running on my Raspberry Pi device. One of the reasons for this was ability to build cheap GSM gate for home use using chan_dongle. But one of the problems i have found was lack of g.729 codec for the Asterisk on ARM.

On Intel platform it is possible to use codecs from asterisk.hosting.lv or to buy commercial codec from Digium. Unfortunately its not the case for the ARM. So i decided to see if it possible to port some existing g.729 codec.

Project asterisk-g72x is only Open Source g.729 for Asterisk implementation i am aware of. Internally it is using 2 libraries:

  • IPP from Intel
  • Or ITU based reference code.

It is not possible to compile recent IPP versions on ARM and a lot of ASM code making porting of it problematic. ITU g.729 code is on a plain C, but is painfully slow. It compiles on ARM, but performance is terrible. Asterisk eating 100% of CPU on recoding and drops frames. So it was not an option. So i decided to find alternative codec. In the net i found 2 Open Source projects with g.729 implementation suitable for ARM

  1. Experimental version of G.729 codec for ARM device. It seems to be ITU source code with ARM assembler code for some operations.This code also using many global variables so is not ready for multi-thread software like asterisk without additional changes. Also there are issues open from 2011 without any reaction from developers.
  2. Bcg729. It is a software G729A encoder and decoder library written in C, developed by Belledonne Communications, the company supporting the Linphone project. It was written from scratch and is NOT a derivative work of ITU reference source code in any kind.

BCG 729 also supports concurrent channel encoding/decoding for multi-call applications such as Asterisk. I was able to adopt bcg729 for use with asterisk-g72x project, instead of slow ITU code. If you want to test it – use my BitBucker fork. I will post benchmarks later, but now i see about 15-20% CPU load on g.729 encoding with Asterisk, so it should be able to support 4-5 concurrent channels in time.

Advertisements
Tagged , , , , , ,

22 thoughts on “Using g.729 codec with Asterisk on Raspberry Pi (or other ARM device)

  1. pianoquintet says:

    Great project, can you post a step by step tutorial? Thank you.

  2. Abdullah says:

    still unable to find step by step instructions for Raspberry Pi.

    Please guide

    Thanks

  3. Tom says:

    I’m running Asterisk 11.8.0 on Ubuntu 13.04 (Incredible PBX on a Beaglebone Black).

    Are you able to compile a version for that? I haven’t been able to figure out how to install the Intel IPP libraries on the Beaglebone, which seems to be necessary to compile the codec.

    • Tom says:

      I suppose that doesn’t make sense now that I stop to think about it, IPP libraries wouldn’t be available or necessary for ARM.

    • Tom says:

      So, when I try to ./configure to create the makefile it stops on:

      checking host CPU features… configure: error: unable to choose IPP core, use –enable-pentium/etc. to select one

      ./configure –help doesn’t list ARM though?

  4. Abdullah says:

    Thanks buddy

    here is my Pi info

    Linux raspberrypi 3.10.25+ #622 PREEMPT Fri Jan 3 18:41:00 GMT 2014 armv6l GNU/Linux

    and Asterisk is

    Asterisk 1.8.13.1~dfsg1-3+deb7u3

  5. Karl says:

    Hi,

    Nice work, I wonder how difficult it would be to add support for the Cubieboard? I believe it is an ARMv7 based CPU.

    Regards,
    Karl

  6. alferr202 says:

    Hi sammczk,

    Thankyou for your help
    are you able to compile for myself also:

    Linux raspbx 3.10.29+ #686 PREMEPT Sun Feb 9 19:58:58 GMT 2014 armv61 GNU/linux

    Asterisk 11.9.0 built by root @ raspbx on a armv6l running Linux on 2013-11-05 22:19:11 UTC

    Thanks in Advance

  7. pianoquintet says:

    Sammczk, would you be so kind to compile it for my Sheevaplug (ARM Marvell Kirkwood 88F6281 (ARM9E)) or point me to instructions on how to do that?

  8. Marco says:

    Hi – I tried to compile the codec using your mercurial repository + the git one for bcg729. I assembled some instructions for enable a quick compiling on raspbx, it’s on Pastebin (http://pastebin.com/Xnjeca59).

  9. Karl says:

    Hi,

    How would one compile this for the Cubieboard2, it uses ARM Cortex-A8 architecture.

    Regards,
    Karl

  10. Hello sammczk, I can’t find correct files for ARM on http://asterisk.hosting.lv/

    Please, can you help me?

    My Asterisk’s version is +Asterisk 1.8.13.1~dfsg1-3+deb7u3

    …and PI info is Linux raspberrypi 3.12.26+ #707 PREEMPT armv6l GNU/Linux

    Thanks

  11. Grant Pasley says:

    hi samm

    any chance of getting the codec compiled for raspi with asterisk 11? i downloaded and compiled the bcg729 one from linphone website, but have no idea how to implement / integrate with asterisk after compiling.

    Linux raspbx 3.12.25+ #700 PREEMPT Thu Jul 24 17:51:46 BST 2014 armv6l GNU/Linux

    thanks

    grant

  12. sstream says:

    Thank you for providing valuable codec for ARM device.
    You might know CSipSimple, an open source Android Sip application which supports g729.
    Source can be found at https://code.google.com/p/csipsimple/

    CSipsimple also handles g729 on Android devices pretty well.
    You might get better g729 source code for ARM devices there.

  13. techfox says:

    Thank you for your article. I was able to compile BCG729 for RasPBX in Raspberry PI 3,. You can visit – https://techfoxweb.wordpress.com/2017/02/23/g729-raspbx-in-raspberry-pi-3/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: