Changeset 5125 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_vid.c
- Timestamp:
- Jul 3, 2015 6:21:30 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_vid.c
r5118 r5125 227 227 228 228 /* 229 * Set the orientation of the video device. 230 */ 231 PJ_DEF(pj_status_t) pjsua_vid_dev_set_orient( pjmedia_vid_dev_index id, 232 pjmedia_orient orient) 233 { 234 pjsua_vid_win *w; 235 pjmedia_vid_dev_stream *cap_dev; 229 * Set the capability of the video device. 230 */ 231 PJ_DEF(pj_status_t) pjsua_vid_dev_set_setting( pjmedia_vid_dev_index id, 232 pjmedia_vid_dev_cap cap, 233 const void *pval, 234 pj_bool_t keep) 235 { 236 pj_status_t status = PJ_SUCCESS; 236 237 pjsua_vid_win_id wid = vid_preview_get_win(id, PJ_FALSE); 237 238 238 if (wid == PJSUA_INVALID_ID) { 239 PJ_LOG(3, (THIS_FILE, "Unable to set orientation for video dev %d: " 240 "device not active", id)); 241 return PJ_ENOTFOUND; 242 } 243 244 w = &pjsua_var.win[wid]; 239 if (wid != PJSUA_INVALID_ID) { 240 pjsua_vid_win *w; 241 pjmedia_vid_dev_stream *cap_dev; 242 243 w = &pjsua_var.win[wid]; 244 cap_dev = pjmedia_vid_port_get_stream(w->vp_cap); 245 246 status = pjmedia_vid_dev_stream_set_cap(cap_dev, cap, pval); 247 if (status != PJ_SUCCESS) 248 return status; 249 } else { 250 status = PJ_ENOTFOUND; 251 } 252 253 if (keep) { 254 pjmedia_vid_dev_info info; 255 256 status = pjmedia_vid_dev_get_info(id, &info); 257 if (status != PJ_SUCCESS || (info.dir & PJMEDIA_DIR_CAPTURE) == 0) 258 return status; 245 259 246 cap_dev = pjmedia_vid_port_get_stream(w->vp_cap); 247 248 return pjmedia_vid_dev_stream_set_cap(cap_dev, 249 PJMEDIA_VID_DEV_CAP_ORIENTATION, 250 &orient); 260 /* Get real capture ID, if set to PJMEDIA_VID_DEFAULT_CAPTURE_DEV */ 261 id = info.id; 262 status = pjmedia_vid_dev_param_set_cap(&pjsua_var.vid_param[id], 263 cap, pval); 264 if (status == PJ_SUCCESS) { 265 pjsua_var.vid_caps[id] |= cap; 266 } 267 } 268 269 return status; 270 } 271 272 /* 273 * Get the value of the video device capability. 274 */ 275 PJ_DEF(pj_status_t) pjsua_vid_dev_get_setting( pjmedia_vid_dev_index id, 276 pjmedia_vid_dev_cap cap, 277 void *pval) 278 { 279 pj_status_t status = PJ_SUCCESS; 280 pjsua_vid_win_id wid = vid_preview_get_win(id, PJ_FALSE); 281 282 if (wid != PJSUA_INVALID_ID) { 283 pjsua_vid_win *w; 284 pjmedia_vid_dev_stream *cap_dev; 285 286 w = &pjsua_var.win[wid]; 287 cap_dev = pjmedia_vid_port_get_stream(w->vp_cap); 288 289 status = pjmedia_vid_dev_stream_get_cap(cap_dev, cap, pval); 290 } else { 291 pjmedia_vid_dev_info info; 292 293 status = pjmedia_vid_dev_get_info(id, &info); 294 if (status != PJ_SUCCESS) 295 return status; 296 297 /* Get real device ID, if set to default device */ 298 id = info.id; 299 300 if ((pjsua_var.vid_caps[id] & cap) != 0) { 301 status = pjmedia_vid_dev_param_get_cap(&pjsua_var.vid_param[id], 302 cap, pval); 303 } else { 304 status = PJ_ENOTFOUND; 305 } 306 } 307 308 return status; 251 309 } 252 310 … … 614 672 vp_param.active = PJ_TRUE; 615 673 vp_param.vidparam.dir = PJMEDIA_DIR_CAPTURE; 616 if (fmt) 674 675 /* Update the video setting with user preference */ 676 #define update_param(cap, field) \ 677 if ((pjsua_var.vid_caps[cap_id] & cap) && (vdi.caps & cap)) { \ 678 vp_param.vidparam.flags |= cap; \ 679 pj_memcpy(&vp_param.vidparam.field, \ 680 &pjsua_var.vid_param[cap_id].field, \ 681 sizeof(vp_param.vidparam.field)); \ 682 } 683 684 if (fmt) { 617 685 vp_param.vidparam.fmt = *fmt; 686 } else { 687 update_param(PJMEDIA_VID_DEV_CAP_FORMAT, fmt); 688 } 689 690 update_param(PJMEDIA_VID_DEV_CAP_ORIENTATION, orient); 691 692 #undef update_param 618 693 619 694 status = pjmedia_vid_port_create(w->pool, &vp_param, &w->vp_cap);
Note: See TracChangeset
for help on using the changeset viewer.