[Nexus 4 General] acegolfer:
UPDATE: This may not work any more because Google said that they will cut off the Google Talk XMPP on 5/15/2014, which PBXES relies on.

This guide is not about how to make free calls. It's about how to make free calls using iLBC codec so that you can make reliable calls over 3g connection. If you only want the instructions, then skip to part V.

(edited) I have changed my VoIP set up to PIAF on AWS EC2. See my signature.

I. BACKGROUND

There are several known methods to make free VoIP (internet) calls over 3g. I'll briefly discuss each to explain why there's no perfect solution. I'm not claiming my solution is perfect, either. You have to try them out and find out yourself what works for you.

1. Groove IP app

codec: PCMU (aka G711u, uncompressed signal used by PSTN and Google Voice, only good for fast/reliable wifi connection)

pros: simple setup, works well on wifi. If you use VoIP only on wifi, this is for you.

cons: echo. The voice quality is terrible on mobile data (3g) connection.

2. talkatone app

codec: speex for standard quality

pros: easy setup, good quality on 3g using speex .

cons: doesn't integrate well with android

3. Vonage mobile app

codec: G729(?) when making regular calls. iSAC when calling a Vonage member.

pros: G729 provides an excellent quality even on 3g.

cons: can't receive calls and doesn't integrate with Android. You need to input 10 digit number to make a call, unless the number is in your contacts.

4. Google Voice/pbxes/sipdroid (http://xdaforums.com/showthread.php?t=1791957)

codec: lots of options based on connection type

pros: excellent battery life (http://code.google.com/p/sipdroid/wiki/NewStandbyTechnique), If you choose speex codec for 3g, then call quality is pretty good on 3g.

cons: must unlock the screen before answering the call. doesn't support better codecs such as iLBC/G729.

5. simonics GV gateway https://simonics.com/gvgw/ + sip client of your choice

codec: PCMU

pros: simpler setup than pbxes, some ppl claim it's more reliable.

cons: limited codec support. no multiple registrations

6. Setting up your own asterisk server (http://enjoytechnology.info/)

pros: everything is configurable

cons: requires a 24/7 running server

I have been primarily using #4 setup but wasn't satisfied with the call quality on 3g so I was about to do #6. But I found a way to tweak #4 to use iLBC codec and greatly improved the call quality on 3g.

II. CODEC COMPARISONS

The call quality basically depends on (1) the codec that your phone uses and (2) the network throughput. Unfortunately, there's no perfect solution because of trade-offs.

PCMU (64kbps) is the uncompressed signal that is transmitted at PSTN. So it will give you the best quality as long as your network throughput supports it. This is the preferred codec for wifi connection. However, 3g network cannot consistently sustain 64kbps and will suffer from packet loss resulting in jitter. This explains why Groove IP works best on wifi but not over 3g.

At the other end of the spectrum is GSM codec (8kbps). It's designed in 1990 for wireless communication over 2g. It's the most compressed signal, which is used by your regular GSM providers (AT&T, Tmo). These wireless providers allocate sufficient capacity on voice calls so your voice calls will suffer little jitter. However, the call quality is inferior to PCMU codec.

There are many codecs in between. For example, Sipdroid and talktatone can use speex, which requires low bandwidth. These apps can send the same signal twice to compensate for packet loss.

The 2 codecs that haven't been used widely in commercial apps are G729 and iLBC. These 2 codecs require low bandwidth (<15kbps) but have algorithm to interpolate loss packets. It is suggested these 2 codecs are ideal codec for 3g connection. Here are some readings comparing G729 vs iLBC.

http://blogs.elastix.org/en/2009/11/...cs-in-elastix/

http://forums.whirlpool.net.au/archive/1413041

In short, both are excellent codecs for 3g. iLBC has a better quality but requires more CPU power, which Nexus 4 can easily handle. My setup relies on iLBC.

III. SETUP

My setup is an extension to #4 method above. It involves 4 free resources.

1. Google Voice (same phone number for in/out calls and free outbound calls using gtalk)

2. callcentric (VoIP provider for free inbound calls)

3. pbxes (PBX that manages in/out calls)

4. csipsimple (android VOIP app that supports iLBC)

Once set up properly, here's how the incoming and outgoing calls will work.

1. Incoming GV calls

Someone calls your GV number. GV forwards the call to callcentric. Pbxes intercepts the call and rings your phone. Your phone displays caller ID (CID) properly.

2. Outgoing GV calls

You place a call in your phone dialer. Pbxes calls the number using gtalk trunk. The recipient will see your GV number as CID.

IV. BENEFITS

What are the benefits of my setup?

1. Completely free in/out calls. You don't even give out any CC information. All I'm paying is 30/m for Tmobile's 100 min, unlimited data prepaid plan.

2. Excellent call quality even on 3g using iLBC codec. I often get better call quality than Tmo's GSM.

3. Keeping the same number for in/out calls.

4. Full Android integration.

5. Battery life. Only requires 1 SIP registration to pbxes using TCP port. Battery stat screenshots after 10 hours are attached here: http://xdaforums.com/showpost.php?p=35889479&postcount=91

V. INSTRUCTIONS

Are you still with me? Then follow these steps.

#1. Get a fast phone that can handle iLBC codec. FYI, a 2-yr old Galaxy S has the sufficient CPU power for iLBC.

#2. Get an unlimited fast data plan such as Tmobile's $30 prepaid plan. http://prepaid-phones.t-mobile.com/monthly-4g-plans

#3. Install and set up Google Voice app on your phone. Without GV, you can't open a free pbxes account in #4.

#4. Install Sipdroid to create a pbxes account.

When Sipdroid opens, it will detect whether you have GV app installed. If so, it will give you an option to open a free pbxes account linked with Google Voice. Create the pbxes account. In case Gmail flags for an attempted login, allow pbxes to gain access. Once you create the pbxes account, make test calls in and out using Sipdroid. Some ISPs may block you from using VoIP so make sure you can make calls before the next step. As of now, sipdroid doesn't support iLBC codec so we will be using other sip clients for making calls.

#5. Log in to pbxes.org and click "personal data".

Fill out all the blanks. Doesn't need to be correct. If you skip this step, pbxes has been known to remove the account later. While you are doing it, I recommend changing the pbxes login password that you used in step #4 to something else. In addition, pick a data center (server) closest to you to lower latency. If you have registration issues, change to a different server. FYI, I had registration issues with www7 (Miami) server.

#6. Open a free phone number (DID) account at callcentric.com.

You can only get a NY area code number but it doesn't matter because you will be giving out your GV number to your friends. All incoming calls to callcentric (including GV forwarded calls) will be free. You can decline E911 service to stay completely free. Callcentric supports efficient codecs such as G.729 and iLBC. We will be relying on iLBC. The outgoing calls are not free but we will be using GV to make free outbound calls.

Next, we have to link pbxes with callcentric so that pbxes can receive GV forwarded calls to callcentric. There are two ways to do this. (If you are wondering why we are using callcentric instead of gtalk, it's because pbxes has issues with iLBC for gtalk incoming calls. Callcentric handles iLBC better so we are piggybacking it.)

#7a. Callcentric call forwarding to pbxes.

Log in to callcentric.com. Go to preferences>DID forwarding. Input your name@pbxes.org in the box and save. AFAIK, callcentric doesn't charge call forwarding to a SIP address (our method). However, it does to a regular phone number.

Alternatively,

#7b. Have pbxes intercept the calls to callcentric.

Log in to pbxes.org. Click add trunk, select SIP trunk and input callcentric credentials. (user name starts with your callcentric 1777 number.) Select "audio bypass" to pass-through callcentric's iLBC signal to the phone. See the attachment for what my setup looks like.

Here's a tutorial on adding trunks: http://www4.pbxes.com/wiki/index.php/Getting_Started

#8. Add extension(s) in pbxes.

Log in pbxes.org. Click extensions. If you followed step #4, you should see extension "Sipdroid-200." You can add new ones or modify extension 200. Change the password to something that you can easily remember. This will be the password you will use to register your phone to pbxes in the next step. Finally, select "audio bypass."

#9. Install nightly version csipsimple app from http://nightlies.csipsimple.com/trunk/. The play store version crashed with iLBC.

First, add the pbxes account. If you are new to VoIP, use the wizard for pbxes. User name should be yourgoogleID-200, where 200 is the extension you used in #8. The password is what you changed to in #8. (I recommended you change the password in #8 so that you don't use your gmail password everywhere.)

Do not add callcentric account because having 2 registrations drains battery faster. If you followed the steps above, you will still be able to receive callcentric calls from your pbxes account.

I prefer csipsimple because it is has lots of options to configure. But it can be too overwhelming to some people. If you can't get it to work, then try other sip clients such as media5-fone.

#10. Let's change csipsimple for better call quality.

First, in settings/media/codecs, select iLBC as the only codec for 3g connection. If you have a strong wifi connection, then select PCMU for wifi connection.

(optional) If you experience looping when making calls, set up filters appropriately. I set up mine such that all calls will be made by pbxes except for 911.

#11. Google Voice (from webpage)

Add callcentric DID number (not the 1777 number). All the GV forwarded calls to callcentric will be forwarded to pbxes and ring csipsimple on your phone.

Uncheck Google chat so that pbxes only receives callcentric forwarded calls. FYI, GV doesn't support iLBC codec natively.

(optional) uncheck Tmo mobile number, if you are completely satisfied with this setup. If GV is forwarding to your cell, then your cell will be ringing twice and you may accidentally answer the cell phone using your minutes.

#12. (optional) Test in/out calls.

I use these numbers to test the audio quality.

*43 (pbxes echo test)

(909) 390-0003 (PSTN echo test)

(408) 647-4636 (record/playback)

Note that during a call in csipsimple, you can click the settings button in the lower right corner to change the in/out volumes and enable/disable echo cancellation.

You should also test incoming call quality using Google Voice call back. This is where I had the most troubleshooting. My incoming call quality was awful until I found callcentric trick.

I have tested this setup in many different scenarios including in a car running at 45 mph and very happy with the results. Of course, YMMV depending on how good your 3g connection is.

VI. LIMITATIONS

What are the drawbacks?

1. latency (audio delay). iLBC codec makes CPU interpolate to make up for loss packets. This is why the call quality is better than other codecs over 3g. However, the disadvantage is it increases audio lag. I'm experiencing a 0.5s lag one way on 3g. This is not too bad considering a cell>GV>cell call has a similar latency (http://www.howardforums.com/showthread.php/1621673-Voice-Latency-Test-Results, couldn't find a more recent test result)

2. Once a caller calls your GV number, it takes 5-6 seconds for your phone to ring. This is a limitation of PSTN and GV forwarding not VOIP. On the other hand, if a caller calls my cell number directly, it rings in 4-5 seconds. So all the call routing through caller>Google Voice>callcentric>pbxes>phone will add 1 extra second for your phone to ring compared with caller>phone.

3. Pbxes with gtalk trunk will make your Google chat status show as "online and available" all the time. Your friends may think you are online when you are actually not. Another side effect is you won't be able to answer GV calls from PC gmail any more. I haven't found any workaround to fix this other than creating a new google voice account.

4. Nexus 4 VoIP issues. It has been reported that several hardware mic functions (echo/noise cancellation) are disabled for N4 VoIP. http://code.google.com/p/android/issues/detail?id=41626 OTOH, echo cancellation is enabled in Galaxy Nexus. You can mitigate the issue with adjusting the media settings in sip client. But if you are in a noisy area, the mic is going to pick up all the noise. Consider using the headset.

VII. TIPS/TRICKS

1. If your family/friends know how to internet call, then it's best to give out your SIP address; googleID@pbxes.org. Then the call will go out fast and the phone quality will be the best because you are not using PSTN at all. If both caller and recipient are using the same pbxes server, then pbxes is the only node between the two. For example, when my wife with the same setup calls me [MENTION=2229589]pbx[/MENTION]es, my phone rings in less than 2 seconds and the call quality is the best.

2. Create multiple extensions (300, 400, etc) in pbxes.

I have 3 devices registered to pbxes simultaneously: my cell phone, my tablet and the ATA for my home POTS phone. When I receive a GV call, all 3 devices ring simultaneously. And I can call any other extension independently by entering its 3 digit extension number.

3. Try other sip clients

I suggested csipsimple because it's open source and free despite being an unstable nightly version. You should try out other apps because they may perform better for you. For example, when I use media5-fone (free w/ ads, $5 to remove ads), the audio latency improved but it consumed a little more battery.

4. Battery improvement

My Nexus 4 easily lasts 16 hours w/ 3+ hour screen time. There are several things you can do to improve battery life. Use TCP only in client to communicate with pbxes.org. If you use csipsimple, you need to change the account settings. First, use the wizard to switch to expert mode. Then you will see "transport" option in the account settings. Select TCP. Another thing you can do to improve battery life is to experiment with larger keep alive intervals.

5. Use a different gmail account for your GV number

If you are uncomfortable with giving out your gmail password (even the app specific one) to pbxes, then transfer your GV number to another gmail account. http://support.google.com/voice/bin/static.py?hl=en&ts=1378507&page=ts.cs The whole process took less than 30 minutes. Once done, you don't need to create a new pbxes account. Just log in pbxes.org, go to Trunk>Gtalk and make the necessary changes. If done properly, you can make calls out again instantly. If you are using GV app, then you need to add the new account.

6. Delayed GV call forwarding

You can set up pbxes such that it rings your cell phone if you don't answer the internet call in X seconds. See

http://xdaforums.com/showpost.php?p=36041116&postcount=196

VIII. Troubleshooting

1. This guide is definitely not simple. Lots of things can go wrong. If you want help, then provide as much information as possible. Posting a screenshot of pbxes call monitor log will be a good start.

2. If csipsimple doesn't work, try other sip clients such as media5-fone. If you can't make a call with media5 either, then you know at least it's not csip's fault.

3. If you suspect pbxes malfunctioning, change the datacenter (server) from pbxes.org.