diff --git a/AUTHORS b/AUTHORS index 5f8113f5a4..8b63772068 100644 --- a/AUTHORS +++ b/AUTHORS @@ -6,6 +6,7 @@ Akshay Shah Alexander Brauckmann Alexandre Gouaillard Andrew MacDonald +Andrey Efremov Anil Kumar Ben Strong Bob Withers diff --git a/sdk/objc/components/capturer/RTCCameraVideoCapturer.m b/sdk/objc/components/capturer/RTCCameraVideoCapturer.m index 744edf6ae5..f83c03e4c0 100644 --- a/sdk/objc/components/capturer/RTCCameraVideoCapturer.m +++ b/sdk/objc/components/capturer/RTCCameraVideoCapturer.m @@ -41,6 +41,7 @@ const int64_t kNanosecondsPerSecond = 1000000000; RTCVideoRotation _rotation; #if TARGET_OS_IPHONE UIDeviceOrientation _orientation; + BOOL _generatingOrientationNotifications; #endif } @@ -158,7 +159,12 @@ const int64_t kNanosecondsPerSecond = 1000000000; RTCLogInfo("startCaptureWithDevice %@ @ %ld fps", format, (long)fps); #if TARGET_OS_IPHONE - [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; + dispatch_async(dispatch_get_main_queue(), ^{ + if (!self->_generatingOrientationNotifications) { + [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; + self->_generatingOrientationNotifications = YES; + } + }); #endif self.currentDevice = device; @@ -200,7 +206,12 @@ const int64_t kNanosecondsPerSecond = 1000000000; [self.captureSession stopRunning]; #if TARGET_OS_IPHONE - [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; + dispatch_async(dispatch_get_main_queue(), ^{ + if (self->_generatingOrientationNotifications) { + [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; + self->_generatingOrientationNotifications = NO; + } + }); #endif self.isRunning = NO; if (completionHandler) {