Changeset 2170


Ignore:
Timestamp:
Jul 24, 2008 9:00:28 AM (16 years ago)
Author:
bennylp
Message:

pjsua.py: fixed transport port bug, changed default tracing to disabled, and removed documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/python/pjsua.py

    r2165 r2170  
    44# 
    55# Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> 
     6# 
     7# This program is free software; you can redistribute it and/or modify 
     8# it under the terms of the GNU General Public License as published by 
     9# the Free Software Foundation; either version 2 of the License, or 
     10# (at your option) any later version. 
     11# 
     12# This program is distributed in the hope that it will be useful, 
     13# but WITHOUT ANY WARRANTY; without even the implied warranty of 
     14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     15# GNU General Public License for more details. 
     16# 
     17# You should have received a copy of the GNU General Public License 
     18# along with this program; if not, write to the Free Software 
     19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
    620# 
    721 
     
    4155tutorial. The paragraphs below explain basic tasks on using this module. 
    4256 
    43  
    44 2.1 Initialization 
    45  
    46 Instantiate Lib class. This class is a singleton class, there can only be 
    47 one instance of this class in the program. 
    48  
    49 Initialize the library with lib.init() method, and optionally specify various 
    50 settings like UAConfig, MediaConfig, and LogConfig. 
    51  
    52 Create one or more SIP Transport instances. 
    53  
    54 Create one or more SIP Account's instances, as explained below. 
    55  
    56 Once initialization is complete, call lib.start(). 
    57  
    58  
    59 2.2 Accounts 
    60  
    61 At least one Account must be created in the program. Use Lib's create_account() 
    62 or create_account_for_transport() to create the account instance. 
    63  
    64 Account may emit events, and to capture these events, application must derive 
    65 a class from AccountCallback class, and install the callback to the Account 
    66 instance using set_callback() method. 
    67  
    68  
    69 2.3 Calls 
    70  
    71 Calls are represented with Call class. Use the Call methods to operate the 
    72 call. Outgoing calls are made with make_call() method of Account class.  
    73 Incoming calls are reported by on_incoming_call() callback of AccountCallback  
    74 class. 
    75  
    76 Call may emit events, and to capture these events, application must derive 
    77 a class from CallCallback class, and install the callback to the Call instance 
    78 using set_callback() method. 
    79  
    80 Note that just like every other operations in this module, the make_call()  
    81 method is non-blocking (i.e. it doesn't wait until the call is established  
    82 before the function returns). Progress to the Call is reported via CallCallback 
    83 class above. 
    84  
    85  
    86 2.4 Media 
    87  
    88 Every objects that can transmit or receive media/audio (e.g. calls, WAV player, 
    89 WAV recorder, WAV playlist) are connected to a central conference bridge. 
    90 Application can use the object's method or Lib's method to retrieve the slot 
    91 number of that particular object in the conference bridge: 
    92   - to retrieve the slot number of a call, use Call.info().conf_slot 
    93   - to retrieve the slot number of a WAV player, use Lib.player_get_slot() 
    94   - to retrieve the slot number of a WAV recorder, use Lib.recorder_get_slot() 
    95   - to retrieve the slot number of a playlist, use Lib.playlist_get_slot() 
    96   - the slot number zero is used to identity the sound device. 
    97  
    98 The conference bridge provides powerful switching and mixing functionality 
    99 for application. With the conference bridge, each conference slot (e.g.  
    100 a call) can transmit to multiple destinations, and one destination can 
    101 receive from multiple sources. If more than one media terminations are  
    102 terminated in the same slot, the conference bridge will mix the signal  
    103 automatically. 
    104  
    105 Application connects one media termination/slot to another by calling 
    106 lib.conf_connect() method. This will establish unidirectional media flow from  
    107 the source termination to the sink termination. To establish bidirectional  
    108 media flow, application would need to make another call to lib/conf_connect(),  
    109 this time inverting the source and destination slots in the parameter. 
    110  
    111  
    112 2.5 Presence  
    113  
    114 To subscribe to presence information of a buddy, add Buddy object with 
    115 add_buddy() method of Account class. Subsequent presence information for that 
    116 Buddy will be reported via BuddyCallback class (which application should 
    117 device and install to the Buddy object). 
    118  
    119 Each Account has presence status associated with it, which will be informed 
    120 to remote buddies when they subscribe to our presence information. Incoming 
    121 presence subscription request by default will be accepted automatically, 
    122 unless on_incoming_subscribe() method of AccountCallback is implemented. 
    123  
    124  
    125 2.6 Instant Messaging 
    126  
    127 Use Buddy's send_pager() and send_typing_ind() to send instant message and 
    128 typing indication to the specified buddy. 
    129  
    130 Incoming instant messages and typing indications will be reported via one of  
    131 the three mechanisms below. 
    132  
    133 If the instant message or typing indication is received in the context of an 
    134 active call, then it will be reported via on_pager() or on_typing() method 
    135 of CallCallback class. 
    136  
    137 If the instant message or typing indication is received outside any call  
    138 contexts, and it is received from a registered buddy, then it will be reported 
    139 via on_pager() or on_typing() method of BuddyCallback class. 
    140  
    141 If the criterias above are not met, the instant message or typing indication 
    142 will be reported via on_pager() or on_typing() method of the AccountCallback  
    143 class. 
    144  
    145 The delivery status of outgoing instant messages are reported via  
    146 on_pager_status() method of CallCallback, BuddyCallback, or AccountCallback, 
    147 depending on whether the instant message was sent using Call, Buddy, or 
    148 Account's send_pager() method. 
    14957 
    15058""" 
     
    572480    public_addr = "" 
    573481 
    574     def __init__(self, port=5060,  
     482    def __init__(self, port=0,  
    575483                 bound_addr="", public_addr=""): 
    576484        self.port = port 
     
    20992007# PJSUA Library 
    21002008_lib = None 
     2009enable_trace = False 
     2010 
    21012011class Lib: 
    21022012    """Library instance. 
     
    22332143        """ 
    22342144        lck = self.auto_lock() 
    2235         if not cfg: cfg=TransportConfig(type) 
     2145        if not cfg: cfg=TransportConfig() 
    22362146        err, tp_id = _pjsua.transport_create(type, cfg._cvt_to_pjsua()) 
    22372147        self._err_check("create_transport()", self, err) 
     
    28692779 
    28702780def _Trace(args): 
    2871     if True: 
     2781    global enable_trace 
     2782    if enable_trace: 
    28722783        print "** ", 
    28732784        for arg in args: 
Note: See TracChangeset for help on using the changeset viewer.