Changeset 4729 for pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_cli.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_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)
Note: See TracChangeset
for help on using the changeset viewer.