Changeset 4763 for pjproject/trunk


Ignore:
Timestamp:
Feb 27, 2014 2:03:59 AM (11 years ago)
Author:
bennylp
Message:

Re #1715: updated book with latest Rst

Location:
pjproject/trunk/doc/pjsip-book
Files:
1 added
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/doc/pjsip-book/conf.py

    r4704 r4763  
    4141 
    4242# General information about the project. 
    43 project = u'The PJSIP Book' 
    44 copyright = u'2013, Teluu Ltd.' 
     43project = u'PJSUA2 Documentation' 
     44copyright = u'2014, Teluu Ltd.' 
    4545 
    4646# The version info for the project you're documenting, acts as replacement for 
     
    5151version = '1.0' 
    5252# The full version, including alpha/beta/rc tags. 
    53 release = '1.0-beta' 
     53release = '1.0-alpha' 
    5454 
    5555# The language for content autogenerated by Sphinx. Refer to documentation 
     
    165165 
    166166# Output file base name for HTML help builder. 
    167 htmlhelp_basename = 'ThePJSIPBookdoc' 
     167htmlhelp_basename = 'PJSUA2Doc' 
    168168 
    169169 
     
    184184# (source start file, target name, title, author, documentclass [howto/manual]). 
    185185latex_documents = [ 
    186   ('index', 'ThePJSIPBook.tex', u'The PJSIP Book Documentation', 
     186  ('index', 'PJSUA2Doc.tex', u'PJSUA2 Documentation', 
    187187   u'Sauw Ming Liong, Benny Prijono', 'manual'), 
    188188] 
     
    214214# (source start file, name, description, authors, manual section). 
    215215man_pages = [ 
    216     ('index', 'thepjsipbook', u'The PJSIP Book Documentation', 
     216    ('index', 'pjsua2doc', u'PJSUA2 Documentation', 
    217217     [u'Sauw Ming Liong', u'Benny Prijono'], 1) 
    218218] 
     
    228228#  dir menu entry, description, category) 
    229229texinfo_documents = [ 
    230   ('index', 'ThePJSIPBook', u'The PJSIP Book Documentation', 
     230  ('index', 'PJSUA2Doc', u'PJSUA2 Documentation', 
    231231   u'Sauw Ming Liong@*Benny Prijono', 'ThePJSIPBook', 'One line description of project.', 
    232232   'Miscellaneous'), 
  • pjproject/trunk/doc/pjsip-book/consider.rst

    r4762 r4763  
    2323**Essential:** set your editor to use 8 characters tab size in order to see PJSIP source correctly. 
    2424 
    25 These below are PJSIP coding style. You don't need to follow it unless you are submitting patches to PJSIP: 
    26  
    27 * indentation uses tabs and spaces. Tab size is 8 characters, indentation 4. 
    28 * all public API in header file must be documented in Doxygen format. 
    29 * other than that, we mostly just use `K & R style <http://en.wikipedia.org/wiki/1_true_brace_style#K.26R_style>`_, which is the only correct style anyway. 
     25Detailed below is the PJSIP coding style. You don't need to follow it unless you are submitting patches to PJSIP: 
     26 
     27* Indentation uses tabs and spaces. Tab size is 8 characters, indentation 4. 
     28* All public API in header file must be documented in Doxygen format. 
     29* Apart from that, we mostly just use `K & R style <http://en.wikipedia.org/wiki/1_true_brace_style#K.26R_style>`_, which is the only correct style anyway. 
    3030 
    3131 
     
    4343Windows is supported from Windows 2000 up to the recent Windows 8 and beyond. All features are expected to work. 64bit support was added recently. Development is based on Visual Studio. Considerations for this platform include: 
    4444 
    45 #. because Visual Studio file format keeps changing on every release, we decided to support the lowest denominator, namely Visual Studio 2005. Unfortunately the project upgrade procedure fails on Visual Studio 2010, and we don't have any solution for that. But VS 2008 and VS 20012 work. 
     45#. Because Visual Studio file format keeps changing on every release, we decided to support the lowest denominator, namely Visual Studio 2005. Unfortunately the project upgrade procedure fails on Visual Studio 2010, and we don't have any solution for that. VS 2008 and VS 2012 onwards should work. 
    4646 
    4747MacOS X 
     
    4949All features are expected to work. Considerations include: 
    5050 
    51 #. development with XCode is currently not supported. This is **not** to say that you cannot use XCode, but PJSIP only provides basic Makefiles and if you want to use XCode you'd need to arrange the project yourself. 
     51#. Development with XCode is currently not supported. This is **not** to say that you cannot use XCode, but PJSIP only provides basic Makefiles and if you want to use XCode you'd need to arrange the project yourself. 
    5252#. Mac systems typically provides very good sound device, so we don't expect any problems with audio on Mac.  
    5353 
     
    5656All features are expected to work. Linux considerations: 
    5757 
    58 #. use our native ALSA backend instead of PortAudio because ALSA has less jitter than OSS and our backend is more lightweight than PortAudio 
     58#. Use our native ALSA backend instead of PortAudio because ALSA has less jitter than OSS and our backend is more lightweight than PortAudio 
    5959 
    6060 
     
    6363All features except video are expected to work (video is coming soon!). Considerations for iOS: 
    6464 
    65 #. you need to use TCP transport for SIP for the background feature to work 
     65#. You need to use TCP transport for SIP for the background feature to work 
    6666#. IP change (for example when user is changing access point) is a feature frequently asked by developers and you can find the documentation here: http://trac.pjsip.org/repos/wiki/IPAddressChange 
    67 #. there are some specific issues for iOS 7 and beyond, please see http://trac.pjsip.org/repos/ticket/1697 
    68 #. if SSL is needed, you need to compile OpenSSL for iOS 
     67#. There are some specific issues for iOS 7 and beyond, please see http://trac.pjsip.org/repos/ticket/1697 
     68#. If SSL is needed, you need to compile OpenSSL for iOS 
    6969 
    7070 
     
    7373All features except video are expected to work (video is coming soon!). Considerations for Android: 
    7474 
    75 #. you can only use pjsua2 Java binding for this target 
    76 #. it has been reported that Android audio device is not so good in general, so some audio tuning may be needed. Echo cancellation also needs to be checked 
    77 #. this is also a new platform for us  
     75#. You can only use pjsua2 Java binding for this target. 
     76#. It has been reported that Android audio device is not so good in general, so some audio tuning may be needed. Echo cancellation also needs to be checked. 
     77#. This is also a new platform for us.  
    7878 
    7979 
    8080Symbian 
    8181------- 
    82 Symbian has been supported for a long time but it doesn't get too many attention recently. In general all features (excluding video) are expected to work, but we're not going to do Symbian specific development anymore. Other considerations for Symbian: 
    83  
    84 #. the MDA audio is not very good (it has high latency), so normally you'd want to use Audio Proxy Server (APS) or VoIP Audio Service (VAS) for the audio device, which we support. Using these audio backends will also provide us with high quality echo cancellation as well as low bitrate codecs such as AMR-NB, G.729, and iLBC. But VAS and APS requires purchase of Nokia development certificate to sign the app, and also since APS and VAS only run on specific device type, you need to package the app carefully and manage the deployment to cover various device types. 
    85  
    86  
    87 Blackberry 10 
    88 ------------- 
    89 Blackberry 10 is supported since PJSIP version 2.2. As this is a relatively new platform for us, we are currently listening to developer's feedback regarding the port. But so far it seems to be working well. Some considerations for BB10 platform include: 
     82Symbian has been supported for a long time. In general all features (excluding video) are expected to work, but we're not going to do Symbian specific development anymore. Other considerations for Symbian: 
     83 
     84#. The MDA audio is not very good (it has high latency), so normally you'd want to use Audio Proxy Server (APS) or VoIP Audio Service (VAS) for the audio device, which we support. Using these audio backends will also provide us with high quality echo cancellation as well as low bitrate codecs such as AMR-NB, G.729, and iLBC. But VAS and APS requires purchase of Nokia development certificate to sign the app, and also since APS and VAS only run on specific device type, you need to package the app carefully and manage the deployment to cover various device types. 
     85 
     86 
     87BlackBerry 10 
     88------------- 
     89BlackBerry 10 (BB10) is supported since PJSIP version 2.2. As this is a relatively new platform for us, we are currently listening to developer's feedback regarding the port. But so far it seems to be working well. Some considerations for BB10 platform include: 
    9090 
    9191#. IP change (for example when user is changing access point) is a feature frequently asked by developers and you can find the documentation here: http://trac.pjsip.org/repos/wiki/IPAddressChange 
     
    9494Windows Mobile 
    9595-------------- 
    96 This is the old Windows Mobile platform that is based on WinCE. This platform has been supported for a long time, but doesn't seem to attract any attentions recently. We expect all features except video to work, but there may be some errors every now and then because this target is not actively maintained. No new development will be done for this platform. 
     96This is the old Windows Mobile platform that is based on WinCE. This platform has been supported for a long time. We expect all features except video to work, but there may be some errors every now and then because this target is not actively maintained. No new development will be done for this platform. 
    9797 
    9898Other considerations for Windows Mobile platform are: 
    9999 
    100 #. the quality of audio device on WM varies a lot, and this affects audio latency. Audio latency could go as high as hundreds of millisecond on bad hardware. 
    101 #. echo cancellation could be a problem. We can only use basic echo suppressor due to hardware limitation, and combined with bad quality of audio device, it may cause ineffective echo cancellation. This could be mitigated by setting the audio level to low. 
     100#. The quality of audio device on WM varies a lot, and this affects audio latency. Audio latency could go as high as hundreds of millisecond on bad hardware. 
     101#. Echo cancellation could be a problem. We can only use basic echo suppressor due to hardware limitation, and combined with bad quality of audio device, it may cause ineffective echo cancellation. This could be mitigated by setting the audio level to low. 
    102102 
    103103 
     
    106106Windows Phone 8 (WP8) support is being added to PJSIP version 2.2 and is still under development. Specific considerations for this platform are: 
    107107 
    108 #. WP8 governs specific interaction with WP8 GUI and framework that needs to be followed by application in order to make VoIP call work seamlessly on the device. Some lightweight process will be created by WP8 framework in order for background call to work and PJSIP needs to put it's background processing in this process's context. Currently this feature is under development. 
     108#. WP8 governs specific interaction with WP8 GUI and framework that needs to be followed by application in order to make VoIP call work seamlessly on the device. Some lightweight process will be created by WP8 framework in order for background call to work and PJSIP needs to put its background processing in this process' context. Currently this feature is under development. 
    109109 
    110110 
     
    114114In general embedded Linux support is similar to Linux and we find no problems with it. We found some specific considerations for embedded Linux as follows: 
    115115 
    116 #. the performance of the audio device is probably the one with most issues, as some development boards have not so descent sound device that has high audio jitter (or burst) and latency. This will affect end to end audio latency and also the performance of the echo canceller. Also we found that ALSA generally works better than OSS, so if you can have ALSA up and running that will be better. Use our native ALSA backend audio device instead of PortAudio since it is simpler and lighter. 
     116#. The performance of the audio device is probably the one with most issues, as some development boards does not have a decent sound device. Typically there is high audio jitter (or burst) and latency. This will affect end to end audio latency and also the performance of the echo canceller. Also we found that ALSA generally works better than OSS, so if you can have ALSA up and running that will be better. Use our native ALSA backend audio device instead of PortAudio since it is simpler and lighter. 
    117117 
    118118 
    119119QNX or Other Posix Embedded OS 
    120120------------------------------ 
    121 This is not part of our officially supported OSes, but users have run PJSIP on QNX and Blackberry 10 is based on QNX too. Since QNX provides Posix API, and maybe by using the settings found in the configure-bb10 script, PJSIP should be able to run on it, but you need to develop PJMEDIA sound device wrapper for your audio device. Other than this, we don't have enough experience to comment on the platform.  
     121This is not part of our officially supported OS platforms, but users have run PJSIP on QNX and BlackBerry 10 is based on QNX too. Since QNX provides Posix API, and maybe by using the settings found in the configure-bb10 script, PJSIP should be able to run on it, but you need to develop PJMEDIA sound device wrapper for your audio device. Other than this, we don't have enough experience to comment on the platform.  
    122122 
    123123 
     
    127127 
    128128 
    129 Porting to Other Embedded OSes 
     129Porting to Other Embedded OS 
    130130------------------------------ 
    131 It is possible to port PJSIP to other embedded OSes or even directly to device without OS and people have done so. In general, the closer resemblance the new OS to existing supported OS, the easier the porting job will be. The good thing is, PJSIP has been made to be very very portable, and system dependent features are localized in PJLIB and PJMEDIA audio device, so the effort is more quantifiable. Once you are able to successfully run *pjlib-test*, you are more or less there with your porting effort. Other than that, if you really want to port PJSIP to new platform, you probably already know what you're doing.  
     131It is possible to port PJSIP to other embedded OS or even directly to device without OS and people have done so. In general, the closer resemblance the new OS to existing supported OS, the easier the porting job will be. The good thing is, PJSIP has been made to be very very portable, and system dependent features are localized in PJLIB and PJMEDIA audio device, so the effort is more quantifiable. Once you are able to successfully run *pjlib-test*, you are more or less there with your porting effort. Other than that, if you really want to port PJSIP to new platform, you probably already know what you're doing.  
    132132 
    133133 
     
    140140At the lowest level we have the individual PJSIP **C** libraries, which consist of PJSIP, PJMEDIA, and PJNATH, with PJLIB-UTIL and PJLIB as support libraries. This level provides the most flexibility, but it's also the hardest to use. The only reason you'd want to use this level is if: 
    141141 
    142 #. you only need the individual library (say, PJNATH) 
    143 #. you need to be very very tight in footprint (say when things need to be measured in Kilobytes instead of Megabytes) 
    144 #. you are **not** developing a SIP client 
     142#. You only need the individual library (say, PJNATH) 
     143#. You need to be very very tight in footprint (say when things need to be measured in Kilobytes instead of Megabytes) 
     144#. You are **not** developing a SIP client 
    145145 
    146146Use the corresponding PJSIP, PJMEDIA, PJNATH manuals from http://trac.pjsip.org/repos/ for information on how to use the libraries. If you use PJSIP, the PJSIP Developer's Guide (PDF) from that page provides in-depth information about PJSIP library.   
     
    152152Motivations for using PJSUA-LIB library includes: 
    153153 
    154 #. developing client application (PJSUA-LIB is optimized for developing client app) 
    155 #. better efficiency than higher level API 
     154#. Developing client application (PJSUA-LIB is optimized for developing client app) 
     155#. Better efficiency than higher level API 
    156156 
    157157 
     
    160160pjsua2 is a new, objected oriented, C++ API created on top of PJSUA-LIB. The API is different than PJSUA-LIB, but it should be even easier to use and it should have better documentation too (such as this book). The pjsua2 API removes most cruxes typically associated with PJSIP, such as the pool and pj_str_t, and add new features such as object persistence so you can save your configs to a file, for example. All data structures are rewritten for more clarity.  
    161161 
    162 A C++ application can use pjsua2 natively, while at the same time still has access to the lower level objects if it needs to. This means that the C++ application should not loose any information from using the C++ abstraction, compared to if it is using PJSUA-LIB directly. The C++ application also should not loose the ability to extend the library. It would still be able to register a custom PJSIP module, pjmedia_port, pjmedia_transport, and so on. 
     162A C++ application can use pjsua2 natively, while at the same time still has access to the lower level objects if it needs to. This means that the C++ application should not lose any information from using the C++ abstraction, compared to if it is using PJSUA-LIB directly. The C++ application also should not lose the ability to extend the library. It would still be able to register a custom PJSIP module, pjmedia_port, pjmedia_transport, and so on. 
    163163 
    164164Benefits of using pjsua2 C++ API include: 
    165165 
    166 #. cleaner object oriented API 
    167 #. uniform API for higher level language such as Java and Python 
    168 #. persistence API 
    169 #. the ability to access PJSUA-LIB and lower level libraries when needed (including the ability to extend the libraries, for example creating custom PJSIP module, pjmedia_port, pjmedia_transport, etc.) 
     166#. Cleaner object oriented API 
     167#. Uniform API for higher level language such as Java and Python 
     168#. Persistence API 
     169#. The ability to access PJSUA-LIB and lower level libraries when needed (including the ability to extend the libraries, for example creating custom PJSIP module, pjmedia_port, pjmedia_transport, etc.) 
    170170 
    171171 
    172172Some considerations on pjsua2 C++ API are: 
    173 #. instead of returning error, the API uses exception for error reporting 
     173#. Instead of returning error, the API uses exception for error reporting 
    174174#. pjsua2 uses standard C++ library 
    175 #. the performance penalty due to the API abstraction should be negligible on typical modern device 
     175#. The performance penalty due to the API abstraction should be negligible on typical modern device 
    176176 
    177177 
  • pjproject/trunk/doc/pjsip-book/index.rst

    r4762 r4763  
    1 .. The PJSIP Book documentation master file, created by 
     1.. PJSUA2 documentation master file, created by 
    22   sphinx-quickstart on Sat Nov 30 06:36:26 2013. 
    33   You can adapt this file completely to your liking, but it should at least 
    44   contain the root `toctree` directive. 
    55 
    6 The PJSIP Book 
     6PJSUA2 Documentation 
    77========================================== 
    88 
     
    1616   consider 
    1717   intro_pjsua2 
    18    getting_started 
    1918   endpoint 
    2019   account 
     
    2322   presence 
    2423   samples 
    25    optimization 
    2624   media_quality 
    2725   network_problems 
    2826   reference 
     27   breathe 
    2928 
    3029    
  • pjproject/trunk/doc/pjsip-book/intro.rst

    r4762 r4763  
    11 
    2 Introduction to PJSUA2 
     2Introduction 
    33******************************* 
    44This documentation is intended for developers looking to develop Session Initiation Protocol (SIP) based client application. Some knowledge on SIP is definitely required, and of course some programming experience. Prior knowledge of PJSUA C API is not needed, although it will probably help. 
    55 
    6 This PJSUA2 module provides very high level C++ API to do SIP calls, presence, and instant messaging, as well as handling media and NAT traversal. Knowledge of SIP protocol details (such as the grammar, transaction, dialog, and whatnot) are not required, however you should know how SIP works in general and particularly how to configure SIP clients to, e.g. register to a SIP provider, specify SIP URI to make call to, and so on, to use the module. 
     6PJSIP libraries provide multi-level APIs to do SIP calls, presence, and instant messaging, as well as handling media and NAT traversal. Knowledge of SIP protocol details (such as the grammar, transaction, dialog, and whatnot) are not required (but it will help a lot!), however you should know how SIP works in general and particularly how to configure SIP clients to, e.g. register to a SIP provider, specify SIP URI to make call to, and so on, to use the module. 
    77 
    88Getting Started with PJSIP 
     
    1212.. _`PJSIP's Features List`: http://trac.pjsip.org/repos/wiki/PJSIP-Datasheet 
    1313 
    14 Then to begin using PJSIP, the `Getting Started Guide`_ contains instructions to acquire and build PJSIP on various platforms that we support. 
     14To start using PJSIP, the `Getting Started Guide`_ contains instructions to acquire and build PJSIP on various platforms that we support. 
    1515 
    1616.. _`Getting Started Guide`: http://trac.pjsip.org/repos/wiki/Getting-Started  
     
    2828.. _`PJSIP Reference Manual`: http://trac.pjsip.org/repos/wiki 
    2929 
    30 Building PJSUA2 
    31 ================= 
    32 PJSUA2 API declaration can be found in ``pjsip/include/pjsua2`` while the source codes are located in ``pjsip/src/pjsua2``. It will be automatically built when you compile PJSIP. 
    3330 
    34 PJSUA2 Language Binding Support 
    35 =================================== 
    36 The PJSUA2 API is also available for other programming languages via SWIG binding, such as Java and Python. 
    3731 
  • pjproject/trunk/doc/pjsip-book/intro_pjsua2.rst

    r4762 r4763  
    55PJSUA2 is implemented on top of PJSUA-LIB API. The SIP and media features and object modelling follows what PJSUA-LIB provides (for example, we still have accounts, call, buddy, and so on), but the API to access them is different. These features will be described later in this chapter. PJSUA2 is a C++ library, which you can find under ``pjsip`` directory in the PJSIP distribution. The C++ library can be used by native C++ applications directly. But PJSUA2 is not just a C++ library. From the beginning, it has been designed to be accessible from high level non-native languages such as Java and Python. This is achieved by SWIG binding. And thanks to SWIG, binding to other languages can be added relatively easily in the future. 
    66 
    7  
    8 Building PJSUA2 
    9 ====================== 
    10 The PJSUA2 C++ library will be built by default by PJSIP build system. 
    11  
    12 The SWIG modules for Python and Java are built by invoking ``make`` manually from ``pjsip-apps/src/swig`` directory. 
     7PJSUA2 API declaration can be found in ``pjsip/include/pjsua2`` while the source codes are located in ``pjsip/src/pjsua2``. It will be automatically built when you compile PJSIP. 
    138 
    149 
     
    10095 
    10196 
     97Building PJSUA2 
     98====================== 
     99The PJSUA2 C++ library will be built by default by PJSIP build system. 
     100 
     101Building Python and Java SWIG Modules 
     102====================================== 
     103The SWIG modules for Python and Java are built by invoking ``make`` and ``make install`` manually from ``pjsip-apps/src/swig`` directory. The ``make install`` will install the Python SWIG module to user's ``site-packages`` directory. 
     104 
     105Requirements 
     106------------ 
     107 
     108#. ``JDK``. 
     109#. ``Python``, version 2.7 or above is required. 
     110   For **Linux/UNIX**, you will also need ``Python developent package`` (called ``python-devel`` (e.g. on Fedora) or ``python2.7-dev`` (e.g. on Ubuntu)). For **Windows**, you will need MinGW and ``Python SDK`` such as `ActivePython-2.7.5`_ from `ActiveState`_. 
     111 
     112.. _`ActivePython-2.7.5`: http://www.activestate.com/activepython/downloads 
     113.. _`ActiveState`: http://www.activestate.com 
     114 
     115Testing The Installation 
     116------------------------ 
     117To test the installation, simply run python and import ``pjsua2`` module:: 
     118 
     119  $ python 
     120  > import pjsua2 
     121  > ^Z 
     122 
     123 
     124Using in C++ Application 
     125======================== 
     126As mentioned in previous chapter, a C++ application can use *pjsua2* natively, while at the same time still has access to the lower level objects and the ability to extend the libraries if it needs to. Using the API will be exactly the same as the API reference that is written in this book. 
     127 
     128Here is a sample complete C++ application to give you some idea about the API. The snippet below initializes the library and creates an account that registers to our pjsip.org SIP server. 
     129 
     130.. code-block:: c++ 
     131     
     132  #include <pjsua2.hpp> 
     133  #include <iostream> 
     134   
     135  using namespace pj; 
     136   
     137  // Subclass to extend the Account and get notifications etc. 
     138  class MyAccount : public Account { 
     139  public: 
     140      virtual void onRegState(OnRegStateParam &prm) { 
     141          AccountInfo ai = getInfo(); 
     142          std::cout << (ai.regIsActive? "*** Register:" : "*** Unregister:") 
     143                    << " code=" << prm.code << std::endl; 
     144      } 
     145  }; 
     146 
     147  int main() 
     148  { 
     149      Endpoint ep; 
     150       
     151      ep.libCreate(); 
     152       
     153      // Initialize endpoint 
     154      EpConfig ep_cfg; 
     155      ep.libInit( ep_cfg ); 
     156       
     157      // Create SIP transport. Error handling sample is shown 
     158      TransportConfig tcfg; 
     159      tcfg.port = 5060; 
     160      try { 
     161          ep.transportCreate(PJSIP_TRANSPORT_UDP, tcfg); 
     162      } catch (Error &err) { 
     163          std::cout << err.info() << std::endl; 
     164          return 1; 
     165      } 
     166       
     167      // Start the library (worker threads etc) 
     168      ep.libStart(); 
     169      std::cout << "*** PJSUA2 STARTED ***" << std::endl; 
     170       
     171      // Configure an AccountConfig 
     172      AccountConfig acfg; 
     173      acfg.idUri = "sip:test@pjsip.org"; 
     174      acfg.regConfig.registrarUri = "sip:pjsip.org"; 
     175      AuthCredInfo cred("digest", "*", "test", 0, "secret"); 
     176      acfg.sipConfig.authCreds.push_back( cred ); 
     177       
     178      // Create the account 
     179      MyAccount *acc = new MyAccount; 
     180      acc->create(acfg); 
     181       
     182      // Here we don't have anything else to do.. 
     183      pj_thread_sleep(10000); 
     184       
     185      // Delete the account. This will unregister from server 
     186      delete acc; 
     187       
     188      // This will implicitly shutdown the library 
     189      return 0; 
     190  } 
     191 
     192 
     193Using in Python Application 
     194=========================== 
     195The equivalence of the C++ sample code above in Python is as follows: 
     196 
     197.. code-block:: python 
     198 
     199  # Subclass to extend the Account and get notifications etc. 
     200  class Account(pj.Account): 
     201    def onRegState(self, prm): 
     202        print "***OnRegState: " + prm.reason 
     203 
     204  # pjsua2 test function 
     205  def pjsua2_test(): 
     206    # Create and initialize the library 
     207    ep_cfg = pj.EpConfig() 
     208    ep = pj.Endpoint() 
     209    ep.libCreate() 
     210    ep.libInit(ep_cfg) 
     211     
     212    # Create SIP transport. Error handling sample is shown 
     213    sipTpConfig = pj.TransportConfig(); 
     214    sipTpConfig.port = 5060; 
     215    ep.transportCreate(pj.PJSIP_TRANSPORT_UDP, sipTpConfig); 
     216    # Start the library 
     217    ep.libStart(); 
     218     
     219    acfg = pj.AccountConfig(); 
     220    acfg.idUri = "sip:test@pjsip.org"; 
     221    acfg.regConfig.registrarUri = "sip:pjsip.org"; 
     222    cred = pj.AuthCredInfo("digest", "*", "test", 0, "pwtest"); 
     223    acfg.sipConfig.authCreds.append( cred ); 
     224    # Create the account 
     225    acc = Account(); 
     226    acc.create(acfg); 
     227    # Here we don't have anything else to do.. 
     228    time.sleep(10); 
     229 
     230    # Destroy the library 
     231    ep.libDestroy() 
     232 
     233  # 
     234  # main() 
     235  # 
     236  if __name__ == "__main__": 
     237    pjsua2_test() 
     238 
     239 
     240Using in Java Application 
     241========================= 
     242The equivalence of the C++ sample code above in Java is as follows: 
     243 
     244.. code-block:: java 
     245 
     246  import org.pjsip.pjsua2.*; 
     247 
     248  // Subclass to extend the Account and get notifications etc. 
     249  class MyAccount extends Account { 
     250    @Override 
     251    public void onRegState(OnRegStateParam prm) { 
     252        System.out.println("*** On registration state: " + prm.getCode() + prm.getReason()); 
     253    } 
     254  } 
     255 
     256  public class test { 
     257    static { 
     258        System.loadLibrary("pjsua2"); 
     259        System.out.println("Library loaded"); 
     260    } 
     261     
     262    public static void main(String argv[]) { 
     263        try { 
     264            // Create endpoint 
     265            Endpoint ep = new Endpoint(); 
     266            ep.libCreate(); 
     267            // Initialize endpoint 
     268            EpConfig epConfig = new EpConfig(); 
     269            ep.libInit( epConfig ); 
     270            // Create SIP transport. Error handling sample is shown 
     271            TransportConfig sipTpConfig = new TransportConfig(); 
     272            sipTpConfig.setPort(5060); 
     273            ep.transportCreate(pjsip_transport_type_e.PJSIP_TRANSPORT_UDP, sipTpConfig); 
     274            // Start the library 
     275            ep.libStart(); 
     276 
     277            AccountConfig acfg = new AccountConfig(); 
     278            acfg.setIdUri("sip:test@pjsip.org"); 
     279            acfg.getRegConfig().setRegistrarUri("sip:pjsip.org"); 
     280            AuthCredInfo cred = new AuthCredInfo("digest", "*", "test", 0, "secret"); 
     281            acfg.getSipConfig().getAuthCreds().add( cred ); 
     282            // Create the account 
     283            MyAccount acc = new MyAccount(); 
     284            acc.create(acfg); 
     285            // Here we don't have anything else to do.. 
     286            Thread.sleep(10000); 
     287            /* Explicitly delete the account. 
     288             * This is to avoid GC to delete the endpoint first before deleting 
     289             * the account. 
     290             */ 
     291            acc.delete(); 
     292             
     293            // Explicitly destroy and delete endpoint 
     294            ep.libDestroy(); 
     295            ep.delete(); 
     296             
     297        } catch (Exception e) { 
     298            System.out.println(e); 
     299            return; 
     300        } 
     301    } 
     302  } 
  • pjproject/trunk/doc/pjsip-book/reference.rst

    r4762 r4763  
     1 
    12 
    23PJSUA2 API Reference Manuals 
    34**************************** 
    45 
    5 Endpoint 
    6 ======== 
     6endpoint.hpp 
     7============= 
     8.. doxygenfile:: endpoint.hpp 
     9        :path: xml 
    710 
    8 Account 
    9 ======= 
     11account.hpp 
     12=========== 
     13.. doxygenfile:: account.hpp 
     14        :path: xml 
    1015 
    11 Media 
    12 ===== 
    1316 
    14 Call 
    15 ==== 
     17media.hpp 
     18========= 
     19.. doxygenfile:: media.hpp 
     20        :path: xml 
    1621 
    17 Buddy 
    18 ===== 
    1922 
     23call.hpp 
     24========= 
     25.. doxygenfile:: call.hpp 
     26        :path: xml 
     27 
     28 
     29presence.hpp 
     30============ 
     31.. doxygenfile:: presence.hpp 
     32        :path: xml 
     33 
     34persistent.hpp 
     35================ 
     36.. doxygenfile:: persistent.hpp 
     37        :path: xml 
     38 
     39json.hpp 
     40================ 
     41.. doxygenfile:: json.hpp 
     42        :path: xml 
     43 
     44siptypes.hpp 
     45================ 
     46.. doxygenfile:: siptypes.hpp 
     47        :path: xml 
     48 
     49types.hpp 
     50================ 
     51.. doxygenfile:: types.hpp 
     52        :path: xml 
     53 
     54config.hpp 
     55================ 
     56.. doxygenfile:: config.hpp 
     57        :path: xml 
     58 
Note: See TracChangeset for help on using the changeset viewer.