- Timestamp:
- Nov 18, 2019 6:24:11 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-videodev/darwin_dev.m
r5874 r6109 295 295 first_idx = qf->dev_count; 296 296 if (NSClassFromString(@"AVCaptureSession")) { 297 NSArray *dev_list; 298 299 #if TARGET_OS_IPHONE && defined(__IPHONE_10_0) 300 if (NSClassFromString(@"AVCaptureDeviceTypeBuiltInWideAngleCamera")) { 301 /* Starting in iOS 10, [AVCaptureDevice devices] is deprecated 302 * and replaced by AVCaptureDeviceDiscoverySession. 297 NSArray *dev_list = NULL; 298 299 #if (TARGET_OS_IPHONE && defined(__IPHONE_10_0)) || \ 300 (TARGET_OS_OSX && defined(__MAC_10_15)) 301 if (__builtin_available(macOS 10.15, iOS 10.0, *)) { 302 /* Starting in iOS 10 and macOS 10.15, [AVCaptureDevice devices] 303 * is deprecated and replaced by AVCaptureDeviceDiscoverySession. 303 304 */ 304 305 AVCaptureDeviceDiscoverySession *dds; 305 306 NSArray<AVCaptureDeviceType> *dev_types = 306 @[AVCaptureDeviceTypeBuiltInWideAngleCamera, 307 AVCaptureDeviceTypeBuiltInDuoCamera, 308 AVCaptureDeviceTypeBuiltInTelephotoCamera]; 307 @[AVCaptureDeviceTypeBuiltInWideAngleCamera 308 #if TARGET_OS_IPHONE && defined(__IPHONE_10_0) 309 , AVCaptureDeviceTypeBuiltInDuoCamera 310 , AVCaptureDeviceTypeBuiltInTelephotoCamera 311 #endif 312 ]; 309 313 310 314 dds = [AVCaptureDeviceDiscoverySession … … 315 319 dev_list = [dds devices]; 316 320 } else { 321 #if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_15 317 322 dev_list = [AVCaptureDevice devices]; 323 #endif 318 324 } 319 325 #else … … 563 569 pj_uint8_t *p, *p_end, *Y, *U, *V; 564 570 pj_size_t p_len; 565 /* Image stride is not always equal to the image width. I.e on Ipad 566 * air, at 352*288 the image stride is 384. 571 pj_size_t wxh = stream->vid_size.w * stream->vid_size.h; 572 /* Image stride is not always equal to the image width. 573 * For example, resolution 352*288 can have a stride of 384. 567 574 */ 568 575 pj_size_t stride = CVPixelBufferGetBytesPerRowOfPlane(img, 0); 576 /* Image height is not always equal to the video resolution. 577 * For example, resolution 352*288 can have a height of 264. 578 */ 569 579 pj_size_t height = CVPixelBufferGetHeight(img); 570 580 pj_bool_t need_clip; 571 581 572 582 /* Auto detect rotation */ 573 if (height != stream->vid_size.h) { 583 if ((stream->vid_size.w > stream->vid_size.h && stride < height) || 584 (stream->vid_size.h > stream->vid_size.w && stride > height)) 585 { 586 pj_size_t w = stream->vid_size.w; 574 587 stream->vid_size.w = stream->vid_size.h; 575 stream->vid_size.h = height;588 stream->vid_size.h = w; 576 589 } 577 590 … … 580 593 p = (pj_uint8_t*)CVPixelBufferGetBaseAddressOfPlane(img, 0); 581 594 582 p_len = stream->vid_size.w * stream->vid_size.h;595 p_len = stream->vid_size.w * height; 583 596 Y = (pj_uint8_t*)stream->capture_buf; 584 U = Y + p_len;585 V = U + p_len/4;597 U = Y + wxh; 598 V = U + wxh/4; 586 599 587 600 if (!need_clip) { 588 601 pj_memcpy(Y, p, p_len); 602 Y += p_len; 589 603 } else { 590 604 int i = 0; 591 for (; i < stream->vid_size.h; ++i) {605 for (; i < height; ++i) { 592 606 pj_memcpy(Y, p, stream->vid_size.w); 593 607 Y += stream->vid_size.w; 594 608 p += stride; 595 609 } 610 } 611 612 if (stream->vid_size.h > height) { 613 pj_memset(Y, 16, (stream->vid_size.h - height) * 614 stream->vid_size.w); 596 615 } 597 616 … … 607 626 } else { 608 627 int i = 0; 609 for (;i< (stream->vid_size.h)/2;++i) {628 for (;i<height/2;++i) { 610 629 int y=0; 611 630 for (;y<(stream->vid_size.w)/2;++y) { … … 615 634 p += (stride - stream->vid_size.w); 616 635 } 636 } 637 638 if (stream->vid_size.h > height) { 639 pj_size_t UV_size = (stream->vid_size.h - height) * 640 stream->vid_size.w / 4; 641 pj_memset(U, 0x80, UV_size); 642 pj_memset(V, 0x80, UV_size); 617 643 } 618 644 }
Note: See TracChangeset
for help on using the changeset viewer.