VoipLib

public interface VoipLib

It is the core class of the Library, that allows you to:

  • initialize the Voip Library
  • create an account and register it on a remote Sip Server
  • make a call
  • listen for incoming calls and answer
  • get instances of IAccount, ICall and IServer objects

Methods

answerCall

public boolean answerCall()

Answer a call

Returns:false if this command was ignored for some reasons (e.g there is already an active call), true otherwise

destroyLib

public boolean destroyLib()

Destroy the Voip Lib

Returns:true if no error occurred in the deinitialization process

getAccount

public IAccount getAccount()

Get informations about the local sip account

Returns:informations about the local sip account , like its current state

getCall

public ICall getCall()

Get the current call info (if any)

Returns:informations about the current call (if any), like the current Call State

getServer

public IServer getServer()

Get informations about the remote Sip Server

Returns:informations about the current sip server, like the current Server State

hangupCall

public boolean hangupCall()

Close the current active call

Returns:true if no error occurred during this operation, false otherwise

holdCall

public boolean holdCall()

Put the active call on hold status

Returns:true if no error occurred during this operation, false otherwise

initLib

public boolean initLib(Context context, HashMap<String, String> configParams, Handler notificationHandler)

Initialize the Voip Lib

Parameters:
  • context – application context of the activity that uses this library
  • configParams – All needed configuration string parameters. All the supported parameters are the following (turn server params are needed only if you intend to use a turn server):
  • sipServerIp: the ip address of the Sip Server (e.g Asterisk)
  • sipServerPort: the port of the Sip Server (default: 5060)
  • sipServerTransport: the sip transport: it can be “udp” or “tcp” (default: “udp”)
  • sipUserName: the account name of the peer to register to the sip server
  • sipUserPwd: the account password of the peer to register to the sip server
  • turnServerIp: the ip address of the Turn Server
  • turnServerPort: the port of the Turn Server (default: 3478)
  • turnServerUser: the username used for TurnServer Authentication
  • turnServerPwd: the password of the user used for TurnServer Authentication
  • turnAuthRealm: the realm for the authentication (default:”most.crs4.it”)
  • onHoldSound: the path of the sound file played when the call is put on hold status
  • onIncomingCallSound: the path of the sound file played for outcoming calls
  • onOutcomingCallSound: the path of the sound file played for outcoming calls
Parameters:
  • notificationHandler – the handller that will receive all sip notifications
Returns:

true if the initialization request completes without errors, false otherwise

makeCall

public boolean makeCall(String extension)

Make a call to the specific extension

Parameters:
  • extension – The extension to dial
Returns:

true if no error occurred during this operation, false otherwise

registerAccount

public boolean registerAccount()

Register the account according to the configuration params provided in the initLib(HashMap,Handler) method

Returns:true if the registration request was sent to the sip server, false otherwise

unholdCall

public boolean unholdCall()

Put the active call on active status

Returns:true if no error occurred during this operation, false otherwise

unregisterAccount

public boolean unregisterAccount()

Unregister the currently registered account

Returns:true if the unregistration request was sent to the sip server, false otherwise