Thursday, November 18, 2010

Better support for sipdroid on Android

For a while I've wanted to use my fancy Asterisk setup with my HTC Evo 4G, but i've always been getting horrible performance from sipdroid as well as any other clients I was trying on the phone.

It seems that i've identified the problem as actually being a codec problem.


I looked a little closer at the verbose logs in asterisk and saw messages like this:
[Nov 19 02:57:44] WARNING[9373] chan_gtalk.c: Asked to transmit frame type alaw, while native formats is 0x4 (ulaw) (read/write = ulaw/ulaw)


It seems that whenever I was making calls, the formats kept on flipping from ulaw to alaw and vice versa.  When it did work, only one end could hear the other.  To make matters worse, I couldn't get G722 to work whenever I tried to force it.

Comparing the OpenWRT Asterisk 1.8.x install to a standard install on Ubuntu, it looks like the codec files for G722 weren't even getting installed.  I modified the packaging and republished additional packages at my repository for Asterisk on arctangent.net (http://arctangent.net/~superm1/openwrt)

Now there is two more packages available, one for alaw and the other for g722.  You should be able to update your opkg list and install them:

# opkg install asterisk18-codec-alaw asterisk18-codec-g722

After they're installed, modify sip.conf to make sure you explicitly mention that you now support G722:

[101]
username=101
secret=101
type=friend
callerid="Mario"
host=dynamic
context=outgoing
outgoinglimit=1
incominglimit=1
canreinvite=no
disallow=all
allow=g722
allow=alaw
allow=ulaw
allow=gsm
Now restart Asterisk and Sipdroid should be able to use G722 for some much better audio.