Changeset 2156 for pjproject/trunk/pjsip-apps/src/python/pjsua.py
- Timestamp:
- Jul 18, 2008 11:00:56 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/python/pjsua.py
r2122 r2156 148 148 Member documentation: 149 149 150 N ONE-- media is not available.150 NULL -- media is not available. 151 151 ACTIVE -- media is active. 152 152 LOCAL_HOLD -- media is put on-hold by local party. … … 154 154 ERROR -- media error (e.g. ICE negotiation failure). 155 155 """ 156 N ONE= 0156 NULL = 0 157 157 ACTIVE = 1 158 158 LOCAL_HOLD = 2 … … 166 166 Member documentation: 167 167 168 N ONE-- media is not active168 NULL -- media is not active 169 169 ENCODING -- media is active in transmit/encoding direction only. 170 170 DECODING -- media is active in receive/decoding direction only 171 171 ENCODING_DECODING -- media is active in both directions. 172 172 """ 173 N ONE= 0173 NULL = 0 174 174 ENCODING = 1 175 175 DECODING = 2 … … 189 189 AWAY = 1 190 190 BUSY = 2 191 192 193 class SubscriptionState: 194 """Presence subscription state constants. 195 196 """ 197 NULL = 0 198 SENT = 1 199 ACCEPTED = 2 200 PENDING = 3 201 ACTIVE = 4 202 TERMINATED = 5 203 UNKNOWN = 6 204 191 205 192 206 class TURNConnType: … … 862 876 reject the call with default status code. 863 877 864 Keyword arguments:865 call -- the new incoming call878 Keyword arguments: 879 call -- the new incoming call 866 880 """ 867 881 call.hangup() 882 883 def on_incoming_subscribe(self, buddy, from_uri, pres_obj): 884 """Notification when incoming SUBSCRIBE request is received. 885 886 Application may use this callback to authorize the incoming 887 subscribe request (e.g. ask user permission if the request 888 should be granted) 889 890 Keyword arguments: 891 buddy -- The buddy object, if buddy is found. Otherwise 892 the value is None. 893 from_uri -- The URI string of the sender. 894 pres_obj -- Opaque presence subscription object, which is 895 needed by Account.pres_notify() 896 897 Return: 898 Tuple (code, reason), where: 899 code: The status code. If code is >= 300, the 900 request is rejected. If code is 200, the 901 request is accepted and NOTIFY will be sent 902 automatically. If code is 202, application 903 must accept or reject the request later with 904 Account.press_notify(). 905 reason: Optional reason phrase, or None to use the 906 default reasoh phrase for the status code. 907 """ 908 return (200, None) 868 909 869 910 def on_pager(self, from_uri, contact, mime_type, body): … … 952 993 id -- the pjsua account ID. 953 994 """ 954 _cb = AccountCallback(self)995 self._cb = AccountCallback(self) 955 996 self._id = id 956 997 self._lib = lib … … 1102 1143 return Buddy(self._lib, buddy_id, self) 1103 1144 1145 def pres_notify(self, pres_obj, state, reason="", hdr_list=None): 1146 """Send NOTIFY to inform account presence status or to terminate 1147 server side presence subscription. 1148 1149 Keyword arguments: 1150 pres_obj -- The subscription object from on_incoming_subscribe() 1151 callback 1152 state -- Subscription state, from SubscriptionState 1153 reason -- Optional reason phrase. 1154 hdr_list -- Optional header list. 1155 """ 1156 _pjsua.acc_pres_notify(self._id, pres_obj, state, reason, 1157 Lib._create_msg_data(hdr_list)) 1104 1158 1105 1159 class CallCallback: … … 1276 1330 last_code = 0 1277 1331 last_reason = "" 1278 media_state = MediaState.N ONE1279 media_dir = MediaDir.N ONE1332 media_state = MediaState.NULL 1333 media_dir = MediaDir.NULL 1280 1334 conf_slot = -1 1281 1335 call_time = 0 … … 1530 1584 subscribed -- specify whether buddy's presence status is currently 1531 1585 being subscribed. 1586 sub_state -- SubscriptionState 1587 sub_term_reason -- The termination reason string of the last presence 1588 subscription to this buddy, if any. 1532 1589 """ 1533 1590 uri = "" … … 1537 1594 activity = PresenceActivity.UNKNOWN 1538 1595 subscribed = False 1596 sub_state = SubscriptionState.NULL 1597 sub_term_reason = "" 1539 1598 1540 1599 def __init__(self, pjsua_bi=None): … … 1549 1608 self.activity = inf.activity 1550 1609 self.subscribed = inf.monitor_pres 1610 self.sub_state = inf.sub_state 1611 self.sub_term_reason = inf.sub_term_reason 1551 1612 1552 1613 … … 1867 1928 py_ua_cfg.cb.on_call_replaced = _cb_on_call_replaced 1868 1929 py_ua_cfg.cb.on_reg_state = _cb_on_reg_state 1930 py_ua_cfg.cb.on_incoming_subscribe = _cb_on_incoming_subscribe 1869 1931 py_ua_cfg.cb.on_buddy_state = _cb_on_buddy_state 1870 1932 py_ua_cfg.cb.on_pager = _cb_on_pager … … 2267 2329 2268 2330 def _lookup_buddy(self, buddy_id, uri=None): 2269 print "lookup_buddy, id=", buddy_id2270 2331 buddy = self.buddy.has_key(buddy_id) and self.buddy[buddy_id] or None 2271 2332 if uri and not buddy: 2272 2333 sip_uri = SIPUri(uri) 2273 print "lookup_buddy, uri=", sip_uri.user, sip_uri.host2274 2334 buddy = self.buddy_by_uri.has_key( (sip_uri.user, sip_uri.host) ) \ 2275 2335 and self.buddy_by_uri[(sip_uri.user, sip_uri.host)] or \ … … 2289 2349 if acc: 2290 2350 acc._cb.on_reg_state() 2351 2352 def _cb_on_incoming_subscribe(self, acc_id, buddy_id, from_uri, pres_obj): 2353 acc = self._lookup_account(acc_id) 2354 if acc: 2355 buddy = self._lookup_buddy(buddy_id) 2356 return acc._cb.on_incoming_subscribe(buddy, from_uri, pres_obj) 2357 else: 2358 return (404, None) 2291 2359 2292 2360 def _cb_on_incoming_call(self, acc_id, call_id, rdata): … … 2425 2493 _lib._cb_on_reg_state(acc_id) 2426 2494 2495 def _cb_on_incoming_subscribe(acc_id, buddy_id, from_uri, pres): 2496 return _lib._cb_on_incoming_subscribe(acc_id, buddy_id, from_uri, pres) 2497 2427 2498 def _cb_on_buddy_state(buddy_id): 2428 2499 _lib._cb_on_buddy_state(buddy_id)
Note: See TracChangeset
for help on using the changeset viewer.