Changeset 4834 for pjproject/trunk
- Timestamp:
- May 5, 2014 7:47:48 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-videodev/ios_dev.m
r4824 r4834 253 253 qdi = &qf->dev_info[i]; 254 254 qdi->info.fmt_cnt = PJ_ARRAY_SIZE(ios_fmts); 255 qdi->info.caps |= PJMEDIA_VID_DEV_CAP_FORMAT; 255 qdi->info.caps |= PJMEDIA_VID_DEV_CAP_FORMAT | 256 PJMEDIA_VID_DEV_CAP_OUTPUT_RESIZE | 257 PJMEDIA_VID_DEV_CAP_OUTPUT_POSITION | 258 PJMEDIA_VID_DEV_CAP_OUTPUT_HIDE | 259 PJMEDIA_VID_DEV_CAP_ORIENTATION; 256 260 257 261 for (l = 0; l < PJ_ARRAY_SIZE(ios_fmts); l++) { … … 575 579 576 580 /* Native preview */ 577 if ((param->flags & PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW) && 578 param->native_preview) 579 { 580 /* Preview layer instantiation should be in main thread! */ 581 dispatch_async(dispatch_get_main_queue(), ^{ 582 /* Create view */ 583 ios_init_view(strm); 584 585 /* Create preview layer */ 586 AVCaptureVideoPreviewLayer *previewLayer = 587 [AVCaptureVideoPreviewLayer layerWithSession: strm->cap_session]; 588 589 /* Attach preview layer to a UIView */ 590 CGRect r = strm->render_view.bounds; 591 previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; 592 previewLayer.frame = r; 593 [[strm->render_view layer] addSublayer:previewLayer]; 594 595 NSLog(@"Native preview initialized."); 596 }); 581 if (param->flags & PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW) { 582 ios_stream_set_cap(&strm->base, PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW, 583 ¶m->native_preview); 597 584 } 598 585 … … 677 664 678 665 switch (cap) { 666 /* Native preview */ 667 case PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW: 668 { 669 pj_bool_t native_preview = *((pj_bool_t *)pval); 670 671 if (!strm->cap_session) return PJ_EINVAL; 672 673 if (!native_preview || strm->render_view) 674 return PJ_SUCCESS; 675 676 /* Create view */ 677 ios_init_view(strm); 678 679 /* Preview layer instantiation should be in main thread! */ 680 dispatch_async(dispatch_get_main_queue(), ^{ 681 /* Create preview layer */ 682 AVCaptureVideoPreviewLayer *previewLayer = 683 [AVCaptureVideoPreviewLayer layerWithSession:strm->cap_session]; 684 685 /* Attach preview layer to a UIView */ 686 CGRect r = strm->render_view.bounds; 687 previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; 688 previewLayer.frame = r; 689 [[strm->render_view layer] addSublayer:previewLayer]; 690 }); 691 692 NSLog(@"Native preview initialized."); 693 694 return PJ_SUCCESS; 695 } 696 679 697 /* Fast switch */ 680 698 case PJMEDIA_VID_DEV_CAP_SWITCH: … … 907 925 908 926 if (stream->render_view) { 927 UIView *view = stream->render_view; 909 928 dispatch_async(dispatch_get_main_queue(), 910 929 ^{ 911 [ stream->render_view removeFromSuperview];912 [ stream->render_view release];930 [view removeFromSuperview]; 931 [view release]; 913 932 }); 914 933 stream->render_view = NULL;
Note: See TracChangeset
for help on using the changeset viewer.