- Timestamp:
- Oct 25, 2011 9:35:11 AM (13 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r3841 r3850 53 53 }; 54 54 55 /* Video settings */ 56 struct app_vid 57 { 58 unsigned vid_cnt; 59 int vcapture_dev; 60 int vrender_dev; 61 pj_bool_t in_auto_show; 62 pj_bool_t out_auto_transmit; 63 }; 55 64 56 65 /* Pjsua application data */ … … 125 134 pjmedia_port *ring_port; 126 135 127 int vcapture_dev, vrender_dev;136 struct app_vid vid; 128 137 } app_config; 129 138 … … 392 401 pjsua_buddy_config_default(&cfg->buddy_cfg[i]); 393 402 394 cfg->v capture_dev = PJSUA_INVALID_ID;395 cfg->v render_dev = PJSUA_INVALID_ID;403 cfg->vid.vcapture_dev = PJMEDIA_VID_DEFAULT_CAPTURE_DEV; 404 cfg->vid.vrender_dev = PJMEDIA_VID_DEFAULT_RENDER_DEV; 396 405 } 397 406 … … 1389 1398 1390 1399 case OPT_CAPTURE_DEV: 1391 cfg-> capture_dev = atoi(pj_optarg);1400 cfg->vid.vcapture_dev = atoi(pj_optarg); 1392 1401 break; 1393 1402 1394 1403 case OPT_PLAYBACK_DEV: 1395 cfg-> playback_dev = atoi(pj_optarg);1404 cfg->vid.vrender_dev = atoi(pj_optarg); 1396 1405 break; 1397 1406 … … 1447 1456 break; 1448 1457 case OPT_VIDEO: 1449 ++cur_acc->max_video_cnt; 1450 cur_acc->vid_in_auto_show = PJ_TRUE; 1451 cur_acc->vid_out_auto_transmit = PJ_TRUE; 1452 PJ_TODO(implement_pjsua_option_for_vid_auto_show_and_transmit); 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; 1453 1461 break; 1454 1462 case OPT_EXTRA_AUDIO: … … 1457 1465 1458 1466 case OPT_VCAPTURE_DEV: 1459 cfg->v capture_dev = atoi(pj_optarg);1460 cur_acc->vid_cap_dev = cfg->v capture_dev;1467 cfg->vid.vcapture_dev = atoi(pj_optarg); 1468 cur_acc->vid_cap_dev = cfg->vid.vcapture_dev; 1461 1469 break; 1462 1470 1463 1471 case OPT_VRENDER_DEV: 1464 cfg->v render_dev = atoi(pj_optarg);1465 cur_acc->vid_rend_dev = cfg->v render_dev;1472 cfg->vid.vrender_dev = atoi(pj_optarg); 1473 cur_acc->vid_rend_dev = cfg->vid.vrender_dev; 1466 1474 break; 1467 1475 … … 2042 2050 } 2043 2051 2044 if (config->v capture_dev != PJSUA_INVALID_ID) {2045 pj_ansi_sprintf(line, "--vcapture-dev %d\n", config->v capture_dev);2052 if (config->vid.vcapture_dev != PJMEDIA_VID_DEFAULT_CAPTURE_DEV) { 2053 pj_ansi_sprintf(line, "--vcapture-dev %d\n", config->vid.vcapture_dev); 2046 2054 pj_strcat2(&cfg, line); 2047 2055 } 2048 if (config->v render_dev != PJSUA_INVALID_ID) {2049 pj_ansi_sprintf(line, "--vrender-dev %d\n", config->v render_dev);2056 if (config->vid.vrender_dev != PJMEDIA_VID_DEFAULT_RENDER_DEV) { 2057 pj_ansi_sprintf(line, "--vrender-dev %d\n", config->vid.vrender_dev); 2050 2058 pj_strcat2(&cfg, line); 2051 2059 } … … 3419 3427 puts("| |"); 3420 3428 puts("| vid help Show this help screen |"); 3429 puts("| vid acc show Show current account video settings |"); 3430 puts("| vid acc enable|disable Enable or disable video on current account |"); 3431 puts("| vid acc autorx on|off Automatically show incoming video on/off |"); 3432 puts("| vid acc autotx on|off Automatically offer video on/off |"); 3433 puts("| vid acc cap ID Set default capture device for current acc |"); 3434 puts("| vid acc rend ID Set default renderer device for current acc |"); 3421 3435 puts("| vid call rx on|off N Enable/disable video rx for stream N in curr call |"); 3422 3436 puts("| vid call tx on|off N Enable/disable video tx for stream N in curr call |"); … … 3848 3862 } 3849 3863 3864 static void app_config_init_video(pjsua_acc_config *acc_cfg) 3865 { 3866 acc_cfg->max_video_cnt = app_config.vid.vid_cnt; 3867 acc_cfg->vid_in_auto_show = app_config.vid.in_auto_show; 3868 acc_cfg->vid_out_auto_transmit = app_config.vid.out_auto_transmit; 3869 acc_cfg->vid_cap_dev = app_config.vid.vcapture_dev; 3870 acc_cfg->vid_rend_dev = app_config.vid.vrender_dev; 3871 } 3872 3873 static void app_config_show_video(int acc_id, const pjsua_acc_config *acc_cfg) 3874 { 3875 PJ_LOG(3,(THIS_FILE, 3876 "Account %d:\n" 3877 " Video count: %d\n" 3878 " RX auto show: %d\n" 3879 " TX auto transmit: %d\n" 3880 " Capture dev: %d\n" 3881 " Render dev: %d", 3882 acc_id, 3883 acc_cfg->max_video_cnt, 3884 acc_cfg->vid_in_auto_show, 3885 acc_cfg->vid_out_auto_transmit, 3886 acc_cfg->vid_cap_dev, 3887 acc_cfg->vid_rend_dev)); 3888 } 3889 3850 3890 static void vid_handle_menu(char *menuin) 3851 3891 { … … 3862 3902 if (argc == 1 || strcmp(argv[1], "help")==0) { 3863 3903 vid_show_help(); 3904 } else if (strcmp(argv[1], "acc")==0) { 3905 pjsua_acc_config acc_cfg; 3906 pj_bool_t changed = PJ_FALSE; 3907 3908 pjsua_acc_get_config(current_acc, &acc_cfg); 3909 3910 if (argc == 3 && strcmp(argv[2], "show")==0) { 3911 app_config_show_video(current_acc, &acc_cfg); 3912 3913 } else if (argc == 3 && (strcmp(argv[2], "enable")==0 || 3914 strcmp(argv[2], "disable")==0)) 3915 { 3916 int enabled = (strcmp(argv[2], "enable")==0); 3917 acc_cfg.max_video_cnt = (enabled ? 1 : 0); 3918 if (enabled) { 3919 app_config_init_video(&acc_cfg); 3920 acc_cfg.max_video_cnt = (enabled ? 1 : 0); 3921 } 3922 changed = PJ_TRUE; 3923 } else if (argc == 4 && strcmp(argv[2], "autorx")==0) { 3924 int on = (strcmp(argv[3], "on")==0); 3925 acc_cfg.vid_in_auto_show = on; 3926 changed = PJ_TRUE; 3927 } else if (argc == 4 && strcmp(argv[2], "autotx")==0) { 3928 int on = (strcmp(argv[3], "on")==0); 3929 acc_cfg.vid_out_auto_transmit = on; 3930 changed = PJ_TRUE; 3931 } else if (argc == 4 && strcmp(argv[2], "cap")==0) { 3932 int dev = atoi(argv[3]); 3933 acc_cfg.vid_cap_dev = dev; 3934 changed = PJ_TRUE; 3935 } else if (argc == 4 && strcmp(argv[2], "rend")==0) { 3936 int dev = atoi(argv[3]); 3937 acc_cfg.vid_rend_dev = dev; 3938 changed = PJ_TRUE; 3939 } else { 3940 goto on_error; 3941 } 3942 3943 if (changed) { 3944 pj_status_t status = pjsua_acc_modify(current_acc, &acc_cfg); 3945 if (status != PJ_SUCCESS) 3946 PJ_PERROR(1,(THIS_FILE, status, "Error modifying account %d", 3947 current_acc)); 3948 } 3949 3864 3950 } else if (strcmp(argv[1], "call")==0) { 3865 3951 pjsua_call_vid_strm_op_param param; 3952 pj_status_t status = PJ_SUCCESS; 3866 3953 3867 3954 pjsua_call_vid_strm_op_param_default(¶m); … … 3882 3969 else param.dir = (si.info.vid.dir & PJMEDIA_DIR_ENCODING); 3883 3970 3884 pjsua_call_set_vid_strm(current_call, PJSUA_CALL_VID_STRM_CHANGE_DIR, ¶m); 3971 status = pjsua_call_set_vid_strm(current_call, 3972 PJSUA_CALL_VID_STRM_CHANGE_DIR, 3973 ¶m); 3885 3974 } 3886 3975 else if (argc == 5 && strcmp(argv[2], "tx")==0) { … … 3891 3980 param.med_idx = atoi(argv[4]); 3892 3981 3893 pjsua_call_set_vid_strm(current_call, op, ¶m);3982 status = pjsua_call_set_vid_strm(current_call, op, ¶m); 3894 3983 } 3895 3984 else if (argc == 3 && strcmp(argv[2], "add")==0) { 3896 pjsua_call_set_vid_strm(current_call, PJSUA_CALL_VID_STRM_ADD, NULL); 3985 status = pjsua_call_set_vid_strm(current_call, 3986 PJSUA_CALL_VID_STRM_ADD, NULL); 3897 3987 } 3898 3988 else if (argc >= 3 && … … 3905 3995 param.med_idx = argc >= 4? atoi(argv[3]) : -1; 3906 3996 param.dir = PJMEDIA_DIR_ENCODING_DECODING; 3907 pjsua_call_set_vid_strm(current_call, op, ¶m);3997 status = pjsua_call_set_vid_strm(current_call, op, ¶m); 3908 3998 } 3909 3999 else if (argc >= 3 && strcmp(argv[2], "cap")==0) { 3910 4000 param.med_idx = argc >= 4? atoi(argv[3]) : -1; 3911 4001 param.cap_dev = argc >= 5? atoi(argv[4]) : PJMEDIA_VID_DEFAULT_CAPTURE_DEV; 3912 pjsua_call_set_vid_strm(current_call, PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV, ¶m); 4002 status = pjsua_call_set_vid_strm(current_call, 4003 PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV, 4004 ¶m); 3913 4005 } else 3914 4006 goto on_error; 4007 4008 if (status != PJ_SUCCESS) { 4009 PJ_PERROR(1,(THIS_FILE, status, "Error modifying video stream")); 4010 } 4011 3915 4012 } else if (argc >= 3 && strcmp(argv[1], "dev")==0) { 3916 4013 if (strcmp(argv[2], "list")==0) { … … 3941 4038 goto on_error; 3942 4039 } else if (strcmp(argv[1], "win")==0) { 4040 pj_status_t status = PJ_SUCCESS; 4041 3943 4042 if (argc==3 && strcmp(argv[2], "list")==0) { 3944 4043 pjsua_vid_win_id wids[PJSUA_MAX_VID_WINS]; … … 3962 4061 pj_bool_t show = (strcmp(argv[2], "show")==0); 3963 4062 pjsua_vid_win_id wid = atoi(argv[3]); 3964 pjsua_vid_win_set_show(wid, show);4063 status = pjsua_vid_win_set_show(wid, show); 3965 4064 } else if (argc==6 && strcmp(argv[2], "move")==0) { 3966 4065 pjsua_vid_win_id wid = atoi(argv[3]); … … 3969 4068 pos.x = atoi(argv[4]); 3970 4069 pos.y = atoi(argv[5]); 3971 pjsua_vid_win_set_pos(wid, &pos);4070 status = pjsua_vid_win_set_pos(wid, &pos); 3972 4071 } else if (argc==6 && strcmp(argv[2], "resize")==0) { 3973 4072 pjsua_vid_win_id wid = atoi(argv[3]); … … 3976 4075 size.w = atoi(argv[4]); 3977 4076 size.h = atoi(argv[5]); 3978 pjsua_vid_win_set_size(wid, &size);4077 status = pjsua_vid_win_set_size(wid, &size); 3979 4078 } else if (strcmp(argv[2], "arrange")==0) { 3980 4079 arrange_window(PJSUA_INVALID_ID); 3981 4080 } else 3982 4081 goto on_error; 4082 4083 if (status != PJ_SUCCESS) { 4084 PJ_PERROR(1,(THIS_FILE, status, "Window operation error")); 4085 } 4086 3983 4087 } else if (strcmp(argv[1], "codec")==0) { 3984 4088 pjmedia_vid_codec_info ci[PJMEDIA_CODEC_MGR_MAX_CODECS]; … … 5421 5525 /* Add local account */ 5422 5526 pjsua_acc_add_local(transport_id, PJ_TRUE, &aid); 5527 if (PJMEDIA_HAS_VIDEO) { 5528 pjsua_acc_config acc_cfg; 5529 pjsua_acc_get_config(aid, &acc_cfg); 5530 app_config_init_video(&acc_cfg); 5531 pjsua_acc_modify(aid, &acc_cfg); 5532 } 5423 5533 //pjsua_acc_set_transport(aid, transport_id); 5424 5534 pjsua_acc_set_online_status(current_acc, PJ_TRUE); … … 5454 5564 /* Add local account */ 5455 5565 pjsua_acc_add_local(transport_id, PJ_TRUE, &aid); 5566 if (PJMEDIA_HAS_VIDEO) { 5567 pjsua_acc_config acc_cfg; 5568 pjsua_acc_get_config(aid, &acc_cfg); 5569 app_config_init_video(&acc_cfg); 5570 pjsua_acc_modify(aid, &acc_cfg); 5571 } 5456 5572 //pjsua_acc_set_transport(aid, transport_id); 5457 5573 pjsua_acc_set_online_status(current_acc, PJ_TRUE); … … 5580 5696 goto on_error; 5581 5697 } 5582 5583 #if PJSUA_HAS_VIDEO5584 if (app_config.vcapture_dev != PJSUA_INVALID_ID ||5585 app_config.vrender_dev != PJSUA_INVALID_ID)5586 {5587 //status = pjsua_vid_set_dev(app_config.vcapture_dev,5588 // app_config.vrender_dev);5589 PJ_TODO(vid_implement_pjsua_vid_set_dev);5590 if (status != PJ_SUCCESS)5591 goto on_error;5592 }5593 #endif5594 5698 5595 5699 return PJ_SUCCESS; -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r3849 r3850 3093 3093 3094 3094 /** 3095 * Get current config for the account. This will copy current account setting 3096 * to the specified parameter. Note that all pointers in the settings will 3097 * point to the original settings in the account and application must not 3098 * modify the values in any way. Application must also take care that these 3099 * data is only valid until the account is destroyed. 3100 * 3101 * @param acc_id The account ID. 3102 * @param acc_cfg Structure to receive the settings. 3103 * 3104 * @return PJ_SUCCESS on success, or the appropriate error code. 3105 */ 3106 PJ_DECL(pj_status_t) pjsua_acc_get_config(pjsua_acc_id acc_id, 3107 pjsua_acc_config *acc_cfg); 3108 3109 3110 /** 3095 3111 * Modify account information. 3096 3112 * -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r3841 r3850 644 644 } 645 645 646 647 /* Get config */ 648 PJ_DEF(pj_status_t) pjsua_acc_get_config(pjsua_acc_id acc_id, 649 pjsua_acc_config *acc_cfg) 650 { 651 PJ_ASSERT_RETURN(acc_id>=0 && acc_id<(int)PJ_ARRAY_SIZE(pjsua_var.acc) 652 && pjsua_var.acc[acc_id].valid, PJ_EINVAL); 653 pj_memcpy(acc_cfg, &pjsua_var.acc[acc_id].cfg, sizeof(*acc_cfg)); 654 return PJ_SUCCESS; 655 } 646 656 647 657 /*
Note: See TracChangeset
for help on using the changeset viewer.