From 9e31cca8f49cddab997843ffb8a62df7af9cad78 Mon Sep 17 00:00:00 2001 From: magjed Date: Sat, 8 Oct 2016 02:57:50 -0700 Subject: [PATCH] iOS: Fix rotation bug for back camera The rotation is currently incorrect for the back camera in landscape mode. The reason is that device rotation needs to be reversed for the back camera compared to the front camera. The camera sensor can also be mounted with a specific orientation. So when front camera rotation goes through: 0->90->180->270, back camera rotation goes in reverse: 180->90->0->270. BUG=b/31984246,b/30651939 Review-Url: https://codereview.webrtc.org/2401033002 Cr-Commit-Position: refs/heads/master@{#14580} --- .../sdk/objc/Framework/Classes/avfoundationvideocapturer.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm b/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm index 547cc57ca4..47180934b2 100644 --- a/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm +++ b/webrtc/sdk/objc/Framework/Classes/avfoundationvideocapturer.mm @@ -630,10 +630,12 @@ static BOOL SetFormatForCaptureDevice(AVCaptureDevice *device, _rotation = webrtc::kVideoRotation_270; break; case UIDeviceOrientationLandscapeLeft: - _rotation = webrtc::kVideoRotation_180; + _rotation = _capturer->GetUseBackCamera() ? webrtc::kVideoRotation_0 + : webrtc::kVideoRotation_180; break; case UIDeviceOrientationLandscapeRight: - _rotation = webrtc::kVideoRotation_0; + _rotation = _capturer->GetUseBackCamera() ? webrtc::kVideoRotation_180 + : webrtc::kVideoRotation_0; break; case UIDeviceOrientationFaceUp: case UIDeviceOrientationFaceDown: