- Timestamp:
- Jul 13, 2011 1:31:08 PM (13 years ago)
- Location:
- pjproject/branches/projects/2.0-dev
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjsip-apps/src/pjsua/pjsua_app.c
r3634 r3636 3317 3317 puts("| vid call tx on|off Enable/disable video tx for current call |"); 3318 3318 puts("| vid call add Add video stream for current call |"); 3319 puts("| vid call remove [idx] Remove video stream #idx for current call |"); 3319 puts("| vid call remove N Remove video stream #N for current call |"); 3320 puts("| vid call modify N CAP Modify capture dev of video stream #N |"); 3320 3321 puts("| vid dev list List all video devices |"); 3321 3322 puts("| vid dev refresh Refresh video device list |"); … … 3757 3758 } else if (strcmp(argv[1], "call")==0) { 3758 3759 pjsua_call_vid_strm_op_param param; 3759 pj_bool_t tx = (strcmp(argv[2], "tx") == 0); 3760 if ( tx) {3760 3761 if (strcmp(argv[2], "rx")==0) { 3761 3762 pj_bool_t on = (strcmp(argv[3], "on") == 0); 3762 } 3763 3764 if (strcmp(argv[2], "add")==0) { 3763 PJ_TODO(vid_enable_disable_video_RX_on_call); 3764 PJ_LOG(1,(THIS_FILE, "Not implemented")); 3765 } 3766 else if (strcmp(argv[2], "tx")==0) { 3767 pj_bool_t on = (strcmp(argv[3], "on") == 0); 3768 pjsua_call_vid_strm_op op = on? PJSUA_CALL_VID_STRM_START_TRANSMIT : 3769 PJSUA_CALL_VID_STRM_STOP_TRANSMIT; 3770 pjsua_call_set_vid_strm(current_call, op, NULL); 3771 } 3772 else if (strcmp(argv[2], "add")==0) { 3765 3773 pjsua_call_set_vid_strm(current_call, PJSUA_CALL_VID_STRM_ADD, NULL); 3766 3774 } 3767 if (strcmp(argv[2], "remove")==0) { 3775 else if (strcmp(argv[2], "disable")==0 || strcmp(argv[2], "enable")==0) { 3776 pj_bool_t enable = (strcmp(argv[2], "enable") == 0); 3777 pjsua_call_vid_strm_op op = enable? PJSUA_CALL_VID_STRM_ENABLE : 3778 PJSUA_CALL_VID_STRM_DISABLE; 3768 3779 param.med_idx = argc >= 4? atoi(argv[3]) : -1; 3769 pjsua_call_set_vid_strm(current_call, PJSUA_CALL_VID_STRM_REMOVE, ¶m); 3770 } 3771 PJ_TODO(vid_enable_disable_video_on_call); 3772 PJ_LOG(1,(THIS_FILE, "Not implemented")); 3780 pjsua_call_set_vid_strm(current_call, op, ¶m); 3781 } 3782 else if (strcmp(argv[2], "set-cap-dev")==0) { 3783 param.med_idx = argc >= 4? atoi(argv[3]) : -1; 3784 param.cap_dev = argc >= 5? atoi(argv[4]) : PJMEDIA_VID_DEFAULT_CAPTURE_DEV; 3785 pjsua_call_set_vid_strm(current_call, PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV, ¶m); 3786 } 3773 3787 } else if (strcmp(argv[1], "dev")==0) { 3774 3788 if (strcmp(argv[2], "list")==0) { -
pjproject/branches/projects/2.0-dev/pjsip/include/pjsua-lib/pjsua.h
r3634 r3636 382 382 383 383 /** 384 * Remove an existing video stream. 385 */ 386 PJSUA_CALL_VID_STRM_REMOVE, 387 388 /** 389 * Modify an existing video stream, such as changing the capture device. 390 */ 391 PJSUA_CALL_VID_STRM_MODIFY, 384 * Disable/remove an existing video stream. 385 */ 386 PJSUA_CALL_VID_STRM_DISABLE, 387 388 /** 389 * Enable video stream. 390 */ 391 PJSUA_CALL_VID_STRM_ENABLE, 392 393 /** 394 * Changing capture device of a video stream. 395 */ 396 PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV, 392 397 393 398 /** … … 425 430 * 426 431 * This field is valid for the following video stream operations: 427 * PJSUA_CALL_VID_STRM_ADD, PJSUA_CALL_VID_STRM_ MODIFY, and432 * PJSUA_CALL_VID_STRM_ADD, PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV, and 428 433 * PJSUA_CALL_VID_STRM_START_TRANSMIT. 429 434 */ -
pjproject/branches/projects/2.0-dev/pjsip/src/pjsua-lib/pjsua_vid.c
r3634 r3636 573 573 unsigned i, j; 574 574 575 status = pjmedia_vid_dev_get_info(acc->cfg.vid_cap_dev, &dev_info); 575 status = pjmedia_vid_dev_get_info(call_med->strm.v.cap_dev, 576 &dev_info); 576 577 if (status != PJ_SUCCESS) 577 578 return status; … … 740 741 } 741 742 742 if ( acc->cfg.vid_out_auto_transmit) {743 if (!acc->cfg.vid_out_auto_transmit) { 743 744 status = pjmedia_vid_stream_pause(call_med->strm.v.stream, 744 745 PJMEDIA_DIR_ENCODING); … … 1113 1114 pjmedia_sdp_media *sdp_m; 1114 1115 pjmedia_transport_info tpinfo; 1115 pjmedia_vid_dev_info vinfo;1116 1116 unsigned active_cnt; 1117 1117 pj_status_t status; … … 1124 1124 if (active_cnt == acc_cfg->max_video_cnt) 1125 1125 return PJ_ETOOMANY; 1126 1127 /* Verify the capture device */1128 status = pjmedia_vid_dev_get_info(cap_dev, &vinfo);1129 if (status != PJ_SUCCESS)1130 return status;1131 1132 if (vinfo.dir != PJMEDIA_DIR_CAPTURE)1133 return PJ_EINVAL;1134 1135 cap_dev = vinfo.id;1136 1126 1137 1127 /* Get active local SDP */ … … 1194 1184 1195 1185 1196 /* Remove a video stream from a call */ 1197 static pj_status_t call_remove_video(pjsua_call *call, 1198 int med_idx) 1186 /* Modify a video stream from a call, i.e: enable/disable */ 1187 static pj_status_t call_modify_video(pjsua_call *call, 1188 int med_idx, 1189 pj_bool_t enable) 1199 1190 { 1200 1191 pjsua_call_media *call_med; … … 1219 1210 return PJ_EINVAL; 1220 1211 1221 /* Verify if the stream already disabled */ 1222 if (call_med->dir != PJMEDIA_DIR_NONE) 1212 /* Verify if the stream already enabled/disabled */ 1213 if (( enable && call_med->dir != PJMEDIA_DIR_NONE) || 1214 (!enable && call_med->dir == PJMEDIA_DIR_NONE)) 1223 1215 return PJ_SUCCESS; 1224 1225 /* Mark media transport to disabled */1226 // Don't close this here, as SDP negotiation has not been1227 // done and stream may be still active.1228 call_med->tp_st = PJSUA_MED_TP_DISABLED;1229 1216 1230 1217 /* Get active local SDP */ … … 1234 1221 1235 1222 pj_assert(med_idx < (int)sdp->media_count); 1236 sdp->media[med_idx]->desc.port = 0; 1223 1224 if (enable) { 1225 pjsua_acc_config *acc_cfg = &pjsua_var.acc[call->acc_id].cfg; 1226 pj_pool_t *pool = call->inv->pool_prov; 1227 pjmedia_sdp_media *sdp_m; 1228 pjmedia_transport_info tpinfo; 1229 1230 status = pjsua_call_media_init(call_med, PJMEDIA_TYPE_VIDEO, 1231 &acc_cfg->rtp_cfg, call->secure_level, 1232 NULL); 1233 if (status != PJ_SUCCESS) 1234 goto on_error; 1235 1236 /* Init transport media */ 1237 status = pjmedia_transport_media_create(call_med->tp, pool, 0, 1238 NULL, call_med->idx); 1239 if (status != PJ_SUCCESS) 1240 goto on_error; 1241 1242 call_med->tp_st = PJSUA_MED_TP_INIT; 1243 1244 /* Get transport address info */ 1245 pjmedia_transport_info_init(&tpinfo); 1246 pjmedia_transport_get_info(call_med->tp, &tpinfo); 1247 1248 /* Create SDP media line */ 1249 status = pjmedia_endpt_create_video_sdp(pjsua_var.med_endpt, pool, 1250 &tpinfo.sock_info, 0, &sdp_m); 1251 if (status != PJ_SUCCESS) 1252 goto on_error; 1253 1254 sdp->media[med_idx] = sdp_m; 1255 1256 /* Update SDP media line by media transport */ 1257 status = pjmedia_transport_encode_sdp(call_med->tp, pool, 1258 sdp, NULL, call_med->idx); 1259 if (status != PJ_SUCCESS) 1260 goto on_error; 1261 1262 on_error: 1263 if (status != PJ_SUCCESS) { 1264 if (call_med->tp) { 1265 pjmedia_transport_close(call_med->tp); 1266 call_med->tp = call_med->tp_orig = NULL; 1267 } 1268 return status; 1269 } 1270 } else { 1271 /* Mark media transport to disabled */ 1272 // Don't close this here, as SDP negotiation has not been 1273 // done and stream may be still active. 1274 call_med->tp_st = PJSUA_MED_TP_DISABLED; 1275 1276 /* Disable the stream in SDP by setting port to 0 */ 1277 sdp->media[med_idx]->desc.port = 0; 1278 } 1237 1279 1238 1280 status = call_reoffer_sdp(call->index, sdp); … … 1244 1286 1245 1287 1246 /* Modifya video stream in a call */1247 static pj_status_t call_ modify_video(pjsua_call *call,1248 int med_idx,1249 pjmedia_vid_dev_index cap_dev)1288 /* Change capture device of a video stream in a call */ 1289 static pj_status_t call_change_cap_dev(pjsua_call *call, 1290 int med_idx, 1291 pjmedia_vid_dev_index cap_dev) 1250 1292 { 1251 1293 pjsua_call_media *call_med; … … 1275 1317 /* Verify the capture device */ 1276 1318 status = pjmedia_vid_dev_get_info(cap_dev, &info); 1277 if (status != PJ_SUCCESS) 1278 return status; 1279 1280 if (info.dir != PJMEDIA_DIR_CAPTURE) 1319 if (status != PJ_SUCCESS || info.dir != PJMEDIA_DIR_CAPTURE) 1281 1320 return PJ_EINVAL; 1282 1283 cap_dev = info.id;1284 1321 1285 1322 /* The specified capture device is being used already */ … … 1401 1438 } 1402 1439 1403 /* Apply the new capture device*/1404 status = call_ modify_video(call, med_idx, cap_dev);1440 /* Apply the capture device, it may be changed! */ 1441 status = call_change_cap_dev(call, med_idx, cap_dev); 1405 1442 if (status != PJ_SUCCESS) 1406 1443 return status; … … 1479 1516 } 1480 1517 1481 /* Get real capture ID, if set to PJMEDIA_VID_DEFAULT_CAPTURE_DEV */ 1518 /* If set to PJMEDIA_VID_DEFAULT_CAPTURE_DEV, replace it with 1519 * account default video capture device. 1520 */ 1482 1521 if (param_.cap_dev == PJMEDIA_VID_DEFAULT_CAPTURE_DEV) { 1483 pjmedia_vid_dev_info info; 1484 pjmedia_vid_dev_get_info(param_.cap_dev, &info); 1485 param_.cap_dev = info.id; 1522 pjsua_acc_config *acc_cfg = &pjsua_var.acc[call->acc_id].cfg; 1523 param_.cap_dev = acc_cfg->vid_cap_dev; 1524 1525 /* If the account default video capture device is 1526 * PJMEDIA_VID_DEFAULT_CAPTURE_DEV, replace it with 1527 * global default video capture device. 1528 */ 1529 if (param_.cap_dev == PJMEDIA_VID_DEFAULT_CAPTURE_DEV) { 1530 pjmedia_vid_dev_info info; 1531 pjmedia_vid_dev_get_info(param_.cap_dev, &info); 1532 pj_assert(info.dir == PJMEDIA_DIR_CAPTURE); 1533 param_.cap_dev = info.id; 1534 } 1486 1535 } 1487 1536 … … 1490 1539 status = call_add_video(call, param_.cap_dev); 1491 1540 break; 1492 case PJSUA_CALL_VID_STRM_ REMOVE:1493 status = call_ remove_video(call, param_.med_idx);1541 case PJSUA_CALL_VID_STRM_ENABLE: 1542 status = call_modify_video(call, param_.med_idx, PJ_TRUE); 1494 1543 break; 1495 case PJSUA_CALL_VID_STRM_MODIFY: 1496 status = call_modify_video(call, param_.med_idx, param_.cap_dev); 1544 case PJSUA_CALL_VID_STRM_DISABLE: 1545 status = call_modify_video(call, param_.med_idx, PJ_FALSE); 1546 break; 1547 case PJSUA_CALL_VID_STRM_CHANGE_CAP_DEV: 1548 status = call_change_cap_dev(call, param_.med_idx, param_.cap_dev); 1497 1549 break; 1498 1550 case PJSUA_CALL_VID_STRM_START_TRANSMIT:
Note: See TracChangeset
for help on using the changeset viewer.