TRROMediaObserver

TRROMediaObserver Interface

Methods

onMqttConnectionState(param) → {function}

MQTT connection state callback

Parameters:
NameTypeDescription
paramObject
Properties
NameTypeAttributesDescription
stateMqttConnectionState

MQTT connection state

messagestring<optional>

Related information

Returns:
Type: 
function

onSignalingState(param, roomId) → {function}

Signaling state callback

Parameters:
NameTypeDescription
paramObject
roomIdstring

Signaling room ID

param.statestring

socket.io-client built-in events, refer to: https://socket.io/docs/v2/client-api/#events

param.dataObject

Parameters for socket.io-client built-in events, refer to: https://socket.io/docs/v2/client-api/#events

Returns:
Type: 
function

onPeerConnectionState(param) → {function}

Peer connection state change callback

CONNECTED = 0 Connection successful
NEW = 1 New connection
CONNECTING = 2 Connecting
FAILED = 3 Connection failed
DISCONNECTED = 4 Connection disconnected
CLOSED = 5 Actively closed
RECONNECTING = 6 Reconnecting
NOT_SUPPORT = 255 Browser doesn't support WebRTC
LIMIT_EXCEEDED = 256 PeerConnection count has reached browser limit

Parameters:
NameTypeDescription
paramObject

Connection state code

Properties
NameTypeAttributesDescription
deviceIdstring

Field device ID. In public cloud mode, format is ${projectId}/${fieldDeviceId}

streamIdnumber<optional>

Stream ID (only available in server2 mode)

mediaTypeMediaType<optional>

Stream type (only available in server2 mode)

statestring

Connection state information

codestring

Connection state code

messagestring

Message

dataObject

Extended information

Returns:
Type: 
function

onDataChannelState(param) → {void|function}

Data channel state callback

Parameters:
NameTypeDescription
paramObject
Properties
NameTypeAttributesDescription
deviceIdstring

Field device ID. In public cloud mode, format is ${projectId}/${fieldDeviceId}

statestring

Data channel state: 'open' | 'close' | 'error'

messagestring<optional>

Error message

labelstring

Data channel label

Returns:
  • Type: 
    void
  • Type: 
    function

onConnected(param) → {function}

Field device connection callback

Parameters:
NameTypeDescription
paramObject

Callback data

Properties
NameTypeDescription
deviceIdstring

Field device ID. In public cloud mode, format is ${projectId}/${fieldDeviceId}

Returns:
Type: 
function

onDisconnected(param) → {function}

Field device disconnection callback

Parameters:
NameTypeDescription
paramObject

Callback data

Properties
NameTypeDescription
deviceIdstring

Field device ID. In public cloud mode, format is ${projectId}/${fieldDeviceId}

Returns:
Type: 
function

onTrackPublishState(param) → {function}

Video stream publish/unpublish callback

Parameters:
NameTypeDescription
paramObject

Callback data

Properties
NameTypeDescription
statestring

Stream state 'publish' | 'unpublish'

deviceIdstring

Field device ID. In public cloud mode, format is ${projectId}/${fieldDeviceId}

streamIdnumber

Corresponding subscribed stream ID

mediaTypeMediaType

'video' | 'audio'

Returns:
Type: 
function

onControlData(param) → {function}

DataChannel custom message callback

Parameters:
NameTypeDescription
paramObject

Callback data

Properties
NameTypeDescription
deviceIdstring

Field device ID. In public cloud mode, format is ${projectId}/${fieldDeviceId}

dataTypestring

Custom message type: 'string' | 'arrayBuffer'

datastring | ArrayBuffer

Custom message

orderedboolean

Whether sent through reliable channel

Returns:
Type: 
function

onKick(param) → {function}

Kickout callback

Parameters:
NameTypeDescription
paramObject

Callback data

Properties
NameTypeDescription
codenumber

Code

reasonstring

Reason

Returns:
Type: 
function

onPermissionStateChange(param) → {function}

Permission state change callback

Parameters:
NameTypeDescription
paramObject

Callback data

Properties
NameTypeDescription
deviceIdstring

Field device ID. In public cloud mode, format is ${projectId}/${fieldDeviceId}

userIdstring

Remote device ID

permissionPermissionState

Permission information

Returns:
Type: 
function

onError(param) → {function}

Error notification

Parameters:
NameTypeDescription
paramObject

Callback data

Properties
NameTypeDescription
codenumber

Error code

messagestring

Error message

Returns:
Type: 
function

onEvent(param) → {function}

Event callback

Parameters:
NameTypeDescription
paramOnEventResponse

Callback data

Properties
NameTypeDescription
typestring

Event type: autoplay | webrtcStats | gatewayStats | localTrackUnpublished

dataObject

Extended information

Returns:
Type: 
function