Changeset 3891 for pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
- Timestamp:
- Dec 1, 2011 9:06:14 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r3875 r3891 135 135 136 136 struct app_vid vid; 137 unsigned aud_cnt; 137 138 } app_config; 138 139 … … 403 404 cfg->vid.vcapture_dev = PJMEDIA_VID_DEFAULT_CAPTURE_DEV; 404 405 cfg->vid.vrender_dev = PJMEDIA_VID_DEFAULT_RENDER_DEV; 406 cfg->aud_cnt = 1; 405 407 } 406 408 … … 1456 1458 break; 1457 1459 case OPT_VIDEO: 1458 app_config.vid.vid_cnt = 1;1459 app_config.vid.in_auto_show = PJ_TRUE;1460 app_config.vid.out_auto_transmit = PJ_TRUE;1460 cfg->vid.vid_cnt = 1; 1461 cfg->vid.in_auto_show = PJ_TRUE; 1462 cfg->vid.out_auto_transmit = PJ_TRUE; 1461 1463 break; 1462 1464 case OPT_EXTRA_AUDIO: 1463 ++cur_acc->max_audio_cnt;1465 cfg->aud_cnt++; 1464 1466 break; 1465 1467 … … 1718 1720 if (acc_cfg->mwi_enabled) 1719 1721 pj_strcat2(result, "--mwi\n"); 1720 1721 /* Video & extra audio */1722 for (i=0; i<acc_cfg->max_video_cnt; ++i) {1723 pj_strcat2(result, "--video\n");1724 }1725 for (i=1; i<acc_cfg->max_audio_cnt; ++i) {1726 pj_strcat2(result, "--extra-audio\n");1727 }1728 1722 } 1729 1723 … … 1890 1884 1891 1885 pj_strcat2(&cfg, "\n#\n# Media settings:\n#\n"); 1886 1887 /* Video & extra audio */ 1888 for (i=0; i<config->vid.vid_cnt; ++i) { 1889 pj_strcat2(&cfg, "--video\n"); 1890 } 1891 for (i=1; i<config->aud_cnt; ++i) { 1892 pj_strcat2(&cfg, "--extra-audio\n"); 1893 } 1892 1894 1893 1895 /* SRTP */ … … 2576 2578 2577 2579 if (app_config.auto_answer > 0) { 2578 pjsua_call_answer(call_id, app_config.auto_answer, NULL, NULL); 2579 } 2580 2580 pjsua_call_setting call_opt; 2581 2582 pjsua_call_setting_default(&call_opt); 2583 call_opt.audio_cnt = app_config.aud_cnt; 2584 call_opt.video_cnt = app_config.vid.vid_cnt; 2585 2586 pjsua_call_answer2(call_id, &call_opt, app_config.auto_answer, NULL, NULL); 2587 } 2588 2581 2589 if (app_config.auto_answer < 200) { 2590 char notif_st[80] = {0}; 2591 2592 #if PJSUA_HAS_VIDEO 2593 if (call_info.rem_offerer && call_info.rem_video_cnt) { 2594 snprintf(notif_st, sizeof(notif_st), 2595 "To %s the video, type \"vid %s\" first, " 2596 "before answering the call!\n", 2597 (app_config.vid.vid_cnt? "reject":"accept"), 2598 (app_config.vid.vid_cnt? "disable":"enable")); 2599 } 2600 #endif 2601 2582 2602 PJ_LOG(3,(THIS_FILE, 2583 2603 "Incoming call for account %d!\n" 2604 "Media count: %d audio & %d video\n" 2605 "%s" 2584 2606 "From: %s\n" 2585 2607 "To: %s\n" 2586 2608 "Press a to answer or h to reject call", 2587 2609 acc_id, 2610 call_info.rem_audio_cnt, 2611 call_info.rem_video_cnt, 2612 notif_st, 2588 2613 call_info.remote_info.ptr, 2589 2614 call_info.local_info.ptr)); … … 2847 2872 pjsua_call_hangup(call_id, 500, &reason, NULL); 2848 2873 } 2874 2875 #if PJSUA_HAS_VIDEO 2876 /* Check if remote has just tried to enable video */ 2877 if (call_info.rem_offerer && call_info.rem_video_cnt) 2878 { 2879 int vid_idx; 2880 2881 /* Check if there is active video */ 2882 vid_idx = pjsua_call_get_vid_stream_idx(call_id); 2883 if (vid_idx == -1 || call_info.media[vid_idx].dir == PJMEDIA_DIR_NONE) { 2884 PJ_LOG(3,(THIS_FILE, 2885 "Just rejected incoming video offer on call %d" 2886 "use \"vid call add\" to enable video!", 2887 call_id)); 2888 } 2889 } 2890 #endif 2849 2891 } 2850 2892 … … 3423 3465 { 3424 3466 #if PJSUA_HAS_VIDEO 3467 pj_bool_t vid_enabled = (app_config.vid.vid_cnt > 0); 3468 3425 3469 puts("+=============================================================================+"); 3426 3470 puts("| Video commands: |"); 3427 3471 puts("| |"); 3428 3472 puts("| vid help Show this help screen |"); 3473 puts("| vid enable|disable Enable or disable video in next offer/answer |"); 3429 3474 puts("| vid acc show Show current account video settings |"); 3430 puts("| vid acc enable|disable Enable or disable video on current account |");3431 3475 puts("| vid acc autorx on|off Automatically show incoming video on/off |"); 3432 3476 puts("| vid acc autotx on|off Automatically offer video on/off |"); … … 3436 3480 puts("| vid call tx on|off N Enable/disable video tx for stream N in curr call |"); 3437 3481 puts("| vid call add Add video stream for current call |"); 3438 puts("| vid call enable /disable N Enable/disable stream #N in current call |");3482 puts("| vid call enable|disable N Enable/disable stream #N in current call |"); 3439 3483 puts("| vid call cap N ID Set capture dev ID for stream #N in current call |"); 3440 3484 puts("| vid dev list List all video devices |"); … … 3448 3492 puts("| vid win move ID X Y Move window ID to position X,Y |"); 3449 3493 puts("| vid win resize ID w h Resize window ID to the specified width, height |"); 3494 puts("+=============================================================================+"); 3495 printf("| Video will be %s in the next offer/answer %s |\n", 3496 (vid_enabled? "enabled" : "disabled"), (vid_enabled? " " : "")); 3450 3497 puts("+=============================================================================+"); 3451 3498 #endif … … 3864 3911 static void app_config_init_video(pjsua_acc_config *acc_cfg) 3865 3912 { 3866 acc_cfg->max_video_cnt = app_config.vid.vid_cnt;3867 3913 acc_cfg->vid_in_auto_show = app_config.vid.in_auto_show; 3868 3914 acc_cfg->vid_out_auto_transmit = app_config.vid.out_auto_transmit; … … 3880 3926 PJ_LOG(3,(THIS_FILE, 3881 3927 "Account %d:\n" 3882 " Video count: %d\n"3883 3928 " RX auto show: %d\n" 3884 3929 " TX auto transmit: %d\n" … … 3886 3931 " Render dev: %d", 3887 3932 acc_id, 3888 acc_cfg->max_video_cnt,3889 3933 acc_cfg->vid_in_auto_show, 3890 3934 acc_cfg->vid_out_auto_transmit, … … 3907 3951 if (argc == 1 || strcmp(argv[1], "help")==0) { 3908 3952 vid_show_help(); 3953 } else if (argc == 2 && (strcmp(argv[1], "enable")==0 || 3954 strcmp(argv[1], "disable")==0)) 3955 { 3956 pj_bool_t enabled = (strcmp(argv[1], "enable")==0); 3957 app_config.vid.vid_cnt = (enabled ? 1 : 0); 3958 PJ_LOG(3,(THIS_FILE, "Video will be %s in next offer/answer", 3959 (enabled?"enabled":"disabled"))); 3909 3960 } else if (strcmp(argv[1], "acc")==0) { 3910 3961 pjsua_acc_config acc_cfg; … … 3915 3966 if (argc == 3 && strcmp(argv[2], "show")==0) { 3916 3967 app_config_show_video(current_acc, &acc_cfg); 3917 3918 } else if (argc == 3 && (strcmp(argv[2], "enable")==0 ||3919 strcmp(argv[2], "disable")==0))3920 {3921 int enabled = (strcmp(argv[2], "enable")==0);3922 acc_cfg.max_video_cnt = (enabled ? 1 : 0);3923 if (enabled) {3924 app_config_init_video(&acc_cfg);3925 acc_cfg.max_video_cnt = (enabled ? 1 : 0);3926 }3927 changed = PJ_TRUE;3928 3968 } else if (argc == 4 && strcmp(argv[2], "autorx")==0) { 3929 3969 int on = (strcmp(argv[3], "on")==0); … … 4166 4206 pjsua_call_info call_info; 4167 4207 pjsua_acc_info acc_info; 4168 4208 pjsua_call_setting call_opt; 4209 4210 pjsua_call_setting_default(&call_opt); 4211 call_opt.audio_cnt = app_config.aud_cnt; 4212 call_opt.video_cnt = app_config.vid.vid_cnt; 4169 4213 4170 4214 /* If user specifies URI to call, then call the URI */ 4171 4215 if (uri_to_call->slen) { 4172 pjsua_call_make_call( current_acc, uri_to_call, 0, NULL, NULL, NULL);4216 pjsua_call_make_call( current_acc, uri_to_call, &call_opt, NULL, NULL, NULL); 4173 4217 } 4174 4218 … … 4205 4249 } 4206 4250 4251 /* Update call setting */ 4252 pjsua_call_setting_default(&call_opt); 4253 call_opt.audio_cnt = app_config.aud_cnt; 4254 call_opt.video_cnt = app_config.vid.vid_cnt; 4255 4207 4256 switch (menuin[0]) { 4208 4257 … … 4234 4283 pjsua_msg_data_init(&msg_data); 4235 4284 TEST_MULTIPART(&msg_data); 4236 pjsua_call_make_call( current_acc, &tmp, 0, NULL, &msg_data, NULL);4285 pjsua_call_make_call( current_acc, &tmp, &call_opt, NULL, &msg_data, NULL); 4237 4286 break; 4238 4287 … … 4266 4315 pj_status_t status; 4267 4316 4268 status = pjsua_call_make_call(current_acc, &tmp, 0, NULL,4317 status = pjsua_call_make_call(current_acc, &tmp, &call_opt, NULL, 4269 4318 NULL, NULL); 4270 4319 if (status != PJ_SUCCESS) … … 4403 4452 } 4404 4453 4405 pjsua_call_answer (current_call, st_code, NULL, &msg_data);4454 pjsua_call_answer2(current_call, &call_opt, st_code, NULL, &msg_data); 4406 4455 } 4407 4456 … … 4592 4641 * re-INVITE 4593 4642 */ 4594 pjsua_call_reinvite(current_call, PJ_TRUE, NULL); 4643 call_opt.flag |= PJSUA_CALL_UNHOLD; 4644 pjsua_call_reinvite2(current_call, &call_opt, NULL); 4595 4645 4596 4646 } else { … … 4605 4655 if (current_call != -1) { 4606 4656 4607 pjsua_call_update (current_call, 0, NULL);4657 pjsua_call_update2(current_call, &call_opt, NULL); 4608 4658 4609 4659 } else {
Note: See TracChangeset
for help on using the changeset viewer.