iOS: Don’t change video rotation in FaceUp or FaceDown.
Previously, if using the device in landscape and then tilting the phone into FaceUp orientation, the video rotation would reset to portrait. Bug: webrtc:8492 Change-Id: I3e11e3adecabf99249ba3a8d5532291580a93f2e Reviewed-on: https://webrtc-review.googlesource.com/24021 Reviewed-by: Kári Helgason <kthelgason@webrtc.org> Commit-Queue: Kári Helgason <kthelgason@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20792}
This commit is contained in:
committed by
Commit Bot
parent
82ed988a1c
commit
22d43f3352
@ -37,6 +37,7 @@ const int64_t kNanosecondsPerSecond = 1000000000;
|
||||
BOOL _isRunning;
|
||||
// Will the session be running once all asynchronous operations have been completed?
|
||||
BOOL _willBeRunning;
|
||||
RTCVideoRotation _rotation;
|
||||
#if TARGET_OS_IPHONE
|
||||
UIDeviceOrientation _orientation;
|
||||
#endif
|
||||
@ -57,6 +58,7 @@ const int64_t kNanosecondsPerSecond = 1000000000;
|
||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||
#if TARGET_OS_IPHONE
|
||||
_orientation = UIDeviceOrientationPortrait;
|
||||
_rotation = RTCVideoRotation_90;
|
||||
[center addObserver:self
|
||||
selector:@selector(deviceOrientationDidChange:)
|
||||
name:UIDeviceOrientationDidChangeNotification
|
||||
@ -191,7 +193,6 @@ const int64_t kNanosecondsPerSecond = 1000000000;
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
// Default to portrait orientation on iPhone.
|
||||
RTCVideoRotation rotation = RTCVideoRotation_90;
|
||||
BOOL usingFrontCamera = NO;
|
||||
// Check the image's EXIF for the camera the image came from as the image could have been
|
||||
// delayed as we set alwaysDiscardsLateVideoFrames to NO.
|
||||
@ -206,16 +207,16 @@ const int64_t kNanosecondsPerSecond = 1000000000;
|
||||
}
|
||||
switch (_orientation) {
|
||||
case UIDeviceOrientationPortrait:
|
||||
rotation = RTCVideoRotation_90;
|
||||
_rotation = RTCVideoRotation_90;
|
||||
break;
|
||||
case UIDeviceOrientationPortraitUpsideDown:
|
||||
rotation = RTCVideoRotation_270;
|
||||
_rotation = RTCVideoRotation_270;
|
||||
break;
|
||||
case UIDeviceOrientationLandscapeLeft:
|
||||
rotation = usingFrontCamera ? RTCVideoRotation_180 : RTCVideoRotation_0;
|
||||
_rotation = usingFrontCamera ? RTCVideoRotation_180 : RTCVideoRotation_0;
|
||||
break;
|
||||
case UIDeviceOrientationLandscapeRight:
|
||||
rotation = usingFrontCamera ? RTCVideoRotation_0 : RTCVideoRotation_180;
|
||||
_rotation = usingFrontCamera ? RTCVideoRotation_0 : RTCVideoRotation_180;
|
||||
break;
|
||||
case UIDeviceOrientationFaceUp:
|
||||
case UIDeviceOrientationFaceDown:
|
||||
@ -225,14 +226,14 @@ const int64_t kNanosecondsPerSecond = 1000000000;
|
||||
}
|
||||
#else
|
||||
// No rotation on Mac.
|
||||
RTCVideoRotation rotation = RTCVideoRotation_0;
|
||||
_rotation = RTCVideoRotation_0;
|
||||
#endif
|
||||
|
||||
RTCCVPixelBuffer *rtcPixelBuffer = [[RTCCVPixelBuffer alloc] initWithPixelBuffer:pixelBuffer];
|
||||
int64_t timeStampNs = CMTimeGetSeconds(CMSampleBufferGetPresentationTimeStamp(sampleBuffer)) *
|
||||
kNanosecondsPerSecond;
|
||||
RTCVideoFrame *videoFrame = [[RTCVideoFrame alloc] initWithBuffer:rtcPixelBuffer
|
||||
rotation:rotation
|
||||
rotation:_rotation
|
||||
timeStampNs:timeStampNs];
|
||||
[self.delegate capturer:self didCaptureVideoFrame:videoFrame];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user