diff --git a/BeanCovertor.swift b/BeanCovertor.swift index c9690eac7..3b79590fb 100644 --- a/BeanCovertor.swift +++ b/BeanCovertor.swift @@ -11,22 +11,22 @@ import AgoraRtcKit func mapToPoint(_ map: Dictionary) -> CGPoint { var point = CGPoint() - if let x = map["x"] as? Int { - point.x = CGFloat(x) + if let x = map["x"] as? NSNumber { + point.x = CGFloat(truncating: x) } - if let y = map["y"] as? Int { - point.y = CGFloat(y) + if let y = map["y"] as? NSNumber { + point.y = CGFloat(truncating: y) } return point } func mapToSize(_ map: Dictionary) -> CGSize { var size = CGSize() - if let width = map["width"] as? Int { - size.width = CGFloat(width) + if let width = map["width"] as? NSNumber { + size.width = CGFloat(truncating: width) } - if let height = map["height"] as? Int { - size.height = CGFloat(height) + if let height = map["height"] as? NSNumber { + size.height = CGFloat(truncating: height) } return size } @@ -43,30 +43,30 @@ func mapToVideoEncoderConfiguration(_ map: Dictionary) -> AgoraVide if let dimensions = map["dimensions"] as? Dictionary { config.dimensions = mapToSize(dimensions) } - if let frameRate = map["frameRate"] as? Int { - config.frameRate = frameRate + if let frameRate = map["frameRate"] as? NSNumber { + config.frameRate = frameRate.intValue } - if let minFrameRate = map["minFrameRate"] as? Int { - config.minFrameRate = minFrameRate + if let minFrameRate = map["minFrameRate"] as? NSNumber { + config.minFrameRate = minFrameRate.intValue } - if let bitrate = map["bitrate"] as? Int { - config.bitrate = bitrate + if let bitrate = map["bitrate"] as? NSNumber { + config.bitrate = bitrate.intValue } - if let minBitrate = map["minBitrate"] as? Int { - config.minBitrate = minBitrate + if let minBitrate = map["minBitrate"] as? NSNumber { + config.minBitrate = minBitrate.intValue } - if let orientationMode = map["orientationMode"] as? Int { - if let orientationMode = AgoraVideoOutputOrientationMode(rawValue: orientationMode) { + if let orientationMode = map["orientationMode"] as? NSNumber { + if let orientationMode = AgoraVideoOutputOrientationMode(rawValue: orientationMode.intValue) { config.orientationMode = orientationMode } } - if let degradationPreference = map["degradationPrefer"] as? Int { - if let degradationPreference = AgoraDegradationPreference(rawValue: degradationPreference) { + if let degradationPreference = map["degradationPrefer"] as? NSNumber { + if let degradationPreference = AgoraDegradationPreference(rawValue: degradationPreference.intValue) { config.degradationPreference = degradationPreference } } - if let mirrorMode = map["mirrorMode"] as? Int { - if let mirrorMode = AgoraVideoMirrorMode(rawValue: UInt(mirrorMode)) { + if let mirrorMode = map["mirrorMode"] as? NSNumber { + if let mirrorMode = AgoraVideoMirrorMode(rawValue: mirrorMode.uintValue) { config.mirrorMode = mirrorMode } } @@ -75,19 +75,19 @@ func mapToVideoEncoderConfiguration(_ map: Dictionary) -> AgoraVide func mapToBeautyOptions(_ map: Dictionary) -> AgoraBeautyOptions { let options = AgoraBeautyOptions() - if let lighteningContrastLevel = map["lighteningContrastLevel"] as? Int { - if let lighteningContrastLevel = AgoraLighteningContrastLevel(rawValue: UInt(lighteningContrastLevel)) { + if let lighteningContrastLevel = map["lighteningContrastLevel"] as? NSNumber { + if let lighteningContrastLevel = AgoraLighteningContrastLevel(rawValue: lighteningContrastLevel.uintValue) { options.lighteningContrastLevel = lighteningContrastLevel } } - if let lighteningLevel = map["lighteningLevel"] as? Float { - options.lighteningLevel = lighteningLevel + if let lighteningLevel = map["lighteningLevel"] as? NSNumber { + options.lighteningLevel = lighteningLevel.floatValue } - if let smoothnessLevel = map["smoothnessLevel"] as? Float { - options.smoothnessLevel = smoothnessLevel + if let smoothnessLevel = map["smoothnessLevel"] as? NSNumber { + options.smoothnessLevel = smoothnessLevel.floatValue } - if let rednessLevel = map["rednessLevel"] as? Float { - options.rednessLevel = rednessLevel + if let rednessLevel = map["rednessLevel"] as? NSNumber { + options.rednessLevel = rednessLevel.floatValue } return options } @@ -105,45 +105,45 @@ func mapToAgoraImage(_ map: Dictionary) -> AgoraImage { func mapToTranscodingUser(_ map: Dictionary) -> AgoraLiveTranscodingUser { let user = AgoraLiveTranscodingUser() - if let uid = map["uid"] as? Int { - user.uid = UInt(uid) + if let uid = map["uid"] as? NSNumber { + user.uid = uid.uintValue } user.rect = mapToRect(map) - if let zOrder = map["zOrder"] as? Int { - user.zOrder = zOrder + if let zOrder = map["zOrder"] as? NSNumber { + user.zOrder = zOrder.intValue } - if let alpha = map["alpha"] as? Double { - user.alpha = alpha + if let alpha = map["alpha"] as? NSNumber { + user.alpha = alpha.doubleValue } - if let audioChannel = map["audioChannel"] as? Int { - user.audioChannel = audioChannel + if let audioChannel = map["audioChannel"] as? NSNumber { + user.audioChannel = audioChannel.intValue } return user } func mapToColor(_ map: Dictionary) -> UIColor { return UIColor( - red: CGFloat(map["red"] as! Int), - green: CGFloat(map["green"] as! Int), - blue: CGFloat(map["blue"] as! Int), - alpha: 1.0 + red: CGFloat((map["red"] as! NSNumber).intValue), + green: CGFloat((map["green"] as! NSNumber).intValue), + blue: CGFloat((map["blue"] as! NSNumber).intValue), + alpha: 1.0 ) } func mapToLiveTranscoding(_ map: Dictionary) -> AgoraLiveTranscoding { let transcoding = AgoraLiveTranscoding.default() transcoding.size = mapToSize(map) - if let videoBitrate = map["videoBitrate"] as? Int { - transcoding.videoBitrate = videoBitrate + if let videoBitrate = map["videoBitrate"] as? NSNumber { + transcoding.videoBitrate = videoBitrate.intValue } - if let videoFramerate = map["videoFramerate"] as? Int { - transcoding.videoFramerate = videoFramerate + if let videoFramerate = map["videoFramerate"] as? NSNumber { + transcoding.videoFramerate = videoFramerate.intValue } if let lowLatency = map["lowLatency"] as? Bool { transcoding.lowLatency = lowLatency } - if let videoGop = map["videoGop"] as? Int { - transcoding.videoGop = videoGop + if let videoGop = map["videoGop"] as? NSNumber { + transcoding.videoGop = videoGop.intValue } if let watermark = map["watermark"] as? Dictionary { transcoding.watermark = mapToAgoraImage(watermark) @@ -151,24 +151,24 @@ func mapToLiveTranscoding(_ map: Dictionary) -> AgoraLiveTranscodin if let backgroundImage = map["backgroundImage"] as? Dictionary { transcoding.backgroundImage = mapToAgoraImage(backgroundImage) } - if let audioSampleRate = map["audioSampleRate"] as? Int { - if let audioSampleRate = AgoraAudioSampleRateType(rawValue: audioSampleRate) { + if let audioSampleRate = map["audioSampleRate"] as? NSNumber { + if let audioSampleRate = AgoraAudioSampleRateType(rawValue: audioSampleRate.intValue) { transcoding.audioSampleRate = audioSampleRate } } - if let audioBitrate = map["audioBitrate"] as? Int { - transcoding.audioBitrate = audioBitrate + if let audioBitrate = map["audioBitrate"] as? NSNumber { + transcoding.audioBitrate = audioBitrate.intValue } - if let audioChannels = map["audioChannels"] as? Int { - transcoding.audioChannels = audioChannels + if let audioChannels = map["audioChannels"] as? NSNumber { + transcoding.audioChannels = audioChannels.intValue } - if let audioCodecProfile = map["audioCodecProfile"] as? Int { - if let audioCodecProfile = AgoraAudioCodecProfileType(rawValue: audioCodecProfile) { + if let audioCodecProfile = map["audioCodecProfile"] as? NSNumber { + if let audioCodecProfile = AgoraAudioCodecProfileType(rawValue: audioCodecProfile.intValue) { transcoding.audioCodecProfile = audioCodecProfile } } - if let videoCodecProfile = map["videoCodecProfile"] as? Int { - if let videoCodecProfile = AgoraVideoCodecProfileType(rawValue: videoCodecProfile) { + if let videoCodecProfile = map["videoCodecProfile"] as? NSNumber { + if let videoCodecProfile = AgoraVideoCodecProfileType(rawValue: videoCodecProfile.intValue) { transcoding.videoCodecProfile = videoCodecProfile } } @@ -196,8 +196,8 @@ func mapToChannelMediaInfo(_ map: Dictionary) -> AgoraChannelMediaR if let token = map["token"] as? String { info.token = token } - if let uid = map["uid"] as? UInt { - info.uid = uid + if let uid = map["uid"] as? NSNumber { + info.uid = uid.uintValue } return info } @@ -226,11 +226,11 @@ func mapToLastmileProbeConfig(_ map: Dictionary) -> AgoraLastmilePr if let probeDownlink = map["probeDownlink"] as? Bool { config.probeDownlink = probeDownlink } - if let expectedUplinkBitrate = map["expectedUplinkBitrate"] as? Int { - config.expectedUplinkBitrate = UInt(expectedUplinkBitrate) + if let expectedUplinkBitrate = map["expectedUplinkBitrate"] as? NSNumber { + config.expectedUplinkBitrate = expectedUplinkBitrate.uintValue } - if let expectedDownlinkBitrate = map["expectedDownlinkBitrate"] as? Int { - config.expectedDownlinkBitrate = UInt(expectedDownlinkBitrate) + if let expectedDownlinkBitrate = map["expectedDownlinkBitrate"] as? NSNumber { + config.expectedDownlinkBitrate = expectedDownlinkBitrate.uintValue } return config } @@ -252,44 +252,44 @@ func mapToWatermarkOptions(_ map: Dictionary) -> WatermarkOptions { func mapToLiveInjectStreamConfig(_ map: Dictionary) -> AgoraLiveInjectStreamConfig { let config = AgoraLiveInjectStreamConfig.default() config.size = mapToSize(map) - if let videoGop = map["videoGop"] as? Int { - config.videoGop = videoGop + if let videoGop = map["videoGop"] as? NSNumber { + config.videoGop = videoGop.intValue } - if let videoFramerate = map["videoFramerate"] as? Int { - config.videoFramerate = videoFramerate + if let videoFramerate = map["videoFramerate"] as? NSNumber { + config.videoFramerate = videoFramerate.intValue } - if let videoBitrate = map["videoBitrate"] as? Int { - config.videoBitrate = videoBitrate + if let videoBitrate = map["videoBitrate"] as? NSNumber { + config.videoBitrate = videoBitrate.intValue } - if let audioSampleRate = map["audioSampleRate"] as? Int { - if let audioSampleRate = AgoraAudioSampleRateType(rawValue: audioSampleRate) { + if let audioSampleRate = map["audioSampleRate"] as? NSNumber { + if let audioSampleRate = AgoraAudioSampleRateType(rawValue: audioSampleRate.intValue) { config.audioSampleRate = audioSampleRate } } - if let audioBitrate = map["audioBitrate"] as? Int { - config.audioBitrate = audioBitrate + if let audioBitrate = map["audioBitrate"] as? NSNumber { + config.audioBitrate = audioBitrate.intValue } - if let audioChannels = map["audioChannels"] as? Int { - config.audioChannels = audioChannels + if let audioChannels = map["audioChannels"] as? NSNumber { + config.audioChannels = audioChannels.intValue } return config } func mapToCameraCapturerConfiguration(_ map: Dictionary) -> AgoraCameraCapturerConfiguration { let config = AgoraCameraCapturerConfiguration() - if let preference = map["preference"] as? Int { - if let preference = AgoraCameraCaptureOutputPreference(rawValue: preference) { + if let preference = map["preference"] as? NSNumber { + if let preference = AgoraCameraCaptureOutputPreference(rawValue: preference.intValue) { config.preference = preference } } - if let captureWidth = map["captureWidth"] as? Int32 { - config.captureWidth = captureWidth + if let captureWidth = map["captureWidth"] as? NSNumber { + config.captureWidth = captureWidth.int32Value } - if let captureHeight = map["captureHeight"] as? Int32 { - config.captureHeight = captureHeight + if let captureHeight = map["captureHeight"] as? NSNumber { + config.captureHeight = captureHeight.int32Value } - if let cameraDirection = map["cameraDirection"] as? Int { - if let cameraDirection = AgoraCameraDirection(rawValue: cameraDirection) { + if let cameraDirection = map["cameraDirection"] as? NSNumber { + if let cameraDirection = AgoraCameraDirection(rawValue: cameraDirection.intValue) { config.cameraDirection = cameraDirection } } @@ -310,8 +310,8 @@ func mapToChannelMediaOptions(_ map: Dictionary) -> AgoraRtcChannel func mapToRtcEngineConfig(_ map: Dictionary) -> AgoraRtcEngineConfig { let config = AgoraRtcEngineConfig() config.appId = map["appId"] as? String - if let areaCode = map["areaCode"] as? UInt { - config.areaCode = areaCode + if let areaCode = map["areaCode"] as? NSNumber { + config.areaCode = areaCode.uintValue } if let logConfig = map["logConfig"] as? Dictionary { config.logConfig = mapToLogConfig(logConfig) @@ -321,8 +321,8 @@ func mapToRtcEngineConfig(_ map: Dictionary) -> AgoraRtcEngineConfi func mapToEncryptionConfig(_ map: Dictionary) -> AgoraEncryptionConfig { let config = AgoraEncryptionConfig() - if let encryptionMode = map["encryptionMode"] as? Int { - if let encryptionMode = AgoraEncryptionMode(rawValue: encryptionMode) { + if let encryptionMode = map["encryptionMode"] as? NSNumber { + if let encryptionMode = AgoraEncryptionMode(rawValue: encryptionMode.intValue) { config.encryptionMode = encryptionMode } } @@ -334,8 +334,8 @@ func mapToEncryptionConfig(_ map: Dictionary) -> AgoraEncryptionCon func mapToClientRoleOptions(_ map: Dictionary) -> AgoraClientRoleOptions { let options = AgoraClientRoleOptions() - if let audienceLatencyLevel = map["audienceLatencyLevel"] as? Int { - if let audienceLatencyLevel = AgoraAudienceLatencyLevelType(rawValue: audienceLatencyLevel) { + if let audienceLatencyLevel = map["audienceLatencyLevel"] as? NSNumber { + if let audienceLatencyLevel = AgoraAudienceLatencyLevelType(rawValue: audienceLatencyLevel.intValue) { options.audienceLatencyLevel = audienceLatencyLevel } } @@ -345,11 +345,11 @@ func mapToClientRoleOptions(_ map: Dictionary) -> AgoraClientRoleOp func mapToLogConfig(_ map: Dictionary) -> AgoraLogConfig { let config = AgoraLogConfig() config.filePath = map["filePath"] as? String - if let fileSize = map["fileSize"] as? Int { - config.fileSize = fileSize + if let fileSize = map["fileSize"] as? NSNumber { + config.fileSize = fileSize.intValue } - if let level = map["level"] as? Int { - if let level = AgoraLogLevel.init(rawValue: level) { + if let level = map["level"] as? NSNumber { + if let level = AgoraLogLevel.init(rawValue: level.intValue) { config.level = level; } } diff --git a/RtcChannel.swift b/RtcChannel.swift index c2d5abf6c..b0a21ee16 100644 --- a/RtcChannel.swift +++ b/RtcChannel.swift @@ -173,7 +173,7 @@ class RtcChannelManager: NSObject, RtcChannelInterface { } @objc func setClientRole(_ params: NSDictionary, _ callback: Callback) { - let role = AgoraClientRole(rawValue: params["role"] as! Int)! + let role = AgoraClientRole(rawValue: (params["role"] as! NSNumber).intValue)! if let options = params["options"] as? Dictionary { callback.code(self[params["channelId"] as! String]?.setClientRole(role, options: mapToClientRoleOptions(options))) return @@ -182,7 +182,7 @@ class RtcChannelManager: NSObject, RtcChannelInterface { } @objc func joinChannel(_ params: NSDictionary, _ callback: Callback) { - callback.code(self[params["channelId"] as! String]?.join(byToken: params["token"] as? String, info: params["optionalInfo"] as? String, uid: params["optionalUid"] as! UInt, options: mapToChannelMediaOptions(params["options"] as! Dictionary))) + callback.code(self[params["channelId"] as! String]?.join(byToken: params["token"] as? String, info: params["optionalInfo"] as? String, uid: (params["optionalUid"] as! NSNumber).uintValue, options: mapToChannelMediaOptions(params["options"] as! Dictionary))) } @objc func joinChannelWithUserAccount(_ params: NSDictionary, _ callback: Callback) { @@ -218,11 +218,11 @@ class RtcChannelManager: NSObject, RtcChannelInterface { } @objc func adjustUserPlaybackSignalVolume(_ params: NSDictionary, _ callback: Callback) { - callback.code(self[params["channelId"] as! String]?.adjustUserPlaybackSignalVolume(params["uid"] as! UInt, volume: params["volume"] as! Int32)) + callback.code(self[params["channelId"] as! String]?.adjustUserPlaybackSignalVolume((params["uid"] as! NSNumber).uintValue, volume: (params["volume"] as! NSNumber).int32Value)) } @objc func muteRemoteAudioStream(_ params: NSDictionary, _ callback: Callback) { - callback.code(self[params["channelId"] as! String]?.muteRemoteAudioStream(params["uid"] as! UInt, mute: params["muted"] as! Bool)) + callback.code(self[params["channelId"] as! String]?.muteRemoteAudioStream((params["uid"] as! NSNumber).uintValue, mute: params["muted"] as! Bool)) } @objc func muteAllRemoteAudioStreams(_ params: NSDictionary, _ callback: Callback) { @@ -234,7 +234,7 @@ class RtcChannelManager: NSObject, RtcChannelInterface { } @objc func muteRemoteVideoStream(_ params: NSDictionary, _ callback: Callback) { - callback.code(self[params["channelId"] as! String]?.muteRemoteVideoStream(params["uid"] as! UInt, mute: params["muted"] as! Bool)) + callback.code(self[params["channelId"] as! String]?.muteRemoteVideoStream((params["uid"] as! NSNumber).uintValue, mute: params["muted"] as! Bool)) } @objc func muteAllRemoteVideoStreams(_ params: NSDictionary, _ callback: Callback) { @@ -246,7 +246,7 @@ class RtcChannelManager: NSObject, RtcChannelInterface { } @objc func setRemoteVoicePosition(_ params: NSDictionary, _ callback: Callback) { - callback.code(self[params["channelId"] as! String]?.setRemoteVoicePosition(params["uid"] as! UInt, pan: params["pan"] as! Double, gain: params["gain"] as! Double)) + callback.code(self[params["channelId"] as! String]?.setRemoteVoicePosition((params["uid"] as! NSNumber).uintValue, pan: (params["pan"] as! NSNumber).doubleValue, gain: (params["gain"] as! NSNumber).doubleValue)) } @objc func setLiveTranscoding(_ params: NSDictionary, _ callback: Callback) { @@ -274,15 +274,15 @@ class RtcChannelManager: NSObject, RtcChannelInterface { } @objc func setRemoteVideoStreamType(_ params: NSDictionary, _ callback: Callback) { - callback.code(self[params["channelId"] as! String]?.setRemoteVideoStream(params["uid"] as! UInt, type: AgoraVideoStreamType(rawValue: params["streamType"] as! Int)!)) + callback.code(self[params["channelId"] as! String]?.setRemoteVideoStream((params["uid"] as! NSNumber).uintValue, type: AgoraVideoStreamType(rawValue: (params["streamType"] as! NSNumber).intValue)!)) } @objc func setRemoteDefaultVideoStreamType(_ params: NSDictionary, _ callback: Callback) { - callback.code(self[params["channelId"] as! String]?.setRemoteDefaultVideoStreamType(AgoraVideoStreamType(rawValue: params["streamType"] as! Int)!)) + callback.code(self[params["channelId"] as! String]?.setRemoteDefaultVideoStreamType(AgoraVideoStreamType(rawValue: (params["streamType"] as! NSNumber).intValue)!)) } @objc func setRemoteUserPriority(_ params: NSDictionary, _ callback: Callback) { - callback.code(self[params["channelId"] as! String]?.setRemoteUserPriority(params["uid"] as! UInt, type: AgoraUserPriority(rawValue: params["userPriority"] as! Int)!)) + callback.code(self[params["channelId"] as! String]?.setRemoteUserPriority((params["uid"] as! NSNumber).uintValue, type: AgoraUserPriority(rawValue: (params["userPriority"] as! NSNumber).intValue)!)) } @objc func registerMediaMetadataObserver(_ params: NSDictionary, _ callback: Callback) { @@ -313,7 +313,7 @@ class RtcChannelManager: NSObject, RtcChannelInterface { @objc func setMaxMetadataSize(_ params: NSDictionary, _ callback: Callback) { callback.resolve(mediaObserverMap[params["channelId"] as! String]) { - $0.setMaxMetadataSize(params["size"] as! Int) + $0.setMaxMetadataSize((params["size"] as! NSNumber).intValue) } } @@ -329,7 +329,7 @@ class RtcChannelManager: NSObject, RtcChannelInterface { @objc func setEncryptionMode(_ params: NSDictionary, _ callback: Callback) { var encryptionMode = "" - switch params["encryptionMode"] as! Int { + switch (params["encryptionMode"] as! NSNumber).intValue { case AgoraEncryptionMode.AES128XTS.rawValue: encryptionMode = "aes-128-xts" case AgoraEncryptionMode.AES128ECB.rawValue: @@ -364,10 +364,10 @@ class RtcChannelManager: NSObject, RtcChannelInterface { } @objc func sendStreamMessage(_ params: NSDictionary, _ callback: Callback) { - callback.code(self[params["channelId"] as! String]?.sendStreamMessage(params["streamId"] as! Int, data: (params["message"] as! String).data(using: .utf8)!)) + callback.code(self[params["channelId"] as! String]?.sendStreamMessage((params["streamId"] as! NSNumber).intValue, data: (params["message"] as! String).data(using: .utf8)!)) } @objc func enableRemoteSuperResolution(_ params: NSDictionary, callback: Callback) { - callback.code(self[params["channelId"] as! String]?.enableRemoteSuperResolution(params["uid"] as! UInt, enabled: params["enable"] as! Bool)) + callback.code(self[params["channelId"] as! String]?.enableRemoteSuperResolution((params["uid"] as! NSNumber).uintValue, enabled: params["enable"] as! Bool)) } } diff --git a/RtcEngine.swift b/RtcEngine.swift index 805d92748..2e06d115b 100644 --- a/RtcEngine.swift +++ b/RtcEngine.swift @@ -391,7 +391,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface { self?.emitter($0, $1) } engine = AgoraRtcEngineKit.sharedEngine(with: mapToRtcEngineConfig(params["config"] as! Dictionary), delegate: delegate) - callback.code(engine?.setAppType(AgoraRtcAppType(rawValue: params["appType"] as! UInt)!)) + callback.code(engine?.setAppType(AgoraRtcAppType(rawValue: (params["appType"] as! NSNumber).uintValue)!)) } @objc func destroy(_ callback: Callback) { @@ -401,11 +401,11 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func setChannelProfile(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setChannelProfile(AgoraChannelProfile(rawValue: params["profile"] as! Int)!)) + callback.code(engine?.setChannelProfile(AgoraChannelProfile(rawValue: (params["profile"] as! NSNumber).intValue)!)) } @objc func setClientRole(_ params: NSDictionary, _ callback: Callback) { - let role = AgoraClientRole(rawValue: params["role"] as! Int)! + let role = AgoraClientRole(rawValue: (params["role"] as! NSNumber).intValue)! if let options = params["options"] as? Dictionary { callback.code(engine?.setClientRole(role, options: mapToClientRoleOptions(options))) return @@ -417,12 +417,12 @@ class RtcEngineManager: NSObject, RtcEngineInterface { let token = params["token"] as? String let channelName = params["channelName"] as! String let optionalInfo = params["optionalInfo"] as? String - let optionalUid = params["optionalUid"] as! UInt + let optionalUid = params["optionalUid"] as! NSNumber if let options = params["options"] as? Dictionary { - callback.code(engine?.joinChannel(byToken: token, channelId: channelName, info: optionalInfo, uid: optionalUid, options: mapToChannelMediaOptions(options))) + callback.code(engine?.joinChannel(byToken: token, channelId: channelName, info: optionalInfo, uid: optionalUid.uintValue, options: mapToChannelMediaOptions(options))) return } - callback.code(engine?.joinChannel(byToken: token, channelId: channelName, info: optionalInfo, uid: optionalUid)) + callback.code(engine?.joinChannel(byToken: token, channelId: channelName, info: optionalInfo, uid: optionalUid.uintValue)) } @objc func switchChannel(_ params: NSDictionary, _ callback: Callback) { @@ -454,7 +454,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func sendCustomReportMessage(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.sendCustomReportMessage(params["id"] as! String, category: params["category"] as! String, event: params["event"] as! String, label: params["label"] as! String, value: params["value"] as! Int)) + callback.code(engine?.sendCustomReportMessage(params["id"] as! String, category: params["category"] as! String, event: params["event"] as! String, label: params["label"] as! String, value: (params["value"] as! NSNumber).intValue)) } @objc func getCallId(_ callback: Callback) { @@ -464,7 +464,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func rate(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.rate(params["callId"] as! String, rating: params["rating"] as! Int, description: params["description"] as? String)) + callback.code(engine?.rate(params["callId"] as! String, rating: (params["rating"] as! NSNumber).intValue, description: params["description"] as? String)) } @objc func complain(_ params: NSDictionary, _ callback: Callback) { @@ -476,11 +476,11 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func setLogFilter(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setLogFilter(params["filter"] as! UInt)) + callback.code(engine?.setLogFilter((params["filter"] as! NSNumber).uintValue)) } @objc func setLogFileSize(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setLogFileSize((params["fileSizeInKBytes"] as! UInt))) + callback.code(engine?.setLogFileSize((params["fileSizeInKBytes"] as! NSNumber).uintValue)) } @objc func getNativeHandle(_ callback: Callback) { @@ -516,7 +516,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface { @objc func getUserInfoByUid(_ params: NSDictionary, _ callback: Callback) { callback.resolve(engine) { - $0.getUserInfo(byUid: params["uid"] as! UInt, withError: nil)?.toMap() + $0.getUserInfo(byUid: (params["uid"] as! NSNumber).uintValue, withError: nil)?.toMap() } } @@ -529,19 +529,19 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func setAudioProfile(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setAudioProfile(AgoraAudioProfile(rawValue: params["profile"] as! Int)!, scenario: AgoraAudioScenario(rawValue: params["scenario"] as! Int)!)) + callback.code(engine?.setAudioProfile(AgoraAudioProfile(rawValue: (params["profile"] as! NSNumber).intValue)!, scenario: AgoraAudioScenario(rawValue: (params["scenario"] as! NSNumber).intValue)!)) } @objc func adjustRecordingSignalVolume(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.adjustRecordingSignalVolume(params["volume"] as! Int)) + callback.code(engine?.adjustRecordingSignalVolume((params["volume"] as! NSNumber).intValue)) } @objc func adjustUserPlaybackSignalVolume(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.adjustUserPlaybackSignalVolume(params["uid"] as! UInt, volume: params["volume"] as! Int32)) + callback.code(engine?.adjustUserPlaybackSignalVolume((params["uid"] as! NSNumber).uintValue, volume: (params["volume"] as! NSNumber).int32Value)) } @objc func adjustPlaybackSignalVolume(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.adjustPlaybackSignalVolume(params["volume"] as! Int)) + callback.code(engine?.adjustPlaybackSignalVolume((params["volume"] as! NSNumber).intValue)) } @objc func enableLocalAudio(_ params: NSDictionary, _ callback: Callback) { @@ -553,7 +553,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func muteRemoteAudioStream(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.muteRemoteAudioStream(params["uid"] as! UInt, mute: params["muted"] as! Bool)) + callback.code(engine?.muteRemoteAudioStream((params["uid"] as! NSNumber).uintValue, mute: params["muted"] as! Bool)) } @objc func muteAllRemoteAudioStreams(_ params: NSDictionary, _ callback: Callback) { @@ -565,7 +565,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func enableAudioVolumeIndication(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.enableAudioVolumeIndication(params["interval"] as! Int, smooth: params["smooth"] as! Int, report_vad: params["report_vad"] as! Bool)) + callback.code(engine?.enableAudioVolumeIndication((params["interval"] as! NSNumber).intValue, smooth: (params["smooth"] as! NSNumber).intValue, report_vad: params["report_vad"] as! Bool)) } @objc func enableVideo(_ callback: Callback) { @@ -597,7 +597,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func muteRemoteVideoStream(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.muteRemoteVideoStream(params["uid"] as! UInt, mute: params["muted"] as! Bool)) + callback.code(engine?.muteRemoteVideoStream((params["uid"] as! NSNumber).uintValue, mute: params["muted"] as! Bool)) } @objc func muteAllRemoteVideoStreams(_ params: NSDictionary, _ callback: Callback) { @@ -613,7 +613,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func startAudioMixing(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.startAudioMixing(params["filePath"] as! String, loopback: params["loopback"] as! Bool, replace: params["replace"] as! Bool, cycle: params["cycle"] as! Int)) + callback.code(engine?.startAudioMixing(params["filePath"] as! String, loopback: params["loopback"] as! Bool, replace: params["replace"] as! Bool, cycle: (params["cycle"] as! NSNumber).intValue)) } @objc func stopAudioMixing(_ callback: Callback) { @@ -629,15 +629,15 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func adjustAudioMixingVolume(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.adjustAudioMixingVolume(params["volume"] as! Int)) + callback.code(engine?.adjustAudioMixingVolume((params["volume"] as! NSNumber).intValue)) } @objc func adjustAudioMixingPlayoutVolume(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.adjustAudioMixingPlayoutVolume(params["volume"] as! Int)) + callback.code(engine?.adjustAudioMixingPlayoutVolume((params["volume"] as! NSNumber).intValue)) } @objc func adjustAudioMixingPublishVolume(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.adjustAudioMixingPublishVolume(params["volume"] as! Int)) + callback.code(engine?.adjustAudioMixingPublishVolume((params["volume"] as! NSNumber).intValue)) } @objc func getAudioMixingPlayoutVolume(_ callback: Callback) { @@ -665,11 +665,11 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func setAudioMixingPosition(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setAudioMixingPosition(params["pos"] as! Int)) + callback.code(engine?.setAudioMixingPosition((params["pos"] as! NSNumber).intValue)) } @objc func setAudioMixingPitch(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setAudioMixingPitch(params["pitch"] as! Int)) + callback.code(engine?.setAudioMixingPitch((params["pitch"] as! NSNumber).intValue)) } @objc func getEffectsVolume(_ callback: Callback) { @@ -679,19 +679,19 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func setEffectsVolume(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setEffectsVolume(params["volume"] as! Double)) + callback.code(engine?.setEffectsVolume((params["volume"] as! NSNumber).doubleValue)) } @objc func setVolumeOfEffect(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setVolumeOfEffect(params["soundId"] as! Int32, withVolume: params["volume"] as! Double)) + callback.code(engine?.setVolumeOfEffect((params["soundId"] as! NSNumber).int32Value, withVolume: (params["volume"] as! NSNumber).doubleValue)) } @objc func playEffect(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.playEffect(params["soundId"] as! Int32, filePath: params["filePath"] as? String, loopCount: params["loopCount"] as! Int32, pitch: params["pitch"] as! Double, pan: params["pan"] as! Double, gain: params["gain"] as! Double, publish: params["publish"] as! Bool)) + callback.code(engine?.playEffect((params["soundId"] as! NSNumber).int32Value, filePath: params["filePath"] as? String, loopCount: (params["loopCount"] as! NSNumber).int32Value, pitch: (params["pitch"] as! NSNumber).doubleValue, pan: (params["pan"] as! NSNumber).doubleValue, gain: (params["gain"] as! NSNumber).doubleValue, publish: params["publish"] as! Bool)) } @objc func stopEffect(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.stopEffect(params["soundId"] as! Int32)) + callback.code(engine?.stopEffect((params["soundId"] as! NSNumber).int32Value)) } @objc func stopAllEffects(_ callback: Callback) { @@ -699,15 +699,15 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func preloadEffect(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.preloadEffect(params["soundId"] as! Int32, filePath: params["filePath"] as? String)) + callback.code(engine?.preloadEffect((params["soundId"] as! NSNumber).int32Value, filePath: params["filePath"] as? String)) } @objc func unloadEffect(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.unloadEffect(params["soundId"] as! Int32)) + callback.code(engine?.unloadEffect((params["soundId"] as! NSNumber).int32Value)) } @objc func pauseEffect(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.pauseEffect(params["soundId"] as! Int32)) + callback.code(engine?.pauseEffect((params["soundId"] as! NSNumber).int32Value)) } @objc func pauseAllEffects(_ callback: Callback) { @@ -715,7 +715,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func resumeEffect(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.resumeEffect(params["soundId"] as! Int32)) + callback.code(engine?.resumeEffect((params["soundId"] as! NSNumber).int32Value)) } @objc func resumeAllEffects(_ callback: Callback) { @@ -724,44 +724,44 @@ class RtcEngineManager: NSObject, RtcEngineInterface { @objc func setAudioSessionOperationRestriction(_ params: NSDictionary, _ callback: Callback) { callback.resolve(engine) { - $0.setAudioSessionOperationRestriction(AgoraAudioSessionOperationRestriction(rawValue: params["restriction"] as! UInt)) + $0.setAudioSessionOperationRestriction(AgoraAudioSessionOperationRestriction(rawValue: (params["restriction"] as! NSNumber).uintValue)) } } @objc func setLocalVoiceChanger(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setLocalVoiceChanger(AgoraAudioVoiceChanger(rawValue: params["voiceChanger"] as! Int)!)) + callback.code(engine?.setLocalVoiceChanger(AgoraAudioVoiceChanger(rawValue: (params["voiceChanger"] as! NSNumber).intValue)!)) } @objc func setLocalVoiceReverbPreset(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setLocalVoiceReverbPreset(AgoraAudioReverbPreset(rawValue: params["preset"] as! Int)!)) + callback.code(engine?.setLocalVoiceReverbPreset(AgoraAudioReverbPreset(rawValue: (params["preset"] as! NSNumber).intValue)!)) } @objc func setLocalVoicePitch(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setLocalVoicePitch(params["pitch"] as! Double)) + callback.code(engine?.setLocalVoicePitch((params["pitch"] as! NSNumber).doubleValue)) } @objc func setLocalVoiceEqualization(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setLocalVoiceEqualizationOf(AgoraAudioEqualizationBandFrequency(rawValue: params["bandFrequency"] as! Int)!, withGain: params["bandGain"] as! Int)) + callback.code(engine?.setLocalVoiceEqualizationOf(AgoraAudioEqualizationBandFrequency(rawValue: (params["bandFrequency"] as! NSNumber).intValue)!, withGain: (params["bandGain"] as! NSNumber).intValue)) } @objc func setLocalVoiceReverb(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setLocalVoiceReverbOf(AgoraAudioReverbType(rawValue: params["reverbKey"] as! Int)!, withValue: params["value"] as! Int)) + callback.code(engine?.setLocalVoiceReverbOf(AgoraAudioReverbType(rawValue: (params["reverbKey"] as! NSNumber).intValue)!, withValue: (params["value"] as! NSNumber).intValue)) } @objc func setAudioEffectPreset(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setAudioEffectPreset(AgoraAudioEffectPreset(rawValue: params["preset"] as! Int)!)) + callback.code(engine?.setAudioEffectPreset(AgoraAudioEffectPreset(rawValue: (params["preset"] as! NSNumber).intValue)!)) } @objc func setVoiceBeautifierPreset(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setVoiceBeautifierPreset(AgoraVoiceBeautifierPreset(rawValue: params["preset"] as! Int)!)) + callback.code(engine?.setVoiceBeautifierPreset(AgoraVoiceBeautifierPreset(rawValue: (params["preset"] as! NSNumber).intValue)!)) } @objc func setVoiceConversionPreset(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setVoiceConversionPreset(AgoraVoiceConversionPreset(rawValue: params["preset"] as! Int)!)) + callback.code(engine?.setVoiceConversionPreset(AgoraVoiceConversionPreset(rawValue: (params["preset"] as! NSNumber).intValue)!)) } @objc func setAudioEffectParameters(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setAudioEffectParameters(AgoraAudioEffectPreset(rawValue: params["preset"] as! Int)!, param1: params["param1"] as! Int32, param2: params["param2"] as! Int32)) + callback.code(engine?.setAudioEffectParameters(AgoraAudioEffectPreset(rawValue: (params["preset"] as! NSNumber).intValue)!, param1: (params["param1"] as! NSNumber).int32Value, param2: (params["param2"] as! NSNumber).int32Value)) } @objc func enableSoundPositionIndication(_ params: NSDictionary, _ callback: Callback) { @@ -769,7 +769,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func setRemoteVoicePosition(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setRemoteVoicePosition(params["uid"] as! UInt, pan: params["pan"] as! Double, gain: params["gain"] as! Double)) + callback.code(engine?.setRemoteVoicePosition((params["uid"] as! NSNumber).uintValue, pan: (params["pan"] as! NSNumber).doubleValue, gain: (params["gain"] as! NSNumber).doubleValue)) } @objc func setLiveTranscoding(_ params: NSDictionary, _ callback: Callback) { @@ -815,7 +815,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func setInEarMonitoringVolume(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setInEarMonitoringVolume(params["volume"] as! Int)) + callback.code(engine?.setInEarMonitoringVolume((params["volume"] as! NSNumber).intValue)) } @objc func enableDualStreamMode(_ params: NSDictionary, _ callback: Callback) { @@ -823,27 +823,27 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func setRemoteVideoStreamType(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setRemoteVideoStream(params["uid"] as! UInt, type: AgoraVideoStreamType(rawValue: params["streamType"] as! Int)!)) + callback.code(engine?.setRemoteVideoStream((params["uid"] as! NSNumber).uintValue, type: AgoraVideoStreamType(rawValue: (params["streamType"] as! NSNumber).intValue)!)) } @objc func setRemoteDefaultVideoStreamType(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setRemoteDefaultVideoStreamType(AgoraVideoStreamType(rawValue: params["streamType"] as! Int)!)) + callback.code(engine?.setRemoteDefaultVideoStreamType(AgoraVideoStreamType(rawValue: (params["streamType"] as! NSNumber).intValue)!)) } @objc func setLocalPublishFallbackOption(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setLocalPublishFallbackOption(AgoraStreamFallbackOptions(rawValue: params["option"] as! Int)!)) + callback.code(engine?.setLocalPublishFallbackOption(AgoraStreamFallbackOptions(rawValue: (params["option"] as! NSNumber).intValue)!)) } @objc func setRemoteSubscribeFallbackOption(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setRemoteSubscribeFallbackOption(AgoraStreamFallbackOptions(rawValue: params["option"] as! Int)!)) + callback.code(engine?.setRemoteSubscribeFallbackOption(AgoraStreamFallbackOptions(rawValue: (params["option"] as! NSNumber).intValue)!)) } @objc func setRemoteUserPriority(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.setRemoteUserPriority(params["uid"] as! UInt, type: AgoraUserPriority(rawValue: params["userPriority"] as! Int)!)) + callback.code(engine?.setRemoteUserPriority((params["uid"] as! NSNumber).uintValue, type: AgoraUserPriority(rawValue: (params["userPriority"] as! NSNumber).intValue)!)) } @objc func startEchoTest(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.startEchoTest(withInterval: params["intervalInSeconds"] as! Int)) + callback.code(engine?.startEchoTest(withInterval: (params["intervalInSeconds"] as! NSNumber).intValue)) } @objc func stopEchoTest(_ callback: Callback) { @@ -889,7 +889,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface { @objc func setMaxMetadataSize(_ params: NSDictionary, _ callback: Callback) { callback.resolve(mediaObserver) { - $0.setMaxMetadataSize(params["size"] as! Int) + $0.setMaxMetadataSize((params["size"] as! NSNumber).intValue) } } @@ -913,7 +913,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface { @objc func setEncryptionMode(_ params: NSDictionary, _ callback: Callback) { var encryptionMode = "" - switch params["encryptionMode"] as! Int { + switch (params["encryptionMode"] as! NSNumber).intValue { case AgoraEncryptionMode.AES128XTS.rawValue: encryptionMode = "aes-128-xts" case AgoraEncryptionMode.AES128ECB.rawValue: @@ -930,7 +930,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func startAudioRecording(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.startAudioRecording(params["filePath"] as! String, sampleRate: params["sampleRate"] as! Int, quality: AgoraAudioRecordingQuality(rawValue: params["quality"] as! Int)!)) + callback.code(engine?.startAudioRecording(params["filePath"] as! String, sampleRate: (params["sampleRate"] as! NSNumber).intValue, quality: AgoraAudioRecordingQuality(rawValue: (params["quality"] as! NSNumber).intValue)!)) } @objc func stopAudioRecording(_ callback: Callback) { @@ -979,7 +979,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface { @objc func setCameraZoomFactor(_ params: NSDictionary, _ callback: Callback) { callback.resolve(engine) { - $0.setCameraZoomFactor(CGFloat(params["factor"] as! Float)) + $0.setCameraZoomFactor(CGFloat(truncating: params["factor"] as! NSNumber)) return nil } } @@ -990,14 +990,14 @@ class RtcEngineManager: NSObject, RtcEngineInterface { @objc func setCameraFocusPositionInPreview(_ params: NSDictionary, _ callback: Callback) { callback.resolve(engine) { - $0.setCameraFocusPositionInPreview(CGPoint(x: params["positionX"] as! Double, y: params["positionY"] as! Double)) + $0.setCameraFocusPositionInPreview(CGPoint(x: (params["positionX"] as! NSNumber).doubleValue, y: (params["positionY"] as! NSNumber).doubleValue)) return nil } } @objc func setCameraExposurePosition(_ params: NSDictionary, _ callback: Callback) { callback.resolve(engine) { - $0.setCameraExposurePosition(CGPoint(x: params["positionXinView"] as! Double, y: params["positionYinView"] as! Double)) + $0.setCameraExposurePosition(CGPoint(x: (params["positionXinView"] as! NSNumber).doubleValue, y: (params["positionYinView"] as! NSNumber).doubleValue)) return nil } } @@ -1033,11 +1033,11 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func sendStreamMessage(_ params: NSDictionary, _ callback: Callback) { - callback.code(engine?.sendStreamMessage(params["streamId"] as! Int, data: (params["message"] as! String).data(using: .utf8)!)) + callback.code(engine?.sendStreamMessage((params["streamId"] as! NSNumber).intValue, data: (params["message"] as! String).data(using: .utf8)!)) } @objc func setVoiceBeautifierParameters(_ params: NSDictionary, callback: Callback) { - callback.code(engine?.setVoiceBeautifierParameters(AgoraVoiceBeautifierPreset.init(rawValue: params["preset"] as! Int)!, param1: params["param1"] as! Int32, param2: params["param2"] as! Int32)) + callback.code(engine?.setVoiceBeautifierParameters(AgoraVoiceBeautifierPreset.init(rawValue: (params["preset"] as! NSNumber).intValue)!, param1: (params["param1"] as! NSNumber).int32Value, param2: (params["param2"] as! NSNumber).int32Value)) } @objc func getSdkVersion(callback: Callback) { @@ -1045,7 +1045,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func getErrorDescription(_ params: NSDictionary, callback: Callback) { - callback.success(AgoraRtcEngineKit.getErrorDescription(params["code"] as! Int)) + callback.success(AgoraRtcEngineKit.getErrorDescription((params["code"] as! NSNumber).intValue)) } @objc func enableDeepLearningDenoise(_ params: NSDictionary, callback: Callback) { @@ -1053,7 +1053,7 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func setCloudProxy(_ params: NSDictionary, callback: Callback) { - callback.code(engine?.setCloudProxy(AgoraCloudProxyType.init(rawValue: params["proxyType"] as! UInt)!)) + callback.code(engine?.setCloudProxy(AgoraCloudProxyType.init(rawValue: (params["proxyType"] as! NSNumber).uintValue)!)) } @objc func uploadLogFile(callback: Callback) { @@ -1063,6 +1063,6 @@ class RtcEngineManager: NSObject, RtcEngineInterface { } @objc func enableRemoteSuperResolution(_ params: NSDictionary, callback: Callback) { - callback.code(engine?.enableRemoteSuperResolution(params["uid"] as! UInt, enabled: params["enabled"] as! Bool)) + callback.code(engine?.enableRemoteSuperResolution((params["uid"] as! NSNumber).uintValue, enabled: params["enabled"] as! Bool)) } } diff --git a/RtcSurfaceView.swift b/RtcSurfaceView.swift index 9ae740cab..89b4f9826 100644 --- a/RtcSurfaceView.swift +++ b/RtcSurfaceView.swift @@ -37,10 +37,10 @@ class RtcSurfaceView: UIView { removeObserver(self, forKeyPath: observerForKeyPath(), context: nil) } - func setData(_ engine: AgoraRtcEngineKit, _ channel: AgoraRtcChannel?, _ uid: Int) { + func setData(_ engine: AgoraRtcEngineKit, _ channel: AgoraRtcChannel?, _ uid: UInt) { self.channel = channel canvas.channelId = channel?.getId() - canvas.uid = UInt(uid) + canvas.uid = uid setupVideoCanvas(engine) } @@ -73,13 +73,13 @@ class RtcSurfaceView: UIView { } } - func setRenderMode(_ engine: AgoraRtcEngineKit, _ renderMode: Int) { - canvas.renderMode = AgoraVideoRenderMode(rawValue: UInt(renderMode))! + func setRenderMode(_ engine: AgoraRtcEngineKit, _ renderMode: UInt) { + canvas.renderMode = AgoraVideoRenderMode(rawValue: renderMode)! setupRenderMode(engine) } - func setMirrorMode(_ engine: AgoraRtcEngineKit, _ mirrorMode: Int) { - canvas.mirrorMode = AgoraVideoMirrorMode(rawValue: UInt(mirrorMode))! + func setMirrorMode(_ engine: AgoraRtcEngineKit, _ mirrorMode: UInt) { + canvas.mirrorMode = AgoraVideoMirrorMode(rawValue: mirrorMode)! setupRenderMode(engine) }