Changes between Version 11 and Version 12 of Python_SIP_Tutorial


Ignore:
Timestamp:
Jul 22, 2008 7:04:47 PM (16 years ago)
Author:
bennylp
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Python_SIP_Tutorial

    v11 v12  
    11= PJSUA Python Module = 
    22 
     3[[TracNav(Python_SIP_TOC)]] 
     4 
    35The PJSUA for Python Module is an object oriented Python wrapper/abstraction for [http://www.pjsip.org/pjsip/docs/html/group__PJSUA__LIB.htm PJSUA API]. It provides high level API for constructing SIP multimedia user agent applications. It wraps together the signaling, media, and NAT traversal functionality into an easy to use call control API, account management, buddy list management, presence, instant messaging, along with multimedia features such as local conferencing, file streaming, local playback, and voice recording, and powerful NAT traversal techniques utilizing STUN, TURN, and ICE. 
    4  
    5 [[TracNav(Python_SIP_TOC)]] 
    66 
    77 
     
    4747== Developing Python SIP Application == #develop 
    4848 
    49 == Introduction == 
    50  
    51 The pjsua module only contains few classes so it should be straightforward to use. 
    52  
    53 == Error Handling == 
    54  
    55 By convention, we use exceptions as means to report error. Operations which yields error will raise [http://www.pjsip.org/python/pjsua.htm#Error pjsua.Error] exception. 
     49=== Concepts === #concepts 
     50 
     51==== Asynchronous Operations ==== 
     52 
     53If you have developed applications with PJSIP you'll know about this already, but this concept probably needs to be explained a little bit here to new PJSIP users. 
     54 
     55In PJSIP, all operations that involve sending and receiving SIP messages are asynchronous, meaning that the function that invokes the operation will complete immediately, and you will be given the completion status as callbacks. Take a look for example the {{{make_call()}}} method of the [http://www.pjsip.org/python/pjsua.htm#Account Account] class. This function is used to initiate outgoing call to a destination. When this function returns successfully, it does not mean that the call has been established, but rather that the call has been '''initiated''' successfully. You will be given the report of the call completion (such as ''Ringing'' or ''Connected''/''Confirmed''' events) in the {{{on_state()}}} callback of [http://www.pjsip.org/python/pjsua.htm#CallCallback CallCallback] class. 
     56 
     57 
     58==== Basic Usage Pattern ==== 
     59 
     60Ah, talking about callbacks. 
     61 
     62 
     63 
     64==== Error Handling ==== 
     65 
     66By convention, we use exceptions as means to report error, as this would make the program flows more naturally. Operations which yield error will raise [http://www.pjsip.org/python/pjsua.htm#Error pjsua.Error] exception. Here is a sample: 
     67 
     68 {{{ 
     69#!python 
     70import pjsua 
     71 
     72try: 
     73    call = acc.make_call('sip:buddy@example.org') 
     74except pjsua.Error, err: 
     75    print 'Exception has occured:', err 
     76except: 
     77    print 'Ouch..' 
     78 }}} 
     79 
     80The sample above will print the full error information to stdout. If you prefer to display the error in more structured manner, the [http://www.pjsip.org/python/pjsua.htm#Error pjsua.Error] class has several members to explain the error, such as the object name that raised the error, the operation name, and the error message itself. 
     81 
     82 
    5683 
    5784