Closed x3mall1986 closed 7 years ago
I ran into a similar issue. If you're using a RTCCameraPreviewView for your local video stream you could try something like this:
if let previewLayer = localVideoView.layer as? AVCaptureVideoPreviewLayer,
let connection = previewLayer.connection,
connection.isVideoOrientationSupported {
switch UIDevice.current.orientation {
case .landscapeLeft:
connection.videoOrientation = .landscapeLeft
localVideoView.transform = CGAffineTransform.init(scaleX: 1, y: -1)
break
case .landscapeRight:
connection.videoOrientation = .landscapeRight
localVideoView.transform = CGAffineTransform.init(scaleX: 1, y: -1)
break
case .portrait:
connection.videoOrientation = .portrait
localVideoView.transform = CGAffineTransform.identity
break
case .portraitUpsideDown:
connection.videoOrientation = .portraitUpsideDown
localVideoView.transform = CGAffineTransform.identity
break
default:
print("unsupport orientation")
}
}
Basically need to translate UIDeviceOrientation to AVCaptureVideoOrientation and perform the transform so localVideoView is rotated correctly.
Hope this helps.
Also just found that there is a feature request related to this issue:
Yea the behaviour is a bit different with android, Whenever you rotate the app even though your app set autoRotate false, The view created always rendering agian, For now like @obaskanderi said, we can manipulate the view by change rotation or y axis.
I assume it's fixed in the upstream.
Hello. Help me plz. When i rotate the device my localVideoStream View rotate, but video stream from camera is inverted. How to change orientation for this localVideoStream when I rotate device?