# Global

##

### Members

#### NetworkErrorCode[undefined]

Description:

  - Success Default response for all signaling

Success Default response for all signaling

#### NetworkErrorCode[undefined]

Description:

  - Stream not found Media service - Stream doesn't exist Returned by subscribe signaling

Stream not found Media service - Stream doesn't exist Returned by subscribe signaling

#### NetworkErrorCode[undefined]

Description:

  - Parameter error Media service - Invalid parameters Returned by subscribe signaling

Parameter error Media service - Invalid parameters Returned by subscribe signaling

#### NetworkErrorCode[undefined]

Description:

  - Track not found Media service - Subscribed track doesn't exist Returned by subscribe signaling

Track not found Media service - Subscribed track doesn't exist Returned by subscribe signaling

#### NetworkErrorCode[undefined]

Description:

  - Invalid JSON Check signaling structure and parameters

Invalid JSON Check signaling structure and parameters

#### NetworkErrorCode[undefined]

Description:

  - Invalid parameters Check signaling parameters

Invalid parameters Check signaling parameters

#### NetworkErrorCode[undefined]

Description:

  - User not joined User hasn't joined the room

User not joined User hasn't joined the room

#### NetworkErrorCode[undefined]

Description:

  - User repeated join User logged in repeatedly

User repeated join User logged in repeatedly

#### NetworkErrorCode[undefined]

Description:

  - Source user doesn't exist Remote user doesn't exist Applies to signaling related to remote users (invite, offer, answer, custom data, etc.)

Source user doesn't exist Remote user doesn't exist Applies to signaling related to remote users (invite, offer, answer, custom data, etc.)

#### NetworkErrorCode[undefined]

Description:

  - Invalid user signature

Invalid user signature

#### NetworkErrorCode[undefined]

Description:

  - Invalid auth server signature Public cloud authentication failed

Invalid auth server signature Public cloud authentication failed

#### NetworkErrorCode[undefined]

Description:

  - No track exists Stream doesn't exist Returned by subscribe signaling

No track exists Stream doesn't exist Returned by subscribe signaling

#### NetworkErrorCode[undefined]

Description:

  - Server overload Returned by join signaling

Server overload Returned by join signaling

#### NetworkErrorCode[undefined]

Description:

  - Media server exception

Media server exception

#### NetworkErrorCode[undefined]

Description:

  - Unknown error

Unknown error

### Type Definitions

#### ConnectionState

Description:

  - Connection State

Connection State

##### Type:

- 'new' | 'connecting' | 'connected' | 'failed' | 'disconnected' | 'reconnecting' | 'not_support' | 'limit_exceeded'

#### CloudMode

Description:

  - Cloud Mode public - Public cloud public_intl - Public cloud (international) private - Private cloud

Cloud Mode public - Public cloud public_intl - Public cloud (international) private - Private cloud

##### Type:

- 'public' | 'public_intl' | 'private'

#### SDKMode

Description:

  - Service Mode server - Dedicated acceleration mode server2 - Standard acceleration mode

Service Mode server - Dedicated acceleration mode server2 - Standard acceleration mode

##### Type:

- 'server' | 'server2'

#### MediaType

Description:

  - Media Type

Media Type

##### Type:

- 'video' | 'audio'

#### RoomState

Description:

  - Room State

Room State

##### Type:

- 'joining' | 'joined' | 'unjoined'

#### SignalingState

Description:

  - Signaling State

Signaling State

##### Type:

- 'new' | 'scheduling' | 'scheduled' | 'connecting' | 'connected' | 'disconnected' | 'closed' | 'reconnecting'

#### MqttConnectionState

Description:

  - MQTT Connection State

MQTT Connection State

##### Type:

- 'new' | 'connecting' | 'connected' | 'reconnecting' | 'error' | 'closed'

#### PermissionState

Description:

  - Gateway Device Permission

Gateway Device Permission

##### Type:

- 'master' | 'guest'

#### Gateway

Description:

  - Gateway Information

##### Properties:

Name | Type | Attributes | Description
--- | --- | --- | ---
`deviceId` | string |  | Field device ID. In public cloud mode, format is `${projectId}/${fieldDeviceId}`
`deviceName` | string |  |
`deviceType` | string |  |
`streamCount` | number |  |
`status` | string |  |
`version` | string |  | Gateway SDK version
`licenseExpire` | number | <optional> | License expiration timestamp (seconds)

Gateway Information

##### Type:

- object

#### OnEventAutoplayResponse

Description:

  - Autoplay Response Type

##### Properties:

Name | Type | Description
--- | --- | ---
`type` | 'autoplay' |
`data` | object | ###### Properties
Name | Type | Attributes | Description
--- | --- | --- | ---
`code` | number |  | 0 - Success, -1 - Failed, 20 - MQTT client not found (public cloud only), 21 - MQTT client not connected (public cloud only), 22 - MQTT publish failed (public cloud only), 25 - MQTT sessionId not found (public cloud only)
`message` | string |  |
`fieldDeviceId` | string |  |
`srcUserId` | string |  |
`streamId` | number |  |
`trackId` | string |  |
`mediaType` | MediaType |  |
`videoWidth` | number | <optional> |
`videoHeight` | number | <optional> |

Autoplay Response Type

##### Type:

- object

#### WebRTCStats

Description:

  - Media Stream Statistics

##### Properties:

Name | Type | Attributes | Description
--- | --- | --- | ---
`srcUserId` | string |  | Media stream source user ID
`trackId` | string |  | Media stream track ID
`streamId` | number |  | Media stream ID
`mediaType` | MediaType |  | Media type
`bitrate` | number |  | Current bitrate in Mbps
`packetsReceived` | number |  | Total received RTP packets (cumulative)
`packetsLost` | number |  | Total lost RTP packets (cumulative)
`lost` | number |  | Current packet loss rate in %
`lostAvg` | number |  | Average packet loss rate in %
`rtt` | number |  | RTT (Round Trip Time) in ms
`rttAvg` | number |  | Average RTT in ms
`codec` | string |  | Media codec MIME type
`decoderImplementation` | string |  | Decoder identifier
`decoderType` | 'hardware' | 'software' | 'unknown' |  | Decoder type:, hardware: Hardware decoder, software: Software decoder, unknown: Unknown type
`nack` | number |  | Total NACK packets sent (cumulative)
`firCount` | number |  | FIR count
`pliCount` | number |  | PLI count (video only)
`framesReceived` | number |  | Total frames received (cumulative, video only)
`framesDecoded` | number |  | Total frames decoded (cumulative, video only)
`keyFramesDecoded` | number |  | Total key frames decoded (cumulative, video only)
`resolution` | string |  | Resolution in format `${width}x${height}` (video only)
`fps` | number |  | Frame rate (video only)
`decodeTime` | number |  | Current decode time in ms (video only)
`decodeTimeAvg` | number |  | Average decode time in ms (video only)
`processingDelay` | number |  | Current processing delay in ms (video only)
`processingDelayAvg` | number |  | Average processing delay in ms (video only)
`audioLevel` | number |  | Current audio level (0-1, audio only)
`jitter` | number |  | Jitter in seconds
`jitterBuffer` | number |  | Current jitter buffer delay in ms
`jitterBufferAvg` | number |  | Average jitter buffer delay in ms
`jitterBufferTarget` | number |  | Current target jitter buffer delay in ms
`jitterBufferTargetAvg` | number |  | Average target jitter buffer delay in ms
`latency` | number |  | Video latency in ms
`latency1` | number | <optional> |
`latency2` | number | <optional> |
`lag100` | number |  | Video freeze rate at 100ms
`lag150` | number |  | Video freeze rate at 150ms
`nackDelta` | number |  | Period delta: NACK count in current collection period
`firCountDelta` | number |  | Period delta: FIR count in current collection period
`pliCountDelta` | number |  | Period delta: PLI count in current collection period
`framesReceivedDelta` | number |  | Period delta: frames received in current collection period
`framesDecodedDelta` | number |  | Period delta: frames decoded in current collection period
`packetsReceivedDelta` | number |  | Period delta: packets received in current collection period
`packetsLostDelta` | number |  | Period delta: packets lost in current collection period
`stableFps` | number |  | Stable FPS: 10s sliding window average, excluding 0 values (video only)

Media Stream Statistics

##### Type:

- object

#### DiagnosisReport

Description:

  - Diagnosis Report

##### Properties:

Name | Type | Attributes | Description
--- | --- | --- | ---
`diag_error` | string |  | Diagnosis error message, returns 'ok' if no error, otherwise error message
`device_id` | string |  | Field device ID
`field_pid` | string | <optional> | Field device process ID
`license_check` | string | <optional> | Field device license check, returns 'ok' if passed, otherwise error message
`field_mqtt_connect` | string | <optional> | Field device MQTT connection status, returns 'ok' if connected, otherwise error message
`remote_mqtt_connect` | string |  | Remote device MQTT connection status, returns 'ok' if connected, otherwise error message
`result` | Array |  | Video stream diagnosis reports
`result[].stream_id` | number |  | Video stream ID
`result[].field` | object | <optional> | Field device video stream diagnosis report ###### Properties
Name | Type | Description
--- | --- | ---
`field_mode` | string | Field device service mode
`signal_connect` | string | Field device signaling connection status, returns 'ok' if connected, otherwise error message
`media_connect` | string | Field device media connection status, returns 'ok' if connected, otherwise error message
`video_transfer` | string | Field device video transfer status, returns 'ok' if normal, otherwise error message
`video_capture` | string | Field device video capture status, returns 'ok' if normal, otherwise error message
`video_encode` | string | Field device video encode status, returns 'ok' if normal, otherwise error message
`rtt` | Array.<number> | Field device RTT statistics in ms, 2-second interval
`lost` | Array.<number> | Field device packet loss rate statistics, 2-second interval
`bps` | Array.<number> | Field device bitrate statistics in kbps, 2-second interval
`fps` | Array.<number> | Field device frame rate statistics, 2-second interval
`result[].remote` | object | <optional> | Remote device video stream diagnosis report ###### Properties
Name | Type | Description
--- | --- | ---
`remote_mode` | string | Remote device service mode
`signal_connect` | string | Remote device signaling connection status, returns 'ok' if connected, otherwise error message
`media_connect` | string | Remote device media connection status, returns 'ok' if connected, otherwise error message
`video_transfer` | string | Remote device video transfer status, returns 'ok' if normal, otherwise error message
`video_decode` | string | Remote device video decode status, returns 'ok' if normal, otherwise error message
`lag_k100` | number | Remote device 100ms freeze rate
`lag_k150` | number | Remote device 150ms freeze rate
`rtt` | Array.<number> | Remote device RTT statistics in ms, 2-second interval
`lost` | Array.<number> | Remote device packet loss rate statistics, 2-second interval
`bps` | Array.<number> | Remote device bitrate statistics in kbps, 2-second interval
`fps` | Array.<number> | Remote device frame rate statistics, 2-second interval
`latency` | Array.<number> | Remote device latency statistics in ms, 2-second interval
`webrtc_stats` | Array.<WebRTCStats> | Remote device complete statistics, 2-second interval

Diagnosis Report

##### Type:

- object

#### OnEventWebRTCStatsResponse

Description:

  - WebRTC Stats Callback

##### Properties:

Name | Type | Description
--- | --- | ---
`type` | 'webrtcStats' |
`data` | Array.<WebRTCStats> |

WebRTC Stats Callback

##### Type:

- object

#### OnEventGatewayStatsResponse

Description:

  - Gateway Stats Callback

##### Properties:

Name | Type | Description
--- | --- | ---
`type` | 'gatewayStats' |
`data` | object | ###### Properties
Name | Type | Description
--- | --- | ---
`fieldDeviceId` | string |
`stats` | any |

Gateway Stats Callback

##### Type:

- object

#### OnEventLocalTrackUnpublishedResponse

Description:

  - Local Audio Track Unpublish Callback

##### Properties:

Name | Type | Description
--- | --- | ---
`type` | 'localTrackUnpublished' |
`data` | Object |

Local Audio Track Unpublish Callback

##### Type:

- object

#### OnEventResponse

Description:

  - OnEvent Response

OnEvent Response

##### Type:

- OnEventAutoplayResponse | OnEventWebRTCStatsResponse | OnEventGatewayStatsResponse | OnEventLocalTrackUnpublishedResponse