Fixed video capturing on Mac.

On specific Macbooks (no exact pattern, unfortunately),
video from an integrated camera is not captured.
Changed AVCaptureVideoDataOutput pixel format configuration
as in Chromium which solved the problem.
https://chromium.googlesource.com/chromium/src/media/+/master/capture/video/mac/video_capture_device_avfoundation_mac.mm
FourCharCode best_fourcc = kCVPixelFormatType_422YpCbCr8;

Tested with external cameras as well.

Bug: webrtc:8958
Change-Id: Ib99382b38d1914e2963761a33df310024524c9a4
Reviewed-on: https://webrtc-review.googlesource.com/58880
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22709}
This commit is contained in:
Maksim Khobat 2018-02-28 17:57:23 +03:00 committed by Commit Bot
parent 8487988b28
commit 3cfe9e167e
2 changed files with 9 additions and 13 deletions

View File

@ -28,6 +28,7 @@ Jens Nielsen <jens.nielsen@berotec.se>
Jiawei Ou <jiawei.ou@gmail.com>
Jie Mao <maojie0924@gmail.com>
Luke Weber <luke.weber@gmail.com>
Maksim Khobat <maksimkhobat@gmail.com>
Mallikarjuna Rao V <vm.arjun@samsung.com>
Manish Jethani <manish.jethani@gmail.com>
Martin Storsjo <martin@martin.st>

View File

@ -59,7 +59,7 @@ using namespace webrtc::videocapturemodule;
AVCaptureVideoDataOutput* captureOutput = [[AVCaptureVideoDataOutput alloc] init];
NSString* key = (NSString*)kCVPixelBufferPixelFormatTypeKey;
NSNumber* val = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_420YpCbCr8BiPlanarFullRange];
NSNumber* val = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_422YpCbCr8];
NSDictionary* videoSettings = [NSDictionary dictionaryWithObject:val forKey:key];
captureOutput.videoSettings = videoSettings;
@ -319,21 +319,16 @@ using namespace webrtc::videocapturemodule;
return;
}
const int kYPlaneIndex = 0;
const int kUVPlaneIndex = 1;
uint8_t* baseAddress = (uint8_t*)CVPixelBufferGetBaseAddressOfPlane(videoFrame, kYPlaneIndex);
size_t yPlaneBytesPerRow = CVPixelBufferGetBytesPerRowOfPlane(videoFrame, kYPlaneIndex);
size_t yPlaneHeight = CVPixelBufferGetHeightOfPlane(videoFrame, kYPlaneIndex);
size_t uvPlaneBytesPerRow = CVPixelBufferGetBytesPerRowOfPlane(videoFrame, kUVPlaneIndex);
size_t uvPlaneHeight = CVPixelBufferGetHeightOfPlane(videoFrame, kUVPlaneIndex);
size_t frameSize = yPlaneBytesPerRow * yPlaneHeight + uvPlaneBytesPerRow * uvPlaneHeight;
uint8_t* baseAddress = (uint8_t*)CVPixelBufferGetBaseAddress(videoFrame);
const size_t width = CVPixelBufferGetWidth(videoFrame);
const size_t height = CVPixelBufferGetHeight(videoFrame);
const size_t frameSize = width * height * 2;
VideoCaptureCapability tempCaptureCapability;
tempCaptureCapability.width = CVPixelBufferGetWidth(videoFrame);
tempCaptureCapability.height = CVPixelBufferGetHeight(videoFrame);
tempCaptureCapability.width = width;
tempCaptureCapability.height = height;
tempCaptureCapability.maxFPS = _capability.maxFPS;
tempCaptureCapability.videoType = VideoType::kNV12;
tempCaptureCapability.videoType = VideoType::kUYVY;
_owner->IncomingFrame(baseAddress, frameSize, tempCaptureCapability, 0);