fix an issue where current call implementation won't compile for simulators

This commit is contained in:
Ryan Zhao 2022-04-26 15:59:37 +10:00
parent 75d922eb3a
commit f48cdd02ee
2 changed files with 26 additions and 3 deletions

View File

@ -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
}
}
}

View File

@ -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?