Reputation: 1373
I have an iOS app that only supports portrait when rotating the device the video captured by the RTCMTLVideoView rotates to landscape orientation, even when the rest of the UI stays in portrait.
So far the only solution that I found is to listen for the UIDeviceOrientationDidChangeNotification notification
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
and disabling it
- (void)orientationChanged:(NSNotification *)notification{
NSLog(@"orientation changed");
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
}
Is there any way to prevent this behaviour and keep it locked to portrait without this ugly workaround?
Upvotes: 3
Views: 3152
Reputation: 1373
The problem in my case was that the video captured with the front camera was no mirrored.
I fixed the issue flipping the RTCMTLVideoView
self.myRTCMTLVideoView.transform = CGAffineTransformMakeScale(-1.0, 1.0)
Upvotes: 3
Reputation: 2972
The answer assumes usage of the latest stable M70 branch of WebRTC at the moment, as it's a moving target and API of its internal classes changes frequently.
Looks like RTCMTLVideoView
is still work in progress and doesn't handle all scenarios appropriately. It has a rotationOverride
property, but no documentation or example on how to use it. There is a similar question on Google Groups, which hasn't yet received attention, I encourage you to participate in discussion there, so WebRTC developers would know about that issue relevancy and made actions to fix it.
In the meantime, I suggest to switch to RTCEAGLVideoView
which should work fine in that case.
Upvotes: 0