Monday, September 8, 2014

Using JAIN SIP for Android part I

Why do this?

  • Limitations of native sip stack.
Native android sip stack is built on top of JAIN SIP stack but it does not have all the functionality, there is no support for IM, presence and video calls right now. Google forked the SIP Stack and never really updated the SIP API that is shipped by default and using the same package names as the original JAIN SIP project instead of renaming to google.com proved to be a major hassle to developers that wanted to add SIP capabilities worldwide as they couldn't use JAIN SIP out of the box.
An opensource implementation of the stack can be found here. It is a java based SIP stack which allows you to integrate the sip stack seamlessly in your android application without the hassle of NDK.
  • A Complete SIP Stack
JAIN SIP is a full implementation of the RFC 3261 Specification and as well as support for several SIP RFCs.

What is the issue using the existing JAIN SIP stack?

JAIN SIP uses package name javax which  is also used by android's native sip stack implemented by google. So if JAIN SIP libraries are used in an android application, it causes a conflict and causes a runtime exception. <insert runtime exception when try to use JAIN SIP libraries>

Using ANT to compile SIP library for  android?

In order to solve the package name conflict, the ant script is modified to output the libraries which can be used in your android application. To compile android library from the package you are going to need ANT . After you have setup ant, test it in your command prompt with

c:\> ant -version
Apache Ant(TM) version 1.9.2 compiled on July 8 2013

If you see a similar output you are good to go ahead. Next step is to use the ant script below, change your directory to where you downloaded JAIN SIP Stack and run ant all.

c:\>ant all
if everything goes well, libraries for android will be placed at dist\android\android-sip-stack.jar.

How to use JAIN SIP in an android project?

In your android application use the jar created by the ant script and include as an external jar. In the next post we are going to see how to register a SIP client in an android application using the stack.

No comments:

Post a Comment