TRROMediaObserver

TRROMediaObserver

Description:
  • TRROMediaObserver 回调函数

TRROMediaObserver 回调函数

Methods

onMqttConnectionState(param) → {function}

Description:
  • MQTT 连接状态回调

Parameters:
Name Type Description
param Object
Properties
Name Type Attributes Description
state MqttConnectionState

MQTT 连接状态

message string <optional>

相关信息

Returns:
Type
function

onSignalingState(param, roomId) → {function}

Description:
  • 信令状态回调

Parameters:
Name Type Description
param Object
roomId string

信令房间 ID

param.state string

socket.io-client 内置事件,具体可以参考 https://socket.io/docs/v2/client-api/#events

param.data Object

socket.io-client 内置事件的相关参数,具体可以参考 https://socket.io/docs/v2/client-api/#events

Returns:
Type
function

onPeerConnectionState(param) → {function}

Description:
  • peer connection 连接改变回调

    CONNECTED = 0 连接成功
    NEW = 1 新建连接
    CONNECTING = 2 连接中
    FAILED = 3 连接失败
    DISCONNECTED = 4 连接断开
    CLOSED = 5 主动关闭
    RECONNECTING = 6 重连中
    NOT_SUPPORT = 255 当前浏览器不支持 WebRTC
    LIMIT_EXCEEDED = 256 当前 PeerConnection 连接数已达到浏览器上限

Parameters:
Name Type Description
param Object
Properties
Name Type Attributes Description
deviceId string

现场设备 ID。公有云模式下,返回的 ID 的格式为 ${projectId}/${fieldDeviceId}

streamId number <optional>

流 ID,该字段只在 server2 模式下有值

mediaType MediaType <optional>

流类型,该字段只在 server2 模式下有值

state string

连接状态信息

code string

连接状态码

message string

message

data Object

扩展信息

Returns:
Type
function

onDataChannelState(param) → {void|function}

Description:
  • 数据通道状态回调

Parameters:
Name Type Description
param Object
Properties
Name Type Attributes Description
deviceId string

现场设备 ID。公有云模式下,返回的 ID 的格式为 ${projectId}/${fieldDeviceId}

state string

数据通道状态,取值为 'open' | 'close' | 'error'

message string <optional>

错误信息

label string

数据通道标签

Returns:
  • Type
    void
  • Type
    function

onConnected(param) → {function}

Description:
  • 现场设备连接回调

Parameters:
Name Type Description
param Object

回调数据

Properties
Name Type Description
deviceId string

现场设备 ID。公有云模式下,返回的 ID 的格式为 ${projectId}/${fieldDeviceId}

Returns:
Type
function

onDisconnected(param) → {function}

Description:
  • 现场设备断开连接回调

Parameters:
Name Type Description
param Object

回调数据

Properties
Name Type Description
deviceId string

现场设备 ID。公有云模式下,返回的 ID 的格式为 ${projectId}/${fieldDeviceId}

Returns:
Type
function

onTrackPublishState(param) → {function}

Description:
  • 视频流 发布/取消发布 回调

Parameters:
Name Type Description
param Object

回调数据

Properties
Name Type Description
state string

视频流状态 'publish' | 'unpublish'

deviceId string

现场设备 ID。公有云模式下,返回的 ID 的格式为 ${projectId}/${fieldDeviceId}

streamId number

对应已经订阅的 streamId

mediaType MediaType

'video' | 'audio'

Returns:
Type
function

onControlData(param) → {function}

Description:
  • DataChannel 自定义消息 回调

Parameters:
Name Type Description
param Object

回调数据

Properties
Name Type Attributes Description
deviceId string

现场设备 ID。公有云模式下,返回的 ID 的格式为 ${projectId}/${fieldDeviceId}

dataType string

自定义消息类型 'string' | 'arrayBuffer'

data string | ArrayBuffer

自定义消息

ordered boolean <optional>

是否通过可靠通道发送,仅在 channelType 为 'sctp' 时有值

channelType 'sctp' | 'mqtt'

消息通道类型,'sctp' 表示 DataChannel,'mqtt' 表示 MQTT

Returns:
Type
function

onKick(param) → {function}

Description:
  • 剔除回调

Parameters:
Name Type Description
param Object

回调数据

Properties
Name Type Description
code number

code

reason string

原因

Returns:
Type
function

onPermissionStateChange(param) → {function}

Description:
  • 权限信息回调

Parameters:
Name Type Description
param Object

回调数据

Properties
Name Type Description
deviceId string

现场设备 ID。公有云模式下,返回的 ID 的格式为 ${projectId}/${fieldDeviceId}

userId string

远端设备 ID

permission PermissionState

权限信息

Returns:
Type
function

onError(param) → {function}

Description:
  • 错误通知

    错误码 原因
    20101 用户名或者密码错误
    20102 同名用户登录
    20199 MQTT 连接错误
Parameters:
Name Type Description
param Object

回调数据

Properties
Name Type Description
code number

错误码

message string

错误信息

Returns:
Type
function

onEvent(param) → {function}

Description:
  • 事件回调

Parameters:
Name Type Description
param OnEventResponse

回调数据

Properties
Name Type Description
type string

事件类型 autoplay | webrtcStats | gatewayStats | localTrackUnpublished

data Object

扩展信息

Returns:
Type
function