Most Voip Library¶
The MOST-Voip Library is a fast and lightweight library created for handling VOIP sessions.
Main features:
- Sip Account creation and registration on a remote Sip Server (e.g Asterisk)
- Sip Call handling (making, holding, unholding, answering incoming calls)
- Buddies Subscription and Real Time Presence Notification
Supported platforms:
- Mobile: Android
- Desktop: Linux Ubuntu
So far, MOST-Voip for desktop platforms has been tested only on Linux Ubuntu v.14.04 distribution. However, it is written in Python 2.7, so other platforms should be supported as well.
Table Of Contents¶
Python Most Voip Library¶
Contents:
Getting Started¶
The following tutorial shows you the main features of the library.
This tutorial assumes that you have installed and configured the Asterisk Sip Server on a reachable PC. (For getting instructions about the Asterisk manual configuration click on the Asterisk configuration link below)
Alternatively, you can download a virtual machine containing a running Asterisk Server instance already configured for running the proposed android examples, as explained here
Asterisk Configuration Guide for Most Voip Examples¶
All examples describing the Most Voip Library features require, to work properly, a Sip Server running on a reachable PC. In this guide we show how to configure the Asterisk Sip Server
Alternatively, if you prefer, you can install on your pc the Asterisk Virtual Machine (that contains an already configured Asterisk instance, as explained here.
How to add Sip Users to Asterisk¶
Open the sip.conf configuration file (generally located in the folder /etc/asterisk) set to yes the following options in the [general] section:
[general]
callevents=yes
notifyhold = yes
callcounter=yes
Also, add these sections at the end of ** sip.conf **:
[ste]
type=friend
secret=ste
host=dynamic
context=local_test
[steand]
type=friend
secret=steand
host=dynamic
context=local_test
How to add extensions to dial in Asterisk¶
Open the extensions.conf configuration file (generally located in the folder /etc/asterisk) and add these lines at the end:
[local_test]
exten => 1234,1,Answer ; answer the call
exten => 1234,2,Playback(tt-weasels) ; play an audio file that simulates the voice of the called user
exten => 1234,3,Hangup ; hang up the call
exten => ste,1,Set(VOLUME(RX)=10) ; set the RX volume
exten => ste,2,Set(VOLUME(TX)=10) ; set the RX volume
exten => ste,hint,SIP/ste; hint 'ste' used for presence notification
exten => ste,3,Dial(SIP/ste) ; call the user ste'
exten => steand,1,Set(VOLUME(RX)=10) ; set the RX volume
exten => steand,2,Set(VOLUME(TX)=10) ; set the RX volume
exten => steand,hint,SIP/ste; hint 'steand' used for presence notification
exten => steand,3,Dial(SIP/steand) call the user 'steand' used for presence notification
How to open the Asterisk Command Line Interface (CLI) Shell¶
sudo asterisk -r
How to look for sip users current state:¶
sip show peer
How to reload the dialplan (useful when you add and/or modify a new extension):¶
dialplan reload
How to originate a call:¶
This following command originates a call from the sip server to the user ‘ste’. Obviously, it assumes that you have configured the Asterisk Server so that the user ‘ste’ is a known sip user. To do it , you have to configure the sip configuration file, called sip.conf (in Linux platforms, it is generally located in the folder /etc/asterisk).
originate SIP/ste extension
Tutorial 1: Making a Call¶
This first tutorial shows how to make a call to an arbitrary destination using the Voip Library. To make a call, you have to perform the following steps, each of them explained in the next sections.
Note that this example, to work, requires a Sip Server (e.g Asterisk) installed and running on a reachable PC. For getting instructions about the Asterisk configuration, click here
Step 1: Initialize the Library¶
First of all, you have to import and instance the class VoipLib
# add the most.voip library root dir to the current python path...
import sys
sys.path.append("../src/")
# import the Voip Library
from most.voip.api import VoipLib
# instanziate the lib
my_voip = VoipLib()
Now, you have to build a dictionary containing all parameters needed for the Lib initialization
# build a dictionary containing all parameters needed for the Lib initialization
voip_params = { u'username': u'ste', # a name describing the user
u'sip_server_address': u'192.168.1.100', # the ip of the remote sip server (default port: 5060)
u'sip_server_user': u'ste', # the username of the sip account
u'sip_server_pwd': u'ste', # the password of the sip account
u'sip_server_transport' :u'udp', # the transport type (default: tcp)
u'log_level' : 1, # the log level (greater values provide more informations)
u'debug' : False # enable/disable debugging messages
}
called by the voip library to notify any relevant voip event. You can choose an arbitrary name for this method, but it must contain the following 3 arguments: 1. voip_event_type argument indicating the type of the triggered event (VoipEventType.LIB_EVENT, VoipEventType.ACCOUNT_EVENT, VoipEventType.BUDDY_EVENT or VoipEventType.CALL_EVENT) | 2. voip_event reporting the specific event (e.g VoipEvent.ACCOUNT_REGISTERED to notify an account registration) 3. params a dictionary containing additional informations, depending on the specific triggered event call the initialize method passing the 2 parameters defined above
# define a method used for receive event notifications from the lib:
def notify_events(voip_event_type, voip_event, params):
print "Received Event Type:%s -> Event: %s Params: %s" % (voip_event_type, voip_event, params)
At this point, you are ready to initialize the library passing the dictionary and the callback method defined above:
# initialize the lib passing the dictionary and the callback method defined above:
my_voip.init_lib(voip_params, notify_events)
Received Event Type:EVENT_TYPE__LIB_EVENT -> Event: VOIP_EVENT__LIB_INITIALIZING Params: {'params': {u'username': u'ste', u'sip_server_transport': u'udp', u'log_level': 1, u'sip_server_user': u'ste', u'sip_server_pwd': u'ste', u'debug': False, u'sip_server_address': u'192.168.1.100'}, 'success': True}
Received Event Type:EVENT_TYPE__LIB_EVENT -> Event: VOIP_EVENT__LIB_INITIALIZED Params: {'sip_server': '192.168.1.100', 'success': True}
True
The example above assumes that you have a Sip Server (e.g, Asterisk) running on a pc reachable at the address 192.168.1.100.
Note that, so far, no connection to the Sip Server has been established yet. The init_lib method returns a True value if the initialization request completes without errors, False otherwise.
Finally, note that at the end of the inititialization process the method notify_events is called, containing all informations related to the outcome of the initialization process.
Step 2: Registering the account on the Sip Server¶
Now, you are ready to register the user to the sip server (in this example, we are registering a user called ste with the password ste. We assume that the Sip Server knows this user and is able to accept the registration request from it).
my_voip.register_account()
Received Event Type:EVENT_TYPE__ACCOUNT_EVENT -> Event: VOIP_EVENT__ACCOUNT_REGISTERING Params: {'account_info': u'ste', 'Success': True}
True
Also in this case, the library calls the method notify_events to notify the outcome of the registration process. In particular, this method is called as soon as a registration request is sent (with a VoipEvent._ACCOUNT_REGISTERING event) and later, as soon as the registration is accepted by the remote Sip server (with a VoipEvent._ACCOUNT_REGISTERED state) or refused (with a VoipEvent._ACCOUNT_REGISTRATION_FAILED event)
Step 3: Making a call to an arbitrary extension¶
In case of successfull registration, you can dial an extension (or call an arbitrary Sip User) in the following way:
my_extension = "1234"
my_voip.make_call(my_extension)
import time
# wait until the call is active
while(True):
time.sleep(1)
Note that the notify_events method is called when the call is established (with the event VoipEvent.CALL_ACTIVE)
Step 4: Hangup the active call¶
To hangup the call you have just to call the method hangup_call:
# ends the current call
my_voip.hangup_call()
True
Note that, when the user hangs up the call , the callback method is called again with the event VoipEvent.CALL_HANGUP)
Tutorial 2: Answering a Call¶
This second tutorial of the Most Voip Library shows how to listen for and to answer to incoming calls.
Note that this example, to work, requires a Sip Server (e.g Asterisk) installed and running on a reachable PC. For getting instructions about the Asterisk configuration, click here
The tutorial consists in the following steps, each of them explained in the next sections.
Step 1: Import and instance the voip lib¶
These steps have been already explained in the previous tutorial. However note that, this time, we also import the VoipEvent class, that will be used in the callback method notify_events for detecting the type of the incoming events.
# append the most voip library location to the pythonpath
import sys
sys.path.append("../src/")
# import the Voip Library
from most.voip.api import VoipLib
from most.voip.constants import VoipEvent
# instanziate the lib
my_voip = VoipLib()
# build a dictionary containing all parameters needed for the Lib initialization
voip_params = { u'username': u'ste', # a name describing the user
u'sip_server_address': u'192.168.1.100', # the ip of the remote sip server (default port: 5060)
u'sip_server_user': u'ste', # the username of the sip account
u'sip_server_pwd': u'ste', # the password of the sip account
u'sip_server_transport' :u'udp', # the transport type (default: tcp)
u'log_level' : 1, # the log level (greater values provide more informations)
u'debug' : False # enable/disable debugging messages
}
Step 2: Implement the CallBack method where to receive notifications about incoming calls and other relevant events¶
import time
end_of_call = False # used as exit condition from the while loop at the end of this example
# implement a method that will capture all the events triggered by the Voip Library
def notify_events(voip_event_type,voip_event, params):
print "Received Event Type:%s Event:%s -> Params: %s" % (voip_event_type, voip_event, params)
# event triggered when the account registration has been confirmed by the remote Sip Server
if (voip_event==VoipEvent.ACCOUNT_REGISTERED):
print "Account %s registered: ready to accept call!" % myVoip.get_account().get_uri()
# event triggered when a new call is incoming
elif (voip_event==VoipEvent.CALL_INCOMING):
print "INCOMING CALL From %s" % params["from"]
time.sleep(2)
print "Answering..."
myVoip.answer_call()
# event triggered when the call has been established
elif(voip_event==VoipEvent.CALL_ACTIVE):
print "The call with %s has been established" % myVoip.get_call().get_remote_uri()
dur = 4
print "Waiting %s seconds before hanging up..." % dur
time.sleep(dur)
myVoip.hangup_call()
# events triggered when the call ends for some reasons
elif (voip_event in [VoipEvent.CALL_REMOTE_DISCONNECTION_HANGUP, VoipEvent.CALL_REMOTE_HANGUP, VoipEvent.CALL_HANGUP]):
print "End of call. Destroying lib..."
myVoip.destroy_lib()
# event triggered when the library was destroyed
elif (voip_event==VoipEvent.LIB_DEINITIALIZED):
print "Call End. Exiting from the app."
end_of_call = True
# just print informations about other events triggered by the library
else:
print "Received unhandled event type:%s --> %s" % (voip_event_type,voip_event)
The method above detects the VoipEvent.CALL_INCOMING state, that is triggered when a remote user makes a call to the registered account (the user ‘ste’ in this example). In this example, we answer the incoming call and, in this way, the call is enstablished between the 2 users and the event VoipEvent.CALL_CALLING is triggered. At this point, we decide to wait 4 seconds before hanging up the call, by calling the hangup_call method. This method will end the current active call and will trigger the VoipEvent.CALL_HANGUP method (or one of the events VoipEvent.CALL_REMOTE_DISCONNECTION_HANGUP and VoipEvent.CALL_REMOTE_HANGUP if the remote user terminates the call before us), so we destroy the voip lib and wait for the VoipEvent.LIB_DEINITIALIZED event to set the flag end_of_call equals to True to notify the end of this example outside of this method.
Step 3: Initialize the Voip Library and register the account on the Sip Server¶
Now we have to initialize the library (by passing the notification method and the initialization params defined above) and register the account.
# initialize the lib passing the dictionary and the callback method defined above:
my_voip.init_lib(voip_params, notify_events)
# register the account
my_voip.register_account()
Received Event Type:EVENT_TYPE__LIB_EVENT Event:VOIP_EVENT__LIB_INITIALIZING -> Params: {'params': {u'username': u'ste', u'sip_server_transport': u'udp', u'log_level': 1, u'sip_server_user': u'ste', u'sip_server_pwd': u'ste', u'debug': False, u'sip_server_address': u'192.168.1.100'}, 'success': True}
Received unhandled event type:EVENT_TYPE__LIB_EVENT --> VOIP_EVENT__LIB_INITIALIZING
Received Event Type:EVENT_TYPE__LIB_EVENT Event:VOIP_EVENT__LIB_INITIALIZED -> Params: {'sip_server': '192.168.1.100', 'success': True}
Received unhandled event type:EVENT_TYPE__LIB_EVENT --> VOIP_EVENT__LIB_INITIALIZED
Received Event Type:EVENT_TYPE__ACCOUNT_EVENT Event:VOIP_EVENT__ACCOUNT_REGISTERING -> Params: {'account_info': u'ste', 'Success': True}
Received unhandled event type:EVENT_TYPE__ACCOUNT_EVENT --> VOIP_EVENT__ACCOUNT_REGISTERING
True
Step 4: Add a ‘while’ loop for waiting for incoming calls¶
Now we are ready to wait for incoming call, so we can add a simple ‘while loop’ that doen’t anything and exit when tha flag ‘end_of_call’ assumes the true value.
while (end_of_call==False):
time.sleep(2)
Step 5: Originate a call from the Sip Server for testing the example¶
Open a CLI asterisk console and type the the following command for making a call to the user registered at the step 3:
originate SIP/ste extension
This commands originate a call from the sip server to the user ‘ste’ registered at the step 3. Obviously, it assumes that you have configured the Asterisk Server so that the user ‘ste’ is a known sip user. To do it , you have to configure the sip configuration file, called sip.conf (in Linux platforms, it is generally located in the folder /etc/asterisk).
; user section added at the end odf the configuration file sip.conf
[ste]
type=friend
secret=ste
host=dynamic
context=local_test
API¶
Most Voip Python API documentation.
Core Module¶
Most-Voip API - VoipLib Class
-
class
most.voip.api.
VoipLib
(backend=None)[source]¶ 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_account
()[source]¶ Get informations about the local account
Returns: an most.voip.interfaces.IAccount
object containing informations about the local sip account
-
get_call
()[source]¶ Get the current ICall instance
Returns: an most.voip.interfaces.ICall
object containing informations about the current call
-
get_server
()[source]¶ Get informations about the remote sip server
Returns: an most.voip.interfaces.IServer
object containing informations about the remote sip server
-
init_lib
(params, notification_cb)[source]¶ Initialize the voip library
Parameters: - params – a dictionary containing all initialization parameters
- notification_cb – a callback method called by the library for all event notificationa (status changes, errors, events and so on)
Returns: True if the initialization request completes without errors, False otherwise
-
make_call
(extension)[source]¶ Make a call to the specified extension
Parameters: extension – the extension to dial
-
register_account
()[source]¶ Register the account specified into the params dictionary passed to the
init_lib()
method
-
unregister_account
()[source]¶ Unregister the account specified in the params dictionary passed to the
init_lib()
method
Core Interfaces¶
Most-Voip Interfaces
-
class
most.voip.interfaces.
IAccount
[source]¶ This class contains informations about the local sip account.
-
add_buddy
(extension)[source]¶ Add the specified buddy to this account (so its current state can be notified)
Parameters: extension – the extension related to the buddy to add
-
get_buddies
()[source]¶ Get the list of buddies of the current registered account
Returns: the list of most.voip.interfaces.IBuddy
subscribed by the local account
-
get_buddy
(extension)[source]¶ Get the buddy with the given extension
Parameters: extension – the extension of the buddy Returns: the most.voip.interfaces.IBuddy
with the specified extension
-
get_state
()[source]¶ Returns: the current state of this account (see most.voip.constants.AccountState
)
-
-
class
most.voip.interfaces.
IBuddy
[source]¶ This class contains informations about a buddy. A buddy is a Sip user that notify its presence status to sip accounts that are interested to get informations by them.
-
get_state
()[source]¶ Returns: the current state of this buddy (see most.voip.constants.BuddyState
)
-
-
class
most.voip.interfaces.
ICall
[source]¶ This class contains informations about a call between 2 sip accounts.
-
get_state
()[source]¶ Returns: the current state of this call (see most.voip.constants.CallState
)
-
Constants¶
Most-Voip Constants
-
class
most.voip.constants.
VoipEvent
[source]¶ This class contains all events triggered by the library
-
class
most.voip.constants.
VoipEventType
[source]¶ This class contains the list of different types of event triggerable by the library
-
ACCOUNT_EVENT
= 'EVENT_TYPE__ACCOUNT_EVENT'¶ Account Event Type (account (un)registration)
-
BUDDY_EVENT
= 'EVENT_TYPE__BUDDY_EVENT'¶ Buddy Event Type ((un)subsscribing, (dis)connection, remote (un)holding)
-
CALL_EVENT
= 'EVENT_TYPE__CALL_EVENT'¶ Call Event Type (incoming, dialing, active, (un)holding, hanging up)
-
LIB_EVENT
= 'EVENT_TYPE__LIB_EVENT'¶ Library Event Type (Library (de)initialization, Sip server (dis)onnection)
-
-
class
most.voip.constants.
AccountState
[source]¶ This class contains all allowed states of the local account
-
REGISTERED
= 'SIP_ACCOUNT_STATE__REGISTERED'¶ Registered
-
UNREGISTERED
= 'SIP_ACCOUNT_STATE__UNREGISTERED'¶ Unregistered
-
-
class
most.voip.constants.
BuddyState
[source]¶ This class contains all allowed states of a buddy
-
NOT_FOUND
= 'BUDDY_STATE__NOT_FOUND'¶ Not Found
-
OFF_LINE
= 'BUDDY_STATE__OFF_LINE'¶ Off line
-
ON_HOLD
= 'BUDDY_STATE__ON_HOLD'¶ On hold
-
ON_LINE
= 'BUDDY_STATE__ON_LINE'¶ On line
-
UNKNOWN
= 'BUDDY_STATE__UNKNOWN'¶ Unknown
-
-
class
most.voip.constants.
CallState
[source]¶ This class contains all allowed states of a call
-
ACTIVE
= 'CALL_STATE__ACTIVE'¶ Active call
-
DIALING
= 'CALL_STATE__DIALING'¶ Dialing an outcoming call
-
HOLDING
= 'CALL_STATE__HOLDING'¶ The local account put the active call on hold
-
IDLE
= 'CALL_STATE__IDLE'¶ No call
-
INCOMING
= 'CALL_STATE__INCOMING'¶ Dialing an incoming call
-
Examples¶
Basic usage examples can be found in the python tutorial page . Advanced examples can be found in the python/examples/ subdirectory of the MOST-Voip sources.
Android Most Voip Library¶
Contents:
Getting Started¶
The following tutorial shows you the main features of the library on the Android platform.
This tutorial assumes that you have installed and configured the Asterisk Sip Server on a reachable PC. For getting instructions about the Asterisk configuration click here
Alternatively, you can download a virtual machine containing a running Asterisk Server instance already configured for running the proposed android examples, as explained here
[COMING SOON!]
Javadoc¶
most.voip.api¶
Utils¶
-
public class
Utils
¶
Methods¶
-
public static String
getResourcePathByAssetCopy
(Context ctx, String assetSubFolder, String fileToCopy)¶ Copy the specified resource file from the assets folder into the “files dir” of this application, so that this resource can be opened by the Voip Lib by providing it the absolute path of the copied resource
Parameters: - ctx – The application context
- assetPath – The path of the resource (e.g on_hold.wav or sounds/on_hold.wav)
Returns: the absolute path of the copied resource, or null if no file was copied.
VoipEventBundle¶
-
public class
VoipEventBundle
¶
Constructors¶
-
public
VoipEventBundle
(VoipEventType eventType, VoipEvent event, String info, Object data)¶ This object contains all the informations of a Sip Event triggered by the Voip Library
Parameters: - eventType – the type of this event
- event – the event
- info – a textual information describing this event
- data – a generic object containing event-specific informations (the object type depends on the type of the event)
Methods¶
-
public VoipEventType
getEventType
()¶ Get the event type
Returns: the event type
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¶
-
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
-
public boolean
destroyLib
()¶ Destroy the Voip Lib
Returns: true
if no error occurred in the deinitialization process
-
public boolean
hangupCall
()¶ Close the current active call
Returns: true if no error occurred during this operation, false otherwise
-
public boolean
holdCall
()¶ Put the active call on hold status
Returns: true if no error occurred during this operation, false otherwise
-
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
-
public boolean
registerAccount
()¶ Register the account according to the configuration params provided in the
initLib(HashMap,Handler)
methodReturns: true
if the registration request was sent to the sip server,false
otherwise
VoipLibBackend¶
-
public class
VoipLibBackend
extends Application implements VoipLib¶ This class implements the
most.voip.api.VoipLib
interface by using the PJSip library as backend. So, you can get amost.voip.api.VoipLib
instance in the following way:VoipLib myVoip = new VoipLibBackend();
To get a
most.voip.api.interfaces.ICall
instance you can call thegetCall()
method:ICall myCall = myVoip.getCall();
To get a
most.voip.api.interfaces.IAccount
instance you can call thegetAccount()
method:IAccount myAccount = myVoip.getAccount();
To get a
most.voip.api.interfaces.IServer
instance you can call thegetServer()
method:IServer mySipSever = myVoip.getServer();
See also:
VoipLib
most.voip.api.enums¶
AccountState¶
-
public enum
AccountState
¶
Enum Constants¶
-
public static final AccountState
REGISTERED
¶
-
public static final AccountState
UNREGISTERED
¶
BuddyState¶
-
public enum
BuddyState
¶
Enum Constants¶
-
public static final BuddyState
NOT_FOUND
¶
-
public static final BuddyState
OFF_LINE
¶
-
public static final BuddyState
ON_HOLD
¶
-
public static final BuddyState
ON_LINE
¶
-
public static final BuddyState
UNKNOWN
¶
RegistrationState¶
-
public enum
RegistrationState
¶
Enum Constants¶
-
public static final RegistrationState
FORBIDDEN
¶
-
public static final RegistrationState
NOT_FOUND
¶
-
public static final RegistrationState
OK
¶
-
public static final RegistrationState
REQUEST_TIMEOUT
¶
ServerState¶
-
public enum
ServerState
¶
Enum Constants¶
-
public static final ServerState
CONNECTED
¶
-
public static final ServerState
DISCONNECTED
¶
VoipEvent¶
-
public enum
VoipEvent
¶ Contains all events triggered by the library
Enum Constants¶
VoipEventType¶
-
public enum
VoipEventType
¶
Enum Constants¶
-
public static final VoipEventType
ACCOUNT_EVENT
¶ Voip Account Events ((un)registration)
-
public static final VoipEventType
BUDDY_EVENT
¶ Voip Buddy Events (buddy presence notification: (un)subsscribing, (dis)connection, remote (un)holding)
-
public static final VoipEventType
CALL_EVENT
¶ Voip Call Events (incoming, dialing, active, (un)holding, hanging up)
-
public static final VoipEventType
LIB_EVENT
¶ Voip Library Events (Voip (de)initialization)
most.voip.api.interfaces¶
IAccount¶
-
public interface
IAccount
¶ Represents a local sip account
IBuddy¶
-
public interface
IBuddy
¶ An IBuddy is a remote Sip user that notify its presence status to sip accounts (
IAccount
objects) that are interested to get informations by them.
Methods¶
-
BuddyState
getState
()¶ get the current state of this buddy
Returns: the current state of this buddy See also:
IBuddy.refreshStatus()
ICall¶
-
public interface
ICall
¶ Contains informations about a call between 2 sip accounts.
IServer¶
-
public interface
IServer
¶ Contains informations about the remote Sip Server (e.g Asterisk)
Methods¶
-
ServerState
getState
()¶ get the current status of the sip server (see
most.voip.constants.ServerState
)Returns: the current status of the sip server
Examples¶
A tutorial can be found in the getting started page . Basic and advanced examples can be found in the android/examples/ subdirectory of the MOST-Voip sources. The available examples are the following:
- MostVoipActivityFirstExample: shows how to initialize the Voip Lib and register a Sip Account on a remote Sip Server
- MostVoipActivitySecondExample: shows how to make a call to a remote Sip account
- MostVoipActivityAnswerCallExample: shows how to answer a call incoming from a remote Sip account
- MostVoipActivityCallStateExample: shows how to monitor the state of the remote Sip Server, of the current call and of the remote buddies
- MostVoipActivityDemo: show how to make a call to a remote buddy, answer a call, and monitor the state of the remote Sip Server, of the current call and of the remote buddies
- MostVoipActivityRemoteConfigurationExample: like the previous example, but it also shows how to load the Sip Account Configuration from a remote Web Server
How to build and run the examples¶
First of all, download the Most-voip Asterisk VM, containing a running Asterisk Server instance already configured for running the proposed android examples, as explained here .
Then, do the following:
- Open your preferred IDE and import the Android Most Voip library project from the android/src/AndroidVoipLib folder (if you are using Eclipse, select File/Import.../Android/Existing Android Code Into Workspace to import the project)
- Add to the project the dependence android-support-v4.jar . Please, visit this site to get detailed instructions about how to do it.
- Import your preferred example project (e.g MostVoipActivityFirstExample) located in the android/examples folder in the same way you have imported the Android Most Voip library project
- Set the AndroidVoipLib library project (previously added to the workspace) as a Project Reference of the example project imported at the previous step
- Add to the example project the dependence ‘android-support-v4.jar’ , in the same way you have done for the AndroidVoipLib library project
- Build the example project and deploy the generated .apk on your android emulator or mobile phone
Authors¶
Code author: Francesco Cabras <francesco.cabras@crs4.it>
Code author: Stefano Leone Monni <stefano.monni@crs4.it>
Installation¶
Most-Voip Library is based on PJSIP 2.2.1 library. So, first of all, you have to install PJSip, by performing the following steps:
- Download the last svn revision from http://svn.pjsip.org/repos/pjproject/trunk/ (revision 4818 works well). (tar.gz and zip archives don’t compile!)
- ./configure CFLAGS=’-fPIC’
- make dep
- make
- sudo make install
- cd pjsip-apps/src/python/
- sudo python setup.py install
If you intend to use Most-Voip on the Android platform, you also have to build Pjsip for Android, as explained here
Get the latest release from GitHub: https://github.com/crs4/most-voip
License¶
Project MOST - Moving Outcomes to Standard Telemedicine Practice
http://most.crs4.it/
Copyright 2014, CRS4 srl. (http://www.crs4.it/)
Dual licensed under the MIT or GPL Version 2 licenses.
See license-GPLv2.txt or license-MIT.txt
Detailed Dual Licensing Info¶
The MOST-Voip API is licensed under both General Public License (GPL) version 2 and the MIT licence. In practical sense, this means:
- if you are developing Open Source Software (OSS) based on MOST-Voip, chances are you will be able to use MOST-Voip under GPL. Note that the Most-Voip Library depends on the PJSIP API, so please double check here for OSS license compatibility with GPL.
- alternatively, you can release your application under MIT licence, provided that you have followed the guidelines of the PJSIP licence explained here.