Internet Telephony and SIP based VOIP application development on android

1)Internet telephony and SIP

Internet telephony is one of the latest emerging technology which provides the transmission of human voice over Internet channel.It provides call services at cheaper rate than normal PSTN based call. The technology establishes call and sends/receives data over existing internet network using IP protocol.SIP is the application layer protocol, a signaling protocol which is used for establishing multimedia session over IP network in the internet telephony process.The standard port for SIP is 5060.The protocol can use both UDP or TCP as underlying transport protocol. SIP is used for multimedia session establishment ,session termination like call set up and call release.The application has to create TCP/UDP socket with the SIP server for sending SIP signaling.SIP packet contains header and payload. SIP headers are formed as per RFC specification.

2)Device Network transaction

2.1)Device Registration

To use SIP services, application has to perform registration with its identity to SIP server, an application server for SIP signaling and routing packet to the external IP network. User(application) sends SIP REGISTER packet to perform Registration with the SIP server. The server may ask for user authentication through SIP unauthorized 401 and user again needs to register with proper credential response information in an encrypted form. If User credential is validated by Server, then Register acceptance request in form of 200 OK will be sent to user.The SIP server contacts HSS to get user information, user subscription and for user credential verification.

The below figure depicts the SIP transaction process that happens when User performs registration to SIP server


2.2)Call Establishment

Once device is registered with SIP server, it is allowed to use SIP service request like call,sms over IP channel. To make audio calls over internet ,a VOIP application has to be installed on mobile device which would use SIP protocol . Once the call session is established using SIP signaling, real time data like audio/video will be passed through medial protocol like RTP(Real time protocol).

The below figure depicts the SIP transaction process that happens between calling party, A and called party B on establishing audio call.


The above call transaction is defined as let’s calling party A wants to make call to called party B assuming both the parties are registered to SIP server.The calling party A sends call set up message using SIP packet INVITE to its registered SIP server.The SIP server of A sends to SIP server of B over IP network.SIP server of B delivers call set up request INVITE to called party B.The B acknowledges the request with SIP 100 trying. When called party device B starts ringing, it sends SIP 180 Ringing to calling party,A. When called party picks up and receives the call, SIP 200 OK is sent from B to A. The calling party, A sends acknowledgement for 200 Ok to called party as SIP ACK. The signaling is completed and call session is established between A and B.Now the actual audio conversion is transmitted as data using RTP .When called party B ends the call SIP BYE packet is sent to calling party. The calling part A, acknowledges the call termination with SIP 200 OK. SIP REGISTER SIP BYE,SIP 200,180 are the different kinds of SIP packet.

3)SIP based VOIP (voice over IP) client development on android.

Android 2.3 version, Gingerbread has come up with VOIP framework stack which ease developer to make VOIP application and use VOIP framework API’s.The VOIP application connects with Android SIP service which runs as a separate process.Like TelephonyManager is an interface to use phone services, similarly android provides SIPManager for an application to start SIP services and use exposed apis of SIP service like makeAudoCall(). When SIP service receives call request from application, it uses SIP signaling method first to establish call session and then actual audio data will be sent over RTP.The SIP service uses javax.sip package to create SIP headers, to send and receive SIP packets.

The steps for developing VOIP includes following points:

a)Setting up User profile and Registering Intent.

SIP manager is instantiated first as

mSIPManager = new SIManager(context)

This installation connects application with SIP services. The application first registers his identity for using sip services like audio call to sip service. A sip profile object, sp is created which includes SIP account user id,password,SIP server domain name. The user must hold account with VOIP provider. Secondly, application has to register an intent to the sip service for receiving incoming call. This intent is passed to the SIP service. When SIP service receives incoming VOIP call ,it broadcast the registered intent and register receiver in application context receives the broadcast intent.

PendingIntent pi = PendingIntent.getBroadcast(this,0,new Intent(“android.SipDemo.INCOMING_CAL”),Intent.FILL_IN_DATA);

The application uses SIPManager’s open(sp,pi) call to register sip profile and incoming call intent to SIP service. The application must define a broadcast receiver to receive the broadcast from SIP service with intent action android.SipDemo.INCOMING_CAL.This intent is broadcasted when sip service receives incoming SIP call from network.

b)Registration listener

To use SIP services, device has to register with SIP server as explained above. So application needs to set up registration listener to know its registration status with SIP server. If device is de-registered with server, it will not be able to make call. Registration is the signaling procedure that UE has to perform before making SIP audio call.

mSIPManager.setRegistrationListener(new SIPREgistrationListener(){

public void onRegistrationFailed(String localProfileUri, int errorCode,

String errorMessage) {

// TODO Auto-generated method stub

print(“sip registration is failed”);

} public void onRegistrationDone(String localProfileUri, long expiryTime) {

// TODO Auto-generated method stub

Log.d(LOG_TAG,”sip registration is done”);

} public void onRegistering(String localProfileUri) {

// TODO Auto-generated method stub

Log.d(LOG_TAG,”sip registration in progress”);

}}); });

c)Now the application is ready to make audio call using SIP manager api’s makeAdiocall passing audiolistner interface instance.

Let’s destAddr is the destination address String.

mSIPManager.makeAudioCall(mlocalProfile,(new SipProfile.Builder(destAddr)).build(), mSIPAdioListner , timeout_value);

where mSIPAudioListner is the audi listener interface which is the callback invoked when audio call is established, released.

SIPAudioCall.listner mSIPAdioListner = new SIPAudioCall.listner(){


public void onCallEstablished(SipAudioCall call) {






public void onCallEnded(SipAudioCall call) {

Log.d(LOG_TAG,”onCallEnded”); }}

Whenever SIP manager is instantiated by application, the application connects with SIP service. In makeAudioCall api call, the application creates SIP session with connected sip service and set up the audio listener.The makeAdiocall() api of SIP service is triggered with the arguments as destination and sender user profile. The SIP service process has SIPHelper class which has apis for sending SIP REGISTER,SIP INVITE,SIP 200 OK response, SIP ACK.This class uses javax.sip.header.HeaderFactory class to create SIP header from arguments user profile of sender and receiver. Once the SIP header is formed, SIPHelper sends SIP request to javax.sip.ClientTransaction class.Finally SIP packet delivered to network through established socket connection with SIP server.If you want to know the internally call flow in details, it is recommended to download VOIP framework source code from android git repo.

4)Source code :

1: SIP demo application example can be found at

2: The VOIP framework present in android source code directory is  /framework/base/voip

3: The third part application uses classes and interface present in package. /voip/java/android

4: The package used by SIP services process is  /voip/java/com/

5: Find the source code of android voip framework at

About Author

Jainendra Kumar is Android developer. He has rich experience in developing commercial Android application. He received B.E (Gold Medalist) from BIT Mesra and MS from BITS Pilani.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.