Vanilla Installation of Asterisk 13 on Raspberry Pi 3 with G729 Codec

I have an Asterisk server at home I built few years ago. It has an old Intel atom processor running on CentOS 6. It works quite well. I have couple SIP trunks to severial ITSP, including Google Voice. The Asterisk is version 11 LTS and it is a vinilla installation.

The current Asterisk LTS version is 13 and it come with support of PJSIP. I never had a chance to learn PJSIP configuration. And I just happen to have a Raspberry Pi 3 on hand. So I think I should give a try.

Raspbian Jessie

First, I load Raspbian on a 8GB micro SD card and boot it up. I try to keep this system clean and tight so I used “Raspbian Jessie Lite” (Release date: 2016-09-23) without Desktop.

After the RPi up and running, set the timezone.

timedatectl set-timezone America/Vancouver

And bring it up to date:

sudo apt-get update
sudo apt-get upgrade
sudo reboot

After reboot, start installation as root

Install MySQL database

I need to use MySQL database to save CDR.

sudo apt-get install mysql-server -y
sudo mysql_secure_installation

The database creation and configration is just starand as on other platform. So I just skip them here.

Install Asterisk

Some dependencies need to be installed:

apt-get install build-essential
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

Installation of Astersik is quite simple:

cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
tar zvxf asterisk-13-current.tar.gz
cd asterisk-13.12.1/
./contrib/scripts/get_mp3_source.sh
./configure --with-pjproject-bundled
make menuselect
make -j 4
make install
make config
make samples

G729 Codec

In order to compile the g729 codec for a Raspberry Pi(ARM processor), the fastest way is to build it with the bcg729. The bcg729 is a software encoder for g729a and decoder library written from scratch.

The resulting codec will be x2 slower than if it has been compiled with IPP, but it’s good enough for my home use.

Install autoreconf:

sudo apt-get install dh-autoreconf

bcg729

cd /usr/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
sudo make install

Compiling g729 codecs

cd /usr/src
wget http://asterisk.hosting.lv/src/asterisk-g72x-1.2.tar.bz2
tar xjf asterisk-g72x-1.2.tar.bz2
cd asterisk-g72x-1.2
./autogen.sh
./configure CFLAGS='-march=armv6' --with-asterisk130 --with-bcg729 --with-asterisk-includes=../asterisk-13.12.1/include
make
sudo make install

Test

Restart asterisk and log in CLI:

core show translation

It looks good, g729 is on the list!

Time to learn chan_pjsip now.