Chromium Code Reviews| Index: webrtc/sdk/objc/Framework/Classes/RTCCameraPreviewView.m |
| diff --git a/webrtc/sdk/objc/Framework/Classes/RTCCameraPreviewView.m b/webrtc/sdk/objc/Framework/Classes/RTCCameraPreviewView.m |
| index 659973ff1804c280306221ff88a706dc9252f4b1..738da4700b6b0cbde0796ff0f2be94a8368f0c08 100644 |
| --- a/webrtc/sdk/objc/Framework/Classes/RTCCameraPreviewView.m |
| +++ b/webrtc/sdk/objc/Framework/Classes/RTCCameraPreviewView.m |
| @@ -11,12 +11,14 @@ |
| #import "WebRTC/RTCCameraPreviewView.h" |
| #import <AVFoundation/AVFoundation.h> |
| +#import <UIKit/UIKit.h> |
| #import "RTCDispatcher+Private.h" |
| @implementation RTCCameraPreviewView |
| @synthesize captureSession = _captureSession; |
| +@synthesize shouldAutoRotate = _shouldAutoRotate; |
| + (Class)layerClass { |
| return [AVCaptureVideoPreviewLayer class]; |
| @@ -34,6 +36,38 @@ - (void)setCaptureSession:(AVCaptureSession *)captureSession { |
| }]; |
| } |
| +- (void) setShouldAutoRotate:(BOOL)shouldAutoRotate { |
|
daniela-webrtc
2017/04/06 09:45:37
Remove space.
Hint: use `git cl format before` sub
tkchin_webrtc
2017/04/06 17:39:22
Is that what your team has decided on now? Is ther
meetAkshay99
2017/04/07 05:19:29
I tried that but got following error:
YAML:8:11: e
|
| + if (shouldAutoRotate) { |
|
daniela-webrtc
2017/04/06 09:45:37
You are not assigning the synthesized ivar _should
meetAkshay99
2017/04/06 10:24:34
My bad. Yes thats required.
|
| + [[NSNotificationCenter defaultCenter] addObserver:self |
|
daniela-webrtc
2017/04/06 09:45:37
This seems like overhead - (Un)Registering for not
meetAkshay99
2017/04/06 10:24:34
That is what I was having earlier. A method was de
daniela-webrtc
2017/04/06 14:44:46
I think the other reviewers meant that there is no
meetAkshay99
2017/04/07 05:19:29
Yeah, updating to call setCorrectVideoOrientation
|
| + selector:@selector(deviceOrientationDidChange:) |
| + name:UIDeviceOrientationDidChangeNotification |
| + object:nil]; |
| + [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; |
| + } else { |
| + [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; |
| + [[NSNotificationCenter defaultCenter] removeObserver:self |
| + name:UIDeviceOrientationDidChangeNotification |
| + object:nil]; |
| + } |
| +} |
| + |
| +- (void)deviceOrientationDidChange:(NSNotification *)notification { |
| + // Get current device orientation. |
| + UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation; |
| + AVCaptureVideoPreviewLayer *previewLayer = [self previewLayer]; |
| + |
| + // Set the video orientation based on device orientation. |
| + if (deviceOrientation == UIInterfaceOrientationPortraitUpsideDown) { |
|
Chuck
2017/04/06 19:06:46
This header docs say you should only set this prop
meetAkshay99
2017/04/07 05:19:29
Added a check for the same.
|
| + [previewLayer.connection setVideoOrientation:AVCaptureVideoOrientationPortraitUpsideDown]; |
|
Chuck
2017/04/06 19:06:46
Please use property syntax here:
previewLayer.conn
meetAkshay99
2017/04/07 05:19:29
I would update it to property syntax, but would li
Chuck
2017/04/07 12:57:40
It's modern objective-c syntax and to match the st
|
| + } else if (deviceOrientation == UIInterfaceOrientationPortrait) { |
| + [previewLayer.connection setVideoOrientation:AVCaptureVideoOrientationPortrait]; |
| + } else if (deviceOrientation == UIInterfaceOrientationLandscapeLeft) { |
| + [previewLayer.connection setVideoOrientation:AVCaptureVideoOrientationLandscapeLeft]; |
| + } else { |
| + [previewLayer.connection setVideoOrientation:AVCaptureVideoOrientationLandscapeRight]; |
| + } |
| +} |
| + |
| #pragma mark - Private |
| - (AVCaptureVideoPreviewLayer *)previewLayer { |