From f48cdd02ee7bbd4561afdc4563047ab5f2437d24 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Tue, 26 Apr 2022 15:59:37 +1000 Subject: [PATCH] fix an issue where current call implementation won't compile for simulators --- .../Calls/Views & Modals/CallVideoView.swift | 17 ++++++++++++++--- Session/Calls/Views & Modals/MiniCallView.swift | 12 ++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Session/Calls/Views & Modals/CallVideoView.swift b/Session/Calls/Views & Modals/CallVideoView.swift index f32d513e4..6bf5ce6f7 100644 --- a/Session/Calls/Views & Modals/CallVideoView.swift +++ b/Session/Calls/Views & Modals/CallVideoView.swift @@ -2,9 +2,17 @@ import WebRTC import Foundation +#if arch(arm64) +// Note: 'RTCMTLVideoView' requires arm64 (so won't work on the simulator which +// we need to build for x86_64 due to WebRTC not supporting arm64 simulator builds) +typealias TargetView = RTCMTLVideoView +#else +typealias TargetView = RTCEAGLVideoView +#endif + // MARK: RemoteVideoView -class RemoteVideoView: RTCMTLVideoView { +class RemoteVideoView: TargetView { override func renderFrame(_ frame: RTCVideoFrame?) { super.renderFrame(frame) @@ -39,7 +47,7 @@ class RemoteVideoView: RTCMTLVideoView { // Assume we're already setup for the correct orientation. break } - +#if arch(arm64) if let rotationOverride = rotationOverride { self.rotationOverride = NSNumber(value: rotationOverride.rawValue) if [ RTCVideoRotation._0, RTCVideoRotation._180 ].contains(rotationOverride) { @@ -59,13 +67,14 @@ class RemoteVideoView: RTCMTLVideoView { if frameRatio < 1.5 { self.videoContentMode = .scaleAspectFit } +#endif } } } // MARK: LocalVideoView -class LocalVideoView: RTCMTLVideoView { +class LocalVideoView: TargetView { static let width: CGFloat = 80 static let height: CGFloat = 173 @@ -77,7 +86,9 @@ class LocalVideoView: RTCMTLVideoView { // sometimes the rotationOverride is not working // if it is only set once on initialization self.rotationOverride = NSNumber(value: RTCVideoRotation._0.rawValue) +#if arch(arm64) self.videoContentMode = .scaleAspectFill +#endif } } } diff --git a/Session/Calls/Views & Modals/MiniCallView.swift b/Session/Calls/Views & Modals/MiniCallView.swift index 6c7d5a424..dec4bbe9c 100644 --- a/Session/Calls/Views & Modals/MiniCallView.swift +++ b/Session/Calls/Views & Modals/MiniCallView.swift @@ -16,6 +16,9 @@ final class MiniCallView: UIView, RTCVideoViewDelegate { private var top: NSLayoutConstraint? private var bottom: NSLayoutConstraint? +#if arch(arm64) + // Note: 'RTCMTLVideoView' requires arm64 (so won't work on the simulator which + // we need to build for x86_64 due to WebRTC not supporting arm64 simulator builds) private lazy var remoteVideoView: RTCMTLVideoView = { let result = RTCMTLVideoView() result.delegate = self @@ -24,6 +27,15 @@ final class MiniCallView: UIView, RTCVideoViewDelegate { result.backgroundColor = .black return result }() +#else + private lazy var remoteVideoView: RTCEAGLVideoView = { + let result = RTCEAGLVideoView() + result.delegate = self + result.alpha = self.callVC.call.isRemoteVideoEnabled ? 1 : 0 + result.backgroundColor = .black + return result + }() +#endif // MARK: Initialization public static var current: MiniCallView?