/ikran

Ikran, an addon for Mozilla for making audio/video call using SIP

Primary LanguageC

---------------
0. Introduction
---------------
  Ikran is an experimental addon for Firefox that turns your browser into a SIP endpoint 
  for both audio and video.  It currently uses WebRTC for audio/video media support.

  The ikran is a bird from the mythical world of Pandora (Avatar).  It is well known for
  its birdcall which travels long distances using widely accepted standards for audio and video.

  Ikran can operate in two modes. (1) Registration mode, where it is a SIP UA and registers with 
  a SIP server. (2) Peer to Peer Mode, where is can communicate directly with other ikran clients
  in the same mode using SIP. 
  
Source tree strcture:
<SOURCE> 
tests                       [Standalone test application and add-on]
	testapp_softphone
ikran                       [addon code and sample html]
third_party                 [Third party dependencies ]
	chromium_base
src/sipcc                   [SIP stack]
src                         [ECC - call control wrapper for SIP stack]

-------------------
1. Platform Support 
-------------------
Required for all platforms:
  Python (www.python.org) -  known to work with 2.6 & 2.7 
  SCons (www.scons.org) - 'sudo apt-get install scons' or 'sudo yum install scons'
  MOZSDKPATH environment variable pointing to the Gecko2 SDK (6.0 or later)
  WEBRTCPATH environment variable pointing to the webrtc source trunk
  
  
Linux:
  Built regularly on Ubuntu 10.4 32bit and 64bit
  Built regularly on Ubuntu 11.0.4 32bit and 64bit
  Close to building on Fedora 15 64-bit
  Third-Party Libraries
  +libxml2 - sudo apt-get install libxml2-dev
  +Glib    - sudo apt-get install libdbus-glib-1-dev
  +asound  - sudo apt-get install libasound2-dev
  +libgtk  - sudo apt-get install libgtk2.0-dev     

Mac OSX:
  Built on OSX 10.7 with XCode 4.1 and OSX 10.6 with XCode 3.2.6
  Links to Framework 10.6, minimum version 10.5
  Requires libidl installed.  You can use MacPorts ("sudo port install libidl")

Windows:
  Built regularly on Windows XP & Windows 7 32bit.
  Python path is in runSconsBuild.py and set to c:\python27
  Requires setting following environment variables
  SCONS_LOCATION pointing to scons installation
  ZIP_LOCATION pointing to 7z zip installation (windows only)
  MS_WINDOWS_SDK_PATH pointing to Windows SDK path ( v7.1)
  MS_VC_PATH pointing to Visual Studio installation ( VS9.0)
  DXSDK_DIR pointing to Micrisoft DirectX SDK installation
	e.g SCONS_LOCATION=c:\Python26\Scripts
  
-----------
2. Building 
-----------
  - Get the Gecko2 SDK 6.0 for your platform and target bitlength from 
	 https://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/6.0/sdk
  - Extract the package & Set the MOZSDKPATH env variable to point to it
  - NOTE FOR OSX : If you are compiling 32bit OSX use the 32bit Gecko2 SDK, 
      but copy in the xpidl executable from the 64bit SDK.
  - Build WEBRTC for video and audio engine libraries 
      +  Follow the instructions @ http://www.webrtc.org/reference/getting-started
      +  webtrc version > 595 has been tested. To download a specific version use 
		gclient sync --revision 595 
      +  Set WEBRTCPATH to point to it : export WEBRTCPATH=/Users/XTM/HTML5/webrtc/trunk
  - Instead of using scons directly, use runSconsBuild.py like this
    'python runSconsBuild.py debug' or
    'python runSconsBuild.py clean'
    Current command line options are 'debug', 'release', 'clean', 'noaddon' and 'x64'.
    
---------
4. Output
---------
  Build will create a standalone test app and an addon for Firefox 4, 5 or 6.
  Test App Exe: TestApp_Softphone
  Addon: ikran-0.2-dev.xpi

--------------------
5. Testing the addon
--------------------
  To build  & test addon , follow below steps

  - Addon executable shall be generated under the <SOURCE>/ikran
 	 called ikran-0.2-dev.xpi
  - OSX 
	Start Firefox in 32 bit as 
		arch -i386 /Applications/Firefox.app/Contents/MacOS/firefox-bin 
  - Linux (32 bit and 64 bit)
	Connect your camera and make sure it works :)
	Start Firefox normally  
  - Install the addon
  - Test add-on with sample page at
		<SOURCE>/ikran/content/ikran.html		
NOTES:
1. ikran.html should be served from a server due to permission issues
   with file loaded locally (file://) 

-----------------------------
6. Using the Test Application
-----------------------------
Use the command line test application to exercise the SIP stack.
The test application can be used against Cisco Call Manager, Asterisk and kamailio.

 Run the Test Application from the command line with no parameters
   ./tests/testapp_softphone/TestApp_SoftPhone

   ********************************
   Please Choose One :
         0. Quit
         1. Register User
         2. Place Call
         3. Answer Call
         4. End Call
	 5. Start P2P mode
	 6. Place P2P Call
   What Action do you want to perform Monsieur ??

   Select 1 to register, enter the following details, inside square brackets are defaults.

      Enter SIP Server IP Address [ 10.53.47.140 ]:
      Enter SIP Server username (phone DN for CUCM) [ 9995 ]:
      Enter Password (not required for CUCM [ Enter ]:
      Enter device name (only required for CUCM) [ emannionsip01 ]:

   Select 5 to start ikran in Peer to Peer mode.  This requires only the SIP username to start.

      Enter local peer username (usually a phone DN) [ 9995 ]:

   To make a P2P call select option 6, this will require remote SIP username and remote IP Address.


 When running the Test Application in Linux it operates slightly differently. To see the available
 list of commangs use the '?' key.
 
------------
7. Addon API
------------
The JS API offers support for 
	SIP Registration, Place Call, HangUp Call & Answer Call
        P2P Mode, Place P2P Call

window.navigator.service.call obtains handle to session-control 
object. 

<session-control>.registerUser(user_device, user, credential, sip-proxy, sessObserver);
registers user to the sip-proxy. 

'sessObserver' is a JS function that will be called whenever there is 
a change in the session state such as "no-registrar","registering",
"registered", "incoming-call" & "registration-failed".

On successful registration, one can place call with the below API
<session-control>.placeCall(dial-number, canvas, mediaObserver);
where dial-number is number to dial and mediaObserver reports 
significant media state changes suhc as "call-connected",
"call-terminated" as of today.

JS APIs unRegisterUser() and hangupCall() allows de-registration
& end-call functionalities.

Few Points to Note
1. One user is suported as registered by instance
 
Please see content/ikran.html for sample usage of the API.

----------------------------------
8. Configuring Asterisk SIP Server
----------------------------------

1. Create a SIP user in /etc/asterisk/sip.conf

  [bob]
  type=friend
  defaultuser=bob
  secret=1234
  host=dynamic
  context=ikran

2. Create a phone extension in /etc/asterisk/extensions.conf

  [ikran]
  extn => 1234,1,Dial(SIP/bob)
  
3. From the Asterisk CLI> sip reload  

---------------------------------
9. Configuring kamailo SIP Server
---------------------------------
Here is a good reference: http://www.oldskoolphreak.com/tfiles/voip/beginners_openser.txt

1. Create two users

  kamctl add userbob bobpassword bob@localhost
  kamctl add useralice alicepassword alice@localhost


2. Start kamailio

  /usr/local/sbin$ ./kamailio