diff --git a/Annotations.java b/Annotations.java index 64361ecc6..aac2340ca 100644 --- a/Annotations.java +++ b/Annotations.java @@ -6,6 +6,7 @@ import java.lang.annotation.RetentionPolicy; import io.agora.rtc.Constants; +import io.agora.rtc.IRtcEngineEventHandler; import io.agora.rtc.RtcEngineConfig; import io.agora.rtc.video.BeautyOptions; import io.agora.rtc.video.VideoCanvas; @@ -265,12 +266,14 @@ public class Annotations { AgoraCameraCaptureOutputPreference.CAPTURER_OUTPUT_PREFERENCE_AUTO, AgoraCameraCaptureOutputPreference.CAPTURER_OUTPUT_PREFERENCE_PERFORMANCE, AgoraCameraCaptureOutputPreference.CAPTURER_OUTPUT_PREFERENCE_PREVIEW, + AgoraCameraCaptureOutputPreference.CAPTURER_OUTPUT_PREFERENCE_MANUAL, }) @Retention(RetentionPolicy.SOURCE) public @interface AgoraCameraCaptureOutputPreference { int CAPTURER_OUTPUT_PREFERENCE_AUTO = 0; int CAPTURER_OUTPUT_PREFERENCE_PERFORMANCE = 1; int CAPTURER_OUTPUT_PREFERENCE_PREVIEW = 2; + int CAPTURER_OUTPUT_PREFERENCE_MANUAL = 3; } @IntDef({ @@ -362,6 +365,7 @@ public class Annotations { Constants.CONNECTION_CHANGED_RENEW_TOKEN, Constants.CONNECTION_CHANGED_CLIENT_IP_ADDRESS_CHANGED, Constants.CONNECTION_CHANGED_KEEP_ALIVE_TIMEOUT, + Constants.CONNECTION_CHANGED_PROXY_SERVER_INTERRUPTED, }) @Retention(RetentionPolicy.SOURCE) public @interface AgoraConnectionChangedReason { @@ -452,6 +456,7 @@ public class Annotations { Constants.ERR_PUBLISH_STREAM_INTERNAL_SERVER_ERROR, Constants.ERR_PUBLISH_STREAM_NOT_FOUND, Constants.ERR_PUBLISH_STREAM_FORMAT_NOT_SUPPORTED, + Constants.ERR_MODULE_NOT_FOUND, Constants.ERR_LOAD_MEDIA_ENGINE, Constants.ERR_START_CALL, Constants.ERR_START_CAMERA, @@ -765,8 +770,7 @@ public class Annotations { Constants.WARN_ADM_RECORD_IS_OCCUPIED, Constants.WARN_APM_HOWLING, Constants.WARN_ADM_GLITCH_STATE, - // TODO(3.3.0) WARN_APM_RESIDUAL_ECHO - Constants.WARN_ADM_IMPROPER_SETTINGS, + Constants.WARN_APM_RESIDUAL_ECHO, Constants.WARN_SUPER_RESOLUTION_STREAM_OVER_LIMITATION, Constants.WARN_SUPER_RESOLUTION_USER_COUNT_OVER_LIMITATION, Constants.WARN_SUPER_RESOLUTION_DEVICE_NOT_SUPPORTED, @@ -845,6 +849,7 @@ public class Annotations { Constants.CHAT_BEAUTIFIER_MAGNETIC, Constants.CHAT_BEAUTIFIER_FRESH, Constants.CHAT_BEAUTIFIER_VITALITY, + Constants.SINGING_BEAUTIFIER, Constants.TIMBRE_TRANSFORMATION_VIGOROUS, Constants.TIMBRE_TRANSFORMATION_DEEP, Constants.TIMBRE_TRANSFORMATION_MELLOW, @@ -865,4 +870,72 @@ public class Annotations { @Retention(RetentionPolicy.SOURCE) public @interface AgoraAudienceLatencyLevelType { } + + @IntDef({ + Constants.TRANSPORT_TYPE_NONE_PROXY, + Constants.TRANSPORT_TYPE_UDP_PROXY, + Constants.TRANSPORT_TYPE_TCP_PROXY, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraCloudProxyType { + } + + @IntDef({ + AgoraLogLevel.LOG_LEVEL_NONE, + AgoraLogLevel.LOG_LEVEL_INFO, + AgoraLogLevel.LOG_LEVEL_WARN, + AgoraLogLevel.LOG_LEVEL_ERROR, + AgoraLogLevel.LOG_LEVEL_FATAL, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraLogLevel { + int LOG_LEVEL_NONE = 0; + int LOG_LEVEL_INFO = 1; + int LOG_LEVEL_WARN = 2; + int LOG_LEVEL_ERROR = 4; + int LOG_LEVEL_FATAL = 8; + } + + @IntDef({ + Constants.CAPTURE_BRIGHTNESS_LEVEL_INVALID, + Constants.CAPTURE_BRIGHTNESS_LEVEL_NORMAL, + Constants.CAPTURE_BRIGHTNESS_LEVEL_BRIGHT, + Constants.CAPTURE_BRIGHTNESS_LEVEL_DARK, + }) + public @interface AgoraCaptureBrightnessLevelType { + } + + @IntDef({ + IRtcEngineEventHandler.UploadErrorReason.UPLOAD_SUCCESS, + IRtcEngineEventHandler.UploadErrorReason.UPLOAD_NET_ERROR, + IRtcEngineEventHandler.UploadErrorReason.UPLOAD_SERVER_ERROR, + }) + public @interface AgoraUploadErrorReason { + } + + @IntDef({ + IRtcEngineEventHandler.ExperienceQuality.EXPERIENCE_GOOD, + IRtcEngineEventHandler.ExperienceQuality.EXPERIENCE_BAD, + }) + public @interface AgoraExperienceQualityType { + } + + @IntDef({ + IRtcEngineEventHandler.ExperiencePoorReason.EXPERIENCE_REASON_NONE, + IRtcEngineEventHandler.ExperiencePoorReason.REMOTE_NETWORK_QUALITY_POOR, + IRtcEngineEventHandler.ExperiencePoorReason.LOCAL_NETWORK_QUALITY_POOR, + IRtcEngineEventHandler.ExperiencePoorReason.WIRELESS_SIGNAL_POOR, + IRtcEngineEventHandler.ExperiencePoorReason.WIFI_BLUETOOTH_COEXIST, + }) + public @interface AgoraExperiencePoorReason { + } + + @IntDef({ + Constants.SR_STATE_REASON_SUCCESS, + Constants.SR_STATE_REASON_STREAM_OVER_LIMITATION, + Constants.SR_STATE_REASON_USER_COUNT_OVER_LIMITATION, + Constants.SR_STATE_REASON_DEVICE_NOT_SUPPORTED, + }) + public @interface AgoraSuperResolutionStateReason { + } } diff --git a/BeanCovertor.kt b/BeanCovertor.kt index 7001164c8..3ae90efde 100644 --- a/BeanCovertor.kt +++ b/BeanCovertor.kt @@ -1,6 +1,7 @@ package io.agora.rtc.base import android.graphics.Color +import io.agora.rtc.RtcEngineConfig import io.agora.rtc.internal.EncryptionConfig import io.agora.rtc.internal.LastmileProbeConfig import io.agora.rtc.live.LiveInjectStreamConfig @@ -8,6 +9,7 @@ import io.agora.rtc.live.LiveTranscoding import io.agora.rtc.live.LiveTranscoding.TranscodingUser import io.agora.rtc.models.ChannelMediaOptions import io.agora.rtc.models.ClientRoleOptions +import io.agora.rtc.models.DataStreamConfig import io.agora.rtc.video.* fun mapToVideoDimensions(map: Map<*, *>): VideoEncoderConfiguration.VideoDimensions { @@ -162,7 +164,11 @@ fun mapToCameraCapturerConfiguration(map: Map<*, *>): CameraCapturerConfiguratio return CameraCapturerConfiguration( intToCapturerOutputPreference((map["preference"] as Number).toInt()), intToCameraDirection((map["cameraDirection"] as Number).toInt()) - ) + ).apply { + dimensions = CameraCapturerConfiguration.CaptureDimensions() + (map["captureWidth"] as? Number)?.toInt()?.let { dimensions.width = it } + (map["captureHeight"] as? Number)?.toInt()?.let { dimensions.height = it } + } } fun mapToChannelMediaOptions(map: Map<*, *>): ChannelMediaOptions { @@ -172,6 +178,14 @@ fun mapToChannelMediaOptions(map: Map<*, *>): ChannelMediaOptions { } } +fun mapToRtcEngineConfig(map: Map<*, *>): RtcEngineConfig { + return RtcEngineConfig().apply { + mAppId = map["appId"] as String + (map["areaCode"] as? Number)?.toInt()?.let { mAreaCode = it } + (map["logConfig"] as? Map<*, *>)?.let { mLogConfig = mapToLogConfig(it) } + } +} + fun mapToEncryptionConfig(map: Map<*, *>): EncryptionConfig { return EncryptionConfig().apply { (map["encryptionMode"] as? Number)?.let { encryptionMode = intToEncryptionMode(it.toInt()) } @@ -184,3 +198,18 @@ fun mapToClientRoleOptions(map: Map<*, *>): ClientRoleOptions { (map["audienceLatencyLevel"] as? Number)?.let { audienceLatencyLevel = it.toInt() } } } + +fun mapToLogConfig(map: Map<*, *>): RtcEngineConfig.LogConfig { + return RtcEngineConfig.LogConfig().apply { + (map["filePath"] as? String)?.let { filePath = it } + (map["fileSize"] as? Number)?.let { fileSize = it.toInt() } + (map["level"] as? Number)?.let { level = it.toInt() } + } +} + +fun mapToDataStreamConfig(map: Map<*, *>): DataStreamConfig { + return DataStreamConfig().apply { + (map["syncWithAudio"] as? Boolean)?.let { syncWithAudio = it } + (map["ordered"] as? Boolean)?.let { ordered = it } + } +} diff --git a/Extensions.kt b/Extensions.kt index 13d594918..df3f85af2 100644 --- a/Extensions.kt +++ b/Extensions.kt @@ -70,7 +70,9 @@ fun RemoteAudioStats.toMap(): Map { "totalFrozenTime" to totalFrozenTime, "frozenRate" to frozenRate, "totalActiveTime" to totalActiveTime, - "publishDuration" to publishDuration + "publishDuration" to publishDuration, + "qoeQuality" to qoeQuality, + "qualityChangedReason" to qualityChangedReason ) } @@ -89,7 +91,8 @@ fun LocalVideoStats.toMap(): Map { "encodedFrameCount" to encodedFrameCount, "codecType" to codecType, "txPacketLossRate" to txPacketLossRate, - "captureFrameRate" to captureFrameRate + "captureFrameRate" to captureFrameRate, + "captureBrightnessLevel" to captureBrightnessLevel ) } diff --git a/MediaObserver.kt b/MediaObserver.kt index fef7214f1..21f3b20c3 100644 --- a/MediaObserver.kt +++ b/MediaObserver.kt @@ -8,7 +8,7 @@ import java.util.concurrent.atomic.AtomicInteger class MediaObserver( private val emit: (data: Map?) -> Unit ) : IMetadataObserver { - private var maxMetadataSize = AtomicInteger(0) + private var maxMetadataSize = AtomicInteger(1024) private var metadataList = Collections.synchronizedList(mutableListOf()) fun addMetadata(metadata: String) { diff --git a/RtcChannel.kt b/RtcChannel.kt index 4734add1c..461a9bda7 100644 --- a/RtcChannel.kt +++ b/RtcChannel.kt @@ -1,6 +1,5 @@ package io.agora.rtc.base -import io.agora.rtc.Constants import io.agora.rtc.IMetadataObserver import io.agora.rtc.RtcChannel import io.agora.rtc.RtcEngine @@ -42,6 +41,7 @@ class IRtcChannel { fun muteAllRemoteAudioStreams(params: Map, callback: Callback) + @Deprecated("") fun setDefaultMuteAllRemoteAudioStreams(params: Map, callback: Callback) } @@ -50,7 +50,10 @@ class IRtcChannel { fun muteAllRemoteVideoStreams(params: Map, callback: Callback) + @Deprecated("") fun setDefaultMuteAllRemoteVideoStreams(params: Map, callback: Callback) + + fun enableRemoteSuperResolution(params: Map, callback: Callback) } interface RtcVoicePositionInterface { @@ -94,8 +97,10 @@ class IRtcChannel { } interface RtcEncryptionInterface { + @Deprecated("") fun setEncryptionSecret(params: Map, callback: Callback) + @Deprecated("") fun setEncryptionMode(params: Map, callback: Callback) fun enableEncryption(params: Map, callback: Callback) @@ -141,11 +146,7 @@ class RtcChannelManager( } override fun destroy(params: Map, callback: Callback) { - var code: Int? = -Constants.ERR_NOT_INITIALIZED - this[params["channelId"] as String]?.let { - code = rtcChannelMap.remove(it.channelId())?.destroy() - } - callback.code(code) + callback.code(rtcChannelMap.remove(params["channelId"] as String)?.destroy()) } override fun setClientRole(params: Map, callback: Callback) { @@ -217,6 +218,10 @@ class RtcChannelManager( callback.code(this[params["channelId"] as String]?.setDefaultMuteAllRemoteVideoStreams(params["muted"] as Boolean)) } + override fun enableRemoteSuperResolution(params: Map, callback: Callback) { + callback.code(this[params["channelId"] as String]?.enableRemoteSuperResolution((params["uid"] as Number).toInt(), 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())) } @@ -258,24 +263,22 @@ class RtcChannelManager( } override fun registerMediaMetadataObserver(params: Map, callback: Callback) { - var code = -Constants.ERR_NOT_INITIALIZED - this[params["channelId"] as String]?.let { - val mediaObserver = MediaObserver { data -> - emit(RtcChannelEvents.MetadataReceived, data?.toMutableMap()?.apply { put("channelId", it.channelId()) }) - } - code = it.registerMediaMetadataObserver(mediaObserver, IMetadataObserver.VIDEO_METADATA) - if (code == 0) mediaObserverMap[it.channelId()] = mediaObserver + val channelId = params["channelId"] as String + val mediaObserver = MediaObserver { data -> + emit(RtcChannelEvents.MetadataReceived, data?.toMutableMap()?.apply { put("channelId", channelId) }) + } + callback.code(this[channelId]?.registerMediaMetadataObserver(mediaObserver, IMetadataObserver.VIDEO_METADATA)) { + mediaObserverMap[channelId] = mediaObserver + Unit } - callback.code(code) } override fun unregisterMediaMetadataObserver(params: Map, callback: Callback) { - var code = -Constants.ERR_NOT_INITIALIZED - this[params["channelId"] as String]?.let { - code = it.registerMediaMetadataObserver(null, IMetadataObserver.VIDEO_METADATA) - if (code == 0) mediaObserverMap.remove(it.channelId()) + val channelId = params["channelId"] as String + callback.code(this[channelId]?.registerMediaMetadataObserver(null, IMetadataObserver.VIDEO_METADATA)) { + mediaObserverMap.remove(channelId) + Unit } - callback.code(code) } override fun setMaxMetadataSize(params: Map, callback: Callback) { @@ -318,18 +321,15 @@ class RtcChannelManager( } override fun createDataStream(params: Map, callback: Callback) { - var code = -Constants.ERR_NOT_INITIALIZED - this[params["channelId"] as String]?.let { - code = it.createDataStream(params["reliable"] as Boolean, params["ordered"] as Boolean) + val channel = this[params["channelId"] as String] + (params["config"] as? Map<*, *>)?.let { config -> + callback.code(channel?.createDataStream(mapToDataStreamConfig(config))) { it } + return@createDataStream } - callback.code(code) { it } + callback.code(channel?.createDataStream(params["reliable"] as Boolean, params["ordered"] as Boolean)) { it } } override fun sendStreamMessage(params: Map, callback: Callback) { - var code = -Constants.ERR_NOT_INITIALIZED - this[params["channelId"] as String]?.let { - code = it.sendStreamMessage((params["streamId"] as Number).toInt(), (params["message"] as String).toByteArray()) - } - callback.code(code) + callback.code(this[params["channelId"] as String]?.sendStreamMessage((params["streamId"] as Number).toInt(), (params["message"] as String).toByteArray())) } } diff --git a/RtcChannelEvent.kt b/RtcChannelEvent.kt index f00f9a5fa..71ff02ae9 100644 --- a/RtcChannelEvent.kt +++ b/RtcChannelEvent.kt @@ -42,6 +42,7 @@ class RtcChannelEvents { const val AudioSubscribeStateChanged = "AudioSubscribeStateChanged" const val VideoSubscribeStateChanged = "VideoSubscribeStateChanged" const val RtmpStreamingEvent = "RtmpStreamingEvent" + const val UserSuperResolutionEnabled = "UserSuperResolutionEnabled" fun toMap(): Map { return hashMapOf( @@ -79,7 +80,8 @@ class RtcChannelEvents { "VideoPublishStateChanged" to VideoPublishStateChanged, "AudioSubscribeStateChanged" to AudioSubscribeStateChanged, "VideoSubscribeStateChanged" to VideoSubscribeStateChanged, - "RtmpStreamingEvent" to RtmpStreamingEvent + "RtmpStreamingEvent" to RtmpStreamingEvent, + "UserSuperResolutionEnabled" to UserSuperResolutionEnabled ) } } @@ -236,4 +238,8 @@ class RtcChannelEventHandler( override fun onRtmpStreamingEvent(rtcChannel: RtcChannel?, url: String?, @Annotations.AgoraRtmpStreamingEvent errCode: Int) { callback(RtcChannelEvents.RtmpStreamingEvent, rtcChannel, url, errCode) } + + override fun onUserSuperResolutionEnabled(rtcChannel: RtcChannel?, uid: Int, enabled: Boolean, @Annotations.AgoraSuperResolutionStateReason reason: Int) { + callback(RtcChannelEvents.UserSuperResolutionEnabled, rtcChannel, uid, enabled, reason) + } } diff --git a/RtcEngine.kt b/RtcEngine.kt index 90d9a7343..8c9d1db70 100644 --- a/RtcEngine.kt +++ b/RtcEngine.kt @@ -42,15 +42,28 @@ class IRtcEngine { fun complain(params: Map, callback: Callback) + @Deprecated("") fun setLogFile(params: Map, callback: Callback) + @Deprecated("") fun setLogFilter(params: Map, callback: Callback) + @Deprecated("") fun setLogFileSize(params: Map, callback: Callback) fun setParameters(params: Map, callback: Callback) + fun getSdkVersion(callback: Callback) + + fun getErrorDescription(params: Map, callback: Callback) + fun getNativeHandle(callback: Callback) + + fun enableDeepLearningDenoise(params: Map, callback: Callback) + + fun setCloudProxy(params: Map, callback: Callback) + + fun uploadLogFile(callback: Callback) } interface RtcUserInfoInterface { @@ -84,6 +97,7 @@ class IRtcEngine { fun muteAllRemoteAudioStreams(params: Map, callback: Callback) + @Deprecated("") fun setDefaultMuteAllRemoteAudioStreams(params: Map, callback: Callback) fun enableAudioVolumeIndication(params: Map, callback: Callback) @@ -108,9 +122,12 @@ class IRtcEngine { fun muteAllRemoteVideoStreams(params: Map, callback: Callback) + @Deprecated("") fun setDefaultMuteAllRemoteVideoStreams(params: Map, callback: Callback) fun setBeautyEffectOptions(params: Map, callback: Callback) + + fun enableRemoteSuperResolution(params: Map, callback: Callback) } interface RtcAudioMixingInterface { @@ -187,6 +204,8 @@ class IRtcEngine { fun setVoiceBeautifierPreset(params: Map, callback: Callback) fun setAudioEffectParameters(params: Map, callback: Callback) + + fun setVoiceBeautifierParameters(params: Map, callback: Callback) } interface RtcVoicePositionInterface { @@ -344,10 +363,8 @@ class RtcEngineManager( } override fun create(params: Map, callback: Callback) { - engine = RtcEngineEx.create(RtcEngineConfig().apply { + engine = RtcEngineEx.create(mapToRtcEngineConfig(params["config"] as Map<*, *>).apply { mContext = params["context"] as Context - mAppId = params["appId"] as String - mAreaCode = (params["areaCode"] as Number).toInt() mEventHandler = RtcEngineEventHandler { methodName, data -> emit(methodName, data) } @@ -373,11 +390,25 @@ class RtcEngineManager( } override fun joinChannel(params: Map, callback: Callback) { - callback.code(engine?.joinChannel(params["token"] as? String, params["channelName"] as String, params["optionalInfo"] as? String, (params["optionalUid"] as Number).toInt())) + 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() + (params["options"] as? Map<*, *>)?.let { + callback.code(engine?.joinChannel(token, channelName, optionalInfo, optionalUid, mapToChannelMediaOptions(it))) + return@joinChannel + } + callback.code(engine?.joinChannel(token, channelName, optionalInfo, optionalUid)) } override fun switchChannel(params: Map, callback: Callback) { - callback.code(engine?.switchChannel(params["token"] as? String, params["channelName"] as String)) + val token = params["token"] as? String + val channelName = params["channelName"] as String + (params["options"] as? Map<*, *>)?.let { + callback.code(engine?.switchChannel(token, channelName, mapToChannelMediaOptions(it))) + return@switchChannel + } + callback.code(engine?.switchChannel(token, channelName)) } override fun leaveChannel(callback: Callback) { @@ -428,16 +459,43 @@ class RtcEngineManager( callback.code(engine?.setParameters(params["parameters"] as String)) } + override fun getSdkVersion(callback: Callback) { + callback.success(RtcEngine.getSdkVersion()) + } + + override fun getErrorDescription(params: Map, callback: Callback) { + callback.success(RtcEngine.getErrorDescription((params["error"] as Number).toInt())) + } + override fun getNativeHandle(callback: Callback) { callback.resolve(engine) { it.nativeHandle } } + override fun enableDeepLearningDenoise(params: Map, callback: Callback) { + callback.code(engine?.enableDeepLearningDenoise(params["enabled"] as Boolean)) + } + + override fun setCloudProxy(params: Map, callback: Callback) { + callback.code(engine?.setCloudProxy((params["proxyType"] as Number).toInt())) + } + + override fun uploadLogFile(callback: Callback) { + callback.resolve(engine) { it.uploadLogFile() } + } + override fun registerLocalUserAccount(params: Map, callback: Callback) { callback.code(engine?.registerLocalUserAccount(params["appId"] as String, params["userAccount"] as String)) } override fun joinChannelWithUserAccount(params: Map, callback: Callback) { - callback.code(engine?.joinChannelWithUserAccount(params["token"] as? String, params["channelName"] as String, params["userAccount"] as String)) + val token = params["token"] as? String + val channelName = params["channelName"] as String + val userAccount = params["userAccount"] as String + (params["options"] as? Map<*, *>)?.let { + callback.code(engine?.joinChannelWithUserAccount(token, channelName, userAccount, mapToChannelMediaOptions(it))) + return@joinChannelWithUserAccount + } + callback.code(engine?.joinChannelWithUserAccount(token, channelName, userAccount)) } override fun getUserInfoByUserAccount(params: Map, callback: Callback) { @@ -548,6 +606,10 @@ class RtcEngineManager( callback.code(engine?.setBeautyEffectOptions(params["enabled"] as Boolean, mapToBeautyOptions(params["options"] as Map<*, *>))) } + override fun enableRemoteSuperResolution(params: Map, callback: Callback) { + callback.code(engine?.enableRemoteSuperResolution((params["uid"] as Number).toInt(), params["enable"] as Boolean)) + } + override fun startAudioMixing(params: Map, callback: Callback) { callback.code(engine?.startAudioMixing(params["filePath"] as String, params["loopback"] as Boolean, params["replace"] as Boolean, (params["cycle"] as Number).toInt())) } @@ -684,6 +746,10 @@ class RtcEngineManager( callback.code(engine?.setAudioEffectParameters((params["preset"] as Number).toInt(), (params["param1"] as Number).toInt(), (params["param2"] as Number).toInt())) } + override fun setVoiceBeautifierParameters(params: Map, callback: Callback) { + callback.code(engine?.setVoiceBeautifierParameters((params["preset"] as Number).toInt(), (params["param1"] as Number).toInt(), (params["param2"] as Number).toInt())) + } + override fun enableSoundPositionIndication(params: Map, callback: Callback) { callback.code(engine?.enableSoundPositionIndication(params["enabled"] as Boolean)) } @@ -785,24 +851,20 @@ class RtcEngineManager( } override fun registerMediaMetadataObserver(callback: Callback) { - var code = -Constants.ERR_NOT_INITIALIZED - engine?.let { - val mediaObserver = MediaObserver { data -> - emit(RtcEngineEvents.MetadataReceived, data) - } - code = it.registerMediaMetadataObserver(mediaObserver, IMetadataObserver.VIDEO_METADATA) - if (code == 0) this.mediaObserver = mediaObserver + val mediaObserver = MediaObserver { data -> + emit(RtcEngineEvents.MetadataReceived, data) + } + callback.code(engine?.registerMediaMetadataObserver(mediaObserver, IMetadataObserver.VIDEO_METADATA)) { + this.mediaObserver = mediaObserver + Unit } - callback.code(code) } override fun unregisterMediaMetadataObserver(callback: Callback) { - var code = -Constants.ERR_NOT_INITIALIZED - engine?.let { - code = it.registerMediaMetadataObserver(null, IMetadataObserver.VIDEO_METADATA) - if (code == 0) mediaObserver = null + callback.code(engine?.registerMediaMetadataObserver(null, IMetadataObserver.VIDEO_METADATA)) { + mediaObserver = null + Unit } - callback.code(code) } override fun setMaxMetadataSize(params: Map, callback: Callback) { @@ -916,18 +978,14 @@ class RtcEngineManager( } override fun createDataStream(params: Map, callback: Callback) { - var code = -Constants.ERR_NOT_INITIALIZED - engine?.let { - code = it.createDataStream(params["reliable"] as Boolean, params["ordered"] as Boolean) + (params["config"] as? Map<*, *>)?.let { config -> + callback.code(engine?.createDataStream(mapToDataStreamConfig(config))) { it } + return@createDataStream } - callback.code(code) { it } + callback.code(engine?.createDataStream(params["reliable"] as Boolean, params["ordered"] as Boolean)) { it } } override fun sendStreamMessage(params: Map, callback: Callback) { - var code = -Constants.ERR_NOT_INITIALIZED - engine?.let { - code = it.sendStreamMessage((params["streamId"] as Number).toInt(), (params["message"] as String).toByteArray()) - } - callback.code(code) + callback.code(engine?.sendStreamMessage((params["streamId"] as Number).toInt(), (params["message"] as String).toByteArray())) } } diff --git a/RtcEngineEvent.kt b/RtcEngineEvent.kt index 553446afd..8a003e383 100644 --- a/RtcEngineEvent.kt +++ b/RtcEngineEvent.kt @@ -84,6 +84,8 @@ class RtcEngineEvents { const val AudioSubscribeStateChanged = "AudioSubscribeStateChanged" const val VideoSubscribeStateChanged = "VideoSubscribeStateChanged" const val RtmpStreamingEvent = "RtmpStreamingEvent" + const val UserSuperResolutionEnabled = "UserSuperResolutionEnabled" + const val UploadLogResult = "UploadLogResult" fun toMap(): Map { return hashMapOf( @@ -163,7 +165,9 @@ class RtcEngineEvents { "VideoPublishStateChanged" to VideoPublishStateChanged, "AudioSubscribeStateChanged" to AudioSubscribeStateChanged, "VideoSubscribeStateChanged" to VideoSubscribeStateChanged, - "RtmpStreamingEvent" to RtmpStreamingEvent + "RtmpStreamingEvent" to RtmpStreamingEvent, + "UserSuperResolutionEnabled" to UserSuperResolutionEnabled, + "UploadLogResult" to UploadLogResult ) } } @@ -512,4 +516,12 @@ class RtcEngineEventHandler( override fun onRtmpStreamingEvent(url: String?, @Annotations.AgoraRtmpStreamingEvent error: Int) { callback(RtcEngineEvents.RtmpStreamingEvent, url, error) } + + override fun onUserSuperResolutionEnabled(uid: Int, enabled: Boolean, @Annotations.AgoraSuperResolutionStateReason reason: Int) { + callback(RtcEngineEvents.UserSuperResolutionEnabled, uid, enabled, reason) + } + + override fun onUploadLogResult(requestId: String?, success: Boolean, @Annotations.AgoraUploadErrorReason reason: Int) { + callback(RtcEngineEvents.UploadLogResult, requestId, success, reason) + } }