From 2fef3aee038b31808af53cee80a0fddc8d444fe8 Mon Sep 17 00:00:00 2001 From: HUI Date: Tue, 15 Dec 2020 14:41:11 +0800 Subject: [PATCH] feat: add `setClientRole(role: ClientRole, options?: ClientRoleOptions): Promise` --- Annotations.java | 8 ++++++++ BeanCovertor.kt | 7 +++++++ RtcChannel.kt | 7 ++++++- RtcEngine.kt | 7 ++++++- 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Annotations.java b/Annotations.java index 54e7ba9a5..64361ecc6 100644 --- a/Annotations.java +++ b/Annotations.java @@ -857,4 +857,12 @@ public class Annotations { @Retention(RetentionPolicy.SOURCE) public @interface AgoraVoiceBeautifierPreset { } + + @IntDef({ + Constants.AUDIENCE_LATENCY_LEVEL_LOW_LATENCY, + Constants.AUDIENCE_LATENCY_LEVEL_ULTRA_LOW_LATENCY, + }) + @Retention(RetentionPolicy.SOURCE) + public @interface AgoraAudienceLatencyLevelType { + } } diff --git a/BeanCovertor.kt b/BeanCovertor.kt index d7a94fb9a..7001164c8 100644 --- a/BeanCovertor.kt +++ b/BeanCovertor.kt @@ -7,6 +7,7 @@ import io.agora.rtc.live.LiveInjectStreamConfig 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.video.* fun mapToVideoDimensions(map: Map<*, *>): VideoEncoderConfiguration.VideoDimensions { @@ -177,3 +178,9 @@ fun mapToEncryptionConfig(map: Map<*, *>): EncryptionConfig { (map["encryptionKey"] as? String)?.let { encryptionKey = it } } } + +fun mapToClientRoleOptions(map: Map<*, *>): ClientRoleOptions { + return ClientRoleOptions().apply { + (map["audienceLatencyLevel"] as? Number)?.let { audienceLatencyLevel = it.toInt() } + } +} diff --git a/RtcChannel.kt b/RtcChannel.kt index 58432cee0..4734add1c 100644 --- a/RtcChannel.kt +++ b/RtcChannel.kt @@ -149,7 +149,12 @@ class RtcChannelManager( } override fun setClientRole(params: Map, callback: Callback) { - callback.code(this[params["channelId"] as String]?.setClientRole((params["role"] as Number).toInt())) + val role = (params["role"] as Number).toInt() + (params["options"] as? Map<*, *>)?.let { + callback.code(this[params["channelId"] as String]?.setClientRole(role, mapToClientRoleOptions(it))) + return@setClientRole + } + callback.code(this[params["channelId"] as String]?.setClientRole(role)) } override fun joinChannel(params: Map, callback: Callback) { diff --git a/RtcEngine.kt b/RtcEngine.kt index 9249a05f3..90d9a7343 100644 --- a/RtcEngine.kt +++ b/RtcEngine.kt @@ -364,7 +364,12 @@ class RtcEngineManager( } override fun setClientRole(params: Map, callback: Callback) { - callback.code(engine?.setClientRole((params["role"] as Number).toInt())) + val role = (params["role"] as Number).toInt() + (params["options"] as? Map<*, *>)?.let { + callback.code(engine?.setClientRole(role, mapToClientRoleOptions(it))) + return@setClientRole + } + callback.code(engine?.setClientRole(role)) } override fun joinChannel(params: Map, callback: Callback) {