Changeset 4729 for pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_legacy.c
- Timestamp:
- Feb 4, 2014 1:13:02 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_legacy.c
r4724 r4729 1 1 /* $Id$ */ 2 /* 2 /* 3 3 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) 4 4 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> … … 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 48 48 continue; 49 49 50 printf(" [%2d] <%.*s> %.*s\n", 51 ids[i]+1, 50 printf(" [%2d] <%.*s> %.*s\n", 51 ids[i]+1, 52 52 (int)info.status_text.slen, 53 info.status_text.ptr, 53 info.status_text.ptr, 54 54 (int)info.uri.slen, 55 55 info.uri.ptr); … … 62 62 * Input URL. 63 63 */ 64 static void ui_input_url(const char *title, char *buf, pj_size_t len, 64 static void ui_input_url(const char *title, char *buf, pj_size_t len, 65 65 input_result *result) 66 66 { … … 98 98 99 99 if (pj_isdigit(*buf) || *buf=='-') { 100 100 101 101 unsigned i; 102 102 103 103 if (*buf=='-') 104 104 i = 1; … … 115 115 result->nb_result = my_atoi(buf); 116 116 117 if (result->nb_result >= 0 && 118 result->nb_result <= (int)pjsua_get_buddy_count()) 117 if (result->nb_result >= 0 && 118 result->nb_result <= (int)pjsua_get_buddy_count()) 119 119 { 120 120 return; … … 155 155 if (!*buf) 156 156 return PJ_FALSE; 157 157 158 158 return PJ_TRUE; 159 159 } … … 170 170 171 171 if (!info.has_registration) { 172 pj_ansi_snprintf(buf, sizeof(buf), "%.*s", 172 pj_ansi_snprintf(buf, sizeof(buf), "%.*s", 173 173 (int)info.status_text.slen, 174 174 info.status_text.ptr); … … 186 186 printf(" %c[%2d] %.*s: %s\n", (acc_id==current_acc?'*':' '), 187 187 acc_id, (int)info.acc_uri.slen, info.acc_uri.ptr, buf); 188 printf(" Online status: %.*s\n", 188 printf(" Online status: %.*s\n", 189 189 (int)info.online_status_text.slen, 190 190 info.online_status_text.ptr); … … 209 209 210 210 print_buddy_list(); 211 211 212 212 //puts("Commands:"); 213 213 puts("+=============================================================================+"); … … 386 386 PJSUA_CALL_VID_STRM_ADD, NULL); 387 387 } 388 else if (argc >= 3 && 388 else if (argc >= 3 && 389 389 (strcmp(argv[2], "disable")==0 || strcmp(argv[2], "enable")==0)) 390 390 { … … 514 514 vfd = pjmedia_format_get_video_format_detail(&cp.enc_fmt, 515 515 PJ_TRUE); 516 PJ_LOG(3,(THIS_FILE, "%.*s%.*s %3d %7.2f %4d/%4d %dx%d", 516 PJ_LOG(3,(THIS_FILE, "%.*s%.*s %3d %7.2f %4d/%4d %dx%d", 517 517 (int)ci[i].codec_id.slen, ci[i].codec_id.ptr, 518 518 13-(int)ci[i].codec_id.slen, " ", … … 591 591 /** UI Command **/ 592 592 static void ui_make_new_call() 593 { 593 { 594 594 char buf[128]; 595 595 pjsua_msg_data msg_data; … … 598 598 599 599 printf("(You currently have %d calls)\n", pjsua_call_get_count()); 600 600 601 601 ui_input_url("Make call", buf, sizeof(buf), &result); 602 602 if (result.nb_result != PJSUA_APP_NO_NB) { … … 620 620 pjsua_msg_data_init(&msg_data); 621 621 TEST_MULTIPART(&msg_data); 622 pjsua_call_make_call(current_acc, &tmp, &call_opt, NULL, 622 pjsua_call_make_call(current_acc, &tmp, &call_opt, NULL, 623 623 &msg_data, ¤t_call); 624 624 } … … 754 754 } 755 755 756 if (current_call == -1 || 756 if (current_call == -1 || 757 757 call_info.role != PJSIP_ROLE_UAS || 758 758 call_info.state >= PJSIP_INV_STATE_CONNECTING) … … 779 779 780 780 if (st_code/100 == 3) { 781 if (!simple_input("Enter URL to be put in Contact", 781 if (!simple_input("Enter URL to be put in Contact", 782 782 contact, sizeof(contact))) 783 783 return; … … 790 790 /* 791 791 * Must check again! 792 * Call may have been disconnected while we're waiting for 792 * Call may have been disconnected while we're waiting for 793 793 * keyboard input. 794 794 */ … … 800 800 801 801 pjsua_call_answer2(current_call, &call_opt, st_code, NULL, &msg_data); 802 } 802 } 803 803 } 804 804 … … 832 832 833 833 pjsua_call_get_info(current_call, &call_info); 834 PJ_LOG(3,(THIS_FILE,"Current dialog: %.*s", 835 (int)call_info.remote_info.slen, 834 PJ_LOG(3,(THIS_FILE,"Current dialog: %.*s", 835 (int)call_info.remote_info.slen, 836 836 call_info.remote_info.ptr)); 837 837 … … 912 912 acc_cfg.cred_info[0].data = pj_str(passwd); 913 913 914 acc_cfg.rtp_cfg = *rtp_cfg; 914 acc_cfg.rtp_cfg = *rtp_cfg; 915 915 app_config_init_video(&acc_cfg); 916 916 … … 959 959 static void ui_call_hold() 960 960 { 961 if (current_call != -1) { 961 if (current_call != -1) { 962 962 pjsua_call_set_hold(current_call, NULL); 963 963 } else { … … 974 974 static void ui_send_update() 975 975 { 976 if (current_call != -1) { 976 if (current_call != -1) { 977 977 pjsua_call_update2(current_call, &call_opt, NULL); 978 978 } else { … … 1037 1037 1038 1038 new_prio = atoi(prio); 1039 if (new_prio < 0) 1039 if (new_prio < 0) 1040 1040 new_prio = 0; 1041 else if (new_prio > PJMEDIA_CODEC_PRIO_HIGHEST) 1041 else if (new_prio > PJMEDIA_CODEC_PRIO_HIGHEST) 1042 1042 new_prio = PJMEDIA_CODEC_PRIO_HIGHEST; 1043 1043 1044 status = pjsua_codec_set_priority(pj_cstr(&id, codec), 1044 status = pjsua_codec_set_priority(pj_cstr(&id, codec), 1045 1045 (pj_uint8_t)new_prio); 1046 1046 #if PJSUA_HAS_VIDEO 1047 1047 if (status != PJ_SUCCESS) { 1048 status = pjsua_vid_codec_set_priority(pj_cstr(&id, codec), 1048 status = pjsua_vid_codec_set_priority(pj_cstr(&id, codec), 1049 1049 (pj_uint8_t)new_prio); 1050 1050 } … … 1106 1106 1107 1107 static void ui_call_transfer_replaces(pj_bool_t no_refersub) 1108 { 1108 { 1109 1109 if (current_call == -1) { 1110 1110 PJ_LOG(3,(THIS_FILE, "No current call")); … … 1179 1179 if (no_refersub) { 1180 1180 /* Add Refer-Sub: false in outgoing REFER request */ 1181 pjsip_generic_string_hdr_init2(&refer_sub, &STR_REFER_SUB, 1181 pjsip_generic_string_hdr_init2(&refer_sub, &STR_REFER_SUB, 1182 1182 &STR_FALSE); 1183 1183 pj_list_push_back(&msg_data.hdr_list, &refer_sub); 1184 1184 } 1185 1185 1186 pjsua_call_xfer_replaces(call, dst_call, 1187 PJSUA_XFER_NO_REQUIRE_REPLACES, 1186 pjsua_call_xfer_replaces(call, dst_call, 1187 PJSUA_XFER_NO_REQUIRE_REPLACES, 1188 1188 &msg_data); 1189 1189 } … … 1202 1202 char buf[128]; 1203 1203 1204 if (!simple_input("DTMF strings to send (0-9*#A-B)", buf, 1204 if (!simple_input("DTMF strings to send (0-9*#A-B)", buf, 1205 1205 sizeof(buf))) 1206 1206 { … … 1235 1235 char buf[128]; 1236 1236 1237 if (!simple_input("DTMF strings to send (0-9*#A-B)", buf, 1237 if (!simple_input("DTMF strings to send (0-9*#A-B)", buf, 1238 1238 sizeof(buf))) 1239 1239 { … … 1260 1260 msg_data.msg_body = pj_str(body); 1261 1261 1262 status = pjsua_call_send_request(current_call, &SIP_INFO, 1262 status = pjsua_call_send_request(current_call, &SIP_INFO, 1263 1263 &msg_data); 1264 1264 if (status != PJ_SUCCESS) { … … 1302 1302 return; 1303 1303 } 1304 } else { 1304 } else { 1305 1305 pjsua_buddy_info binfo; 1306 1306 pjsua_buddy_get_info(result.nb_result-1, &binfo); … … 1327 1327 pj_str_t method = pj_str(text); 1328 1328 pjsua_call_send_request(current_call, &method, NULL); 1329 } 1329 } 1330 1330 } 1331 1331 … … 1362 1362 delay = pj_strtoul(&tmp); 1363 1363 if (delay < 0) delay = 0; 1364 pj_thread_sleep(delay); 1364 pj_thread_sleep(delay); 1365 1365 } 1366 1366 } … … 1429 1429 pj_bool_t online_status; 1430 1430 pjrpid_element elem; 1431 int i, choice; 1431 int choice; 1432 unsigned i; 1432 1433 1433 1434 enum { … … 1450 1451 printf("\n" 1451 1452 "Choices:\n"); 1452 for (i=0; i< PJ_ARRAY_SIZE(opts); ++i) {1453 for (i=0; i<(unsigned)PJ_ARRAY_SIZE(opts); ++i) { 1453 1454 printf(" %d %s\n", opts[i].id+1, opts[i].name); 1454 1455 } … … 1525 1526 pj_ansi_strcat(txlist, s); 1526 1527 } 1527 printf("Port #%02d[%2dKHz/%dms/%d] %20.*s transmitting to: %s\n", 1528 info.slot_id, 1528 printf("Port #%02d[%2dKHz/%dms/%d] %20.*s transmitting to: %s\n", 1529 info.slot_id, 1529 1530 info.clock_rate/1000, 1530 1531 info.samples_per_frame*1000/info.channel_count/info.clock_rate, 1531 1532 info.channel_count, 1532 (int)info.name.slen, 1533 (int)info.name.slen, 1533 1534 info.name.ptr, 1534 1535 txlist); … … 1609 1610 PJ_LOG(1,(THIS_FILE, "Error: not enough buffer")); 1610 1611 else 1611 PJ_LOG(3,(THIS_FILE, "Dumping configuration (%d bytes):\n%s\n", 1612 len, settings)); 1612 PJ_LOG(3,(THIS_FILE, "Dumping configuration (%d bytes):\n%s\n", 1613 len, settings)); 1613 1614 } 1614 1615 … … 1655 1656 PJ_LOG(1,(THIS_FILE, "Call %d has gone", current_call)); 1656 1657 } else if (menuin[1] == 'a') { 1657 pjsua_call_process_redirect(current_call, 1658 pjsua_call_process_redirect(current_call, 1658 1659 PJSIP_REDIRECT_ACCEPT_REPLACE); 1659 1660 } else if (menuin[1] == 'A') { 1660 pjsua_call_process_redirect(current_call, 1661 pjsua_call_process_redirect(current_call, 1661 1662 PJSIP_REDIRECT_ACCEPT); 1662 1663 } else if (menuin[1] == 'r') { … … 1674 1675 */ 1675 1676 void legacy_main() 1676 { 1677 char menuin[80]; 1678 char buf[128]; 1677 { 1678 char menuin[80]; 1679 char buf[128]; 1679 1680 1680 1681 keystroke_help(); … … 1686 1687 1687 1688 if (fgets(menuin, sizeof(menuin), stdin) == NULL) { 1688 /* 1689 /* 1689 1690 * Be friendly to users who redirect commands into 1690 1691 * program, when file ends, resume with kbd. … … 1786 1787 break; 1787 1788 1788 case 'v': 1789 case 'v': 1789 1790 #if PJSUA_HAS_VIDEO 1790 1791 if (menuin[1]=='i' && menuin[2]=='d' && menuin[3]==' ') { … … 1869 1870 ui_register(menuin); 1870 1871 break; 1871 1872 1872 1873 case 't': 1873 1874 ui_toggle_state(); … … 1891 1892 1892 1893 case 'V': 1893 /* Adjust audio volume */ 1894 /* Adjust audio volume */ 1894 1895 ui_adjust_volume(); 1895 1896 break; … … 1897 1898 case 'd': 1898 1899 if (menuin[1] == 'c') { 1899 ui_dump_configuration(); 1900 ui_dump_configuration(); 1900 1901 } else if (menuin[1] == 'q') { 1901 1902 ui_dump_call_quality(); 1902 } else { 1903 } else { 1903 1904 ui_app_dump(menuin[1]=='d'); 1904 1905 } … … 1907 1908 case 'f': 1908 1909 if (simple_input("Enter output filename", buf, sizeof(buf))) { 1909 ui_write_settings(); 1910 ui_write_settings(); 1910 1911 } 1911 1912 break; … … 1916 1917 goto on_exit; 1917 1918 1918 case 'R': 1919 case 'R': 1919 1920 ui_call_redirect(menuin); 1920 1921 break;
Note: See TracChangeset
for help on using the changeset viewer.