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}
diff --git a/AUTHORS b/AUTHORS
index 6ac0fa9..6ae4803 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -28,6 +28,7 @@
 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>
diff --git a/modules/video_capture/objc/rtc_video_capture_objc.mm b/modules/video_capture/objc/rtc_video_capture_objc.mm
index 92bfd64..61ef8db 100644
--- a/modules/video_capture/objc/rtc_video_capture_objc.mm
+++ b/modules/video_capture/objc/rtc_video_capture_objc.mm
@@ -59,7 +59,7 @@
     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 @@
     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);