Changeset 4729
- Timestamp:
- Feb 4, 2014 1:13:02 PM (11 years ago)
- Location:
- pjproject/trunk/pjsip-apps/src/pjsua
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_cli.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 … … 156 156 void cli_destroy(); 157 157 158 PJ_DEF(void) cli_get_info(char *info, pj_size_t size) 158 PJ_DEF(void) cli_get_info(char *info, pj_size_t size) 159 159 { 160 160 pj_cli_telnet_info telnet_info; … … 162 162 163 163 pj_ansi_snprintf(info, size, "Telnet to %.*s:%d", 164 (int)telnet_info.ip_address.slen, 165 telnet_info.ip_address.ptr, 164 (int)telnet_info.ip_address.slen, 165 telnet_info.ip_address.ptr, 166 166 telnet_info.port); 167 167 } … … 221 221 if (app_config.cli_cfg.cli_fe & CLI_FE_CONSOLE) { 222 222 pj_cli_console_cfg *fe_cfg = &app_config.cli_cfg.console_cfg; 223 223 224 224 fe_cfg->quit_command = pj_str("shutdown"); 225 225 status = pj_cli_console_create(cli, fe_cfg, … … 262 262 { 263 263 /* Destroy CLI, it will automatically destroy any FEs */ 264 if (cli) { 264 if (cli) { 265 265 pj_cli_destroy(cli); 266 266 cli = NULL; … … 281 281 282 282 /* Get input URL */ 283 static void get_input_url(char *buf, 283 static void get_input_url(char *buf, 284 284 pj_size_t len, 285 285 pj_cli_cmd_val *cval, … … 316 316 for (; i<len; ++i) { 317 317 if (!pj_isdigit(buf[i])) { 318 pj_cli_sess_write_msg(cval->sess, err_invalid_input.ptr, 318 pj_cli_sess_write_msg(cval->sess, err_invalid_input.ptr, 319 319 (int)err_invalid_input.slen); 320 320 return; … … 324 324 result->nb_result = my_atoi(buf); 325 325 326 if (result->nb_result >= 0 && 327 result->nb_result <= (int)pjsua_get_buddy_count()) 326 if (result->nb_result >= 0 && 327 result->nb_result <= (int)pjsua_get_buddy_count()) 328 328 { 329 329 return; … … 332 332 return; 333 333 334 pj_cli_sess_write_msg(cval->sess, err_invalid_input.ptr, 334 pj_cli_sess_write_msg(cval->sess, err_invalid_input.ptr, 335 335 (int)err_invalid_input.slen); 336 336 result->nb_result = PJSUA_APP_NO_NB; … … 353 353 static void get_buddy_id(pj_cli_dyn_choice_param *param) 354 354 { 355 if (param->cnt < param->max_cnt) { 355 if (param->cnt < param->max_cnt) { 356 356 pjsua_buddy_id ids[64]; 357 357 int i = 0; … … 360 360 361 361 pjsua_enum_buddies(ids, &count); 362 362 363 363 if (count > 0) { 364 364 for (i=0; i<(int)count; ++i) { … … 372 372 pj_strdup2(param->pool, ¶m->choice[i].value, data_out); 373 373 pj_bzero(data_out, PJ_ARRAY_SIZE(data_out)); 374 374 375 375 /* Format & fill description */ 376 pj_ansi_snprintf(data_out, 376 pj_ansi_snprintf(data_out, 377 377 sizeof(data_out), 378 "<%.*s> %.*s", 378 "<%.*s> %.*s", 379 379 (int)info.status_text.slen, 380 info.status_text.ptr, 380 info.status_text.ptr, 381 381 (int)info.uri.slen, 382 382 info.uri.ptr); 383 383 384 pj_strdup2(param->pool, ¶m->choice[i].desc, data_out); 384 pj_strdup2(param->pool, ¶m->choice[i].desc, data_out); 385 385 if (++param->cnt >= (param->max_cnt-1)) 386 break; 386 break; 387 387 } 388 388 } … … 400 400 static void get_account_id(pj_cli_dyn_choice_param *param) 401 401 { 402 if (param->cnt < param->max_cnt) { 402 if (param->cnt < param->max_cnt) { 403 403 char buf[8]; 404 404 char buf_out[80]; … … 407 407 pjsua_acc_id acc_ids[16]; 408 408 unsigned count = PJ_ARRAY_SIZE(acc_ids); 409 int i; 409 int i; 410 410 411 411 pjsua_enum_accs(acc_ids, &count); 412 413 for (i=0; i<(int)count; ++i) { 412 413 for (i=0; i<(int)count; ++i) { 414 414 pj_bzero(&buf_out[0], PJ_ARRAY_SIZE(buf_out)); 415 415 416 416 pjsua_acc_get_info(acc_ids[i], &info); 417 417 418 pj_ansi_snprintf(buf_out, 418 pj_ansi_snprintf(buf_out, 419 419 sizeof(buf_out), 420 "%c%.*s", 420 "%c%.*s", 421 421 (acc_ids[i]==current_acc?'*':' '), 422 (int)info.acc_uri.slen, 422 (int)info.acc_uri.slen, 423 423 info.acc_uri.ptr); 424 424 … … 428 428 pj_strdup2(param->pool, ¶m->choice[i].desc, buf_out); 429 429 if (++param->cnt >= param->max_cnt) 430 break; 430 break; 431 431 } 432 432 } … … 450 450 pjsua_conf_get_port_info(id[i], &info); 451 451 452 pj_ansi_snprintf(slot_id, sizeof(slot_id), 452 pj_ansi_snprintf(slot_id, sizeof(slot_id), 453 453 "%d", info.slot_id); 454 454 pj_strdup2(param->pool, ¶m->choice[i].value, slot_id); … … 459 459 pj_ansi_snprintf(s, sizeof(s), "#%d ", info.listeners[j]); 460 460 pj_ansi_strcat(txlist, s); 461 } 462 463 pj_ansi_snprintf(desc, 461 } 462 463 pj_ansi_snprintf(desc, 464 464 sizeof(desc), 465 "[%2dKHz/%dms/%d] %20.*s transmitting to: %s", 465 "[%2dKHz/%dms/%d] %20.*s transmitting to: %s", 466 466 info.clock_rate/1000, 467 467 info.samples_per_frame*1000/info.channel_count/info.clock_rate, 468 468 info.channel_count, 469 (int)info.name.slen, 469 (int)info.name.slen, 470 470 info.name.ptr, 471 471 txlist); 472 472 473 pj_strdup2(param->pool, ¶m->choice[i].desc, desc); 473 pj_strdup2(param->pool, ¶m->choice[i].desc, desc); 474 474 if (++param->cnt >= param->max_cnt) 475 break; 475 break; 476 476 } 477 477 } … … 479 479 static void get_audio_codec_id(pj_cli_dyn_choice_param *param) 480 480 { 481 if (param->cnt < param->max_cnt) { 481 if (param->cnt < param->max_cnt) { 482 482 pjsua_codec_info c[32]; 483 483 unsigned i, count = PJ_ARRAY_SIZE(c); 484 484 char codec_id[64]; 485 485 char desc[128]; 486 486 487 487 pjsua_enum_codecs(c, &count); 488 for (i=0; i<count; ++i) { 489 pj_ansi_snprintf(codec_id, sizeof(codec_id), 490 "%.*s", (int)c[i].codec_id.slen, 488 for (i=0; i<count; ++i) { 489 pj_ansi_snprintf(codec_id, sizeof(codec_id), 490 "%.*s", (int)c[i].codec_id.slen, 491 491 c[i].codec_id.ptr); 492 492 493 493 pj_strdup2(param->pool, ¶m->choice[param->cnt].value, codec_id); 494 494 495 pj_ansi_snprintf(desc, sizeof(desc), 496 "Audio, prio: %d%s%.*s", 497 c[i].priority, 495 pj_ansi_snprintf(desc, sizeof(desc), 496 "Audio, prio: %d%s%.*s", 497 c[i].priority, 498 498 c[i].desc.slen? " - ":"", 499 499 (int)c[i].desc.slen, … … 502 502 pj_strdup2(param->pool, ¶m->choice[param->cnt].desc, desc); 503 503 if (++param->cnt >= param->max_cnt) 504 break; 505 } 506 } 507 } 508 509 #if PJSUA_HAS_VIDEO 504 break; 505 } 506 } 507 } 508 509 #if PJSUA_HAS_VIDEO 510 510 static void get_video_stream_id(pj_cli_dyn_choice_param *param) 511 511 { 512 if (param->cnt < param->max_cnt) { 512 if (param->cnt < param->max_cnt) { 513 513 pjsua_call_info call_info; 514 514 … … 519 519 if (call_info.media[i].type == PJMEDIA_TYPE_VIDEO) { 520 520 char med_idx[8]; 521 pj_ansi_snprintf(med_idx, sizeof(med_idx), "%d", 521 pj_ansi_snprintf(med_idx, sizeof(med_idx), "%d", 522 522 call_info.media[i].index); 523 523 pj_strdup2(param->pool, ¶m->choice[i].value, med_idx); 524 524 525 switch (call_info.media[i].status) { 525 switch (call_info.media[i].status) { 526 526 case PJSUA_CALL_MEDIA_NONE: 527 pj_strdup2(param->pool, ¶m->choice[i].desc, 527 pj_strdup2(param->pool, ¶m->choice[i].desc, 528 528 "Status:None"); 529 529 break; 530 530 case PJSUA_CALL_MEDIA_ACTIVE: 531 pj_strdup2(param->pool, ¶m->choice[i].desc, 531 pj_strdup2(param->pool, ¶m->choice[i].desc, 532 532 "Status:Active"); 533 533 break; 534 534 case PJSUA_CALL_MEDIA_LOCAL_HOLD: 535 pj_strdup2(param->pool, ¶m->choice[i].desc, 535 pj_strdup2(param->pool, ¶m->choice[i].desc, 536 536 "Status:Local Hold"); 537 537 break; 538 538 case PJSUA_CALL_MEDIA_REMOTE_HOLD: 539 pj_strdup2(param->pool, ¶m->choice[i].desc, 539 pj_strdup2(param->pool, ¶m->choice[i].desc, 540 540 "Status:Remote Hold"); 541 541 break; 542 542 case PJSUA_CALL_MEDIA_ERROR: 543 pj_strdup2(param->pool, ¶m->choice[i].desc, 543 pj_strdup2(param->pool, ¶m->choice[i].desc, 544 544 "Status:Media Error"); 545 545 break; 546 546 } 547 547 if (++param->cnt >= param->max_cnt) 548 break; 548 break; 549 549 } 550 550 } … … 552 552 } 553 553 } 554 555 static void get_video_dev_hint(pj_cli_dyn_choice_param *param, 554 555 static void get_video_dev_hint(pj_cli_dyn_choice_param *param, 556 556 pjmedia_vid_dev_info *vdi, 557 unsigned vid_dev_id) 557 unsigned vid_dev_id) 558 558 { 559 559 char desc[128]; … … 561 561 pj_ansi_snprintf(dev_id, sizeof(dev_id), 562 562 "%d", vid_dev_id); 563 pj_ansi_snprintf(desc, sizeof(desc), "%s [%s]", 563 pj_ansi_snprintf(desc, sizeof(desc), "%s [%s]", 564 564 vdi->name, vdi->driver); 565 565 566 pj_strdup2(param->pool, ¶m->choice[param->cnt].value, 566 pj_strdup2(param->pool, ¶m->choice[param->cnt].value, 567 567 dev_id); 568 pj_strdup2(param->pool, ¶m->choice[param->cnt].desc, 569 desc); 570 } 571 572 static void get_video_dev_id(pj_cli_dyn_choice_param *param, 568 pj_strdup2(param->pool, ¶m->choice[param->cnt].desc, 569 desc); 570 } 571 572 static void get_video_dev_id(pj_cli_dyn_choice_param *param, 573 573 pj_bool_t all, 574 574 pj_bool_t capture) 575 575 { 576 if (param->cnt < param->max_cnt) { 576 if (param->cnt < param->max_cnt) { 577 577 unsigned i, count; 578 578 pjmedia_vid_dev_info vdi; … … 580 580 581 581 count = pjsua_vid_dev_count(); 582 if (count == 0) { 582 if (count == 0) { 583 583 return; 584 } 584 } 585 585 586 586 for (i=0; i<count; ++i) { … … 590 590 ((capture) && (vdi.dir == PJMEDIA_DIR_CAPTURE)) || 591 591 ((!capture) && (vdi.dir == PJMEDIA_DIR_RENDER))) 592 { 592 { 593 593 get_video_dev_hint(param, &vdi, i); 594 594 if (++param->cnt >= param->max_cnt) 595 break; 596 } 595 break; 596 } 597 597 } 598 598 } … … 601 601 602 602 static void get_video_codec_id(pj_cli_dyn_choice_param *param) 603 { 604 if (param->cnt < param->max_cnt) { 603 { 604 if (param->cnt < param->max_cnt) { 605 605 pjsua_codec_info ci[32]; 606 606 unsigned i, count = PJ_ARRAY_SIZE(ci); … … 620 620 vfd = pjmedia_format_get_video_format_detail(&cp.enc_fmt, PJ_TRUE); 621 621 622 pj_ansi_snprintf(codec_id, sizeof(codec_id), 623 "%.*s", (int)ci[i].codec_id.slen, 622 pj_ansi_snprintf(codec_id, sizeof(codec_id), 623 "%.*s", (int)ci[i].codec_id.slen, 624 624 ci[i].codec_id.ptr); 625 625 626 626 pj_strdup2(param->pool, ¶m->choice[param->cnt].value, codec_id); 627 627 628 pj_ansi_snprintf(desc, sizeof(desc), 629 "Video, p[%d], f[%.2f], b[%d/%d], s[%dx%d]", 630 ci[i].priority, 628 pj_ansi_snprintf(desc, sizeof(desc), 629 "Video, p[%d], f[%.2f], b[%d/%d], s[%dx%d]", 630 ci[i].priority, 631 631 (vfd->fps.num*1.0/vfd->fps.denum), 632 632 vfd->avg_bps/1000, vfd->max_bps/1000, 633 633 vfd->size.w, vfd->size.h); 634 634 635 pj_strdup2(param->pool, ¶m->choice[param->cnt].desc, desc); 635 pj_strdup2(param->pool, ¶m->choice[param->cnt].desc, desc); 636 636 if (++param->cnt >= param->max_cnt) 637 break; 637 break; 638 638 } 639 639 } … … 642 642 static void get_video_window_id(pj_cli_dyn_choice_param *param) 643 643 { 644 if (param->cnt < param->max_cnt) { 644 if (param->cnt < param->max_cnt) { 645 645 pjsua_vid_win_id wids[PJSUA_MAX_VID_WINS]; 646 646 unsigned i, cnt = PJ_ARRAY_SIZE(wids); … … 657 657 pj_strdup2(param->pool, ¶m->choice[i].value, win_id); 658 658 659 pj_ansi_snprintf(desc, sizeof(desc), 660 "Show:%c Pos(%d,%d) Size(%dx%d)", 659 pj_ansi_snprintf(desc, sizeof(desc), 660 "Show:%c Pos(%d,%d) Size(%dx%d)", 661 661 (wi.show?'Y':'N'), wi.pos.x, wi.pos.y, 662 662 wi.size.w, wi.size.h); 663 663 664 pj_strdup2(param->pool, ¶m->choice[i].desc, desc); 664 pj_strdup2(param->pool, ¶m->choice[i].desc, desc); 665 665 if (++param->cnt >= param->max_cnt) 666 break; 666 break; 667 667 } 668 668 } … … 671 671 static void get_call_id(pj_cli_dyn_choice_param *param) 672 672 { 673 if (param->cnt < param->max_cnt) { 673 if (param->cnt < param->max_cnt) { 674 674 char call_id[64]; 675 675 char desc[128]; … … 691 691 pj_ansi_snprintf(call_id, sizeof(call_id), "%d", ids[i]); 692 692 pj_strdup2(param->pool, ¶m->choice[i].value, call_id); 693 pj_ansi_snprintf(desc, sizeof(desc), "%.*s [%.*s]", 693 pj_ansi_snprintf(desc, sizeof(desc), "%.*s [%.*s]", 694 694 (int)call_info.remote_info.slen, 695 695 call_info.remote_info.ptr, … … 698 698 pj_strdup2(param->pool, ¶m->choice[i].desc, desc); 699 699 if (++param->cnt >= param->max_cnt) 700 break; 700 break; 701 701 702 702 } … … 723 723 get_audio_codec_id(param); 724 724 break; 725 #if PJSUA_HAS_VIDEO 726 case DYN_CHOICE_CAP_DEV_ID: 725 #if PJSUA_HAS_VIDEO 726 case DYN_CHOICE_CAP_DEV_ID: 727 727 case DYN_CHOICE_REN_DEV_ID: 728 728 case DYN_CHOICE_VID_DEV_ID: 729 get_video_dev_id(param, 729 get_video_dev_id(param, 730 730 (param->arg_id==DYN_CHOICE_VID_DEV_ID), 731 731 (param->arg_id==DYN_CHOICE_CAP_DEV_ID)); … … 750 750 } 751 751 752 /* 752 /* 753 753 * CLI command handler 754 754 */ … … 777 777 pjsua_perror(THIS_FILE, "Error adding new account", status); 778 778 } 779 779 780 780 return status; 781 781 } … … 790 790 791 791 if (!pjsua_acc_is_valid(i)) { 792 pj_ansi_snprintf(out_str, sizeof(out_str), 792 pj_ansi_snprintf(out_str, sizeof(out_str), 793 793 "Invalid account id %d\n", i); 794 794 str_len = (unsigned)pj_ansi_strlen(out_str); … … 813 813 /* Register account */ 814 814 static pj_status_t cmd_reg_account() 815 { 815 { 816 816 pjsua_acc_set_registration(current_acc, PJ_TRUE); 817 817 return PJ_SUCCESS; … … 820 820 /* Unregister account */ 821 821 static pj_status_t cmd_unreg_account() 822 { 822 { 823 823 pjsua_acc_set_registration(current_acc, PJ_FALSE); 824 824 return PJ_SUCCESS; … … 834 834 } else { 835 835 PJ_LOG(3,(THIS_FILE, "Invalid account id %d", i)); 836 } 836 } 837 837 return PJ_SUCCESS; 838 838 } … … 844 844 unsigned count = PJ_ARRAY_SIZE(acc_ids); 845 845 int i; 846 static const pj_str_t header = {"Account list:\n", 15}; 846 static const pj_str_t header = {"Account list:\n", 15}; 847 847 848 848 pjsua_enum_accs(acc_ids, &count); … … 857 857 858 858 if (!info.has_registration) { 859 pj_ansi_snprintf(acc_info, sizeof(acc_info), "%.*s", 859 pj_ansi_snprintf(acc_info, sizeof(acc_info), "%.*s", 860 860 (int)info.status_text.slen, 861 861 info.status_text.ptr); … … 871 871 } 872 872 873 pj_ansi_snprintf(out_str, sizeof(out_str), 874 " %c[%2d] %.*s: %s\n", 875 (acc_ids[i]==current_acc?'*':' '), acc_ids[i], 876 (int)info.acc_uri.slen, info.acc_uri.ptr, 873 pj_ansi_snprintf(out_str, sizeof(out_str), 874 " %c[%2d] %.*s: %s\n", 875 (acc_ids[i]==current_acc?'*':' '), acc_ids[i], 876 (int)info.acc_uri.slen, info.acc_uri.ptr, 877 877 acc_info); 878 878 pj_cli_sess_write_msg(cval->sess, out_str, pj_ansi_strlen(out_str)); … … 880 880 pj_bzero(out_str, sizeof(out_str)); 881 881 pj_ansi_snprintf(out_str, sizeof(out_str), 882 " Online status: %.*s\n", 882 " Online status: %.*s\n", 883 883 (int)info.online_status_text.slen, 884 884 info.online_status_text.ptr); … … 892 892 /* Account command handler */ 893 893 pj_status_t cmd_account_handler(pj_cli_cmd_val *cval) 894 { 894 { 895 895 pj_status_t status = PJ_SUCCESS; 896 896 … … 913 913 status = cmd_unreg_account(); 914 914 break; 915 case CMD_ACCOUNT_NEXT: 915 case CMD_ACCOUNT_NEXT: 916 916 case CMD_ACCOUNT_PREV: 917 status = cmd_next_account(cval); 917 status = cmd_next_account(cval); 918 918 break; 919 919 case CMD_ACCOUNT_SHOW: 920 920 status = cmd_show_account(cval); 921 921 break; 922 } 922 } 923 923 return status; 924 924 } … … 926 926 /* Add buddy */ 927 927 static pj_status_t cmd_add_buddy(pj_cli_cmd_val *cval) 928 { 928 { 929 929 char out_str[80]; 930 930 pjsua_buddy_config buddy_cfg; … … 934 934 935 935 if (pjsua_verify_url(cval->argv[1].ptr) != PJ_SUCCESS) { 936 pj_ansi_snprintf(out_str, sizeof(out_str), 936 pj_ansi_snprintf(out_str, sizeof(out_str), 937 937 "Invalid URI '%s'\n", cval->argv[1].ptr); 938 938 } else { … … 944 944 status = pjsua_buddy_add(&buddy_cfg, &buddy_id); 945 945 if (status == PJ_SUCCESS) { 946 pj_ansi_snprintf(out_str, sizeof(out_str), 946 pj_ansi_snprintf(out_str, sizeof(out_str), 947 947 "New buddy '%s' added at index %d\n", 948 948 cval->argv[1].ptr, buddy_id+1); 949 } 949 } 950 950 } 951 951 pj_cli_sess_write_msg(cval->sess, out_str, pj_ansi_strlen(out_str)); … … 955 955 /* Delete buddy */ 956 956 static pj_status_t cmd_del_buddy(pj_cli_cmd_val *cval) 957 { 957 { 958 958 int i = my_atoi(cval->argv[1].ptr) - 1; 959 959 char out_str[80]; 960 960 961 961 if (!pjsua_buddy_is_valid(i)) { 962 pj_ansi_snprintf(out_str, sizeof(out_str), 963 "Invalid buddy id %d\n", i); 962 pj_ansi_snprintf(out_str, sizeof(out_str), 963 "Invalid buddy id %d\n", i); 964 964 } else { 965 965 pjsua_buddy_del(i); 966 pj_ansi_snprintf(out_str, sizeof(out_str), 967 "Buddy %d deleted\n", i); 966 pj_ansi_snprintf(out_str, sizeof(out_str), 967 "Buddy %d deleted\n", i); 968 968 } 969 969 pj_cli_sess_write_msg(cval->sess, out_str, pj_ansi_strlen(out_str)); … … 973 973 /* Send IM */ 974 974 static pj_status_t cmd_send_im(pj_cli_cmd_val *cval) 975 { 976 int i = -1; 975 { 976 int i = -1; 977 977 struct input_result result; 978 978 char dest[64]; 979 pj_str_t tmp = pj_str(dest); 979 pj_str_t tmp = pj_str(dest); 980 980 981 981 /* make compiler happy. */ … … 983 983 984 984 pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(dest)); 985 985 986 986 /* input destination. */ 987 987 get_input_url(tmp.ptr, tmp.slen, cval, &result); 988 988 if (result.nb_result != PJSUA_APP_NO_NB) { 989 989 990 if (result.nb_result == -1) { 990 if (result.nb_result == -1) { 991 991 static const pj_str_t err_msg = {"you can't send broadcast im " 992 "like that!\n", 40 }; 992 "like that!\n", 40 }; 993 993 pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen); 994 994 return PJ_SUCCESS; … … 997 997 } else { 998 998 pjsua_buddy_info binfo; 999 pjsua_buddy_get_info(result.nb_result-1, &binfo); 999 pjsua_buddy_get_info(result.nb_result-1, &binfo); 1000 1000 pj_strncpy_with_null(&tmp, &binfo.uri, sizeof(dest)); 1001 1001 uri = tmp.ptr; … … 1026 1026 /* Subscribe/unsubscribe presence */ 1027 1027 static pj_status_t cmd_subs_pres(pj_cli_cmd_val *cval, pj_bool_t subscribe) 1028 { 1029 struct input_result result; 1028 { 1029 struct input_result result; 1030 1030 char dest[64] = {0}; 1031 1031 pj_str_t tmp = pj_str(dest); 1032 1032 1033 1033 pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(dest)); 1034 get_input_url(tmp.ptr, tmp.slen, cval, &result); 1034 get_input_url(tmp.ptr, tmp.slen, cval, &result); 1035 1035 if (result.nb_result != PJSUA_APP_NO_NB) { 1036 1036 if (result.nb_result == -1) { … … 1059 1059 /* Toggle online state */ 1060 1060 static pj_status_t cmd_toggle_state(pj_cli_cmd_val *cval) 1061 { 1061 { 1062 1062 char out_str[128]; 1063 1063 pjsua_acc_info acc_info; … … 1066 1066 acc_info.online_status = !acc_info.online_status; 1067 1067 pjsua_acc_set_online_status(current_acc, acc_info.online_status); 1068 pj_ansi_snprintf(out_str, sizeof(out_str), 1068 pj_ansi_snprintf(out_str, sizeof(out_str), 1069 1069 "Setting %s online status to %s\n", 1070 1070 acc_info.acc_uri.ptr, … … 1076 1076 /* Set presence text */ 1077 1077 static pj_status_t cmd_set_presence_text(pj_cli_cmd_val *cval) 1078 { 1078 { 1079 1079 pjrpid_element elem; 1080 1080 int choice; … … 1125 1125 /* Show buddy list */ 1126 1126 static pj_status_t cmd_show_buddy(pj_cli_cmd_val *cval) 1127 { 1127 { 1128 1128 pjsua_buddy_id ids[64]; 1129 1129 int i; 1130 1130 unsigned count = PJ_ARRAY_SIZE(ids); 1131 static const pj_str_t header = {"Buddy list:\n", 13}; 1131 static const pj_str_t header = {"Buddy list:\n", 13}; 1132 1132 char out_str[64]; 1133 1133 … … 1140 1140 pj_cli_sess_write_msg(cval->sess, out_str, pj_ansi_strlen(out_str)); 1141 1141 } else { 1142 for (i=0; i<(int)count; ++i) { 1142 for (i=0; i<(int)count; ++i) { 1143 1143 pjsua_buddy_info info; 1144 1144 pj_bzero(out_str, sizeof(out_str)); … … 1147 1147 continue; 1148 1148 1149 pj_ansi_snprintf(out_str, sizeof(out_str), 1150 " [%2d] <%.*s> %.*s\n", 1151 ids[i]+1, 1149 pj_ansi_snprintf(out_str, sizeof(out_str), 1150 " [%2d] <%.*s> %.*s\n", 1151 ids[i]+1, 1152 1152 (int)info.status_text.slen, 1153 info.status_text.ptr, 1153 info.status_text.ptr, 1154 1154 (int)info.uri.slen, 1155 1155 info.uri.ptr); … … 1157 1157 pj_cli_sess_write_msg(cval->sess, out_str, pj_ansi_strlen(out_str)); 1158 1158 } 1159 } 1159 } 1160 1160 return PJ_SUCCESS; 1161 1161 } … … 1163 1163 /* Presence/buddy command handler */ 1164 1164 pj_status_t cmd_presence_handler(pj_cli_cmd_val *cval) 1165 { 1165 { 1166 1166 pj_status_t status = PJ_SUCCESS; 1167 1167 … … 1178 1178 status = cmd_send_im(cval); 1179 1179 break; 1180 case CMD_PRESENCE_SUB: 1180 case CMD_PRESENCE_SUB: 1181 1181 case CMD_PRESENCE_UNSUB: 1182 status = cmd_subs_pres(cval, 1183 pj_cli_get_cmd_id(cval->cmd)==CMD_PRESENCE_SUB); 1182 status = cmd_subs_pres(cval, 1183 pj_cli_get_cmd_id(cval->cmd)==CMD_PRESENCE_SUB); 1184 1184 break; 1185 1185 case CMD_PRESENCE_TOG_STATE: … … 1192 1192 status = cmd_show_buddy(cval); 1193 1193 break; 1194 } 1194 } 1195 1195 1196 1196 return status; … … 1204 1204 static const pj_str_t header = {"Conference ports:\n", 19}; 1205 1205 1206 pj_cli_sess_write_msg(cval->sess, header.ptr, header.slen); 1206 pj_cli_sess_write_msg(cval->sess, header.ptr, header.slen); 1207 1207 1208 1208 count = PJ_ARRAY_SIZE(id); … … 1223 1223 pj_ansi_strcat(txlist, s); 1224 1224 } 1225 pj_ansi_snprintf(out_str, 1225 pj_ansi_snprintf(out_str, 1226 1226 sizeof(out_str), 1227 "Port #%02d[%2dKHz/%dms/%d] %20.*s transmitting to: %s\n", 1228 info.slot_id, 1227 "Port #%02d[%2dKHz/%dms/%d] %20.*s transmitting to: %s\n", 1228 info.slot_id, 1229 1229 info.clock_rate/1000, 1230 1230 info.samples_per_frame*1000/info.channel_count/info.clock_rate, 1231 1231 info.channel_count, 1232 (int)info.name.slen, 1232 (int)info.name.slen, 1233 1233 info.name.ptr, 1234 1234 txlist); 1235 pj_cli_sess_write_msg(cval->sess, out_str, pj_ansi_strlen(out_str)); 1236 } 1235 pj_cli_sess_write_msg(cval->sess, out_str, pj_ansi_strlen(out_str)); 1236 } 1237 1237 return PJ_SUCCESS; 1238 1238 } … … 1242 1242 { 1243 1243 pj_status_t status; 1244 1244 1245 1245 if (connect) 1246 status = pjsua_conf_connect(pj_strtol(&cval->argv[1]), 1246 status = pjsua_conf_connect(pj_strtol(&cval->argv[1]), 1247 1247 pj_strtol(&cval->argv[2])); 1248 1248 else 1249 status = pjsua_conf_disconnect(pj_strtol(&cval->argv[1]), 1249 status = pjsua_conf_disconnect(pj_strtol(&cval->argv[1]), 1250 1250 pj_strtol(&cval->argv[2])); 1251 1251 1252 1252 if (status == PJ_SUCCESS) { 1253 1253 static const pj_str_t success_msg = {"Success\n", 9}; 1254 pj_cli_sess_write_msg(cval->sess, success_msg.ptr, success_msg.slen); 1254 pj_cli_sess_write_msg(cval->sess, success_msg.ptr, success_msg.slen); 1255 1255 } else { 1256 1256 static const pj_str_t err_msg = {"ERROR!!\n", 9}; … … 1270 1270 1271 1271 /* Adjust mic level */ 1272 orig_level = app_config.mic_level; 1272 orig_level = app_config.mic_level; 1273 1273 pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(level_val)); 1274 1274 app_config.mic_level = (float)strtod(level_val, &err); … … 1276 1276 1277 1277 pj_ansi_snprintf(buf, sizeof(buf), 1278 "Adjust mic level: [%4.1fx] -> [%4.1fx]\n", 1278 "Adjust mic level: [%4.1fx] -> [%4.1fx]\n", 1279 1279 orig_level, app_config.mic_level); 1280 1280 … … 1282 1282 1283 1283 /* Adjust speaker level */ 1284 orig_level = app_config.speaker_level; 1284 orig_level = app_config.speaker_level; 1285 1285 pj_strncpy_with_null(&tmp, &cval->argv[2], sizeof(level_val)); 1286 1286 app_config.speaker_level = (float)strtod(level_val, &err); … … 1288 1288 1289 1289 pj_ansi_snprintf(buf, sizeof(buf), 1290 "Adjust speaker level: [%4.1fx] -> [%4.1fx]\n", 1290 "Adjust speaker level: [%4.1fx] -> [%4.1fx]\n", 1291 1291 orig_level, app_config.speaker_level); 1292 1292 … … 1298 1298 /* Set codec priority */ 1299 1299 static pj_status_t cmd_set_codec_prio(pj_cli_cmd_val *cval) 1300 { 1301 int new_prio; 1302 pj_status_t status; 1300 { 1301 int new_prio; 1302 pj_status_t status; 1303 1303 1304 1304 new_prio = pj_strtol(&cval->argv[2]); 1305 if (new_prio < 0) 1305 if (new_prio < 0) 1306 1306 new_prio = 0; 1307 else if (new_prio > PJMEDIA_CODEC_PRIO_HIGHEST) 1307 else if (new_prio > PJMEDIA_CODEC_PRIO_HIGHEST) 1308 1308 new_prio = PJMEDIA_CODEC_PRIO_HIGHEST; 1309 1309 1310 status = pjsua_codec_set_priority(&cval->argv[1], 1310 status = pjsua_codec_set_priority(&cval->argv[1], 1311 1311 (pj_uint8_t)new_prio); 1312 1312 #if PJSUA_HAS_VIDEO 1313 1313 if (status != PJ_SUCCESS) { 1314 status = pjsua_vid_codec_set_priority(&cval->argv[1], 1314 status = pjsua_vid_codec_set_priority(&cval->argv[1], 1315 1315 (pj_uint8_t)new_prio); 1316 1316 } … … 1335 1335 case CMD_MEDIA_CONF_CONNECT: 1336 1336 case CMD_MEDIA_CONF_DISCONNECT: 1337 status = cmd_media_connect(cval, 1338 pj_cli_get_cmd_id(cval->cmd)==CMD_MEDIA_CONF_CONNECT); 1339 break; 1340 case CMD_MEDIA_ADJUST_VOL: 1337 status = cmd_media_connect(cval, 1338 pj_cli_get_cmd_id(cval->cmd)==CMD_MEDIA_CONF_CONNECT); 1339 break; 1340 case CMD_MEDIA_ADJUST_VOL: 1341 1341 status = cmd_adjust_vol(cval); 1342 1342 break; 1343 1343 case CMD_MEDIA_CODEC_PRIO: 1344 status = cmd_set_codec_prio(cval); 1344 status = cmd_set_codec_prio(cval); 1345 1345 break; 1346 1346 case CMD_MEDIA_SPEAKER_TOGGLE: … … 1369 1369 } 1370 1370 break; 1371 } 1371 } 1372 1372 1373 1373 return status; … … 1390 1390 PJ_LOG(1,(THIS_FILE, "Error: not enough buffer")); 1391 1391 else 1392 PJ_LOG(3,(THIS_FILE, 1392 PJ_LOG(3,(THIS_FILE, 1393 1393 "Dumping configuration (%d bytes):\n%s\n", 1394 1394 len, settings)); … … 1404 1404 pj_str_t tmp = pj_str(buf); 1405 1405 1406 pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(buf)); 1406 pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(buf)); 1407 1407 1408 1408 len = write_settings(&app_config, settings, sizeof(settings)); … … 1447 1447 break; 1448 1448 case CMD_CONFIG_DUMP_CONF: 1449 status = cmd_show_config(); 1450 break; 1451 case CMD_CONFIG_WRITE_SETTING: 1449 status = cmd_show_config(); 1450 break; 1451 case CMD_CONFIG_WRITE_SETTING: 1452 1452 status = cmd_write_config(cval); 1453 1453 break; 1454 } 1454 } 1455 1455 1456 1456 return status; … … 1463 1463 char dest[64] = {0}; 1464 1464 char out_str[128]; 1465 pj_str_t tmp = pj_str(dest); 1466 1467 pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(dest)); 1468 1469 pj_ansi_snprintf(out_str, 1470 sizeof(out_str), 1465 pj_str_t tmp = pj_str(dest); 1466 1467 pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(dest)); 1468 1469 pj_ansi_snprintf(out_str, 1470 sizeof(out_str), 1471 1471 "(You currently have %d calls)\n", 1472 1472 pjsua_call_get_count()); 1473 1473 1474 1474 pj_cli_sess_write_msg(cval->sess, out_str, pj_ansi_strlen(out_str)); 1475 1475 1476 1476 /* input destination. */ 1477 get_input_url(tmp.ptr, tmp.slen, cval, &result); 1477 get_input_url(tmp.ptr, tmp.slen, cval, &result); 1478 1478 if (result.nb_result != PJSUA_APP_NO_NB) { 1479 1479 pjsua_buddy_info binfo; 1480 1480 if (result.nb_result == -1 || result.nb_result == 0) { 1481 static const pj_str_t err_msg = 1481 static const pj_str_t err_msg = 1482 1482 {"You can't do that with make call!\n", 35}; 1483 1483 pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen); 1484 1484 return PJ_SUCCESS; 1485 } 1486 pjsua_buddy_get_info(result.nb_result-1, &binfo); 1485 } 1486 pjsua_buddy_get_info(result.nb_result-1, &binfo); 1487 1487 pj_strncpy(&tmp, &binfo.uri, sizeof(dest)); 1488 1488 } else if (result.uri_result) { … … 1494 1494 pjsua_msg_data_init(&msg_data); 1495 1495 TEST_MULTIPART(&msg_data); 1496 pjsua_call_make_call(current_acc, &tmp, &call_opt, NULL, 1496 pjsua_call_make_call(current_acc, &tmp, &call_opt, NULL, 1497 1497 &msg_data, ¤t_call); 1498 1498 return PJ_SUCCESS; … … 1503 1503 { 1504 1504 struct input_result result; 1505 char dest[64] = {0}; 1505 char dest[64] = {0}; 1506 1506 char out_str[128]; 1507 1507 int i, count; 1508 1508 pj_str_t tmp = pj_str(dest); 1509 1509 1510 pj_ansi_snprintf(out_str, 1511 sizeof(out_str), 1510 pj_ansi_snprintf(out_str, 1511 sizeof(out_str), 1512 1512 "(You currently have %d calls)\n", 1513 1513 pjsua_call_get_count()); 1514 1514 1515 1515 count = pj_strtol(&cval->argv[1]); 1516 1516 if (count < 1) 1517 1517 return PJ_SUCCESS; 1518 1518 1519 1519 pj_strncpy_with_null(&tmp, &cval->argv[2], sizeof(dest)); 1520 1520 1521 1521 /* input destination. */ 1522 get_input_url(tmp.ptr, tmp.slen, cval, &result); 1522 get_input_url(tmp.ptr, tmp.slen, cval, &result); 1523 1523 if (result.nb_result != PJSUA_APP_NO_NB) { 1524 1524 pjsua_buddy_info binfo; 1525 1525 if (result.nb_result == -1 || result.nb_result == 0) { 1526 static const pj_str_t err_msg = 1526 static const pj_str_t err_msg = 1527 1527 {"You can't do that with make call!\n", 35}; 1528 1528 pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen); 1529 1529 return PJ_SUCCESS; 1530 } 1531 pjsua_buddy_get_info(result.nb_result-1, &binfo); 1532 pj_strncpy(&tmp, &binfo.uri, sizeof(dest)); 1530 } 1531 pjsua_buddy_get_info(result.nb_result-1, &binfo); 1532 pj_strncpy(&tmp, &binfo.uri, sizeof(dest)); 1533 1533 } else { 1534 1534 tmp = pj_str(result.uri_result); 1535 } 1535 } 1536 1536 1537 1537 for (i=0; i<count; ++i) { … … 1559 1559 } 1560 1560 1561 if (current_call == PJSUA_INVALID_ID || 1561 if (current_call == PJSUA_INVALID_ID || 1562 1562 call_info.role != PJSIP_ROLE_UAS || 1563 1563 call_info.state >= PJSIP_INV_STATE_CONNECTING) 1564 { 1565 static const pj_str_t err_msg = {"No pending incoming call\n", 26}; 1564 { 1565 static const pj_str_t err_msg = {"No pending incoming call\n", 26}; 1566 1566 pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen); 1567 1567 … … 1570 1570 char contact[120]; 1571 1571 pj_str_t hname = { "Contact", 7 }; 1572 pj_str_t hvalue; 1573 pjsip_generic_string_hdr hcontact; 1572 pj_str_t hvalue; 1573 pjsip_generic_string_hdr hcontact; 1574 1574 1575 1575 st_code = pj_strtol(&cval->argv[1]); … … 1583 1583 static const pj_str_t err_msg = {"Enter URL to be put " 1584 1584 "in Contact\n", 32}; 1585 pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen); 1585 pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen); 1586 1586 return PJ_SUCCESS; 1587 1587 } … … 1595 1595 /* 1596 1596 * Must check again! 1597 * Call may have been disconnected while we're waiting for 1597 * Call may have been disconnected while we're waiting for 1598 1598 * keyboard input. 1599 1599 */ 1600 1600 if (current_call == PJSUA_INVALID_ID) { 1601 static const pj_str_t err_msg = {"Call has been disconnected\n", 1602 28}; 1601 static const pj_str_t err_msg = {"Call has been disconnected\n", 1602 28}; 1603 1603 pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen); 1604 1604 } … … 1617 1617 } else { 1618 1618 if (all) 1619 pjsua_call_hangup_all(); 1619 pjsua_call_hangup_all(); 1620 1620 else 1621 1621 pjsua_call_hangup(current_call, 0, NULL, NULL); … … 1627 1627 static pj_status_t cmd_hold_call() 1628 1628 { 1629 if (current_call != PJSUA_INVALID_ID) { 1629 if (current_call != PJSUA_INVALID_ID) { 1630 1630 pjsua_call_set_hold(current_call, NULL); 1631 1631 … … 1675 1675 } 1676 1676 1677 if (current_call != PJSUA_INVALID_ID) { 1677 if (current_call != PJSUA_INVALID_ID) { 1678 1678 pjsua_call_info call_info; 1679 1679 1680 1680 pjsua_call_get_info(current_call, &call_info); 1681 PJ_LOG(3,(THIS_FILE,"Current dialog: %.*s", 1682 (int)call_info.remote_info.slen, 1681 PJ_LOG(3,(THIS_FILE,"Current dialog: %.*s", 1682 (int)call_info.remote_info.slen, 1683 1683 call_info.remote_info.ptr)); 1684 1684 … … 1706 1706 pj_str_t STR_FALSE = { "false", 5 }; 1707 1707 pjsua_call_info ci; 1708 1709 pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(dest)); 1708 1709 pj_strncpy_with_null(&tmp, &cval->argv[1], sizeof(dest)); 1710 1710 1711 1711 pjsua_call_get_info(current_call, &ci); 1712 pj_ansi_snprintf(out_str, 1713 sizeof(out_str), 1712 pj_ansi_snprintf(out_str, 1713 sizeof(out_str), 1714 1714 "Transferring current call [%d] %.*s\n", 1715 1715 current_call, 1716 (int)ci.remote_info.slen, 1716 (int)ci.remote_info.slen, 1717 1717 ci.remote_info.ptr); 1718 1718 … … 1749 1749 pjsua_call_xfer( current_call, &tmp, &msg_data); 1750 1750 } 1751 } 1751 } 1752 1752 return PJ_SUCCESS; 1753 1753 } … … 1755 1755 /* Transfer call */ 1756 1756 static pj_status_t cmd_transfer_replace_call(pj_cli_cmd_val *cval) 1757 { 1757 { 1758 1758 if (current_call == -1) { 1759 1759 PJ_LOG(3,(THIS_FILE, "No current call")); … … 1764 1764 pj_str_t STR_REFER_SUB = { "Refer-Sub", 9 }; 1765 1765 pj_str_t STR_FALSE = { "false", 5 }; 1766 pjsua_call_id ids[PJSUA_MAX_CALLS]; 1766 pjsua_call_id ids[PJSUA_MAX_CALLS]; 1767 1767 pjsua_msg_data msg_data; 1768 char buf[8] = {0}; 1768 char buf[8] = {0}; 1769 1769 pj_str_t tmp = pj_str(buf); 1770 unsigned count; 1771 static const pj_str_t err_invalid_num = 1770 unsigned count; 1771 static const pj_str_t err_invalid_num = 1772 1772 {"Invalid destination call number\n", 32 }; 1773 1773 count = PJ_ARRAY_SIZE(ids); 1774 1774 pjsua_enum_calls(ids, &count); 1775 1775 1776 if (count <= 1) { 1777 static const pj_str_t err_no_other_call = 1776 if (count <= 1) { 1777 static const pj_str_t err_no_other_call = 1778 1778 {"There are no other calls\n", 25}; 1779 1779 1780 pj_cli_sess_write_msg(cval->sess, err_no_other_call.ptr, 1780 pj_cli_sess_write_msg(cval->sess, err_no_other_call.ptr, 1781 1781 err_no_other_call.slen); 1782 1782 return PJ_SUCCESS; … … 1787 1787 1788 1788 /* Check if call is still there. */ 1789 if (call != current_call) { 1790 static pj_str_t err_call_dc = 1789 if (call != current_call) { 1790 static pj_str_t err_call_dc = 1791 1791 {"Call has been disconnected\n", 27}; 1792 1792 1793 pj_cli_sess_write_msg(cval->sess, err_call_dc.ptr, 1793 pj_cli_sess_write_msg(cval->sess, err_call_dc.ptr, 1794 1794 err_call_dc.slen); 1795 1795 return PJ_SUCCESS; … … 1798 1798 /* Check that destination call is valid. */ 1799 1799 if (dst_call == call) { 1800 static pj_str_t err_same_num = 1800 static pj_str_t err_same_num = 1801 1801 {"Destination call number must not be the " 1802 1802 "same as the call being transferred\n", 74}; 1803 1803 1804 pj_cli_sess_write_msg(cval->sess, err_same_num.ptr, 1804 pj_cli_sess_write_msg(cval->sess, err_same_num.ptr, 1805 1805 err_same_num.slen); 1806 1806 return PJ_SUCCESS; … … 1808 1808 1809 1809 if (dst_call >= PJSUA_MAX_CALLS) { 1810 pj_cli_sess_write_msg(cval->sess, err_invalid_num.ptr, 1810 pj_cli_sess_write_msg(cval->sess, err_invalid_num.ptr, 1811 1811 err_invalid_num.slen); 1812 1812 return PJ_SUCCESS; … … 1814 1814 1815 1815 if (!pjsua_call_is_active(dst_call)) { 1816 pj_cli_sess_write_msg(cval->sess, err_invalid_num.ptr, 1816 pj_cli_sess_write_msg(cval->sess, err_invalid_num.ptr, 1817 1817 err_invalid_num.slen); 1818 1818 return PJ_SUCCESS; … … 1822 1822 if (app_config.no_refersub) { 1823 1823 /* Add Refer-Sub: false in outgoing REFER request */ 1824 pjsip_generic_string_hdr_init2(&refer_sub, &STR_REFER_SUB, 1824 pjsip_generic_string_hdr_init2(&refer_sub, &STR_REFER_SUB, 1825 1825 &STR_FALSE); 1826 1826 pj_list_push_back(&msg_data.hdr_list, &refer_sub); 1827 1827 } 1828 1828 1829 pjsua_call_xfer_replaces(call, dst_call, 1830 PJSUA_XFER_NO_REQUIRE_REPLACES, 1829 pjsua_call_xfer_replaces(call, dst_call, 1830 PJSUA_XFER_NO_REQUIRE_REPLACES, 1831 1831 &msg_data); 1832 1832 } … … 1835 1835 1836 1836 static pj_status_t cmd_redirect_call(pj_cli_cmd_val *cval) 1837 { 1837 { 1838 1838 if (current_call == PJSUA_INVALID_ID) { 1839 1839 PJ_LOG(3,(THIS_FILE, "No current call")); … … 1842 1842 if (!pjsua_call_is_active(current_call)) { 1843 1843 PJ_LOG(1,(THIS_FILE, "Call %d has gone", current_call)); 1844 } else { 1844 } else { 1845 1845 enum { 1846 1846 ACCEPT_REPLACE, ACCEPT, REJECT, STOP … … 1850 1850 switch (choice) { 1851 1851 case ACCEPT_REPLACE: 1852 pjsua_call_process_redirect(current_call, 1853 PJSIP_REDIRECT_ACCEPT_REPLACE); 1852 pjsua_call_process_redirect(current_call, 1853 PJSIP_REDIRECT_ACCEPT_REPLACE); 1854 1854 break; 1855 1855 case ACCEPT: … … 1862 1862 pjsua_call_process_redirect(current_call, PJSIP_REDIRECT_STOP); 1863 1863 break; 1864 } 1864 } 1865 1865 } 1866 1866 return PJ_SUCCESS; … … 1878 1878 PJ_LOG(3,(THIS_FILE, "Media is not established yet!")); 1879 1879 1880 } else { 1880 } else { 1881 1881 int call = current_call; 1882 1882 pj_status_t status; … … 1888 1888 return PJ_SUCCESS;; 1889 1889 } 1890 1890 1891 1891 status = pjsua_call_dial_dtmf(current_call, &cval->argv[1]); 1892 1892 if (status != PJ_SUCCESS) { … … 1909 1909 1910 1910 } else { 1911 const pj_str_t SIP_INFO = pj_str("INFO"); 1911 const pj_str_t SIP_INFO = pj_str("INFO"); 1912 1912 int call = current_call; 1913 1913 int i; … … 1920 1920 return PJ_SUCCESS;; 1921 1921 } 1922 1922 1923 1923 for (i=0; i<cval->argv[1].slen; ++i) { 1924 1924 char body[64]; … … 1927 1927 msg_data.content_type = pj_str("application/dtmf-relay"); 1928 1928 1929 pj_ansi_snprintf(body, 1929 pj_ansi_snprintf(body, 1930 1930 sizeof(body), 1931 1931 "Signal=%c\n" … … 1935 1935 msg_data.msg_body = pj_str(body); 1936 1936 1937 status = pjsua_call_send_request(current_call, &SIP_INFO, 1937 status = pjsua_call_send_request(current_call, &SIP_INFO, 1938 1938 &msg_data); 1939 1939 if (status != PJ_SUCCESS) { … … 1962 1962 static const pj_str_t err_msg = {"Sorry, need at least one " 1963 1963 "account configured\n", 45}; 1964 pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen); 1964 pj_cli_sess_write_msg(cval->sess, err_msg.ptr, err_msg.slen); 1965 1965 } else { 1966 1966 char *uri; 1967 1967 char dest[64] = {0}; 1968 pj_str_t tmp = pj_str(dest); 1968 pj_str_t tmp = pj_str(dest); 1969 1969 struct input_result result; 1970 1970 static const pj_str_t header = {"Send arbitrary request to " 1971 1971 "remote host\n", 39}; 1972 1973 pj_cli_sess_write_msg(cval->sess, header.ptr, header.slen); 1974 1975 pj_strncpy_with_null(&tmp, &cval->argv[2], sizeof(dest)); 1972 1973 pj_cli_sess_write_msg(cval->sess, header.ptr, header.slen); 1974 1975 pj_strncpy_with_null(&tmp, &cval->argv[2], sizeof(dest)); 1976 1976 /* Input destination URI */ 1977 1977 uri = NULL; 1978 1978 get_input_url(tmp.ptr, tmp.slen, cval, &result); 1979 1979 if (result.nb_result != PJSUA_APP_NO_NB) { 1980 if (result.nb_result == -1) { 1980 if (result.nb_result == -1) { 1981 1981 static const pj_str_t err_msg = {"Sorry you can't do that!\n", 1982 1982 26}; … … 1995 1995 } else { 1996 1996 pjsua_buddy_info binfo; 1997 pjsua_buddy_get_info(result.nb_result-1, &binfo); 1997 pjsua_buddy_get_info(result.nb_result-1, &binfo); 1998 1998 pj_strncpy_with_null(&tmp, &binfo.uri, sizeof(dest)); 1999 1999 uri = tmp.ptr; … … 2007 2007 if (uri) { 2008 2008 char method[64] = {0}; 2009 pj_str_t tmp_method = pj_str(method); 2009 pj_str_t tmp_method = pj_str(method); 2010 2010 pj_strncpy_with_null(&tmp_method, &cval->argv[1], sizeof(method)); 2011 2011 tmp = pj_str(uri); … … 2016 2016 * not go well with the call state, so don't do it 2017 2017 * unless it's for testing. 2018 */ 2018 */ 2019 2019 pjsua_call_send_request(current_call, &cval->argv[1], NULL); 2020 } 2020 } 2021 2021 } 2022 2022 return PJ_SUCCESS; … … 2030 2030 "You have %d active call%s\n", i, (i>1?"s":"")); 2031 2031 2032 pj_cli_sess_write_msg(cval->sess, out_str, 2032 pj_cli_sess_write_msg(cval->sess, out_str, 2033 2033 pj_ansi_strlen(out_str)); 2034 2034 2035 2035 if (current_call != PJSUA_INVALID_ID) { 2036 2036 pjsua_call_info ci; 2037 if (pjsua_call_get_info(current_call, &ci)==PJ_SUCCESS) { 2038 pj_ansi_snprintf(out_str, sizeof(out_str), 2037 if (pjsua_call_get_info(current_call, &ci)==PJ_SUCCESS) { 2038 pj_ansi_snprintf(out_str, sizeof(out_str), 2039 2039 "Current call id=%d to %.*s [%.*s]\n", current_call, 2040 2040 (int)ci.remote_info.slen, ci.remote_info.ptr, 2041 2041 (int)ci.state_text.slen, ci.state_text.ptr); 2042 2042 2043 pj_cli_sess_write_msg(cval->sess, out_str, 2043 pj_cli_sess_write_msg(cval->sess, out_str, 2044 2044 pj_ansi_strlen(out_str)); 2045 2045 } 2046 } 2046 } 2047 2047 return PJ_SUCCESS; 2048 2048 } … … 2050 2050 /* Call handler */ 2051 2051 pj_status_t cmd_call_handler(pj_cli_cmd_val *cval) 2052 { 2052 { 2053 2053 pj_status_t status = PJ_SUCCESS; 2054 2054 pj_cli_cmd_id cmd_id = pj_cli_get_cmd_id(cval->cmd); … … 2064 2064 break; 2065 2065 case CMD_CALL_ANSWER: 2066 status = cmd_answer_call(cval); 2067 break; 2068 case CMD_CALL_HANGUP: 2069 case CMD_CALL_HANGUP_ALL: 2066 status = cmd_answer_call(cval); 2067 break; 2068 case CMD_CALL_HANGUP: 2069 case CMD_CALL_HANGUP_ALL: 2070 2070 status = cmd_hangup_call(cval, (cmd_id==CMD_CALL_HANGUP_ALL)); 2071 2071 break; 2072 case CMD_CALL_HOLD: 2072 case CMD_CALL_HOLD: 2073 2073 status = cmd_hold_call(); 2074 2074 break; 2075 case CMD_CALL_REINVITE: 2075 case CMD_CALL_REINVITE: 2076 2076 status = cmd_call_reinvite(); 2077 2077 break; 2078 case CMD_CALL_UPDATE: 2078 case CMD_CALL_UPDATE: 2079 2079 status = cmd_call_update(); 2080 2080 break; 2081 case CMD_CALL_NEXT: 2082 case CMD_CALL_PREVIOUS: 2083 status = cmd_next_call(cmd_id==CMD_CALL_NEXT); 2084 break; 2085 case CMD_CALL_TRANSFER: 2081 case CMD_CALL_NEXT: 2082 case CMD_CALL_PREVIOUS: 2083 status = cmd_next_call(cmd_id==CMD_CALL_NEXT); 2084 break; 2085 case CMD_CALL_TRANSFER: 2086 2086 status = cmd_transfer_call(cval); 2087 2087 break; 2088 case CMD_CALL_TRANSFER_REPLACE: 2088 case CMD_CALL_TRANSFER_REPLACE: 2089 2089 status = cmd_transfer_replace_call(cval); 2090 2090 break; … … 2092 2092 status = cmd_redirect_call(cval); 2093 2093 break; 2094 case CMD_CALL_D2833: 2094 case CMD_CALL_D2833: 2095 2095 status = cmd_dtmf_2833(cval); 2096 2096 break; 2097 case CMD_CALL_INFO: 2097 case CMD_CALL_INFO: 2098 2098 status = cmd_call_info(cval); 2099 2099 break; 2100 case CMD_CALL_DUMP_Q: 2100 case CMD_CALL_DUMP_Q: 2101 2101 status = cmd_call_quality(); 2102 2102 break; 2103 case CMD_CALL_SEND_ARB: 2103 case CMD_CALL_SEND_ARB: 2104 2104 status = cmd_send_arbitrary(cval); 2105 2105 break; … … 2107 2107 status = cmd_show_current_call(cval); 2108 2108 break; 2109 } 2109 } 2110 2110 2111 2111 return status; 2112 2112 } 2113 2113 2114 #if PJSUA_HAS_VIDEO 2114 #if PJSUA_HAS_VIDEO 2115 2115 static pj_status_t cmd_set_video_enable(pj_bool_t enabled) 2116 { 2116 { 2117 2117 app_config.vid.vid_cnt = (enabled ? 1 : 0); 2118 2118 PJ_LOG(3,(THIS_FILE, "Video will be %s in next offer/answer", … … 2136 2136 pjsua_acc_config acc_cfg; 2137 2137 pj_pool_t *pool = pjsua_pool_create("tmp-pjsua", 1000, 1000); 2138 2138 2139 2139 pjsua_acc_get_config(current_acc, pool, &acc_cfg); 2140 2140 app_config_show_video(current_acc, &acc_cfg); … … 2154 2154 2155 2155 switch(cmd_id) { 2156 case CMD_VIDEO_ACC_AUTORX: 2157 case CMD_VIDEO_ACC_AUTOTX: 2156 case CMD_VIDEO_ACC_AUTORX: 2157 case CMD_VIDEO_ACC_AUTOTX: 2158 2158 { 2159 2159 int on = (pj_ansi_strnicmp(cval->argv[1].ptr, "On", 2)==0); 2160 2160 2161 2161 if (cmd_id == CMD_VIDEO_ACC_AUTORX) 2162 2162 acc_cfg.vid_in_auto_show = on; … … 2165 2165 } 2166 2166 break; 2167 case CMD_VIDEO_ACC_CAP_ID: 2167 case CMD_VIDEO_ACC_CAP_ID: 2168 2168 case CMD_VIDEO_ACC_REN_ID: 2169 2169 { 2170 int dev = pj_strtol(&cval->argv[1]); 2170 int dev = pj_strtol(&cval->argv[1]); 2171 2171 2172 2172 if (cmd_id == CMD_VIDEO_ACC_CAP_ID) 2173 2173 acc_cfg.vid_cap_dev = dev; 2174 else 2175 acc_cfg.vid_rend_dev = dev; 2176 } 2174 else 2175 acc_cfg.vid_rend_dev = dev; 2176 } 2177 2177 break; 2178 2178 } … … 2190 2190 static pj_status_t cmd_enable_vid_rx(pj_cli_cmd_val *cval) 2191 2191 { 2192 pjsua_call_vid_strm_op_param param; 2193 pjsua_stream_info si; 2192 pjsua_call_vid_strm_op_param param; 2193 pjsua_stream_info si; 2194 2194 pj_status_t status = PJ_SUCCESS; 2195 2195 pj_bool_t on = (pj_ansi_strnicmp(cval->argv[1].ptr, "On", 2) == 0); 2196 2196 2197 pjsua_call_vid_strm_op_param_default(¶m); 2198 2199 param.med_idx = pj_strtol(&cval->argv[2]); 2197 pjsua_call_vid_strm_op_param_default(¶m); 2198 2199 param.med_idx = pj_strtol(&cval->argv[2]); 2200 2200 if (pjsua_call_get_stream_info(current_call, param.med_idx, &si) || 2201 2201 si.type != PJMEDIA_TYPE_VIDEO) … … 2216 2216 static pj_status_t cmd_enable_vid_tx(pj_cli_cmd_val *cval) 2217 2217 { 2218 pjsua_call_vid_strm_op_param param; 2218 pjsua_call_vid_strm_op_param param; 2219 2219 pj_status_t status = PJ_SUCCESS; 2220 pj_bool_t on = (pj_ansi_strnicmp(cval->argv[1].ptr, "On", 2) == 0); 2221 2220 pj_bool_t on = (pj_ansi_strnicmp(cval->argv[1].ptr, "On", 2) == 0); 2221 2222 2222 pjsua_call_vid_strm_op op = on? PJSUA_CALL_VID_STRM_START_TRANSMIT : 2223 2223 PJSUA_CALL_VID_STRM_STOP_TRANSMIT; 2224 2224 2225 2225 pjsua_call_vid_strm_op_param_default(¶m); 2226 2226 2227 2227 param.med_idx = pj_strtol(&cval->argv[2]); 2228 2228 2229 status = pjsua_call_set_vid_strm(current_call, op, ¶m); 2229 status = pjsua_call_set_vid_strm(current_call, op, ¶m); 2230 2230 return status; 2231 2231 } 2232 2232 2233 static pj_status_t cmd_enable_vid_stream(pj_cli_cmd_val *cval, 2233 static pj_status_t cmd_enable_vid_stream(pj_cli_cmd_val *cval, 2234 2234 pj_bool_t enable) 2235 { 2236 pjsua_call_vid_strm_op_param param; 2235 { 2236 pjsua_call_vid_strm_op_param param; 2237 2237 pjsua_call_vid_strm_op op = enable? PJSUA_CALL_VID_STRM_CHANGE_DIR : 2238 2238 PJSUA_CALL_VID_STRM_REMOVE; … … 2242 2242 param.med_idx = cval->argc > 1 ? pj_strtol(&cval->argv[1]) : -1; 2243 2243 param.dir = PJMEDIA_DIR_ENCODING_DECODING; 2244 return pjsua_call_set_vid_strm(current_call, op, ¶m); 2244 return pjsua_call_set_vid_strm(current_call, op, ¶m); 2245 2245 } 2246 2246 … … 2251 2251 pjsua_call_vid_strm_op_param_default(¶m); 2252 2252 param.med_idx = cval->argc > 1? pj_strtol(&cval->argv[1]) : -1; 2253 param.cap_dev = cval->argc > 2? pj_strtol(&cval->argv[2]) : 2253 param.cap_dev = cval->argc > 2? pj_strtol(&cval->argv[2]) : 2254 2254 PJMEDIA_VID_DEFAULT_CAPTURE_DEV; 2255 2255 … … 2272 2272 2273 2273 static pj_status_t cmd_vid_device_preview(pj_cli_cmd_val *cval) 2274 { 2275 int dev_id = pj_strtol(&cval->argv[2]); 2276 pj_bool_t on = (pj_ansi_strnicmp(cval->argv[1].ptr, "On", 2) == 0); 2274 { 2275 int dev_id = pj_strtol(&cval->argv[2]); 2276 pj_bool_t on = (pj_ansi_strnicmp(cval->argv[1].ptr, "On", 2) == 0); 2277 2277 2278 2278 if (on) { … … 2293 2293 pjsua_vid_preview_stop(dev_id); 2294 2294 } 2295 } 2295 } 2296 2296 return PJ_SUCCESS; 2297 2297 } 2298 2298 2299 2299 static pj_status_t cmd_vid_codec_list() 2300 { 2300 { 2301 2301 pjsua_codec_info ci[PJMEDIA_CODEC_MGR_MAX_CODECS]; 2302 2302 unsigned count = PJ_ARRAY_SIZE(ci); … … 2319 2319 vfd = pjmedia_format_get_video_format_detail(&cp.enc_fmt, 2320 2320 PJ_TRUE); 2321 PJ_LOG(3,(THIS_FILE, "%.*s%.*s %3d %7.2f %4d/%4d %dx%d", 2321 PJ_LOG(3,(THIS_FILE, "%.*s%.*s %3d %7.2f %4d/%4d %dx%d", 2322 2322 (int)ci[i].codec_id.slen, ci[i].codec_id.ptr, 2323 2323 13-(int)ci[i].codec_id.slen, " ", … … 2332 2332 2333 2333 static pj_status_t cmd_set_vid_codec_prio(pj_cli_cmd_val *cval) 2334 { 2334 { 2335 2335 int prio = pj_strtol(&cval->argv[2]); 2336 2336 pj_status_t status; 2337 2337 2338 2338 status = pjsua_vid_codec_set_priority(&cval->argv[1], (pj_uint8_t)prio); 2339 2339 if (status != PJ_SUCCESS) … … 2344 2344 2345 2345 static pj_status_t cmd_set_vid_codec_fps(pj_cli_cmd_val *cval) 2346 { 2346 { 2347 2347 pjmedia_vid_codec_param cp; 2348 int M, N; 2348 int M, N; 2349 2349 pj_status_t status; 2350 2350 … … 2364 2364 2365 2365 static pj_status_t cmd_set_vid_codec_bitrate(pj_cli_cmd_val *cval) 2366 { 2367 pjmedia_vid_codec_param cp; 2366 { 2367 pjmedia_vid_codec_param cp; 2368 2368 int M, N; 2369 2369 pj_status_t status; … … 2385 2385 static pj_status_t cmd_set_vid_codec_size(pj_cli_cmd_val *cval) 2386 2386 { 2387 pjmedia_vid_codec_param cp; 2387 pjmedia_vid_codec_param cp; 2388 2388 int M, N; 2389 2389 pj_status_t status; … … 2430 2430 2431 2431 static pj_status_t cmd_show_vid_win(pj_cli_cmd_val *cval, pj_bool_t show) 2432 { 2432 { 2433 2433 pjsua_vid_win_id wid = pj_strtol(&cval->argv[1]); 2434 2434 return pjsua_vid_win_set_show(wid, show); … … 2457 2457 /* Video handler */ 2458 2458 static pj_status_t cmd_video_handler(pj_cli_cmd_val *cval) 2459 { 2459 { 2460 2460 pj_status_t status = PJ_SUCCESS; 2461 pj_cli_cmd_id cmd_id = pj_cli_get_cmd_id(cval->cmd); 2461 pj_cli_cmd_id cmd_id = pj_cli_get_cmd_id(cval->cmd); 2462 2462 2463 2463 CHECK_PJSUA_RUNNING(); … … 2525 2525 status = cmd_arrange_vid_win(); 2526 2526 break; 2527 case CMD_VIDEO_WIN_SHOW: 2527 case CMD_VIDEO_WIN_SHOW: 2528 2528 case CMD_VIDEO_WIN_HIDE: 2529 2529 status = cmd_show_vid_win(cval, (cmd_id==CMD_VIDEO_WIN_SHOW)); … … 2535 2535 status = cmd_resize_vid_win(cval); 2536 2536 break; 2537 } 2537 } 2538 2538 2539 2539 return status; … … 2543 2543 /* Other command handler */ 2544 2544 static pj_status_t cmd_sleep_handler(pj_cli_cmd_val *cval) 2545 { 2545 { 2546 2546 int delay; 2547 2547 2548 2548 delay = pj_strtoul(&cval->argv[1]); 2549 2549 if (delay < 0) delay = 0; 2550 pj_thread_sleep(delay); 2550 pj_thread_sleep(delay); 2551 2551 2552 2552 return PJ_SUCCESS; … … 2559 2559 2560 2560 CHECK_PJSUA_RUNNING(); 2561 2561 2562 2562 status = pjsua_detect_nat_type(); 2563 2563 if (status != PJ_SUCCESS) … … 2578 2578 } 2579 2579 2580 /* 2581 * Syntax error handler for parser. 2580 /* 2581 * Syntax error handler for parser. 2582 2582 */ 2583 2583 static void on_syntax_error(pj_scanner *scanner) … … 2587 2587 } 2588 2588 2589 /* 2589 /* 2590 2590 * This method will parse buffer string info array of argument string 2591 * @argc On input, maximum array size of argument. On output, number of argument 2591 * @argc On input, maximum array size of argument. On output, number of argument 2592 2592 * parsed 2593 2593 * @argv Array of argument string … … 2598 2598 pj_scanner scanner; 2599 2599 unsigned max_argc = *argc; 2600 2600 2601 2601 PJ_USE_EXCEPTION; 2602 2602 … … 2604 2604 return PJ_SUCCESS; 2605 2605 2606 pj_scan_init(&scanner, options->ptr, options->slen, PJ_SCAN_AUTOSKIP_WS, 2606 pj_scan_init(&scanner, options->ptr, options->slen, PJ_SCAN_AUTOSKIP_WS, 2607 2607 &on_syntax_error); 2608 2608 PJ_TRY { … … 2610 2610 while (!pj_scan_is_eof(&scanner) && (max_argc > *argc)) { 2611 2611 pj_str_t str; 2612 2612 2613 2613 pj_scan_get_until_chr(&scanner, " \t\r\n", &str); 2614 2614 argv[*argc] = str; … … 2617 2617 } 2618 2618 PJ_CATCH_ANY { 2619 pj_scan_fini(&scanner); 2619 pj_scan_fini(&scanner); 2620 2620 return PJ_GET_EXCEPTION(); 2621 2621 } … … 2636 2636 pj_cli_quit(cval->sess->fe->cli, cval->sess, PJ_TRUE); 2637 2637 2638 /** Get the pjsua option **/ 2638 /** Get the pjsua option **/ 2639 2639 for (i=1; i < cval->argc; i++) { 2640 2640 pj_str_t argvst[MAX_ARGC]; … … 2659 2659 2660 2660 static pj_status_t add_call_command(pj_cli_t *cli) 2661 { 2662 char* call_command = 2661 { 2662 char* call_command = 2663 2663 "<CMD name='call' id='100' desc='Call related commands'>" 2664 2664 " <CMD name='new' id='1001' desc='Make a new call/INVITE'>" … … 2699 2699 " <CMD name='transfer_replaces' id='1012' sc='X' " 2700 2700 " desc='Transfer replace call'>" 2701 " <ARG name='call_id' type='choice' id='9911' desc='Call Id'/>" 2701 " <ARG name='call_id' type='choice' id='9911' desc='Call Id'/>" 2702 2702 " </CMD>" 2703 2703 " <CMD name='redirect' id='1013' sc='R' desc='Redirect call'>" … … 2730 2730 2731 2731 pj_str_t xml = pj_str(call_command); 2732 return pj_cli_add_cmd_from_xml(cli, NULL, 2732 return pj_cli_add_cmd_from_xml(cli, NULL, 2733 2733 &xml, cmd_call_handler, 2734 2734 NULL, get_choice_value); … … 2786 2786 pj_str_t xml = pj_str(presence_command); 2787 2787 2788 return pj_cli_add_cmd_from_xml(cli, NULL, 2789 &xml, cmd_presence_handler, 2788 return pj_cli_add_cmd_from_xml(cli, NULL, 2789 &xml, cmd_presence_handler, 2790 2790 NULL, get_choice_value); 2791 2791 } … … 2793 2793 static pj_status_t add_account_command(pj_cli_t *cli) 2794 2794 { 2795 char* account_command = 2795 char* account_command = 2796 2796 "<CMD name='acc' id='300' desc='Account commands'>" 2797 2797 " <CMD name='add' id='3001' sc='+a' desc='Add new account'>" … … 2831 2831 2832 2832 pj_str_t xml = pj_str(account_command); 2833 return pj_cli_add_cmd_from_xml(cli, NULL, 2834 &xml, cmd_account_handler, 2833 return pj_cli_add_cmd_from_xml(cli, NULL, 2834 &xml, cmd_account_handler, 2835 2835 NULL, get_choice_value); 2836 2836 } … … 2838 2838 static pj_status_t add_media_command(pj_cli_t *cli) 2839 2839 { 2840 char* media_command = 2840 char* media_command = 2841 2841 "<CMD name='audio' id='400' desc='Conference and Media commands'>" 2842 2842 " <CMD name='list' id='4001' sc='cl' desc='Show conference list'/>" … … 2866 2866 2867 2867 pj_str_t xml = pj_str(media_command); 2868 return pj_cli_add_cmd_from_xml(cli, NULL, 2869 &xml, cmd_media_handler, 2868 return pj_cli_add_cmd_from_xml(cli, NULL, 2869 &xml, cmd_media_handler, 2870 2870 NULL, get_choice_value); 2871 2871 } … … 2873 2873 static pj_status_t add_config_command(pj_cli_t *cli) 2874 2874 { 2875 char* config_command = 2875 char* config_command = 2876 2876 "<CMD name='stat' id='500' desc='Status and config commands'>" 2877 2877 " <CMD name='dump_stat' id='5001' sc='ds' desc='Dump status'/>" … … 2887 2887 2888 2888 pj_str_t xml = pj_str(config_command); 2889 return pj_cli_add_cmd_from_xml(cli, NULL, 2889 return pj_cli_add_cmd_from_xml(cli, NULL, 2890 2890 &xml, cmd_config_handler, 2891 2891 NULL, get_choice_value); 2892 2892 } 2893 2893 2894 #if PJSUA_HAS_VIDEO 2894 #if PJSUA_HAS_VIDEO 2895 2895 static pj_status_t add_video_command(pj_cli_t *cli) 2896 2896 { … … 3032 3032 3033 3033 pj_str_t xml = pj_str(video_command); 3034 return pj_cli_add_cmd_from_xml(cli, NULL, 3035 &xml, cmd_video_handler, 3034 return pj_cli_add_cmd_from_xml(cli, NULL, 3035 &xml, cmd_video_handler, 3036 3036 NULL, get_choice_value); 3037 3037 } … … 3060 3060 3061 3061 pj_status_t status; 3062 pj_str_t sleep_xml = pj_str(sleep_command); 3062 pj_str_t sleep_xml = pj_str(sleep_command); 3063 3063 pj_str_t network_xml = pj_str(network_command); 3064 3064 pj_str_t shutdown_xml = pj_str(shutdown_command); 3065 3065 pj_str_t restart_xml = pj_str(restart_command); 3066 3066 3067 status = pj_cli_add_cmd_from_xml(cli, NULL, 3068 &sleep_xml, cmd_sleep_handler, 3067 status = pj_cli_add_cmd_from_xml(cli, NULL, 3068 &sleep_xml, cmd_sleep_handler, 3069 3069 NULL, NULL); 3070 3070 if (status != PJ_SUCCESS) 3071 3071 return status; 3072 3072 3073 status = pj_cli_add_cmd_from_xml(cli, NULL, 3074 &network_xml, cmd_network_handler, 3073 status = pj_cli_add_cmd_from_xml(cli, NULL, 3074 &network_xml, cmd_network_handler, 3075 3075 NULL, NULL); 3076 3076 if (status != PJ_SUCCESS) 3077 3077 return status; 3078 3078 3079 status = pj_cli_add_cmd_from_xml(cli, NULL, 3080 &shutdown_xml, cmd_quit_handler, 3079 status = pj_cli_add_cmd_from_xml(cli, NULL, 3080 &shutdown_xml, cmd_quit_handler, 3081 3081 NULL, NULL); 3082 3082 … … 3084 3084 return status; 3085 3085 3086 status = pj_cli_add_cmd_from_xml(cli, NULL, 3087 &restart_xml, cmd_restart_handler, 3086 status = pj_cli_add_cmd_from_xml(cli, NULL, 3087 &restart_xml, cmd_restart_handler, 3088 3088 NULL, NULL); 3089 3089 … … 3115 3115 return status; 3116 3116 3117 #if PJSUA_HAS_VIDEO 3117 #if PJSUA_HAS_VIDEO 3118 3118 status = add_video_command(cli); 3119 3119 if (status != PJ_SUCCESS) -
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_config.c
r4714 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 #include "pjsua_app_common.h" … … 219 219 * Read command arguments from config file. 220 220 */ 221 static int read_config_file(pj_pool_t *pool, const char *filename, 221 static int read_config_file(pj_pool_t *pool, const char *filename, 222 222 int *app_argc, char ***app_argv) 223 223 { … … 249 249 pj_size_t len; 250 250 int token_len; 251 251 252 252 pj_bzero(line, sizeof(line)); 253 253 if (fgets(line, sizeof(line), fhnd) == NULL) break; 254 254 255 255 // Trim ending newlines 256 256 len = strlen(line); … … 268 268 if (*p == '\0') // are we done yet? 269 269 break; 270 270 271 271 if (*p == '"' || *p == '\'') { // is token a quoted string 272 272 cDelimiter = *p++; // save quote delimiter 273 273 token = p; 274 274 275 275 while (*p != '\0' && *p != cDelimiter) p++; 276 276 277 277 if (*p == '\0') // found end of the line, but, 278 278 cDelimiter = '\0'; // didn't find a matching quote … … 280 280 } else { // token's not a quoted string 281 281 token = p; 282 282 283 283 while (*p != '\0' && strchr(whitespace, *p) == NULL) p++; 284 284 285 285 cDelimiter = *p; 286 286 } 287 287 288 288 *p = '\0'; 289 289 token_len = (int)(p-token); 290 290 291 291 if (token_len > 0) { 292 292 if (*token == '#') 293 293 break; // ignore remainder of line 294 294 295 295 argv[argc] = pj_pool_alloc(pool, token_len + 1); 296 296 pj_memcpy(argv[argc], token, token_len + 1); 297 297 ++argc; 298 298 } 299 299 300 300 *p = cDelimiter; 301 301 } … … 307 307 308 308 if (argc == MAX_ARGS && (i!=*app_argc || !feof(fhnd))) { 309 PJ_LOG(1,(THIS_FILE, 309 PJ_LOG(1,(THIS_FILE, 310 310 "Too many arguments specified in cmd line/config file")); 311 311 fflush(stdout); … … 323 323 324 324 /* Parse arguments. */ 325 static pj_status_t parse_args(int argc, char *argv[], 325 static pj_status_t parse_args(int argc, char *argv[], 326 326 pj_str_t *uri_to_call) 327 327 { … … 329 329 int option_index; 330 330 pjsua_app_config *cfg = &app_config; 331 enum { OPT_CONFIG_FILE=127, OPT_LOG_FILE, OPT_LOG_LEVEL, OPT_APP_LOG_LEVEL, 331 enum { OPT_CONFIG_FILE=127, OPT_LOG_FILE, OPT_LOG_LEVEL, OPT_APP_LOG_LEVEL, 332 332 OPT_LOG_APPEND, OPT_COLOR, OPT_NO_COLOR, OPT_LIGHT_BG, OPT_NO_STDERR, 333 333 OPT_HELP, OPT_VERSION, OPT_NULL_AUDIO, OPT_SND_AUTO_CLOSE, 334 OPT_LOCAL_PORT, OPT_IP_ADDR, OPT_PROXY, OPT_OUTBOUND_PROXY, 334 OPT_LOCAL_PORT, OPT_IP_ADDR, OPT_PROXY, OPT_OUTBOUND_PROXY, 335 335 OPT_REGISTRAR, OPT_REG_TIMEOUT, OPT_PUBLISH, OPT_ID, OPT_CONTACT, 336 336 OPT_BOUND_ADDR, OPT_CONTACT_PARAMS, OPT_CONTACT_URI_PARAMS, … … 342 342 OPT_AUTO_CONF, OPT_CLOCK_RATE, OPT_SND_CLOCK_RATE, OPT_STEREO, 343 343 OPT_USE_ICE, OPT_ICE_REGULAR, OPT_USE_SRTP, OPT_SRTP_SECURE, 344 OPT_USE_TURN, OPT_ICE_MAX_HOSTS, OPT_ICE_NO_RTCP, OPT_TURN_SRV, 344 OPT_USE_TURN, OPT_ICE_MAX_HOSTS, OPT_ICE_NO_RTCP, OPT_TURN_SRV, 345 345 OPT_TURN_TCP, OPT_TURN_USER, OPT_TURN_PASSWD, 346 OPT_PLAY_FILE, OPT_PLAY_TONE, OPT_RTP_PORT, OPT_ADD_CODEC, 346 OPT_PLAY_FILE, OPT_PLAY_TONE, OPT_RTP_PORT, OPT_ADD_CODEC, 347 347 OPT_ILBC_MODE, OPT_REC_FILE, OPT_AUTO_REC, 348 348 OPT_COMPLEXITY, OPT_QUALITY, OPT_PTIME, OPT_NO_VAD, 349 349 OPT_RX_DROP_PCT, OPT_TX_DROP_PCT, OPT_EC_TAIL, OPT_EC_OPT, 350 OPT_NEXT_ACCOUNT, OPT_NEXT_CRED, OPT_MAX_CALLS, 350 OPT_NEXT_ACCOUNT, OPT_NEXT_CRED, OPT_MAX_CALLS, 351 351 OPT_DURATION, OPT_NO_TCP, OPT_NO_UDP, OPT_THREAD_CNT, 352 352 OPT_NOREFERSUB, OPT_ACCEPT_REDIRECT, … … 458 458 { "thread-cnt", 1, 0, OPT_THREAD_CNT}, 459 459 #if defined(PJSIP_HAS_TLS_TRANSPORT) && (PJSIP_HAS_TLS_TRANSPORT != 0) 460 { "use-tls", 0, 0, OPT_USE_TLS}, 460 { "use-tls", 0, 0, OPT_USE_TLS}, 461 461 { "tls-ca-file",1, 0, OPT_TLS_CA_FILE}, 462 { "tls-cert-file",1,0, OPT_TLS_CERT_FILE}, 462 { "tls-cert-file",1,0, OPT_TLS_CERT_FILE}, 463 463 { "tls-privkey-file",1,0, OPT_TLS_PRIV_FILE}, 464 464 { "tls-password",1,0, OPT_TLS_PASSWORD}, … … 504 504 unsigned i; 505 505 506 /* Run pj_getopt once to see if user specifies config file to read. */ 506 /* Run pj_getopt once to see if user specifies config file to read. */ 507 507 pj_optind = 0; 508 while ((c=pj_getopt_long(argc, argv, "", long_options, 509 &option_index)) != -1) 508 while ((c=pj_getopt_long(argc, argv, "", long_options, 509 &option_index)) != -1) 510 510 { 511 511 switch (c) { … … 541 541 /* Ignore as this has been processed before */ 542 542 break; 543 543 544 544 case OPT_LOG_FILE: 545 545 cfg->log_cfg.log_filename = pj_str(pj_optarg); … … 549 549 c = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 550 550 if (c < 0 || c > 6) { 551 PJ_LOG(1,(THIS_FILE, 551 PJ_LOG(1,(THIS_FILE, 552 552 "Error: expecting integer value 0-6 " 553 553 "for --log-level")); … … 560 560 case OPT_APP_LOG_LEVEL: 561 561 cfg->log_cfg.console_level = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 562 if (cfg->log_cfg.console_level < 0 || cfg->log_cfg.console_level> 6) {563 PJ_LOG(1,(THIS_FILE, 562 if (cfg->log_cfg.console_level > 6) { 563 PJ_LOG(1,(THIS_FILE, 564 564 "Error: expecting integer value 0-6 " 565 565 "for --app-log-level")); … … 614 614 return PJ_EINVAL; 615 615 } 616 cfg->media_cfg.clock_rate = lval; 616 cfg->media_cfg.clock_rate = lval; 617 617 break; 618 618 … … 624 624 return PJ_EINVAL; 625 625 } 626 cfg->media_cfg.snd_clock_rate = lval; 626 cfg->media_cfg.snd_clock_rate = lval; 627 627 break; 628 628 … … 634 634 lval = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 635 635 if (lval < 0 || lval > 65535) { 636 PJ_LOG(1,(THIS_FILE, 636 PJ_LOG(1,(THIS_FILE, 637 637 "Error: expecting integer value for " 638 638 "--local-port")); … … 676 676 case OPT_PROXY: /* proxy */ 677 677 if (pjsua_verify_sip_url(pj_optarg) != 0) { 678 PJ_LOG(1,(THIS_FILE, 678 PJ_LOG(1,(THIS_FILE, 679 679 "Error: invalid SIP URL '%s' " 680 680 "in proxy argument", pj_optarg)); … … 686 686 case OPT_OUTBOUND_PROXY: /* outbound proxy */ 687 687 if (pjsua_verify_sip_url(pj_optarg) != 0) { 688 PJ_LOG(1,(THIS_FILE, 688 PJ_LOG(1,(THIS_FILE, 689 689 "Error: invalid SIP URL '%s' " 690 690 "in outbound proxy argument", pj_optarg)); … … 696 696 case OPT_REGISTRAR: /* registrar */ 697 697 if (pjsua_verify_sip_url(pj_optarg) != 0) { 698 PJ_LOG(1,(THIS_FILE, 698 PJ_LOG(1,(THIS_FILE, 699 699 "Error: invalid SIP URL '%s' in " 700 700 "registrar argument", pj_optarg)); … … 707 707 cur_acc->reg_timeout = pj_strtoul(pj_cstr(&tmp,pj_optarg)); 708 708 if (cur_acc->reg_timeout < 1 || cur_acc->reg_timeout > 3600) { 709 PJ_LOG(1,(THIS_FILE, 709 PJ_LOG(1,(THIS_FILE, 710 710 "Error: invalid value for --reg-timeout " 711 711 "(expecting 1-3600)")); … … 730 730 lval = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 731 731 if (lval < 0 || lval > 3) { 732 PJ_LOG(1,(THIS_FILE, 732 PJ_LOG(1,(THIS_FILE, 733 733 "Error: expecting integer value 0-3 for --use-timer")); 734 734 return PJ_EINVAL; … … 741 741 cur_acc->timer_setting.sess_expires = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 742 742 if (cur_acc->timer_setting.sess_expires < 90) { 743 PJ_LOG(1,(THIS_FILE, 743 PJ_LOG(1,(THIS_FILE, 744 744 "Error: invalid value for --timer-se " 745 745 "(expecting higher than 90)")); … … 752 752 cur_acc->timer_setting.min_se = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 753 753 if (cur_acc->timer_setting.min_se < 90) { 754 PJ_LOG(1,(THIS_FILE, 754 PJ_LOG(1,(THIS_FILE, 755 755 "Error: invalid value for --timer-min-se " 756 756 "(expecting higher than 90)")); … … 770 770 case OPT_ID: /* id */ 771 771 if (pjsua_verify_url(pj_optarg) != 0) { 772 PJ_LOG(1,(THIS_FILE, 772 PJ_LOG(1,(THIS_FILE, 773 773 "Error: invalid SIP URL '%s' " 774 774 "in local id argument", pj_optarg)); … … 780 780 case OPT_CONTACT: /* contact */ 781 781 if (pjsua_verify_sip_url(pj_optarg) != 0) { 782 PJ_LOG(1,(THIS_FILE, 782 PJ_LOG(1,(THIS_FILE, 783 783 "Error: invalid SIP URL '%s' " 784 784 "in contact argument", pj_optarg)); … … 822 822 case OPT_ACCEPT_REDIRECT: 823 823 cfg->redir_op = my_atoi(pj_optarg); 824 if (cfg->redir_op <0 || cfg->redir_op>PJSIP_REDIRECT_STOP) {825 PJ_LOG(1,(THIS_FILE, 824 if (cfg->redir_op>PJSIP_REDIRECT_STOP) { 825 PJ_LOG(1,(THIS_FILE, 826 826 "Error: accept-redirect value '%s' ", pj_optarg)); 827 827 return PJ_EINVAL; … … 893 893 case OPT_ADD_BUDDY: /* Add to buddy list. */ 894 894 if (pjsua_verify_url(pj_optarg) != 0) { 895 PJ_LOG(1,(THIS_FILE, 895 PJ_LOG(1,(THIS_FILE, 896 896 "Error: invalid URL '%s' in " 897 897 "--add-buddy option", pj_optarg)); … … 899 899 } 900 900 if (cfg->buddy_cnt == PJ_ARRAY_SIZE(cfg->buddy_cfg)) { 901 PJ_LOG(1,(THIS_FILE, 901 PJ_LOG(1,(THIS_FILE, 902 902 "Error: too many buddies in buddy list.")); 903 903 return -1; … … 1022 1022 case OPT_SRTP_SECURE: 1023 1023 app_config.cfg.srtp_secure_signaling = my_atoi(pj_optarg); 1024 if (!pj_isdigit(*pj_optarg) || 1025 app_config.cfg.srtp_secure_signaling > 2) 1024 if (!pj_isdigit(*pj_optarg) || 1025 app_config.cfg.srtp_secure_signaling > 2) 1026 1026 { 1027 1027 PJ_LOG(1,(THIS_FILE, "Invalid value for --srtp-secure option")); … … 1039 1039 1040 1040 range = (65535-START_PORT-PJSUA_MAX_CALLS*2); 1041 cfg->rtp_cfg.port = START_PORT + 1041 cfg->rtp_cfg.port = START_PORT + 1042 1042 ((pj_rand() % range) & 0xFFFE); 1043 1043 } … … 1112 1112 case OPT_QUALITY: 1113 1113 cfg->media_cfg.quality = my_atoi(pj_optarg); 1114 if (cfg->media_cfg.quality < 0 || cfg->media_cfg.quality> 10) {1114 if (cfg->media_cfg.quality > 10) { 1115 1115 PJ_LOG(1,(THIS_FILE, 1116 1116 "Error: invalid --quality (expecting 0-10")); … … 1136 1136 } 1137 1137 break; 1138 1138 1139 1139 case OPT_TX_DROP_PCT: 1140 1140 cfg->media_cfg.tx_drop_pct = my_atoi(pj_optarg); … … 1170 1170 cfg->use_tls = PJ_TRUE; 1171 1171 break; 1172 1172 1173 1173 case OPT_TLS_CA_FILE: 1174 1174 cfg->udp_cfg.tls_setting.ca_list_file = pj_str(pj_optarg); 1175 1175 break; 1176 1176 1177 1177 case OPT_TLS_CERT_FILE: 1178 1178 cfg->udp_cfg.tls_setting.cert_file = pj_str(pj_optarg); 1179 1179 break; 1180 1180 1181 1181 case OPT_TLS_PRIV_FILE: 1182 1182 cfg->udp_cfg.tls_setting.privkey_file = pj_str(pj_optarg); … … 1222 1222 ciphers_cnt = PJ_ARRAY_SIZE(ciphers); 1223 1223 pj_ssl_cipher_get_availables(ciphers, &ciphers_cnt); 1224 1224 1225 1225 PJ_LOG(1,(THIS_FILE, "Cipher \"%s\" is not supported by " 1226 1226 "TLS/SSL backend.", pj_optarg)); … … 1286 1286 cfg->rtp_cfg.qos_type = PJ_QOS_TYPE_VOICE; 1287 1287 /* Directly apply DSCP value to SIP traffic. Say lets 1288 * set it to CS3 (DSCP 011000). Note that this will not 1288 * set it to CS3 (DSCP 011000). Note that this will not 1289 1289 * work on all platforms. 1290 1290 */ … … 1337 1337 1338 1338 default: 1339 PJ_LOG(1,(THIS_FILE, 1339 PJ_LOG(1,(THIS_FILE, 1340 1340 "Argument \"%s\" is not valid. Use --help to see help", 1341 1341 argv[pj_optind-1])); … … 1402 1402 /* Realm must point to the real domain */ 1403 1403 if (*acfg->cred_info[0].realm.ptr=='*') { 1404 PJ_LOG(1,(THIS_FILE, 1404 PJ_LOG(1,(THIS_FILE, 1405 1405 "Error: cannot use '*' as realm with IMS")); 1406 1406 return PJ_EINVAL; … … 1409 1409 /* Username for authentication must be in a@b format */ 1410 1410 if (strchr(acfg->cred_info[0].username.ptr, '@')==0) { 1411 PJ_LOG(1,(THIS_FILE, 1411 PJ_LOG(1,(THIS_FILE, 1412 1412 "Error: Username for authentication must " 1413 1413 "be in user@domain format with IMS")); … … 1456 1456 for (i=0; i<PJ_ARRAY_SIZE(cfg->buddy_cfg); ++i) 1457 1457 pjsua_buddy_config_default(&cfg->buddy_cfg[i]); 1458 1458 1459 1459 cfg->vid.vcapture_dev = PJMEDIA_VID_DEFAULT_CAPTURE_DEV; 1460 1460 cfg->vid.vrender_dev = PJMEDIA_VID_DEFAULT_RENDER_DEV; … … 1500 1500 return status; 1501 1501 1502 if (app_running) { 1502 if (app_running) { 1503 1503 app_config.use_cli = use_cli; 1504 1504 app_config.cli_cfg.cli_fe = cli_fe; -
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.