Test Script

Sunday, March 23, 2014

Building A VoIP Application In Android : Part 1

So you want to build a VoIP application and have no idea where to get started? Well, you have come to the right place. This tutorial will attempt to help you get started with building a VoIP application on Android, by no means is this tutorial an exhaustive end to end guide but rather a simple starting point to build upon. So lets get started.



There are quite a lot of libraries out there which help you build a VoIP application. Today in this tutorial I will be using PJSIP as our preferred choice. With the latest 2.2 version of PJSIP, it now supports object oriented programming. Sounds simple enough ? Well, its not. Building the library from the source files is a big pain and took me hours to finally get it done.  I have integrated OpenSSL in it as well for TLS support.

Building PJSIP :

Requirements :


1. Java, JDK.
2. Android SDK & Android NDK
3. SWIG
4.Pyparcer

SWIG provides glue/bindings between the C/C++ library and Java code by generating wrappers

Pyparcer is a python parser tool which is used by swig internally to parse the interface file before generating the bindings needed for the app, so make sure you have pyparcer installed before hand. We never use it directly but Swig invokes it automatically.
Steps:
1. Getting the latest PJSIP source code from their repository
2. This guide will assume the path of the downloaded PJSIP src code to be pjsip/src
3. Create a new config_site.h file under pjsip/src/pjlib/include/pj with the following text
#define PJ_CONFIG_ANDROID 1
#define PJ_AUTOCONF 1
#define PJ_IS_LITTLE_ENDIAN 1
#define PJ_HAS_SSL_SOCK 1
#include <pj/ config_site_sample.h>
4. Set the path to your Android NDK in the PATH variable

5. Ideally you should compile OpenSSL and integrate it with PJSIP, but I couldn't get it work. So I have used a port of OpenSSL for Android.

6. Build the above project using ndk-build command

7. Now go to pjsip/src folder and run the following command
./configure-android --with-ssl=/path/to/compiled-openssl-folder

8. If that was successful, run the following command
make dep && make clean && make

9. That should have built the needed lib files with OpenSSL support enabled

10. Now navigate to pjsip/src/pjsip-apps/src/swig folder

11. Add SWIG path to your PATH variable

12. Run the following command
make

If everything went well, you should now see a pjsua2.so file under pjsip/src/pjsip-apps/src/swig/java/android/libs/ folder.

That's all that is to be done to build PJSIP for Android. You should now be able to call the native library functions from your Java code. In Part 2 of the tutorial we will have a look at how to start using the compiled library from a demo Android app and basic functions of the PJSIP library. Hope you liked this tutorial, feel free to leave your comments below.

And yes, you should soon see a great VoIP application from me on the Playstore !

Monday, February 17, 2014

Hello after a gap ! Timely & Youtube apps are here !

So, I am now settling down with my new job as an Engineer for Novanet. So in the meanwhile, I have release two more of my Android experiments to github  but never had an opportunity to blog about them. So this blog post is just to inform that I will soon be back to blogging about my experiments with Android. In the meantime please find descriptions about the 2 projects I have posted on github recently :



1. Timely Text View

     So we all loved the animations in the Timely app, and I was really curious to know how they achieved it. I suck at UI badly, so I had almost very little hope of actually figuring out the logic behind it, that's when I stumbled upon an excellent blog post by Sriram Ramani. So with him explaining the logic behind the animation I just figured out the missing bits and pieces and made a simple ready to use library. Yes you can now have to those animations in your app.! The github link below should take you directly to the project.

Timely TextView : https://github.com/adnan-SM/TimelyTextView


2. Youtube app

    I had already written a few blog posts about Chat heads previously(Its here, in case you need them), so I always wanted to improve it, take it a step further and make it more useful. The result? A floating video player ! Just like the latest Youtube app. Hit the link below now to see the source code !

Chat-head Video : https://github.com/adnan-SM/ChatHead-Video-Youtube-Style-



Well, before I finish just so guys know I am working on VOIP related app for the new firm, so expect a few tutorials and knowledge sharing in the VOIP domain as well. That's all for now, stay tuned for further blog posts, I have plans for moving to a privately hosted domain and a WP site as well. Will update soon ! Don't forget to follow me on G+, so that you don't miss any tutorials !

Thanks again for all the support and the love. And yes thanks for 16k visits to the blog as well !  
UA-42774700-1