Skip to content

Commit

Permalink
feat: add `setClientRole(role: ClientRole, options?: ClientRoleOption…
Browse files Browse the repository at this point in the history
…s): Promise<void>`
  • Loading branch information
LichKing-2234 committed Dec 15, 2020
1 parent fcb57cc commit 2fef3ae
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Annotations.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}
}
7 changes: 7 additions & 0 deletions BeanCovertor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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() }
}
}
7 changes: 6 additions & 1 deletion RtcChannel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ class RtcChannelManager(
}

override fun setClientRole(params: Map<String, *>, 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<String, *>, callback: Callback) {
Expand Down
7 changes: 6 additions & 1 deletion RtcEngine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,12 @@ class RtcEngineManager(
}

override fun setClientRole(params: Map<String, *>, 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<String, *>, callback: Callback) {
Expand Down

0 comments on commit 2fef3ae

Please sign in to comment.