Changeset 2170 for pjproject/trunk/pjsip-apps/src/python/pjsua.py
- Timestamp:
- Jul 24, 2008 9:00:28 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/python/pjsua.py
r2165 r2170 4 4 # 5 5 # 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 6 20 # 7 21 … … 41 55 tutorial. The paragraphs below explain basic tasks on using this module. 42 56 43 44 2.1 Initialization45 46 Instantiate Lib class. This class is a singleton class, there can only be47 one instance of this class in the program.48 49 Initialize the library with lib.init() method, and optionally specify various50 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 Accounts60 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 derive65 a class from AccountCallback class, and install the callback to the Account66 instance using set_callback() method.67 68 69 2.3 Calls70 71 Calls are represented with Call class. Use the Call methods to operate the72 call. Outgoing calls are made with make_call() method of Account class.73 Incoming calls are reported by on_incoming_call() callback of AccountCallback74 class.75 76 Call may emit events, and to capture these events, application must derive77 a class from CallCallback class, and install the callback to the Call instance78 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 established82 before the function returns). Progress to the Call is reported via CallCallback83 class above.84 85 86 2.4 Media87 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 slot91 number of that particular object in the conference bridge:92 - to retrieve the slot number of a call, use Call.info().conf_slot93 - 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 functionality99 for application. With the conference bridge, each conference slot (e.g.100 a call) can transmit to multiple destinations, and one destination can101 receive from multiple sources. If more than one media terminations are102 terminated in the same slot, the conference bridge will mix the signal103 automatically.104 105 Application connects one media termination/slot to another by calling106 lib.conf_connect() method. This will establish unidirectional media flow from107 the source termination to the sink termination. To establish bidirectional108 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 Presence113 114 To subscribe to presence information of a buddy, add Buddy object with115 add_buddy() method of Account class. Subsequent presence information for that116 Buddy will be reported via BuddyCallback class (which application should117 device and install to the Buddy object).118 119 Each Account has presence status associated with it, which will be informed120 to remote buddies when they subscribe to our presence information. Incoming121 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 Messaging126 127 Use Buddy's send_pager() and send_typing_ind() to send instant message and128 typing indication to the specified buddy.129 130 Incoming instant messages and typing indications will be reported via one of131 the three mechanisms below.132 133 If the instant message or typing indication is received in the context of an134 active call, then it will be reported via on_pager() or on_typing() method135 of CallCallback class.136 137 If the instant message or typing indication is received outside any call138 contexts, and it is received from a registered buddy, then it will be reported139 via on_pager() or on_typing() method of BuddyCallback class.140 141 If the criterias above are not met, the instant message or typing indication142 will be reported via on_pager() or on_typing() method of the AccountCallback143 class.144 145 The delivery status of outgoing instant messages are reported via146 on_pager_status() method of CallCallback, BuddyCallback, or AccountCallback,147 depending on whether the instant message was sent using Call, Buddy, or148 Account's send_pager() method.149 57 150 58 """ … … 572 480 public_addr = "" 573 481 574 def __init__(self, port= 5060,482 def __init__(self, port=0, 575 483 bound_addr="", public_addr=""): 576 484 self.port = port … … 2099 2007 # PJSUA Library 2100 2008 _lib = None 2009 enable_trace = False 2010 2101 2011 class Lib: 2102 2012 """Library instance. … … 2233 2143 """ 2234 2144 lck = self.auto_lock() 2235 if not cfg: cfg=TransportConfig( type)2145 if not cfg: cfg=TransportConfig() 2236 2146 err, tp_id = _pjsua.transport_create(type, cfg._cvt_to_pjsua()) 2237 2147 self._err_check("create_transport()", self, err) … … 2869 2779 2870 2780 def _Trace(args): 2871 if True: 2781 global enable_trace 2782 if enable_trace: 2872 2783 print "** ", 2873 2784 for arg in args:
Note: See TracChangeset
for help on using the changeset viewer.