Changeset 972 for pjproject/trunk/pjsip-apps/src/py_pjsua/pjsua_app.py
- Timestamp:
- Feb 18, 2007 11:49:14 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/py_pjsua/pjsua_app.py
r934 r972 37 37 g_rec_port = 0 38 38 39 # Utility: display PJ error and exit 40 # 41 def err_exit(title, rc): 42 py_pjsua.perror(THIS_FILE, title, rc) 43 exit(1) 44 45 46 # Logging function (also callback, called by pjsua-lib) 47 # 48 def log_cb(level, str, len): 49 if level <= C_LOG_LEVEL: 50 print str, 51 52 def write_log(level, str): 53 log_cb(level, str + "\n", 0) 54 55 39 56 # Utility to get call info 40 57 # … … 85 102 def on_reg_state(acc_id): 86 103 acc_info = py_pjsua.acc_get_info(acc_id) 104 if acc_info.has_registration != 0: 105 cmd = "registration" 106 else: 107 cmd = "unregistration" 87 108 if acc_info.status != 0 and acc_info.status != 200: 88 write_log(3, "Account (un)registrationfailed: rc=" + `acc_info.status` + " " + acc_info.status_text)89 else: 90 write_log(3, "Account successfully (un)registered")109 write_log(3, "Account " + cmd + " failed: rc=" + `acc_info.status` + " " + acc_info.status_text) 110 else: 111 write_log(3, "Account " + cmd + " success") 91 112 92 113 … … 123 144 write_log(3, "IM indication: " + strfrom + " " + str_t) 124 145 125 # on call transfer status146 # Received the status of previous call transfer request 126 147 # 127 148 def on_call_transfer_status(call_id,status_code,status_text,final,p_cont): … … 137 158 p_cont = 0 138 159 139 # oncall transfer request160 # Callback on incoming call transfer request 140 161 # 141 162 def on_call_transfer_request(call_id, dst, code): 142 163 write_log(3, "Call transfer request from " + `call_id` + " to " + dst + " with code " + `code`) 143 144 # Utility: display PJ error and exit145 #146 def err_exit(title, rc):147 py_pjsua.perror(THIS_FILE, title, rc)148 exit(1)149 150 151 # Logging function (also callback, called by pjsua-lib)152 #153 def log_cb(level, str, len):154 if level <= C_LOG_LEVEL:155 print str,156 157 def write_log(level, str):158 log_cb(level, str + "\n", 0)159 160 164 161 165 # … … 330 334 331 335 def conf_list(): 332 333 334 336 ports = None 335 336 337 print "Conference ports : " 337 338 339 338 ports = py_pjsua.enum_conf_ports() 340 339 … … 401 400 else: 402 401 write_log(3, "No current call") 403 402 404 403 def xfer_call(): 405 404 global g_current_call … … 507 506 508 507 508 # Print account and buddy list 509 def print_acc_buddy_list(): 510 global g_acc_id 511 512 acc_ids = py_pjsua.enum_accs() 513 print "Account list:" 514 for acc_id in acc_ids: 515 acc_info = py_pjsua.acc_get_info(acc_id) 516 if acc_info.has_registration == 0: 517 acc_status = acc_info.status_text 518 else: 519 acc_status = `acc_info.status` + "/" + acc_info.status_text + " (expires=" + `acc_info.expires` + ")" 520 521 if acc_id == g_acc_id: 522 print " *", 523 else: 524 print " ", 525 526 print "[" + `acc_id` + "] " + acc_info.acc_uri + ": " + acc_status 527 print " Presence status: ", 528 if acc_info.online_status != 0: 529 print "Online" 530 else: 531 print "Invisible" 532 533 if py_pjsua.get_buddy_count() > 0: 534 print "" 535 print "Buddy list:" 536 buddy_ids = py_pjsua.enum_buddies() 537 for buddy_id in buddy_ids: 538 bi = py_pjsua.buddy_get_info(buddy_id) 539 print " [" + `buddy_id` + "] " + bi.status_text + " " + bi.uri 540 541 509 542 # Print application menu 510 543 # 511 544 def print_menu(): 545 print "" 546 print ">>>" 547 print_acc_buddy_list() 512 548 print """ 513 549 +============================================================================+ … … 525 561 | X Xfer with Replaces | | | 526 562 | | cl List ports | d Dump status | 527 | | cc Connect port | 563 | | cc Connect port | dd Dump detail | 528 564 | | cd Disconnect port | | 529 565 | | +p Add file player | | 530 566 |------------------------------+ +r Add file recorder | | 531 567 | q Quit application | | | 532 +============================================================================+ 533 """534 print " Choice:",568 +============================================================================+""" 569 print "You have " + `py_pjsua.call_get_count()` + " active call(s)" 570 print ">>>", 535 571 536 572 # Menu … … 592 628 continue 593 629 630 bc.uri = bc.uri.replace("\n", "") 594 631 bc.subscribe = 1 595 632 status, buddy_id = py_pjsua.buddy_add(bc) … … 714 751 py_pjsua.acc_set_registration(g_acc_id, 0) 715 752 elif choice[0] == "d": 716 717 write_log(3, "Start dumping application states : ") 718 write_log(3, "Dumping invite sessions : ") 719 720 if py_pjsua.call_get_count() == 0: 721 write_log(3, " - no sessions -") 722 else: 723 for i in range(0, g_ua_cfg.max_calls): 724 if py_pjsua.call_is_active(i): 725 buf = py_pjsua.call_dump(i, 1, 1024, " ") 726 write_log(3, buf) 727 py_pjsua.pres_dump(1) 728 write_log(3, "Dump complete") 753 py_pjsua.dump(choice[1] == "d") 729 754 elif choice[0] == "a": 730 755 if g_current_call != py_pjsua.PJSUA_INVALID_ID:
Note: See TracChangeset
for help on using the changeset viewer.