Skip to content

Commit 7534c15

Browse files
authored
Fix Mac Catalyst RTCCameraVideoCapturer rotation (#126)
1 parent c600b00 commit 7534c15

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

sdk/objc/components/capturer/RTCCameraVideoCapturer.m

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#import "base/RTCVideoFrameBuffer.h"
1616
#import "components/video_frame_buffer/RTCCVPixelBuffer.h"
1717

18-
#if TARGET_OS_IPHONE
18+
#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST
1919
#import "helpers/UIDevice+RTCDevice.h"
2020
#endif
2121

@@ -41,7 +41,7 @@ @implementation RTC_OBJC_TYPE (RTCCameraVideoCapturer) {
4141
FourCharCode _preferredOutputPixelFormat;
4242
FourCharCode _outputPixelFormat;
4343
RTCVideoRotation _rotation;
44-
#if TARGET_OS_IPHONE
44+
#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST
4545
UIInterfaceOrientation _orientation;
4646
BOOL _generatingOrientationNotifications;
4747
#endif
@@ -74,7 +74,7 @@ - (instancetype)initWithDelegate:(__weak id<RTC_OBJC_TYPE(RTCVideoCapturerDelega
7474
return nil;
7575
}
7676
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
77-
#if TARGET_OS_IPHONE
77+
#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST
7878
_orientation = UIInterfaceOrientationPortrait;
7979
_rotation = RTCVideoRotation_90;
8080
[center addObserver:self
@@ -175,7 +175,7 @@ - (void)startCaptureWithDevice:(AVCaptureDevice *)device
175175
block:^{
176176
RTCLogInfo("startCaptureWithDevice %@ @ %ld fps", format, (long)fps);
177177

178-
#if TARGET_OS_IPHONE
178+
#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST
179179
dispatch_async(dispatch_get_main_queue(), ^{
180180
if (!self->_generatingOrientationNotifications) {
181181
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
@@ -224,7 +224,7 @@ - (void)stopCaptureWithCompletionHandler:(nullable void (^)(void))completionHand
224224
}
225225
[self.captureSession stopRunning];
226226

227-
#if TARGET_OS_IPHONE
227+
#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST
228228
dispatch_async(dispatch_get_main_queue(), ^{
229229
if (self->_generatingOrientationNotifications) {
230230
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
@@ -241,7 +241,7 @@ - (void)stopCaptureWithCompletionHandler:(nullable void (^)(void))completionHand
241241

242242
#pragma mark iOS notifications
243243

244-
#if TARGET_OS_IPHONE
244+
#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST
245245
- (void)deviceOrientationDidChange:(NSNotification *)notification {
246246
[self updateOrientation];
247247
}
@@ -264,7 +264,7 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput
264264
return;
265265
}
266266

267-
#if TARGET_OS_IPHONE
267+
#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST
268268
// Default to portrait orientation on iPhone.
269269
BOOL usingFrontCamera = NO;
270270
// Check the image's EXIF for the camera the image came from as the image could have been
@@ -314,7 +314,7 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput
314314
- (void)captureOutput:(AVCaptureOutput *)captureOutput
315315
didDropSampleBuffer:(CMSampleBufferRef)sampleBuffer
316316
fromConnection:(AVCaptureConnection *)connection {
317-
#if TARGET_OS_IPHONE
317+
#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST
318318
CFStringRef droppedReason =
319319
CMGetAttachment(sampleBuffer, kCMSampleBufferAttachmentKey_DroppedFrameReason, nil);
320320
#else
@@ -328,7 +328,7 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput
328328

329329
- (void)handleCaptureSessionInterruption:(NSNotification *)notification {
330330
NSString *reasonString = nil;
331-
#if TARGET_OS_IPHONE
331+
#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST
332332
NSNumber *reason = notification.userInfo[AVCaptureSessionInterruptionReasonKey];
333333
if (reason) {
334334
switch (reason.intValue) {
@@ -360,7 +360,7 @@ - (void)handleCaptureSessionRuntimeError:(NSNotification *)notification {
360360

361361
[RTC_OBJC_TYPE(RTCDispatcher) dispatchAsyncOnType:RTCDispatcherTypeCaptureSession
362362
block:^{
363-
#if TARGET_OS_IPHONE
363+
#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST
364364
if (error.code == AVErrorMediaServicesWereReset) {
365365
[self handleNonFatalError];
366366
} else {
@@ -411,7 +411,7 @@ - (void)handleNonFatalError {
411411
}];
412412
}
413413

414-
#if TARGET_OS_IPHONE
414+
#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST
415415

416416
#pragma mark - UIApplication notifications
417417

@@ -547,7 +547,7 @@ - (void)reconfigureCaptureSessionInput {
547547
[_captureSession commitConfiguration];
548548
}
549549

550-
#if TARGET_OS_IPHONE
550+
#if TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST
551551
- (void)updateOrientation {
552552
NSAssert([RTC_OBJC_TYPE(RTCDispatcher) isOnQueueForType:RTCDispatcherTypeMain],
553553
@"statusBarOrientation must be called on the main queue.");

0 commit comments

Comments
 (0)