From cdc9eaebc11d49afa4d035ecafc00880d2a2c68c Mon Sep 17 00:00:00 2001 From: "Jerry.Luo" <396912848@qq.com> Date: Fri, 7 May 2021 16:44:38 +0800 Subject: [PATCH] fix(uid compatible): int to uint --- android/build.gradle | 2 +- .../java/io/agora/rtc/base/BeanCovertor.kt | 4 +- .../main/java/io/agora/rtc/base/Extensions.kt | 17 ++++-- .../java/io/agora/rtc/base/MediaObserver.kt | 2 +- .../main/java/io/agora/rtc/base/RtcChannel.kt | 16 ++--- .../java/io/agora/rtc/base/RtcChannelEvent.kt | 32 +++++----- .../main/java/io/agora/rtc/base/RtcEngine.kt | 18 +++--- .../java/io/agora/rtc/base/RtcEngineEvent.kt | 58 +++++++++---------- .../react/RCTAgoraRtcSurfaceViewManager.kt | 3 +- .../react/RCTAgoraRtcTextureViewManager.kt | 3 +- 10 files changed, 83 insertions(+), 72 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index dbe3ca239..2e35c8a91 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -127,7 +127,7 @@ def kotlin_version = getExtOrDefault('kotlinVersion') dependencies { // noinspection GradleDynamicVersion api 'com.facebook.react:react-native:+' - api 'com.github.agorabuilder:native-full-sdk:3.4.1' + api 'com.github.agorabuilder:native-full-sdk:3.4.1.1' implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } diff --git a/android/src/main/java/io/agora/rtc/base/BeanCovertor.kt b/android/src/main/java/io/agora/rtc/base/BeanCovertor.kt index 6b3150b4d..7206eb324 100644 --- a/android/src/main/java/io/agora/rtc/base/BeanCovertor.kt +++ b/android/src/main/java/io/agora/rtc/base/BeanCovertor.kt @@ -55,7 +55,7 @@ fun mapToAgoraImage(map: Map<*, *>): AgoraImage { fun mapToTranscodingUser(map: Map<*, *>): TranscodingUser { return TranscodingUser().apply { - (map["uid"] as? Number)?.let { uid = it.toInt() } + map["uid"]?.toSDKUInt()?.let { uid = it } (map["x"] as? Number)?.let { x = it.toInt() } (map["y"] as? Number)?.let { y = it.toInt() } (map["width"] as? Number)?.let { width = it.toInt() } @@ -105,7 +105,7 @@ fun mapToChannelMediaInfo(map: Map<*, *>): ChannelMediaInfo { return ChannelMediaInfo( map["channelName"] as? String, map["token"] as? String, - (map["uid"] as Number).toInt() + map["uid"]?.toSDKUInt()!! ) } diff --git a/android/src/main/java/io/agora/rtc/base/Extensions.kt b/android/src/main/java/io/agora/rtc/base/Extensions.kt index 147593fc0..766231c8e 100644 --- a/android/src/main/java/io/agora/rtc/base/Extensions.kt +++ b/android/src/main/java/io/agora/rtc/base/Extensions.kt @@ -6,7 +6,7 @@ import io.agora.rtc.models.UserInfo fun UserInfo.toMap(): Map { return hashMapOf( - "uid" to uid, + "uid" to uid.toJSUInt(), "userAccount" to userAccount ) } @@ -59,7 +59,7 @@ fun Rect.toMap(): Map { fun RemoteAudioStats.toMap(): Map { return hashMapOf( - "uid" to uid, + "uid" to uid.toJSUInt(), "quality" to quality, "networkTransportDelay" to networkTransportDelay, "jitterBufferDelay" to jitterBufferDelay, @@ -99,7 +99,7 @@ fun LocalVideoStats.toMap(): Map { fun RemoteVideoStats.toMap(): Map { return hashMapOf( - "uid" to uid, + "uid" to uid.toJSUInt(), "delay" to delay, "width" to width, "height" to height, @@ -117,7 +117,7 @@ fun RemoteVideoStats.toMap(): Map { fun AudioVolumeInfo.toMap(): Map { return hashMapOf( - "uid" to uid, + "uid" to uid.toJSUInt(), "volume" to volume, "vad" to vad, "channelId" to channelId @@ -158,3 +158,12 @@ fun AgoraFacePositionInfo.toMap(): Map { fun Array.toMapList(): List> { return List(size) { this[it].toMap() } } + +@ExperimentalUnsignedTypes +fun Any.toSDKUInt(): Int? { + return (this as? Number)?.toLong()?.toUInt()?.toInt() +} + +fun Int.toJSUInt(): Long { + return this.toUInt().toLong(); +} diff --git a/android/src/main/java/io/agora/rtc/base/MediaObserver.kt b/android/src/main/java/io/agora/rtc/base/MediaObserver.kt index 21f3b20c3..1b7677034 100644 --- a/android/src/main/java/io/agora/rtc/base/MediaObserver.kt +++ b/android/src/main/java/io/agora/rtc/base/MediaObserver.kt @@ -32,7 +32,7 @@ class MediaObserver( override fun onMetadataReceived(buffer: ByteArray, uid: Int, timeStampMs: Long) { emit(hashMapOf( - "data" to arrayListOf(String(buffer), uid, timeStampMs) + "data" to arrayListOf(String(buffer), uid.toJSUInt(), timeStampMs) )) } } diff --git a/android/src/main/java/io/agora/rtc/base/RtcChannel.kt b/android/src/main/java/io/agora/rtc/base/RtcChannel.kt index 461a9bda7..946c64670 100644 --- a/android/src/main/java/io/agora/rtc/base/RtcChannel.kt +++ b/android/src/main/java/io/agora/rtc/base/RtcChannel.kt @@ -159,7 +159,7 @@ class RtcChannelManager( } override fun joinChannel(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.joinChannel(params["token"] as? String, params["optionalInfo"] as? String, (params["optionalUid"] as Number).toInt(), mapToChannelMediaOptions(params["options"] as Map<*, *>))) + callback.code(this[params["channelId"] as String]?.joinChannel(params["token"] as? String, params["optionalInfo"] as? String, params["optionalUid"]?.toSDKUInt()!!, mapToChannelMediaOptions(params["options"] as Map<*, *>))) } override fun joinChannelWithUserAccount(params: Map, callback: Callback) { @@ -191,11 +191,11 @@ class RtcChannelManager( } override fun adjustUserPlaybackSignalVolume(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.adjustUserPlaybackSignalVolume((params["uid"] as Number).toInt(), (params["volume"] as Number).toInt())) + callback.code(this[params["channelId"] as String]?.adjustUserPlaybackSignalVolume(params["uid"]?.toSDKUInt()!!, (params["volume"] as Number).toInt())) } override fun muteRemoteAudioStream(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.muteRemoteAudioStream((params["uid"] as Number).toInt(), params["muted"] as Boolean)) + callback.code(this[params["channelId"] as String]?.muteRemoteAudioStream(params["uid"]?.toSDKUInt()!!, params["muted"] as Boolean)) } override fun muteAllRemoteAudioStreams(params: Map, callback: Callback) { @@ -207,7 +207,7 @@ class RtcChannelManager( } override fun muteRemoteVideoStream(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.muteRemoteVideoStream((params["uid"] as Number).toInt(), params["muted"] as Boolean)) + callback.code(this[params["channelId"] as String]?.muteRemoteVideoStream(params["uid"]?.toSDKUInt()!!, params["muted"] as Boolean)) } override fun muteAllRemoteVideoStreams(params: Map, callback: Callback) { @@ -219,11 +219,11 @@ class RtcChannelManager( } override fun enableRemoteSuperResolution(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.enableRemoteSuperResolution((params["uid"] as Number).toInt(), params["enable"] as Boolean)) + callback.code(this[params["channelId"] as String]?.enableRemoteSuperResolution(params["uid"]?.toSDKUInt()!!, params["enable"] as Boolean)) } override fun setRemoteVoicePosition(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.setRemoteVoicePosition((params["uid"] as Number).toInt(), (params["pan"] as Number).toDouble(), (params["gain"] as Number).toDouble())) + callback.code(this[params["channelId"] as String]?.setRemoteVoicePosition(params["uid"]?.toSDKUInt()!!, (params["pan"] as Number).toDouble(), (params["gain"] as Number).toDouble())) } override fun setLiveTranscoding(params: Map, callback: Callback) { @@ -251,7 +251,7 @@ class RtcChannelManager( } override fun setRemoteVideoStreamType(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.setRemoteVideoStreamType((params["uid"] as Number).toInt(), (params["streamType"] as Number).toInt())) + callback.code(this[params["channelId"] as String]?.setRemoteVideoStreamType(params["uid"]?.toSDKUInt()!!, (params["streamType"] as Number).toInt())) } override fun setRemoteDefaultVideoStreamType(params: Map, callback: Callback) { @@ -259,7 +259,7 @@ class RtcChannelManager( } override fun setRemoteUserPriority(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.setRemoteUserPriority((params["uid"] as Number).toInt(), (params["userPriority"] as Number).toInt())) + callback.code(this[params["channelId"] as String]?.setRemoteUserPriority(params["uid"]?.toSDKUInt()!!, (params["userPriority"] as Number).toInt())) } override fun registerMediaMetadataObserver(params: Map, callback: Callback) { diff --git a/android/src/main/java/io/agora/rtc/base/RtcChannelEvent.kt b/android/src/main/java/io/agora/rtc/base/RtcChannelEvent.kt index 71ff02ae9..f9b74e05d 100644 --- a/android/src/main/java/io/agora/rtc/base/RtcChannelEvent.kt +++ b/android/src/main/java/io/agora/rtc/base/RtcChannelEvent.kt @@ -112,11 +112,11 @@ class RtcChannelEventHandler( } override fun onJoinChannelSuccess(rtcChannel: RtcChannel?, uid: Int, elapsed: Int) { - callback(RtcChannelEvents.JoinChannelSuccess, rtcChannel, rtcChannel?.channelId(), uid, elapsed) + callback(RtcChannelEvents.JoinChannelSuccess, rtcChannel, rtcChannel?.channelId(), uid.toJSUInt(), elapsed) } override fun onRejoinChannelSuccess(rtcChannel: RtcChannel?, uid: Int, elapsed: Int) { - callback(RtcChannelEvents.RejoinChannelSuccess, rtcChannel, rtcChannel?.channelId(), uid, elapsed) + callback(RtcChannelEvents.RejoinChannelSuccess, rtcChannel, rtcChannel?.channelId(), uid.toJSUInt(), elapsed) } override fun onLeaveChannel(rtcChannel: RtcChannel?, stats: IRtcEngineEventHandler.RtcStats?) { @@ -128,11 +128,11 @@ class RtcChannelEventHandler( } override fun onUserJoined(rtcChannel: RtcChannel?, uid: Int, elapsed: Int) { - callback(RtcChannelEvents.UserJoined, rtcChannel, uid, elapsed) + callback(RtcChannelEvents.UserJoined, rtcChannel, uid.toJSUInt(), elapsed) } override fun onUserOffline(rtcChannel: RtcChannel?, uid: Int, @Annotations.AgoraUserOfflineReason reason: Int) { - callback(RtcChannelEvents.UserOffline, rtcChannel, uid, reason) + callback(RtcChannelEvents.UserOffline, rtcChannel, uid.toJSUInt(), reason) } override fun onConnectionStateChanged(rtcChannel: RtcChannel?, @Annotations.AgoraConnectionStateType state: Int, @Annotations.AgoraConnectionChangedReason reason: Int) { @@ -152,19 +152,19 @@ class RtcChannelEventHandler( } override fun onActiveSpeaker(rtcChannel: RtcChannel?, uid: Int) { - callback(RtcChannelEvents.ActiveSpeaker, rtcChannel, uid) + callback(RtcChannelEvents.ActiveSpeaker, rtcChannel, uid.toJSUInt()) } override fun onVideoSizeChanged(rtcChannel: RtcChannel?, uid: Int, width: Int, height: Int, @IntRange(from = 0, to = 360) rotation: Int) { - callback(RtcChannelEvents.VideoSizeChanged, rtcChannel, uid, width, height, rotation) + callback(RtcChannelEvents.VideoSizeChanged, rtcChannel, uid.toJSUInt(), width, height, rotation) } override fun onRemoteVideoStateChanged(rtcChannel: RtcChannel?, uid: Int, @Annotations.AgoraVideoRemoteState state: Int, @Annotations.AgoraVideoRemoteStateReason reason: Int, elapsed: Int) { - callback(RtcChannelEvents.RemoteVideoStateChanged, rtcChannel, uid, state, reason, elapsed) + callback(RtcChannelEvents.RemoteVideoStateChanged, rtcChannel, uid.toJSUInt(), state, reason, elapsed) } override fun onRemoteAudioStateChanged(rtcChannel: RtcChannel?, uid: Int, @Annotations.AgoraAudioRemoteState state: Int, @Annotations.AgoraAudioRemoteStateReason reason: Int, elapsed: Int) { - callback(RtcChannelEvents.RemoteAudioStateChanged, rtcChannel, uid, state, reason, elapsed) + callback(RtcChannelEvents.RemoteAudioStateChanged, rtcChannel, uid.toJSUInt(), state, reason, elapsed) } override fun onLocalPublishFallbackToAudioOnly(rtcChannel: RtcChannel?, isFallbackOrRecover: Boolean) { @@ -172,7 +172,7 @@ class RtcChannelEventHandler( } override fun onRemoteSubscribeFallbackToAudioOnly(rtcChannel: RtcChannel?, uid: Int, isFallbackOrRecover: Boolean) { - callback(RtcChannelEvents.RemoteSubscribeFallbackToAudioOnly, rtcChannel, uid, isFallbackOrRecover) + callback(RtcChannelEvents.RemoteSubscribeFallbackToAudioOnly, rtcChannel, uid.toJSUInt(), isFallbackOrRecover) } override fun onRtcStats(rtcChannel: RtcChannel?, stats: IRtcEngineEventHandler.RtcStats?) { @@ -180,7 +180,7 @@ class RtcChannelEventHandler( } override fun onNetworkQuality(rtcChannel: RtcChannel?, uid: Int, @Annotations.AgoraNetworkQuality txQuality: Int, @Annotations.AgoraNetworkQuality rxQuality: Int) { - callback(RtcChannelEvents.NetworkQuality, rtcChannel, uid, txQuality, rxQuality) + callback(RtcChannelEvents.NetworkQuality, rtcChannel, uid.toJSUInt(), txQuality, rxQuality) } override fun onRemoteVideoStats(rtcChannel: RtcChannel?, stats: IRtcEngineEventHandler.RemoteVideoStats?) { @@ -200,15 +200,15 @@ class RtcChannelEventHandler( } override fun onStreamInjectedStatus(rtcChannel: RtcChannel?, url: String?, uid: Int, @Annotations.AgoraInjectStreamStatus status: Int) { - callback(RtcChannelEvents.StreamInjectedStatus, rtcChannel, url, uid, status) + callback(RtcChannelEvents.StreamInjectedStatus, rtcChannel, url, uid.toJSUInt(), status) } override fun onStreamMessage(rtcChannel: RtcChannel?, uid: Int, streamId: Int, data: ByteArray?) { - callback(RtcChannelEvents.StreamMessage, rtcChannel, uid, streamId, data?.let { String(it, Charsets.UTF_8) }) + callback(RtcChannelEvents.StreamMessage, rtcChannel, uid.toJSUInt(), streamId, data?.let { String(it, Charsets.UTF_8) }) } override fun onStreamMessageError(rtcChannel: RtcChannel?, uid: Int, streamId: Int, @Annotations.AgoraErrorCode error: Int, missed: Int, cached: Int) { - callback(RtcChannelEvents.StreamMessageError, rtcChannel, uid, streamId, error, missed, cached) + callback(RtcChannelEvents.StreamMessageError, rtcChannel, uid.toJSUInt(), streamId, error, missed, cached) } override fun onChannelMediaRelayStateChanged(rtcChannel: RtcChannel?, @Annotations.AgoraChannelMediaRelayState state: Int, @Annotations.AgoraChannelMediaRelayError code: Int) { @@ -228,11 +228,11 @@ class RtcChannelEventHandler( } override fun onAudioSubscribeStateChanged(rtcChannel: RtcChannel?, uid: Int, @Annotations.AgoraStreamSubscribeState oldState: Int, @Annotations.AgoraStreamSubscribeState newState: Int, elapseSinceLastState: Int) { - callback(RtcChannelEvents.AudioSubscribeStateChanged, rtcChannel, rtcChannel?.channelId(), uid, oldState, newState, elapseSinceLastState) + callback(RtcChannelEvents.AudioSubscribeStateChanged, rtcChannel, rtcChannel?.channelId(), uid.toJSUInt(), oldState, newState, elapseSinceLastState) } override fun onVideoSubscribeStateChanged(rtcChannel: RtcChannel?, uid: Int, @Annotations.AgoraStreamSubscribeState oldState: Int, @Annotations.AgoraStreamSubscribeState newState: Int, elapseSinceLastState: Int) { - callback(RtcChannelEvents.VideoSubscribeStateChanged, rtcChannel, rtcChannel?.channelId(), uid, oldState, newState, elapseSinceLastState) + callback(RtcChannelEvents.VideoSubscribeStateChanged, rtcChannel, rtcChannel?.channelId(), uid.toJSUInt(), oldState, newState, elapseSinceLastState) } override fun onRtmpStreamingEvent(rtcChannel: RtcChannel?, url: String?, @Annotations.AgoraRtmpStreamingEvent errCode: Int) { @@ -240,6 +240,6 @@ class RtcChannelEventHandler( } override fun onUserSuperResolutionEnabled(rtcChannel: RtcChannel?, uid: Int, enabled: Boolean, @Annotations.AgoraSuperResolutionStateReason reason: Int) { - callback(RtcChannelEvents.UserSuperResolutionEnabled, rtcChannel, uid, enabled, reason) + callback(RtcChannelEvents.UserSuperResolutionEnabled, rtcChannel, uid.toJSUInt(), enabled, reason) } } diff --git a/android/src/main/java/io/agora/rtc/base/RtcEngine.kt b/android/src/main/java/io/agora/rtc/base/RtcEngine.kt index 7bb3061c1..f726514d0 100644 --- a/android/src/main/java/io/agora/rtc/base/RtcEngine.kt +++ b/android/src/main/java/io/agora/rtc/base/RtcEngine.kt @@ -407,7 +407,7 @@ class RtcEngineManager( val token = params["token"] as? String val channelName = params["channelName"] as String val optionalInfo = params["optionalInfo"] as? String - val optionalUid = (params["optionalUid"] as Number).toInt() + val optionalUid = params["optionalUid"]?.toSDKUInt()!! (params["options"] as? Map<*, *>)?.let { callback.code(engine?.joinChannel(token, channelName, optionalInfo, optionalUid, mapToChannelMediaOptions(it))) return@joinChannel @@ -523,7 +523,7 @@ class RtcEngineManager( override fun getUserInfoByUid(params: Map, callback: Callback) { callback.resolve(engine) { val userInfo = UserInfo() - it.getUserInfoByUid((params["uid"] as Number).toInt(), userInfo) + it.getUserInfoByUid(params["uid"]?.toSDKUInt()!!, userInfo) userInfo.toMap() } } @@ -545,7 +545,7 @@ class RtcEngineManager( } override fun adjustUserPlaybackSignalVolume(params: Map, callback: Callback) { - callback.code(engine?.adjustUserPlaybackSignalVolume((params["uid"] as Number).toInt(), (params["volume"] as Number).toInt())) + callback.code(engine?.adjustUserPlaybackSignalVolume(params["uid"]?.toSDKUInt()!!, (params["volume"] as Number).toInt())) } override fun adjustPlaybackSignalVolume(params: Map, callback: Callback) { @@ -561,7 +561,7 @@ class RtcEngineManager( } override fun muteRemoteAudioStream(params: Map, callback: Callback) { - callback.code(engine?.muteRemoteAudioStream((params["uid"] as Number).toInt(), params["muted"] as Boolean)) + callback.code(engine?.muteRemoteAudioStream(params["uid"]?.toSDKUInt()!!, params["muted"] as Boolean)) } override fun muteAllRemoteAudioStreams(params: Map, callback: Callback) { @@ -617,7 +617,7 @@ class RtcEngineManager( } override fun muteRemoteVideoStream(params: Map, callback: Callback) { - callback.code(engine?.muteRemoteVideoStream((params["uid"] as Number).toInt(), params["muted"] as Boolean)) + callback.code(engine?.muteRemoteVideoStream(params["uid"]?.toSDKUInt()!!, params["muted"] as Boolean)) } override fun muteAllRemoteVideoStreams(params: Map, callback: Callback) { @@ -633,7 +633,7 @@ class RtcEngineManager( } override fun enableRemoteSuperResolution(params: Map, callback: Callback) { - callback.code(engine?.enableRemoteSuperResolution((params["uid"] as Number).toInt(), params["enable"] as Boolean)) + callback.code(engine?.enableRemoteSuperResolution(params["uid"]?.toSDKUInt()!!, params["enable"] as Boolean)) } override fun startAudioMixing(params: Map, callback: Callback) { @@ -811,7 +811,7 @@ class RtcEngineManager( } override fun setRemoteVoicePosition(params: Map, callback: Callback) { - callback.code(engine?.setRemoteVoicePosition((params["uid"] as Number).toInt(), (params["pan"] as Number).toDouble(), (params["gain"] as Number).toDouble())) + callback.code(engine?.setRemoteVoicePosition(params["uid"]?.toSDKUInt()!!, (params["pan"] as Number).toDouble(), (params["gain"] as Number).toDouble())) } override fun setLiveTranscoding(params: Map, callback: Callback) { @@ -863,7 +863,7 @@ class RtcEngineManager( } override fun setRemoteVideoStreamType(params: Map, callback: Callback) { - callback.code(engine?.setRemoteVideoStreamType((params["uid"] as Number).toInt(), (params["streamType"] as Number).toInt())) + callback.code(engine?.setRemoteVideoStreamType(params["uid"]?.toSDKUInt()!!, (params["streamType"] as Number).toInt())) } override fun setRemoteDefaultVideoStreamType(params: Map, callback: Callback) { @@ -879,7 +879,7 @@ class RtcEngineManager( } override fun setRemoteUserPriority(params: Map, callback: Callback) { - callback.code(engine?.setRemoteUserPriority((params["uid"] as Number).toInt(), (params["userPriority"] as Number).toInt())) + callback.code(engine?.setRemoteUserPriority(params["uid"]?.toSDKUInt()!!, (params["userPriority"] as Number).toInt())) } override fun startEchoTest(params: Map, callback: Callback) { diff --git a/android/src/main/java/io/agora/rtc/base/RtcEngineEvent.kt b/android/src/main/java/io/agora/rtc/base/RtcEngineEvent.kt index d7cdffb2a..2ef89dabf 100644 --- a/android/src/main/java/io/agora/rtc/base/RtcEngineEvent.kt +++ b/android/src/main/java/io/agora/rtc/base/RtcEngineEvent.kt @@ -197,11 +197,11 @@ class RtcEngineEventHandler( } override fun onJoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) { - callback(RtcEngineEvents.JoinChannelSuccess, channel, uid, elapsed) + callback(RtcEngineEvents.JoinChannelSuccess, channel, uid.toJSUInt(), elapsed) } override fun onRejoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) { - callback(RtcEngineEvents.RejoinChannelSuccess, channel, uid, elapsed) + callback(RtcEngineEvents.RejoinChannelSuccess, channel, uid.toJSUInt(), elapsed) } override fun onLeaveChannel(stats: RtcStats?) { @@ -209,11 +209,11 @@ class RtcEngineEventHandler( } override fun onLocalUserRegistered(uid: Int, userAccount: String?) { - callback(RtcEngineEvents.LocalUserRegistered, uid, userAccount) + callback(RtcEngineEvents.LocalUserRegistered, uid.toJSUInt(), userAccount) } override fun onUserInfoUpdated(uid: Int, userInfo: UserInfo?) { - callback(RtcEngineEvents.UserInfoUpdated, uid, userInfo?.toMap()) + callback(RtcEngineEvents.UserInfoUpdated, uid.toJSUInt(), userInfo?.toMap()) } override fun onClientRoleChanged(@Annotations.AgoraClientRole oldRole: Int, @Annotations.AgoraClientRole newRole: Int) { @@ -221,11 +221,11 @@ class RtcEngineEventHandler( } override fun onUserJoined(uid: Int, elapsed: Int) { - callback(RtcEngineEvents.UserJoined, uid, elapsed) + callback(RtcEngineEvents.UserJoined, uid.toJSUInt(), elapsed) } override fun onUserOffline(uid: Int, @Annotations.AgoraUserOfflineReason reason: Int) { - callback(RtcEngineEvents.UserOffline, uid, reason) + callback(RtcEngineEvents.UserOffline, uid.toJSUInt(), reason) } override fun onConnectionStateChanged(@Annotations.AgoraConnectionStateType state: Int, @Annotations.AgoraConnectionChangedReason reason: Int) { @@ -253,7 +253,7 @@ class RtcEngineEventHandler( } override fun onActiveSpeaker(uid: Int) { - callback(RtcEngineEvents.ActiveSpeaker, uid) + callback(RtcEngineEvents.ActiveSpeaker, uid.toJSUInt()) } override fun onFirstLocalAudioFrame(elapsed: Int) { @@ -266,15 +266,15 @@ class RtcEngineEventHandler( @Deprecated("", ReplaceWith("onRemoteVideoStateChanged")) override fun onUserMuteVideo(uid: Int, muted: Boolean) { - callback(RtcEngineEvents.UserMuteVideo, uid, muted) + callback(RtcEngineEvents.UserMuteVideo, uid.toJSUInt(), muted) } override fun onVideoSizeChanged(uid: Int, width: Int, height: Int, @IntRange(from = 0, to = 360) rotation: Int) { - callback(RtcEngineEvents.VideoSizeChanged, uid, width, height, rotation) + callback(RtcEngineEvents.VideoSizeChanged, uid.toJSUInt(), width, height, rotation) } override fun onRemoteVideoStateChanged(uid: Int, @Annotations.AgoraVideoRemoteState state: Int, @Annotations.AgoraVideoRemoteStateReason reason: Int, elapsed: Int) { - callback(RtcEngineEvents.RemoteVideoStateChanged, uid, state, reason, elapsed) + callback(RtcEngineEvents.RemoteVideoStateChanged, uid.toJSUInt(), state, reason, elapsed) } override fun onLocalVideoStateChanged(@Annotations.AgoraLocalVideoStreamState localVideoState: Int, @Annotations.AgoraLocalVideoStreamError error: Int) { @@ -282,7 +282,7 @@ class RtcEngineEventHandler( } override fun onRemoteAudioStateChanged(uid: Int, @Annotations.AgoraAudioRemoteState state: Int, @Annotations.AgoraAudioRemoteStateReason reason: Int, elapsed: Int) { - callback(RtcEngineEvents.RemoteAudioStateChanged, uid, state, reason, elapsed) + callback(RtcEngineEvents.RemoteAudioStateChanged, uid.toJSUInt(), state, reason, elapsed) } override fun onLocalAudioStateChanged(@Annotations.AgoraAudioLocalState state: Int, @Annotations.AgoraAudioLocalError error: Int) { @@ -294,7 +294,7 @@ class RtcEngineEventHandler( } override fun onRemoteSubscribeFallbackToAudioOnly(uid: Int, isFallbackOrRecover: Boolean) { - callback(RtcEngineEvents.RemoteSubscribeFallbackToAudioOnly, uid, isFallbackOrRecover) + callback(RtcEngineEvents.RemoteSubscribeFallbackToAudioOnly, uid.toJSUInt(), isFallbackOrRecover) } override fun onAudioRouteChanged(@Annotations.AgoraAudioOutputRouting routing: Int) { @@ -322,7 +322,7 @@ class RtcEngineEventHandler( } override fun onNetworkQuality(uid: Int, @Annotations.AgoraNetworkQuality txQuality: Int, @Annotations.AgoraNetworkQuality rxQuality: Int) { - callback(RtcEngineEvents.NetworkQuality, uid, txQuality, rxQuality) + callback(RtcEngineEvents.NetworkQuality, uid.toJSUInt(), txQuality, rxQuality) } override fun onLastmileProbeResult(result: LastmileProbeResult?) { @@ -377,15 +377,15 @@ class RtcEngineEventHandler( } override fun onStreamInjectedStatus(url: String?, uid: Int, @Annotations.AgoraInjectStreamStatus status: Int) { - callback(RtcEngineEvents.StreamInjectedStatus, url, uid, status) + callback(RtcEngineEvents.StreamInjectedStatus, url, uid.toJSUInt(), status) } override fun onStreamMessage(uid: Int, streamId: Int, data: ByteArray?) { - callback(RtcEngineEvents.StreamMessage, uid, streamId, data?.let { String(it, Charsets.UTF_8) }) + callback(RtcEngineEvents.StreamMessage, uid.toJSUInt(), streamId, data?.let { String(it, Charsets.UTF_8) }) } override fun onStreamMessageError(uid: Int, streamId: Int, @Annotations.AgoraErrorCode error: Int, missed: Int, cached: Int) { - callback(RtcEngineEvents.StreamMessageError, uid, streamId, error, missed, cached) + callback(RtcEngineEvents.StreamMessageError, uid.toJSUInt(), streamId, error, missed, cached) } override fun onMediaEngineLoadSuccess() { @@ -406,22 +406,22 @@ class RtcEngineEventHandler( @Deprecated("", ReplaceWith("onRemoteVideoStateChanged")) override fun onFirstRemoteVideoFrame(uid: Int, width: Int, height: Int, elapsed: Int) { - callback(RtcEngineEvents.FirstRemoteVideoFrame, uid, width, height, elapsed) + callback(RtcEngineEvents.FirstRemoteVideoFrame, uid.toJSUInt(), width, height, elapsed) } @Deprecated("", ReplaceWith("onRemoteAudioStateChanged")) override fun onFirstRemoteAudioFrame(uid: Int, elapsed: Int) { - callback(RtcEngineEvents.FirstRemoteAudioFrame, uid, elapsed) + callback(RtcEngineEvents.FirstRemoteAudioFrame, uid.toJSUInt(), elapsed) } @Deprecated("", ReplaceWith("onRemoteAudioStateChanged")) override fun onFirstRemoteAudioDecoded(uid: Int, elapsed: Int) { - callback(RtcEngineEvents.FirstRemoteAudioDecoded, uid, elapsed) + callback(RtcEngineEvents.FirstRemoteAudioDecoded, uid.toJSUInt(), elapsed) } @Deprecated("", ReplaceWith("onRemoteAudioStateChanged")) override fun onUserMuteAudio(uid: Int, muted: Boolean) { - callback(RtcEngineEvents.UserMuteAudio, uid, muted) + callback(RtcEngineEvents.UserMuteAudio, uid.toJSUInt(), muted) } @Deprecated("", ReplaceWith("onRtmpStreamingStateChanged")) @@ -436,27 +436,27 @@ class RtcEngineEventHandler( @Deprecated("", ReplaceWith("onRemoteAudioStats")) override fun onRemoteAudioTransportStats(uid: Int, delay: Int, lost: Int, rxKBitRate: Int) { - callback(RtcEngineEvents.RemoteAudioTransportStats, uid, delay, lost, rxKBitRate) + callback(RtcEngineEvents.RemoteAudioTransportStats, uid.toJSUInt(), delay, lost, rxKBitRate) } @Deprecated("", ReplaceWith("onRemoteVideoStats")) override fun onRemoteVideoTransportStats(uid: Int, delay: Int, lost: Int, rxKBitRate: Int) { - callback(RtcEngineEvents.RemoteVideoTransportStats, uid, delay, lost, rxKBitRate) + callback(RtcEngineEvents.RemoteVideoTransportStats, uid.toJSUInt(), delay, lost, rxKBitRate) } @Deprecated("", ReplaceWith("onRemoteVideoStateChanged")) override fun onUserEnableVideo(uid: Int, enabled: Boolean) { - callback(RtcEngineEvents.UserEnableVideo, uid, enabled) + callback(RtcEngineEvents.UserEnableVideo, uid.toJSUInt(), enabled) } @Deprecated("", ReplaceWith("onRemoteVideoStateChanged")) override fun onUserEnableLocalVideo(uid: Int, enabled: Boolean) { - callback(RtcEngineEvents.UserEnableLocalVideo, uid, enabled) + callback(RtcEngineEvents.UserEnableLocalVideo, uid.toJSUInt(), enabled) } @Deprecated("", ReplaceWith("onRemoteVideoStateChanged")) override fun onFirstRemoteVideoDecoded(uid: Int, width: Int, height: Int, elapsed: Int) { - callback(RtcEngineEvents.FirstRemoteVideoDecoded, uid, width, height, elapsed) + callback(RtcEngineEvents.FirstRemoteVideoDecoded, uid.toJSUInt(), width, height, elapsed) } @Deprecated("", ReplaceWith("onLocalAudioStateChanged")) @@ -476,7 +476,7 @@ class RtcEngineEventHandler( @Deprecated("", ReplaceWith("onRemoteAudioStats")) override fun onAudioQuality(uid: Int, @Annotations.AgoraNetworkQuality quality: Int, delay: Short, lost: Short) { - callback(RtcEngineEvents.AudioQuality, uid, quality, delay, lost) + callback(RtcEngineEvents.AudioQuality, uid.toJSUInt(), quality, delay, lost) } @Deprecated("", ReplaceWith("onLocalVideoStateChanged")) @@ -506,11 +506,11 @@ class RtcEngineEventHandler( } override fun onAudioSubscribeStateChanged(channel: String?, uid: Int, @Annotations.AgoraStreamSubscribeState oldState: Int, @Annotations.AgoraStreamSubscribeState newState: Int, elapseSinceLastState: Int) { - callback(RtcEngineEvents.AudioSubscribeStateChanged, channel, uid, oldState, newState, elapseSinceLastState) + callback(RtcEngineEvents.AudioSubscribeStateChanged, channel, uid.toJSUInt(), oldState, newState, elapseSinceLastState) } override fun onVideoSubscribeStateChanged(channel: String?, uid: Int, @Annotations.AgoraStreamSubscribeState oldState: Int, @Annotations.AgoraStreamSubscribeState newState: Int, elapseSinceLastState: Int) { - callback(RtcEngineEvents.VideoSubscribeStateChanged, channel, uid, oldState, newState, elapseSinceLastState) + callback(RtcEngineEvents.VideoSubscribeStateChanged, channel, uid.toJSUInt(), oldState, newState, elapseSinceLastState) } override fun onRtmpStreamingEvent(url: String?, @Annotations.AgoraRtmpStreamingEvent error: Int) { @@ -518,7 +518,7 @@ class RtcEngineEventHandler( } override fun onUserSuperResolutionEnabled(uid: Int, enabled: Boolean, @Annotations.AgoraSuperResolutionStateReason reason: Int) { - callback(RtcEngineEvents.UserSuperResolutionEnabled, uid, enabled, reason) + callback(RtcEngineEvents.UserSuperResolutionEnabled, uid.toJSUInt(), enabled, reason) } override fun onUploadLogResult(requestId: String?, success: Boolean, @Annotations.AgoraUploadErrorReason reason: Int) { diff --git a/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcSurfaceViewManager.kt b/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcSurfaceViewManager.kt index 42506fbd0..482f2a0ab 100644 --- a/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcSurfaceViewManager.kt +++ b/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcSurfaceViewManager.kt @@ -7,6 +7,7 @@ import com.facebook.react.uimanager.annotations.ReactProp import io.agora.rtc.RtcChannel import io.agora.rtc.RtcEngine import io.agora.rtc.base.RtcSurfaceView +import io.agora.rtc.base.toSDKUInt class RCTAgoraRtcSurfaceViewManager : SimpleViewManager() { companion object { @@ -43,7 +44,7 @@ class RCTAgoraRtcSurfaceViewManager : SimpleViewManager() { fun setData(view: RtcSurfaceView, data: ReadableMap) { data.toHashMap().let { map -> val channel = (map["channelId"] as? String)?.let { getChannel(it) } - getEngine()?.let { view.setData(it, channel, (map["uid"] as Number).toInt()) } + getEngine()?.let { view.setData(it, channel, map["uid"]?.toSDKUInt()!!) } } } diff --git a/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcTextureViewManager.kt b/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcTextureViewManager.kt index e3bf7f8a0..e586a2fa4 100644 --- a/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcTextureViewManager.kt +++ b/android/src/main/java/io/agora/rtc/react/RCTAgoraRtcTextureViewManager.kt @@ -7,6 +7,7 @@ import com.facebook.react.uimanager.annotations.ReactProp import io.agora.rtc.RtcChannel import io.agora.rtc.RtcEngine import io.agora.rtc.base.RtcTextureView +import io.agora.rtc.base.toSDKUInt class RCTAgoraRtcTextureViewManager : SimpleViewManager() { companion object { @@ -33,7 +34,7 @@ class RCTAgoraRtcTextureViewManager : SimpleViewManager() { fun setData(view: RtcTextureView, data: ReadableMap) { data.toHashMap().let { map -> val channel = (map["channelId"] as? String)?.let { getChannel(it) } - getEngine()?.let { view.setData(it, channel, (map["uid"] as Number).toInt()) } + getEngine()?.let { view.setData(it, channel, map["uid"]?.toSDKUInt()!!) } } }