Atomic X Core API
🚀 AtomicX Core API
腾讯实时音视频 SDK 核心 API 文档
📋 概述
AtomicX Core API 是基于状态管理模式设计的 SDK,通过 Store 类管理各模块的业务逻辑,每个 Store 提供对应的 State 数据类来订阅状态变化。
🏗️ API 概览
| 模块 | Store | State | 说明 |
|---|---|---|---|
| 登录 | LoginStore | LoginState | 用户登录、登出、个人信息管理 |
| 通话 | CallStore | CallState | 音视频通话 |
| 直播 | LiveListStore | LiveListState | 直播间列表管理 |
| LiveAudienceStore | LiveAudienceState | 观众端状态管理 | |
| LiveSeatStore | LiveSeatState | 麦位管理 | |
| CoGuestStore | CoGuestState | 观众连麦管理 | |
| CoHostStore | CoHostState | 主播连麦管理 | |
| BattleStore | BattleState | PK 对战管理 | |
| LikeStore | LikeState | 点赞管理 | |
| 多人音视频房间 | RoomStore | RoomState | 房间管理 |
| RoomParticipantStore | RoomParticipantState | 房间参与者管理 | |
| 弹幕 | BarrageStore | BarrageState | 弹幕消息管理 |
| 礼物 | GiftStore | GiftState | 礼物发送与接收 |
| 设备 | DeviceStore | DeviceState | 摄像头、麦克风管理 |
| AudioEffectStore | AudioEffectState | 音效管理 | |
| BaseBeautyStore | BaseBeautyState | 基础美颜管理 |
🔐 登录模块 (Login)
LoginStore
登录管理核心类,负责用户登录、登出和个人信息设置。
核心 API:
| 方法 | 说明 |
|---|---|
| login | 用户登录 |
| logout | 用户登出 |
| setSelfInfo | 设置个人信息 |
| addLoginListener | 添加登录监听器 |
| removeLoginListener | 移除登录监听器 |
状态订阅 (LoginState):
| 属性 | 类型 | 说明 |
|---|---|---|
| loginStatus | StateFlow<LoginStatus> | 登录状态 |
| loginUserInfo | StateFlow<UserProfile?> | 当前登录用户信息 |
相关类型: LoginStatus | UserProfile | Gender | AllowType | LoginListener
📞 通话模块 (Call)
CallStore
通话管理核心类,负责音视频通话的发起、接听、拒绝、挂断、群组通话管理和通话记录管理。
核心 API:
| 方法 | 说明 |
|---|---|
| calls | 发起通话 |
| accept | 接听通话 |
| reject | 拒绝通话 |
| hangup | 挂断通话 |
| join | 加入群组通话 |
| invite | 邀请用户加入通话 |
| queryRecentCalls | 查询通话记录 |
| deleteRecentCalls | 删除通话记录 |
| addListener | 添加通话监听器 |
| removeListener | 移除通话监听器 |
状态订阅 (CallState):
| 属性 | 类型 | 说明 |
|---|---|---|
| activeCall | StateFlow<CallInfo> | 当前通话信息 |
| recentCalls | StateFlow<LinkedHashSet<CallInfo>> | 通话记录列表 |
| cursor | StateFlow<String> | 分页游标 |
| selfInfo | StateFlow<CallParticipantInfo> | 当前用户信息 |
| allParticipants | StateFlow<LinkedHashSet<CallParticipantInfo>> | 所有参与者列表 |
| speakerVolumes | StateFlow<MutableMap<String, Int>> | 参与者音量信息 |
| networkQualities | StateFlow<MutableMap<String, NetworkQuality>> | 参与者网络质量 |
相关类型: CallMediaType | CallEndReason | CallDirection | CallParticipantStatus | CallParams | CallParticipantInfo | CallInfo | CallListener
📺 直播模块 (Live)
CoGuestStore
观众连麦管理,处理主播与观众之间的连麦申请、邀请、接受、拒绝等操作。
核心 API:
| 方法 | 说明 |
|---|---|
| applyForSeat | 申请上麦 |
| cancelApplication | 取消申请 |
| acceptApplication | 接受申请 |
| rejectApplication | 拒绝申请 |
| inviteToSeat | 邀请上麦 |
| cancelInvitation | 取消邀请 |
| acceptInvitation | 接受邀请 |
| rejectInvitation | 拒绝邀请 |
| disconnect | 断开连麦 |
| addHostListener | 添加主播端监听器 |
| removeHostListener | 移除主播端监听器 |
| addGuestListener | 添加观众端监听器 |
| removeGuestListener | 移除观众端监听器 |
状态订阅 (CoGuestState):
| 属性 | 类型 | 说明 |
|---|---|---|
| connected | StateFlow<List<SeatUserInfo>> | 已连麦用户列表 |
| invitees | StateFlow<List<LiveUserInfo>> | 主播邀请的用户列表 |
| applicants | StateFlow<List<LiveUserInfo>> | 申请连麦的用户列表 |
| candidates | StateFlow<List<LiveUserInfo>> | 连麦候选用户列表 |
相关类型: HostListener | GuestListener | NoResponseReason | SeatUserInfo | LiveUserInfo
CoHostStore
主播连麦管理,处理主播之间的跨房间连麦。
核心 API:
| 方法 | 说明 |
|---|---|
| requestConnection | 请求连麦 |
| cancelRequest | 取消请求 |
| acceptConnection | 接受连麦 |
| rejectConnection | 拒绝连麦 |
| disconnect | 断开连麦 |
状态订阅 (CoHostState):
| 属性 | 类型 | 说明 |
|---|---|---|
| connectedUsers | StateFlow<List<LiveUserInfo>> | 已连麦主播列表 |
| sentConnectionRequests | StateFlow<List<LiveUserInfo>> | 发送的连麦请求列表 |
| receivedConnectionRequests | StateFlow<List<LiveUserInfo>> | 收到的连麦请求列表 |
BattleStore
PK 对战管理,处理主播之间的 PK 对战逻辑。
核心 API:
| 方法 | 说明 |
|---|---|
| requestBattle | 请求 PK |
| cancelRequest | 取消请求 |
| acceptBattle | 接受 PK |
| rejectBattle | 拒绝 PK |
| exitBattle | 退出 PK |
状态订阅 (BattleState):
| 属性 | 类型 | 说明 |
|---|---|---|
| isBattling | StateFlow<Boolean> | 是否正在 PK |
| battleUsers | StateFlow<List<BattleUserInfo>> | PK 用户列表 |
| sentBattleRequests | StateFlow<List<LiveUserInfo>> | 发送的 PK 请求列表 |
| receivedBattleRequests | StateFlow<List<LiveUserInfo>> | 收到的 PK 请求列表 |
LiveSeatStore
麦位管理,控制直播间的麦位状态。
核心 API:
| 方法 | 说明 |
|---|---|
| takeSeat | 上麦 |
| leaveSeat | 下麦 |
| lockSeat | 锁定麦位 |
| kickUserOffSeat | 踢人下麦 |
状态订阅 (LiveSeatState):
| 属性 | 类型 | 说明 |
|---|---|---|
| seatList | StateFlow<List<SeatInfo>> | 麦位列表 |
LiveListStore
直播间列表管理。
核心 API:
| 方法 | 说明 |
|---|---|
| fetchLiveList | 获取直播列表 |
| fetchRecommendedList | 获取推荐列表 |
状态订阅 (LiveListState):
| 属性 | 类型 | 说明 |
|---|---|---|
| liveList | StateFlow<List<LiveInfo>> | 直播列表 |
LiveAudienceStore
观众端状态管理。
核心 API:
| 方法 | 说明 |
|---|---|
| joinLive | 加入直播间 |
| leaveLive | 离开直播间 |
状态订阅 (LiveAudienceState):
| 属性 | 类型 | 说明 |
|---|---|---|
| liveInfo | StateFlow<LiveInfo?> | 当前直播信息 |
LikeStore
点赞管理。
核心 API:
| 方法 | 说明 |
|---|---|
| like | 发送点赞 |
状态订阅 (LikeState):
| 属性 | 类型 | 说明 |
|---|---|---|
| likeCount | StateFlow<Int> | 点赞数量 |
🏠 房间模块 (Room)
RoomStore
房间管理核心类,负责房间的创建、加入、离开、预约等操作。
核心 API:
| 方法 | 说明 |
|---|---|
| createAndJoinRoom | 创建并加入房间 |
| joinRoom | 加入房间 |
| leaveRoom | 离开房间 |
| endRoom | 结束房间 |
| scheduleRoom | 预约房间 |
| cancelScheduledRoom | 取消预约房间 |
| callUserToRoom | 呼叫用户加入房间 |
| acceptCall | 接受呼叫 |
| rejectCall | 拒绝呼叫 |
| addRoomListener | 添加房间监听器 |
| removeRoomListener | 移除房间监听器 |
状态订阅 (RoomState):
| 属性 | 类型 | 说明 |
|---|---|---|
| currentRoom | StateFlow<RoomInfo?> | 当前房间信息 |
| scheduledRoomList | StateFlow<List<RoomInfo>> | 预约房间列表 |
相关类型: RoomStatus | RoomInfo | RoomUser | RoomCall | RoomListener
RoomParticipantStore
房间参与者管理,处理参与者的权限、设备控制、消息禁言等操作。
核心 API:
| 方法 | 说明 |
|---|---|
| getParticipantList | 获取参与者列表 |
| transferOwner | 转让房主 |
| setAdmin | 设置管理员 |
| revokeAdmin | 撤销管理员 |
| kickUser | 踢出用户 |
| closeParticipantDevice | 关闭参与者设备 |
| disableAllDevices | 禁用所有设备 |
| disableAllMessages | 全员禁言 |
| requestToOpenDevice | 请求开启设备 |
| inviteToOpenDevice | 邀请开启设备 |
状态订阅 (RoomParticipantState):
| 属性 | 类型 | 说明 |
|---|---|---|
| participantList | StateFlow<List<RoomParticipant>> | 参与者列表 |
| participantListWithVideo | StateFlow<List<RoomParticipant>> | 有视频的参与者列表 |
| participantWithScreen | StateFlow<RoomParticipant?> | 正在共享屏幕的参与者 |
| localParticipant | StateFlow<RoomParticipant?> | 本地参与者 |
| pendingDeviceApplications | StateFlow<List<DeviceRequestInfo>> | 待处理的设备申请 |
相关类型: ParticipantRole | RoomParticipant | DeviceRequestInfo | RoomParticipantListener
💬 弹幕模块 (Barrage)
BarrageStore
弹幕管理核心类,负责弹幕发送和状态同步。
核心 API:
| 方法 | 说明 |
|---|---|
| sendTextMessage | 发送文本弹幕 |
| sendCustomMessage | 发送自定义弹幕 |
| appendLocalTip | 添加本地提示消息 |
状态订阅 (BarrageState):
| 属性 | 类型 | 说明 |
|---|---|---|
| messageList | StateFlow<List<Barrage>> | 弹幕消息列表 |
相关类型: Barrage | BarrageType
🎁 礼物模块 (Gift)
GiftStore
礼物管理核心类,处理礼物发送和接收。
核心 API:
| 方法 | 说明 |
|---|---|
| sendGift | 发送礼物 |
| refreshUsableGifts | 刷新可用礼物列表 |
| setLanguage | 设置礼物信息显示语言 |
| addGiftListener | 添加礼物事件监听 |
| removeGiftListener | 移除礼物事件监听 |
状态订阅 (GiftState):
| 属性 | 类型 | 说明 |
|---|---|---|
| usableGifts | StateFlow<List<GiftCategory>> | 可用礼物分类列表 |
相关类型: Gift | GiftCategory | GiftListener
📱 设备模块 (Device)
DeviceStore
设备管理核心类,控制摄像头、麦克风等硬件设备。
核心 API:
| 方法 | 说明 |
|---|---|
| openLocalMicrophone | 打开麦克风 |
| closeLocalMicrophone | 关闭麦克风 |
| openLocalCamera | 打开摄像头 |
| closeLocalCamera | 关闭摄像头 |
| switchCamera | 切换前后摄像头 |
| switchMirror | 切换镜像模式 |
| updateVideoQuality | 更新视频质量 |
| setAudioRoute | 设置音频路由 |
| setCaptureVolume | 设置采集音量 |
| setOutputVolume | 设置输出音量 |
| startScreenShare | 开始屏幕共享 |
| stopScreenShare | 停止屏幕共享 |
| startCameraTest | 开始摄像头测试 |
| stopCameraTest | 停止摄像头测试 |
状态订阅 (DeviceState):
| 属性 | 类型 | 说明 |
|---|---|---|
| microphoneStatus | StateFlow<DeviceStatus> | 麦克风状态 |
| microphoneLastError | StateFlow<DeviceError> | 麦克风错误 |
| cameraStatus | StateFlow<DeviceStatus> | 摄像头状态 |
| cameraLastError | StateFlow<DeviceError> | 摄像头错误 |
| isFrontCamera | StateFlow<Boolean> | 是否前置摄像头 |
| localMirrorType | StateFlow<MirrorType> | 本地镜像类型 |
| localVideoQuality | StateFlow<VideoQuality> | 本地视频质量 |
| currentAudioRoute | StateFlow<AudioRoute> | 当前音频路由 |
| screenStatus | StateFlow<DeviceStatus> | 屏幕共享状态 |
| networkInfo | StateFlow<NetworkInfo> | 网络信息 |
| captureVolume | StateFlow<Int> | 采集音量 |
| outputVolume | StateFlow<Int> | 输出音量 |
| currentMicVolume | StateFlow<Int> | 当前麦克风音量 |
相关类型: DeviceType | DeviceStatus | DeviceError | AudioRoute | VideoQuality | MirrorType | NetworkQuality | NetworkInfo
AudioEffectStore
音频音效管理,提供变声、混响等音效功能。
状态订阅 (AudioEffectState):
| 属性 | 类型 | 说明 |
|---|---|---|
| changerType | StateFlow<AudioChangerType> | 变声类型 |
| reverbType | StateFlow<AudioReverbType> | 混响类型 |
| musicVolume | StateFlow<Int> | 音乐音量 |
| voiceVolume | StateFlow<Int> | 人声音量 |
| voicePitch | StateFlow<Double> | 人声音调 |
相关类型: AudioChangerType | AudioReverbType
BaseBeautyStore
基础美颜管理,提供美白、磨皮等美颜功能。
状态订阅 (BaseBeautyState):
| 属性 | 类型 | 说明 |
|---|---|---|
| smoothLevel | StateFlow<Int> | 磨皮等级 |
| whitenessLevel | StateFlow<Int> | 美白等级 |
| ruddyLevel | StateFlow<Int> | 红润等级 |
🖼️ 视图模块 (View)
LiveCoreView
直播核心视图组件,提供直播画面渲染能力。
CameraView
摄像头预览视图组件。
RoomParticipantView
房间参与者视频视图组件,用于展示房间参与者的视频画面。
核心 API:
| 方法 | 说明 |
|---|---|
| init | 初始化视图 |
| updateStreamType | 更新视频流类型 |
| updateParticipant | 更新参与者信息 |
| setFillMode | 设置填充模式 |
| setActive | 设置激活状态 |
相关类型: VideoStreamType | FillMode