Compiling G729 for RasPBX in Raspberry Pi 3

cropped-winter_pic_small1

Asterisk is a very well known open source IP PBX system. It’s scalability is amazing. Now days, Asterisk is used as PBX and also small to mid size Soft-Switches. An office can implement its own pbx system with a small cost with asterisk.

On the other hand, Raspberry Pi is a small yet full featured computer which can run asterisk and serve an office with 50 employees pretty easily at a premise considering no codec conversion is needed, as codec conversion can put nasty load on the server sometimes.

Target

  • Compiling g729 codec and enabling support in RasPBX. Deliverable will be codec_g729.so, compatible for RasPBX.

Environment

  1. Raspberry Pi 3 Model B
  2. RasPBX (raspbx-28-01-2017 with  Asterisk 13.13.1 and FreePBX 13.0.190.11)

To prepare the build environment, I did –

# apt-get update && apt-get upgrade
# apt-get install build-essential
# apt-get install dh-autoreconf

Building BCG729 from Belledona Community

I have tried to pull the source from git and build but is doest support the build process for asterisk (in next phase). So I had to use v1.0.0 to server my purpose.

# cd /usr/local/src
# wget http://download-mirror.savannah.gnu.org/releases/linphone/plugins/sources/bcg729-1.0.0.tar.gz
# tar xzf bcg729-1.0.0.tar.gz
# cd bcg729-1.0.0
# ./configure --libdir=/lib
# make
# make install

Building codec_g729.so for Asterisk

# cd /usr/local/src
# wget http://asterisk.hosting.lv/src/asterisk-g72x-1.4.tar.bz2
# tar -jxvf asterisk-g72x-1.4.tar.bz2
# cd asterisk-g72x-1.4
# ./autogen.sh 
# ./configure CFLAGS='-march=armv6' --with-asterisk130 --with-bcg729 --with-asterisk-includes=/usr/include
# make
# make install

You can see the list of all available parameters by ./configure –help. As my asterisk version in RasPBX was 13.13.1, so I had to chose –with-asterisk130. I didn’t try the ITU code yet. I will share my experience if I try it in future.

Result

The codec_g729.so file will be generated in the /usr/lib/asterisk/modules folder of RasPBX. Try –

# chmod +x /usr/lib/asterisk/modules/codec_g729.so
# asterisk -vvvr
# asterisk> core reload/core restart now
# asterisk> core show translations recalc 10

– and you should see g729 in the list.

Performance

Performance was good for single call as we tested. Extensive test is needed before it should be used in production. I hope, optimization can be achieved by tuning up the build configuration and also ITU source for g729 might produce better result. If you have any idea and/or suggestion then I would love to hear that.

Extras

We may need to compile the library for a different version of Asterisk on Rasbian (Debian on Raspberry Pi).  As an example, let’s try compiling g729 for latest Asterisk 14 (14.3.0) on Rasbian 8 using Raspberry Pi 3.  In this case, we can execute –

# apt-get install openssl libxml2-dev libncurses5-dev uuid-dev sqlite3 libsqlite3-dev pkg-config libjansson-dev subversion libiksemel-dev libspeex-dev libssl-dev libmyodbc unixodbc-dev libsrtp0-dev

# cd /usr/local/src
# wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-14-current.tar.gz
# tar zvxf asterisk-14-current.tar.gz

– and in “Building codec_g729.so for Asterisk” section, we need to change configure parameters as –

...
# ./configure CFLAGS='-march=armv6' --with-asterisk140 --with-bcg729 --with-asterisk-includes=../asterisk-14.3.0/include
...

– to specify the build target as Asterisk 14 and also to include necessary directory containing headers to perform this build job.

Helpful links

8 comments

  1. Thank you for the post. It’s really useful.

    Liked by 1 person

  2. Great job man!

    Liked by 1 person

  3. We are a group of volunteers and starting a new scheme in our community. Your web site offered us with valuable information to work on. You’ve done an impressive job and our whole community will be thankful to you.

    Like

  4. I am very grateful for your help since the Digium G729 is not for ARM, I only have a doubt with the ./configure Why does ARMV6 handle ARMV7?

    At the time of compiling he let me know:

    Architecture: armv7l
    CPU -march:
    CFLAGS: -march=armv6 -I”/usr/include”
    LDFLAGS:
    Codecs impl: Bcg729

    Thanks!!!

    Like

    1. hello dexter_one,
      as we have tested, the armv6 flag is able to produce the library for armv7 processors.we could not find the appropriate flag at that time. we also have the same confusion like you and obviously update the post as soon as we start improving it again and find a better solution. if you find a better way out please share with us.

      Like

    2. Seems, Guong Chung, worked with it and stated something worth trying. Please take a took at – https://sourceforge.net/p/raspbx/discussion/general/thread/60bb4113/?limit=25&page=3#4910

      Like

  5. MD Shekh Rabbani · · Reply

    very very thanks

    Like

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

<span>%d</span> bloggers like this: