Changeset 5002
- Timestamp:
- Mar 19, 2015 7:03:39 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-videodev/ios_dev.m
r4909 r5002 50 50 }; 51 51 52 typedef struct ios_supported_size 53 { 54 pj_size_t supported_size_w; 55 pj_size_t supported_size_h; 56 NSString *preset_str; 57 } ios_supported_size; 58 59 /* Set the preset_str on set_preset_str method. */ 60 static ios_supported_size ios_sizes[] = 61 { 62 { 352, 288, NULL }, 63 { 640, 480, NULL }, 64 { 1280, 720, NULL }, 65 { 1920, 1080, NULL } 66 }; 67 52 68 /* qt device info */ 53 69 struct ios_dev_info … … 170 186 }; 171 187 188 static void set_preset_str() 189 { 190 ios_sizes[0].preset_str = AVCaptureSessionPreset352x288; 191 ios_sizes[1].preset_str = AVCaptureSessionPreset640x480; 192 ios_sizes[2].preset_str = AVCaptureSessionPreset1280x720; 193 ios_sizes[3].preset_str = AVCaptureSessionPreset1920x1080; 194 } 172 195 173 196 /**************************************************************************** … … 199 222 unsigned i, l, first_idx, front_idx = -1; 200 223 enum { MAX_DEV_COUNT = 8 }; 224 225 set_preset_str(); 201 226 202 227 /* Initialize input and output devices here */ … … 269 294 continue; 270 295 } 296 297 if (qdi->info.dir == PJMEDIA_DIR_RENDER) { 298 fmt = &qdi->info.fmt[qdi->info.fmt_cnt++]; 299 pjmedia_format_init_video(fmt, 300 ios_fmts[l].pjmedia_format, 301 DEFAULT_WIDTH, 302 DEFAULT_HEIGHT, 303 DEFAULT_FPS, 1); 304 } else { 305 int m; 306 AVCaptureDevice *dev = qdi->dev; 271 307 272 fmt = &qdi->info.fmt[qdi->info.fmt_cnt++]; 273 pjmedia_format_init_video(fmt, 274 ios_fmts[l].pjmedia_format, 275 DEFAULT_WIDTH, 276 DEFAULT_HEIGHT, 277 DEFAULT_FPS, 1); 308 /* Set supported size for capture device */ 309 for(m = 0; m < PJ_ARRAY_SIZE(ios_sizes) && 310 qdi->info.fmt_cnt<PJMEDIA_VID_DEV_INFO_FMT_CNT; 311 m++) 312 { 313 if ([dev supportsAVCaptureSessionPreset: 314 ios_sizes[m].preset_str]) 315 { 316 fmt = &qdi->info.fmt[qdi->info.fmt_cnt++]; 317 pjmedia_format_init_video(fmt, 318 ios_fmts[l].pjmedia_format, 319 ios_sizes[m].supported_size_w, 320 ios_sizes[m].supported_size_h, 321 DEFAULT_FPS, 1); 322 } 323 } 324 } 278 325 } 279 326 } … … 576 623 577 624 if (param->dir & PJMEDIA_DIR_CAPTURE) { 578 NSString *size_preset_str[] = {579 AVCaptureSessionPreset352x288,580 AVCaptureSessionPreset640x480,581 AVCaptureSessionPreset1280x720,582 AVCaptureSessionPreset1920x1080583 };584 pj_size_t supported_size_w[] = { 352, 640, 1280, 1920 };585 pj_size_t supported_size_h[] = { 288, 480, 720, 1080 };586 pj_size_t supported_size[] = { 352*288, 640*480, 1280*720, 1920*1080 };587 pj_size_t requested_size = strm->size.w * strm->size.h;588 625 int i; 589 626 590 627 /* Create capture stream here */ 591 628 strm->cap_session = [[AVCaptureSession alloc] init]; … … 594 631 goto on_error; 595 632 } 596 597 633 AVCaptureDevice *dev = qf->dev_info[param->cap_id].dev; 598 599 /* Find the closest supported size */ 600 for(i = PJ_ARRAY_SIZE(supported_size)-1; i > 0; --i) { 601 if (![dev supportsAVCaptureSessionPreset: size_preset_str[i]]) 602 continue; 603 if (supported_size[i-1] < requested_size) 634 635 for (i = PJ_ARRAY_SIZE(ios_sizes)-1; i > 0; --i) { 636 if ((vfd->size.w == ios_sizes[i].supported_size_w) && 637 (vfd->size.h == ios_sizes[i].supported_size_h)) 638 { 604 639 break; 605 } 606 strm->cap_session.sessionPreset = size_preset_str[i]; 607 vfd->size.w = supported_size_w[i]; 608 vfd->size.h = supported_size_h[i]; 640 } 641 } 642 643 strm->cap_session.sessionPreset = ios_sizes[i].preset_str; 644 645 vfd->size.w = ios_sizes[i].supported_size_w; 646 vfd->size.h = ios_sizes[i].supported_size_h; 609 647 strm->size = vfd->size; 610 648 strm->bytes_per_row = strm->size.w * vfi->bpp / 8; … … 980 1018 { 981 1019 struct ios_stream *stream = (struct ios_stream*)strm; 982 1020 983 1021 if (stream->frame_size >= frame->size) 984 1022 pj_memcpy(stream->render_buf, frame->buf, frame->size);
Note: See TracChangeset
for help on using the changeset viewer.