Changeset 2163 for pjproject/trunk/pjsip-apps/src/python/samples/call.py
- Timestamp:
- Jul 21, 2008 6:20:57 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/python/samples/call.py
r2119 r2163 1 # $Id :$1 # $Id$ 2 2 # 3 3 # SIP call sample. … … 19 19 class MyAccountCallback(pj.AccountCallback): 20 20 21 def __init__(self, account ):21 def __init__(self, account=None): 22 22 pj.AccountCallback.__init__(self, account) 23 23 … … 25 25 def on_incoming_call(self, call): 26 26 global current_call 27 28 27 if current_call: 29 28 call.answer(486, "Busy") … … 44 43 class MyCallCallback(pj.CallCallback): 45 44 46 def __init__(self, call ):45 def __init__(self, call=None): 47 46 pj.CallCallback.__init__(self, call) 48 47 … … 50 49 def on_state(self): 51 50 global current_call 52 53 51 print "Call with", self.call.info().remote_uri, 54 52 print "is", self.call.info().state_text, … … 58 56 if self.call.info().state == pj.CallState.DISCONNECTED: 59 57 current_call = None 58 print 'Current call is', current_call 60 59 61 60 # Notification when call's media state has changed. … … 74 73 try: 75 74 print "Making call to", uri 76 call = acc.make_call(uri) 77 call_cb = MyCallCallback(call) 78 call.set_callback(call_cb) 79 return call 75 return acc.make_call(uri, cb=MyCallCallback()) 80 76 except pj.Error, e: 81 print "E rror: " + str(e)77 print "Exception: " + str(e) 82 78 return None 83 79 … … 101 97 102 98 # Create local account 103 acc = lib.create_account_for_transport(transport) 104 acc_cb = MyAccountCallback(acc) 105 acc.set_callback(acc_cb) 99 acc = lib.create_account_for_transport(transport, cb=MyAccountCallback()) 106 100 107 101 # If argument is specified then make call to the URI 108 102 if len(sys.argv) > 1: 103 lck = lib.auto_lock() 109 104 current_call = make_call(sys.argv[1]) 105 print 'Current call is', current_call 106 del lck 110 107 111 108 my_sip_uri = "sip:" + transport.info().host + \ … … 126 123 if input == "": 127 124 continue 125 lck = lib.auto_lock() 128 126 current_call = make_call(input) 127 del lck 129 128 130 129 elif input == "h": … … 144 143 145 144 # Shutdown the library 145 transport = None 146 acc.delete() 147 acc = None 146 148 lib.destroy() 147 149 lib = None
Note: See TracChangeset
for help on using the changeset viewer.