帮你快速理解、总结文档立即下载

TXIoTMonitorSession

最近更新时间:2026-09-20 16:47:03
我的收藏

概述

TXIoTMonitorSession 负责拉取设备实时监控画面,包括开始/停止会话、远端拉流与清晰度切换、与设备进行对讲、云台控制、截图。TXIoTMonitorSession 通过 TXIoTEngine.getMonitorSession 获取实例,需在登录成功后调用。
说明:
回调模型:所有 Listener 回调在主线程触发,公共类型与错误码定义见 TXIoTEngineDef

方法列表

方法签名
描述
添加实时监控事件监听器。
移除实时监控事件监听器。
设置 iot-player 的组件 ID
开启实时监控。
停止实时监控。
开始渲染远端视频流。
停止渲染远端视频流。
切换远端视频流类型(高清/标清)。
静音/取消静音单路远端音频。
静音/取消静音所有远端音频。
开启本地音频采集和推送(用于实现对讲功能)。
关闭本地音频采集和推送。
静音/取消静音本地音频。
开启本地视频采集和推送。
关闭本地视频采集和推送。
发送云台控制指令。
对当前正在观看的通道进行截图。

addListener

addListener
addListener
(TXIoTMonitorSessionListener listener)
添加监控事件回调
参数
描述
listener
TXIoTMonitorSessionListener;监听器实例。

removeListener

removeListener
removeListener
(TXIoTMonitorSessionListener listener)
移除监控事件回调
参数
描述
listener
TXIoTMonitorSessionListener;监听器实例。

setIoTPlayer

setIoTPlayer
setIoTPlayer
(int channelId, String iotPlayerComponentId)
绑定渲染组件
参数
描述
channelId
int;通道 ID。
iotPlayerComponentId
String;iot-player 组件 ID。

startSession

startSession
startSession
(TXIoTDeviceId deviceId)
开启实时监控
参数
描述
deviceId
TXIoTDeviceId;设备标识(含 productId / deviceName)。

stopSession

stopSession
stopSession
()
停止实时监控

startRemoteView

startRemoteView
startRemoteView
(int channelId, TXIoTStreamType streamType)
开始渲染远端视频流
参数
描述
channelId
int;通道 ID。
streamType
TXIoTStreamType;视频流类型(高清/标清)。

stopRemoteView

stopRemoteView
stopRemoteView
(int channelId)
停止渲染远端视频流
参数
描述
channelId
int;通道 ID。

switchRemoteStream

switchRemoteStream
switchRemoteStream
(int channelId, TXIoTStreamType streamType)
切换远端视频流类型(高清/标清)
参数
描述
channelId
int;通道 ID。
streamType
TXIoTStreamType;视频流类型(高清/标清)。

muteRemoteAudio

muteRemoteAudio
muteRemoteAudio
(int channelId, boolean mute)
静音/取消静音单路远端音频
参数
描述
channelId
int;通道 ID。
mute
boolean;是否静音。

muteAllRemoteAudio

muteAllRemoteAudio
muteAllRemoteAudio
(boolean mute)
静音/取消静音所有远端音频
参数
描述
mute
boolean;是否静音。

startLocalAudio

startLocalAudio
startLocalAudio
()
开启本地音频采集和推送(用于实现对讲功能)

stopLocalAudio

stopLocalAudio
stopLocalAudio
()
停止本地音频采集和推送

muteLocalAudio

muteLocalAudio
muteLocalAudio
(boolean mute)
静音/取消静音本地音频
参数
描述
mute
boolean;是否静音。

startLocalVideo

startLocalVideo
startLocalVideo
(TXIoTVideoEncoderParams videoEncoderParams)
开启本地视频采集和推送
参数
描述
videoEncoderParams
TXIoTVideoEncoderParams;视频编码参数。

stopLocalVideo

stopLocalVideo
stopLocalVideo
()
停止本地视频采集和推送

sendPTZCommand

sendPTZCommand
sendPTZCommand
(int channelId, TXIoTPTZCommand command, int speed)
发送云台控制指令
参数
描述
channelId
int;通道 ID。
command
TXIoTPTZCommand;云台控制指令。
speed
int;云台运动速度。

takeSnapshot

takeSnapshot
takeSnapshot
(int channelId)
对当前正在观看的通道进行截图
参数
描述
channelId
int;通道 ID。

监控事件回调

TXIoTMonitorSessionListener
回调方法
说明
onError(channelId: Number, code: Number, msg: String)
监控发生错误。
onSessionEstablished()
监控会话建立成功。
onSessionReconnecting()
会话重连中。
onSessionRecovery()
会话恢复成功。
onRemoteStreamAvailable(channelId: Number, available: boolean)
远端流可用性变化。
onRenderFirstFrame(channelId: Number)
首帧渲染完成。
onPlayStateChanged(channelId: Number, state: Number)
播放状态变化。状态类型为 TXIoTPlayState
onSnapshotComplete(channelId: Number, imagePath: String)
截图完成,成功时 imagePath 非 null。

监控相关数据结构与枚举

TXIoTStreamType

TXIoTStreamType
枚举
说明
HD
高清
SD
标清

TXIoTPTZCommand

TXIoTPTZCommand
枚举
说明
UP
DOWN
LEFT
RIGHT
ZOOM_IN
变焦放大
ZOOM_OUT
变焦缩小
STOP
停止

TXIoTPlayState

TXIoTPlayState
枚举
说明
PLAYING
正在播放
LOADING
加载中
STOPPED
已停止

TXIoTVideoResolution

TXIoTVideoResolution
枚举
说明
RESOLUTION_640_360
横屏 640×360
RESOLUTION_960_540
横屏 960×540
RESOLUTION_1280_720
横屏 1280×720
RESOLUTION_1920_1080
横屏 1920×1080
RESOLUTION_360_640
竖屏 360×640
RESOLUTION_540_960
竖屏 540×960
RESOLUTION_720_1280
竖屏 720×1280
RESOLUTION_1080_1920
竖屏 1080×1920

TXIoTVideoEncoderParams

TXIoTVideoEncoderParams
字段
说明
resolution
视频编码分辨率。