|
|
@ -256,10 +256,12 @@ final class CallVC : UIViewController, VideoPreviewDelegate {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setupOrientationMonitoring()
|
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(audioRouteDidChange), name: AVAudioSession.routeChangeNotification, object: nil)
|
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(audioRouteDidChange), name: AVAudioSession.routeChangeNotification, object: nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
deinit {
|
|
|
|
deinit {
|
|
|
|
|
|
|
|
UIDevice.current.endGeneratingDeviceOrientationNotifications()
|
|
|
|
NotificationCenter.default.removeObserver(self)
|
|
|
|
NotificationCenter.default.removeObserver(self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -336,6 +338,41 @@ final class CallVC : UIViewController, VideoPreviewDelegate {
|
|
|
|
localVideoView.removeFromSuperview()
|
|
|
|
localVideoView.removeFromSuperview()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: - Orientation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private func setupOrientationMonitoring() {
|
|
|
|
|
|
|
|
UIDevice.current.beginGeneratingDeviceOrientationNotifications()
|
|
|
|
|
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(didChangeDeviceOrientation), name: UIDevice.orientationDidChangeNotification, object: UIDevice.current)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@objc func didChangeDeviceOrientation(notification: Notification) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func rotateAllButtons(rotationAngle: CGFloat) {
|
|
|
|
|
|
|
|
let transform = CGAffineTransform(rotationAngle: rotationAngle)
|
|
|
|
|
|
|
|
UIView.animate(withDuration: 0.2) {
|
|
|
|
|
|
|
|
self.answerButton.transform = transform
|
|
|
|
|
|
|
|
self.hangUpButton.transform = transform
|
|
|
|
|
|
|
|
self.switchAudioButton.transform = transform
|
|
|
|
|
|
|
|
self.switchCameraButton.transform = transform
|
|
|
|
|
|
|
|
self.videoButton.transform = transform
|
|
|
|
|
|
|
|
self.volumeView.transform = transform
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch UIDevice.current.orientation {
|
|
|
|
|
|
|
|
case .portrait:
|
|
|
|
|
|
|
|
rotateAllButtons(rotationAngle: 0)
|
|
|
|
|
|
|
|
case .portraitUpsideDown:
|
|
|
|
|
|
|
|
rotateAllButtons(rotationAngle: .pi)
|
|
|
|
|
|
|
|
case .landscapeLeft:
|
|
|
|
|
|
|
|
rotateAllButtons(rotationAngle: .halfPi)
|
|
|
|
|
|
|
|
case .landscapeRight:
|
|
|
|
|
|
|
|
rotateAllButtons(rotationAngle: .pi + .halfPi)
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: Call signalling
|
|
|
|
// MARK: Call signalling
|
|
|
|
func handleAnswerMessage(_ message: CallMessage) {
|
|
|
|
func handleAnswerMessage(_ message: CallMessage) {
|
|
|
|
callInfoLabel.text = "Connecting..."
|
|
|
|
callInfoLabel.text = "Connecting..."
|
|
|
|