需要添加直播接口

This commit is contained in:
cbb
2026-01-12 17:52:15 +08:00
parent 83fec2617c
commit 13af9eb303
281 changed files with 313157 additions and 104 deletions

View File

@@ -0,0 +1,42 @@
package uts.sdk.modules.atomicx.observer
import com.google.gson.Gson
import io.trtc.tuikit.atomicxcore.api.device.AudioEffectStore
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
object AudioEffectStoreObserver {
private val gson = Gson()
private var bindDataJob: Job? = null
fun audioEffectStoreChanged(callback: (String, String) -> Unit) {
bindDataJob?.cancel()
bindDataJob = CoroutineScope(Dispatchers.Main).launch {
launch {
AudioEffectStore.shared().audioEffectState.isEarMonitorOpened
.collect { enable ->
callback("isEarMonitorOpened", gson.toJson(enable))
}
}
launch {
AudioEffectStore.shared().audioEffectState.earMonitorVolume
.collect { volume ->
callback("earMonitorVolume", gson.toJson(volume))
}
}
launch {
AudioEffectStore.shared().audioEffectState.audioChangerType
.collect { type ->
callback("audioChangerType", gson.toJson(type.value))
}
}
launch {
AudioEffectStore.shared().audioEffectState.audioReverbType
.collect { type ->
callback("audioReverbType", gson.toJson(type.value))
}
}
}
}
}

View File

@@ -0,0 +1,32 @@
package uts.sdk.modules.atomicx.observer
import com.google.gson.Gson
import io.trtc.tuikit.atomicxcore.api.barrage.Barrage
import io.trtc.tuikit.atomicxcore.api.barrage.BarrageStore
import io.trtc.tuikit.atomicxcore.api.barrage.BarrageType
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
object BarrageStoreObserver {
private val gson = Gson()
private var bindDataJob: Job? = null
fun barrageStoreChanged(liveID: String, callback: (String, String) -> Unit) {
bindDataJob?.cancel()
bindDataJob = CoroutineScope(Dispatchers.Main).launch {
launch {
BarrageStore.create(liveID).barrageState.messageList.collect { messageList ->
callback("messageList", gson.toJson(messageList))
}
}
// TODO: 底层未实现,暂时隐藏
// launch {
// BarrageStore.create(liveID).barrageState.allowSendMessage.collect { allowSendMessage ->
// callback("allowSendMessage", gson.toJson(allowSendMessage))
// }
// }
}
}
}

View File

@@ -0,0 +1,34 @@
package uts.sdk.modules.atomicx.observer
import com.google.gson.Gson
import io.trtc.tuikit.atomicxcore.api.device.BaseBeautyStore
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
object BaseBeautyStoreObserver {
private val gson = Gson()
private var bindDataJob: Job? = null
fun beautyStoreChanged(callback: (String, String) -> Unit) {
bindDataJob?.cancel()
bindDataJob = CoroutineScope(Dispatchers.Main).launch {
launch {
BaseBeautyStore.shared().baseBeautyState.smoothLevel.collect { level ->
callback("smoothLevel", gson.toJson(level))
}
}
launch {
BaseBeautyStore.shared().baseBeautyState.whitenessLevel.collect { level ->
callback("whitenessLevel", gson.toJson(level))
}
}
launch {
BaseBeautyStore.shared().baseBeautyState.ruddyLevel.collect { level ->
callback("ruddyLevel", gson.toJson(level))
}
}
}
}
}

View File

@@ -0,0 +1,36 @@
package uts.sdk.modules.atomicx.observer
import com.google.gson.Gson
import io.trtc.tuikit.atomicxcore.api.live.BattleStore
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
object BattleStoreObserver {
private val gson = Gson()
private var bindDataJob: Job? = null
fun battleStoreChanged(liveID: String, callback: (String, String) -> Unit) {
bindDataJob?.cancel()
bindDataJob = CoroutineScope(Dispatchers.Main).launch {
launch {
BattleStore.create(liveID).battleState.currentBattleInfo.collect { currentBattleInfo ->
callback("currentBattleInfo", gson.toJson(currentBattleInfo))
}
}
launch {
BattleStore.create(liveID).battleState.battleUsers.collect { battleUsers ->
callback("battleUsers", gson.toJson(battleUsers))
}
}
launch {
BattleStore.create(liveID).battleState.battleScore.collect { battleScore ->
callback("battleScore", gson.toJson(battleScore))
}
}
}
}
}

View File

@@ -0,0 +1,72 @@
package uts.sdk.modules.atomicx.observer
import com.google.gson.Gson
import io.trtc.tuikit.atomicxcore.api.live.CoGuestStore
import io.trtc.tuikit.atomicxcore.api.device.DeviceStatus
import io.trtc.tuikit.atomicxcore.api.live.Role
import io.trtc.tuikit.atomicxcore.api.live.SeatUserInfo
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
object CoGuestStoreObserver {
private val gson = Gson()
private var bindDataJob: Job? = null
fun coGuestStoreChanged(liveID: String, callback: (String, String) -> Unit) {
bindDataJob?.cancel()
bindDataJob = CoroutineScope(Dispatchers.Main).launch {
launch {
CoGuestStore.create(liveID).coGuestState.connected.collect { connected ->
val list = connected.map { convertSeatInfoToMap(it) }
callback("connected", gson.toJson(list)) // SeatUserInfo
}
}
launch {
CoGuestStore.create(liveID).coGuestState.invitees.collect { invitees ->
callback("invitees", gson.toJson(invitees)) // LiveUserInfo
}
}
launch {
CoGuestStore.create(liveID).coGuestState.applicants.collect { applicants ->
callback("applicants", gson.toJson(applicants)) // LiveUserInfo
}
}
launch {
CoGuestStore.create(liveID).coGuestState.candidates.collect { candidates ->
callback("candidates", gson.toJson(candidates)) // LiveUserInfo
}
}
}
}
private fun convertSeatInfoToMap(info: SeatUserInfo): Map<String, Any> {
val map = mutableMapOf<String, Any>()
map["userID"] = info.userID
map["userName"] = info.userName
map["avatarURL"] = info.avatarURL
map["role"] = info.role
map["liveID"] = info.liveID
map["microphoneStatus"] = convertDeviceStatus(info.microphoneStatus)
map["allowOpenMicrophone"] = info.allowOpenMicrophone
map["cameraStatus"] = convertDeviceStatus(info.cameraStatus)
map["allowOpenCamera"] = info.allowOpenCamera
return map
}
private fun convertDeviceStatus(status: DeviceStatus?): String {
if (status == DeviceStatus.ON) {
return "ON"
}
return "OFF"
}
private fun convertUserRole(role: Role?): String {
return when (role) {
Role.OWNER -> "OWNER"
Role.ADMIN -> "ADMIN"
else -> "GENERAL_USER"
}
}
}

View File

@@ -0,0 +1,45 @@
package uts.sdk.modules.atomicx.observer
import com.google.gson.Gson
import io.trtc.tuikit.atomicxcore.api.live.CoHostStore
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
object CoHostStoreObserver {
private val gson = Gson()
private var bindDataJob: Job? = null
fun coHostStoreChanged(liveID: String, callback: (String, String) -> Unit) {
bindDataJob?.cancel()
bindDataJob = CoroutineScope(Dispatchers.Main).launch {
launch {
CoHostStore.create(liveID).coHostState.coHostStatus.collect { coHostStatus ->
callback("coHostStatus", gson.toJson(coHostStatus))
}
}
launch {
CoHostStore.create(liveID).coHostState.connected.collect { connected ->
callback("connected", gson.toJson(connected))
}
}
// TODO: 底层未实现,暂时隐藏
// launch {
// CoHostStore.create(liveID).coHostState.candidates.collect { candidates ->
// callback("candidates", gson.toJson(candidates))
// }
// }
launch {
CoHostStore.create(liveID).coHostState.invitees.collect { invitees ->
callback("invitees", gson.toJson(invitees))
}
}
launch {
CoHostStore.create(liveID).coHostState.applicant.collect { applicant ->
callback("applicant", gson.toJson(applicant))
}
}
}
}
}

View File

@@ -0,0 +1,87 @@
package uts.sdk.modules.atomicx.observer
import com.google.gson.Gson
import io.trtc.tuikit.atomicxcore.api.device.DeviceStore
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
object DeviceStoreObserver {
private val gson = Gson()
private var bindDataJob: Job? = null
fun deviceStoreChanged(callback: (String, String) -> Unit) {
bindDataJob?.cancel()
bindDataJob = CoroutineScope(Dispatchers.Main).launch {
launch {
DeviceStore.shared().deviceState.microphoneStatus.collect { status ->
callback("microphoneStatus", gson.toJson(status.value))
}
}
launch {
DeviceStore.shared().deviceState.microphoneLastError.collect { deviceError ->
callback("microphoneLastError", gson.toJson(deviceError.value))
}
}
launch {
DeviceStore.shared().deviceState.captureVolume.collect { volume ->
callback("captureVolume", gson.toJson(volume))
}
}
launch {
DeviceStore.shared().deviceState.currentMicVolume.collect { volume ->
callback("currentMicVolume", gson.toJson(volume))
}
}
launch {
DeviceStore.shared().deviceState.outputVolume.collect { volume ->
callback("outputVolume", gson.toJson(volume))
}
}
launch {
DeviceStore.shared().deviceState.cameraStatus.collect { cameraStatus ->
callback("cameraStatus", gson.toJson(cameraStatus.value))
}
}
launch {
DeviceStore.shared().deviceState.cameraLastError.collect { deviceError ->
callback("cameraLastError", gson.toJson(deviceError.value))
}
}
launch {
DeviceStore.shared().deviceState.isFrontCamera.collect { isFrontCamera ->
callback("isFrontCamera", gson.toJson(isFrontCamera))
}
}
launch {
DeviceStore.shared().deviceState.localMirrorType.collect { localMirrorType ->
callback("localMirrorType", gson.toJson(localMirrorType))
}
}
launch {
DeviceStore.shared().deviceState.localVideoQuality.collect { quality ->
callback("localVideoQuality", gson.toJson(quality))
}
}
launch {
DeviceStore.shared().deviceState.currentAudioRoute.collect { audioRoute ->
callback("currentAudioRoute", gson.toJson(audioRoute.value))
}
}
launch {
DeviceStore.shared().deviceState.screenStatus.collect { screenStatus ->
callback("screenStatus", gson.toJson(screenStatus.value))
}
}
launch {
DeviceStore.shared().deviceState.networkInfo.collect { networkInfo ->
callback("networkInfo", gson.toJson(networkInfo))
}
}
}
}
}

View File

@@ -0,0 +1,24 @@
package uts.sdk.modules.atomicx.observer
import com.google.gson.Gson
import io.trtc.tuikit.atomicxcore.api.gift.GiftStore
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
object GiftStoreObserver {
private val gson = Gson()
private var bindDataJob: Job? = null
fun giftStoreChanged(liveID: String, callback: (String, String) -> Unit) {
bindDataJob?.cancel()
bindDataJob = CoroutineScope(Dispatchers.Main).launch {
launch {
GiftStore.create(liveID).giftState.usableGifts.collect { usableGifts ->
callback("usableGifts", gson.toJson(usableGifts))
}
}
}
}
}

View File

@@ -0,0 +1,24 @@
package uts.sdk.modules.atomicx.observer
import com.google.gson.Gson
import io.trtc.tuikit.atomicxcore.api.live.LikeStore
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
object LikeStoreObserver {
private val gson = Gson()
private var bindDataJob: Job? = null
fun likeStoreChanged(liveID: String, callback: (String, String) -> Unit) {
bindDataJob?.cancel()
bindDataJob = CoroutineScope(Dispatchers.Main).launch {
launch {
LikeStore.create(liveID).likeState.totalLikeCount.collect { count ->
callback("totalLikeCount", gson.toJson(count))
}
}
}
}
}

View File

@@ -0,0 +1,31 @@
package uts.sdk.modules.atomicx.observer
import com.google.gson.Gson
import io.trtc.tuikit.atomicxcore.api.live.LiveAudienceStore
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
object LiveAudienceStoreObserver {
private val gson = Gson()
private var bindDataJob: Job? = null
fun liveAudienceStoreChanged(liveID: String, callback: (String, String) -> Unit) {
bindDataJob?.cancel()
bindDataJob = CoroutineScope(Dispatchers.Main).launch {
launch {
LiveAudienceStore.create(liveID).liveAudienceState.audienceList.collect { audienceList ->
callback("audienceList", gson.toJson(audienceList))
}
}
launch {
LiveAudienceStore.create(liveID).liveAudienceState.audienceCount.collect { audienceCount ->
callback("audienceCount", gson.toJson(audienceCount))
}
}
}
}
}

View File

@@ -0,0 +1,35 @@
package uts.sdk.modules.atomicx.observer
import com.google.gson.Gson
import io.trtc.tuikit.atomicxcore.api.live.LiveListStore
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
object LiveListStoreObserver {
private val gson = Gson()
private var bindDataJob: Job? = null
fun liveStoreChanged(callback: (String, String) -> Unit) {
bindDataJob?.cancel()
bindDataJob = CoroutineScope(Dispatchers.Main).launch {
launch {
LiveListStore.shared().liveState.liveList.collect { liveList ->
callback("liveList", gson.toJson(liveList))
}
}
launch {
LiveListStore.shared().liveState.liveListCursor.collect { cursor ->
callback("liveListCursor", gson.toJson(cursor))
}
}
launch {
LiveListStore.shared().liveState.currentLive.collect { liveInfo ->
callback("currentLive", gson.toJson(liveInfo))
}
}
}
}
}

View File

@@ -0,0 +1,39 @@
package uts.sdk.modules.atomicx.observer
import com.google.gson.Gson
import io.trtc.tuikit.atomicxcore.api.live.LiveSeatStore
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import uts.sdk.modules.atomicx.kotlin.Logger
import io.dcloud.uts.console
object LiveSeatStoreObserver {
private val gson = Gson()
private var bindDataJob: Job? = null
fun liveSeatStoreChanged(liveID: String, callback: (String, String) -> Unit) {
bindDataJob?.cancel()
bindDataJob = CoroutineScope(Dispatchers.Main).launch {
launch {
LiveSeatStore.create(liveID).liveSeatState.seatList.collect { seatList ->
val list = gson.toJson(seatList)
console.info("UTS-Live: liveSeatStoreChanged, seatList: ", list)
Logger.i("UTS-Live: " + "liveSeatStoreChanged, seatList: "+ list);
callback("seatList", gson.toJson(seatList))
}
}
launch {
LiveSeatStore.create(liveID).liveSeatState.canvas.collect { canvas ->
callback("canvas", gson.toJson(canvas))
}
}
launch {
LiveSeatStore.create(liveID).liveSeatState.speakingUsers.collect { speakingUsers ->
callback("speakingUsers", gson.toJson(speakingUsers))
}
}
}
}
}

View File

@@ -0,0 +1,23 @@
package uts.sdk.modules.atomicx.observer
import com.google.gson.Gson
import io.trtc.tuikit.atomicxcore.api.live.LiveSummaryStore
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
object LiveSummaryStoreObserver {
private val gson = Gson()
private var bindDataJob: Job? = null
fun liveSummaryStoreChanged(liveID: String, callback: (String, String) -> Unit) {
bindDataJob?.cancel()
bindDataJob = CoroutineScope(Dispatchers.Main).launch {
launch {
LiveSummaryStore.create(liveID).liveSummaryState.summaryData.collect { data ->
callback("summaryData", gson.toJson(data))
}
}
}
}
}

View File

@@ -0,0 +1,32 @@
package uts.sdk.modules.atomicx.observer
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import io.trtc.tuikit.atomicxcore.api.login.LoginStatus
import io.trtc.tuikit.atomicxcore.api.login.LoginStore
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
object LoginStoreObserver {
private val gson = GsonBuilder().serializeNulls().create()
private var bindDataJob: Job? = null
fun loginStoreChanged(callback: (String, String) -> Unit) {
bindDataJob?.cancel()
bindDataJob = CoroutineScope(Dispatchers.Main).launch {
launch {
LoginStore.shared.loginState.loginUserInfo.collect { userInfo ->
callback("loginUserInfo", gson.toJson(userInfo))
}
}
launch {
LoginStore.shared.loginState.loginStatus.collect { loginStatus ->
// UNLOGIN \ LOGINED
callback("loginStatus", gson.toJson(loginStatus))
}
}
}
}
}