Interface ITRTCCloudCallback
TRTC callback API class
Namespace: trtc
Assembly: cs.temp.dll.dll
Syntax
public interface ITRTCCloudCallback
Methods
onAudioDeviceCaptureVolumeChanged(Int32, Boolean)
6.7 Callback for volume change of the audio capturing device
Declaration
void onAudioDeviceCaptureVolumeChanged(int volume, bool muted)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | volume | Volume. Value range: 0-100 |
System.Boolean | muted | Whether the audio capturing device is muted. |
Remarks
You can use enableAudioVolumeEvaluation
to enable (interval
> 0) or disable (interval
= 0) this callback.
onAudioDevicePlayoutVolumeChanged(Int32, Boolean)
Callback for volume change of the audio playback device
Declaration
void onAudioDevicePlayoutVolumeChanged(int volume, bool muted)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | volume | Volume. Value range: 0-100 |
System.Boolean | muted | Whether the audio playback device is muted. |
Remarks
You can use enableAudioVolumeEvaluation
to enable (interval
> 0) or disable (interval
= 0) this callback.
onCameraDidReady()
6.1 The camera is ready
Declaration
void onCameraDidReady()
onConnectionLost()
5.1 The SDK is disconnected from the server
Declaration
void onConnectionLost()
onConnectionRecovery()
5.3 The SDK is reconnected to the server
Declaration
void onConnectionRecovery()
onConnectOtherRoom(String, TXLiteAVError, String)
2.4 Callback for requesting a cross-room call (anchor competition)
You can call the `connectOtherRoom()` API in `TRTCCloud` to call the anchor of another room. This is the “anchor competition” feature. The caller will receive the `onConnectOtherRoom()` callback, which can be used to determine whether the cross-room call is successful. If it is successful, all users in both rooms will receive the `onUserVideoAvailable()` callback.
Declaration
void onConnectOtherRoom(string userId, TXLiteAVError errCode, string errMsg)
Parameters
Type | Name | Description |
---|---|---|
System.String | userId |
|
TXLiteAVError | errCode | Error code. |
System.String | errMsg | Error message |
onDeviceChange(String, TRTCDeviceType, TRTCDeviceState)
6.4 Callback for the connection/disconnection of a local device
Declaration
void onDeviceChange(String deviceId, TRTCDeviceType type, TRTCDeviceState state)
Parameters
Type | Name | Description |
---|---|---|
String | deviceId | Device ID |
TRTCDeviceType | type | Device type |
TRTCDeviceState | state | Event |
onDisconnectOtherRoom(TXLiteAVError, String)
2.5 Callback for ending a cross-room call (anchor competition)
Declaration
void onDisconnectOtherRoom(TXLiteAVError errCode, string errMsg)
Parameters
Type | Name | Description |
---|---|---|
TXLiteAVError | errCode | Error code. |
System.String | errMsg | Error message |
onEnterRoom(Int32)
2.1 Callback for room entry
After calling the `enterRoom()` API in `TRTCCloud` to enter a room, you will receive the `onEnterRoom(result)` callback from the SDK.
- If room entry succeeds, `result` will be a positive integer (`result` > 0), which indicates the time (ms) it takes to enter the room.
- If room entry fails, `result` will be a negative integer (`result` < 0), which represents the error code.
For more information on room entry error codes, please see [Error Codes](https://cloud.tencent.com/document/product/647/32257).
Declaration
void onEnterRoom(int result)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | result | If |
Remarks
In TRTC earlier than v6.6, the onEnterRoom(result)
callback is returned only if room entry succeeds, and the onError()
callback is returned if room entry fails.
In TRTC v6.6 and above, `onEnterRoom(result)` is returned for both successful and failed room entry, but `result` is a positive integer if room entry succeeds and a negative integer if it fails. The `onError()` callback is also returned if room entry fails.
onError(TXLiteAVError, String, IntPtr)
1.1 Callback for error. This callback indicates that the SDK encountered an unrecoverable error. Such errors must be listened for, and UI reminders should be sent to users if necessary.
Declaration
void onError(TXLiteAVError errCode, String errMsg, IntPtr arg)
Parameters
Type | Name | Description |
---|---|---|
TXLiteAVError | errCode | Error code |
String | errMsg | Error message |
IntPtr | arg | Extended field. Certain error codes may carry extra information for troubleshooting. |
onExitRoom(Int32)
2.2 Callback for leaving room
Calling the `exitRoom()` API in `TRTCCloud` will trigger the execution of room exit-related logic, such as releasing resources of audio/video devices and codecs. When all the resources are released, the SDK will notify you via the `onExitRoom()` callback.
If you need to call `enterRoom()` again or switch to another audio/video SDK, please wait until you receive the `onExitRoom()` callback. Otherwise, you may encounter problems such as the camera or mic being occupied.
Declaration
void onExitRoom(int reason)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | reason | Reason for leaving a room. |
onFirstAudioFrame(String)
3.7 The first audio frame of a remote user is played (no callback for the playback of the first local audio frame)
Declaration
void onFirstAudioFrame(String userId)
Parameters
Type | Name | Description |
---|---|---|
String | userId | ID of the remote user |
onFirstVideoFrame(String, TRTCVideoStreamType, Int32, Int32)
3.6 The first video frame of the local user or a remote user is rendered
If `userId` is `null`, the callback indicates that the first video frame captured from the local camera is rendered. It is triggered by the calling of `startLocalPreview`.
If `userId` is not `null`, the callback indicates that the first video frame of the remote user is rendered. It is triggered by the calling of `startRemoteView`.
Declaration
void onFirstVideoFrame(String userId, TRTCVideoStreamType streamType, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
String | userId | User ID. |
TRTCVideoStreamType | streamType | Video stream type, which may be the camera stream and screen sharing stream |
System.Int32 | width | Video width |
System.Int32 | height | Video height |
Remarks
This callback is triggered only after startLocalPreview()
, startRemoteView()
, or startRemoteSubStreamView()
is called.
onMicDidReady()
6.2 The mic is ready
Declaration
void onMicDidReady()
onMissCustomCmdMsg(String, Int32, Int32, Int32)
7.2 Callback for losing custom messages
TRTC uses UDP channels. Even if you enable reliable messaging, there is a small chance that you may lose a message. Reliable messaging can meet the requirements of common message sending scenarios.
If you enable reliable messaging, the SDK will notify you through this callback of the number of messages lost during a past period of time (usually 5 seconds).
Declaration
void onMissCustomCmdMsg(String userId, int cmdID, int errCode, int missed)
Parameters
Type | Name | Description |
---|---|---|
String | userId | User ID |
System.Int32 | cmdID | Command ID |
System.Int32 | errCode | Error code |
System.Int32 | missed | Number of messages lost |
Remarks
The recipient will receive this callback only if the sender enables reliable messaging.
onNetworkQuality(TRTCQualityInfo, TRTCQualityInfo[], UInt32)
4.1 Callback of statistics on upstream and downstream network quality (triggered every 2 seconds)
Declaration
void onNetworkQuality(TRTCQualityInfo localQuality, TRTCQualityInfo[] remoteQuality, UInt32 remoteQualityCount)
Parameters
Type | Name | Description |
---|---|---|
TRTCQualityInfo | localQuality | Upstream network quality |
TRTCQualityInfo[] | remoteQuality | Downstream network quality (array) |
UInt32 | remoteQualityCount | Number of elements in the downstream network quality array |
Remarks
If userId
is null
, the callback returns statistics on the local user’s video quality.
onRecvCustomCmdMsg(String, Int32, Int32, Byte[], Int32)
7.1 Callback for receiving a custom message
Declaration
void onRecvCustomCmdMsg(String userId, int cmdID, int seq, Byte[] message, int messageSize)
Parameters
Type | Name | Description |
---|---|---|
String | userId | User ID |
System.Int32 | cmdID | Command ID |
System.Int32 | seq | Message sequence number |
Byte[] | message | Message data |
System.Int32 | messageSize | Message size |
onRecvSEIMsg(String, Byte[], UInt32)
7.3 Callback for receiving an SEI message
When a user in a room uses `sendSEIMsg` to send data, other users in the room can receive the data through the `onRecvSEIMsg` callback.
Declaration
void onRecvSEIMsg(String userId, Byte[] message, UInt32 msgSize)
Parameters
Type | Name | Description |
---|---|---|
String | userId | User ID |
Byte[] | message | Message data |
UInt32 | msgSize | Message size |
onRemoteUserEnterRoom(String)
3.1 A user entered the room
To ensure the performance of the SDK, this callback works differently under call and live streaming scenarios.
- Call (`TRTCAppSceneVideoCall` and `TRTCAppSceneAudioCall`): The concept of roles does not apply, and the callback is triggered when any user enters the room.
- Live streaming (`TRTCAppSceneLIVE` and `TRTCAppSceneVoiceChatRoom`): Given that there is no limit on audience size and frequent callbacks may affect the SDK’s performance, the callback is triggered only when an anchor enters the room.
Declaration
void onRemoteUserEnterRoom(String userId)
Parameters
Type | Name | Description |
---|---|---|
String | userId | User ID |
Remarks
Note: onRemoteUserEnterRoom
and onRemoteUserLeaveRoom
are used for maintaining the user list of a room. To play the video of a remote user, please use the onUserVideoAvailable()
callback.
onRemoteUserLeaveRoom(String, Int32)
3.2 A user left the room (which pairs with onRemoteUserEnterRoom
)
Like `onRemoteUserEnterRoom`, this callback works differently under call and live streaming scenarios.
- Call (`TRTCAppSceneVideoCall` and `TRTCAppSceneAudioCall`): The concept of roles does not apply, and the callback is triggered when any user leaves the room.
- Live streaming (`TRTCAppSceneLIVE` and `TRTCAppSceneVoiceChatRoom`): The callback is triggered only when an anchor leaves the room.
Declaration
void onRemoteUserLeaveRoom(String userId, int reason)
Parameters
Type | Name | Description |
---|---|---|
String | userId | User ID |
System.Int32 | reason | Reason for leaving a room. |
onScreenCapturePaused(Int32)
10.3 Callback for pausing screen sharing
Declaration
void onScreenCapturePaused(int reason)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | reason | Reason. |
onScreenCaptureResumed(Int32)
10.4 Callback for resuming screen sharing
Declaration
void onScreenCaptureResumed(int reason)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | reason | Reason. |
onScreenCaptureStarted()
10.2 Callback for starting screen sharing
Declaration
void onScreenCaptureStarted()
onScreenCaptureStoped(Int32)
10.5 Callback for stopping screen sharing
Declaration
void onScreenCaptureStoped(int reason)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | reason | Reason. |
onSendFirstLocalAudioFrame()
3.9. The first local audio frame is sent
After `enterRoom()` and `startLocalAudio()` are called, the SDK will start capturing video from the mic and will encode the audio captured.
This callback is triggered when the SDK successfully sends the first audio frame to the cloud.
Declaration
void onSendFirstLocalAudioFrame()
onSendFirstLocalVideoFrame(TRTCVideoStreamType)
3.8 The first local video frame is sent
After `enterRoom()` and `startLocalPreview()` are called, the SDK will start capturing video from the camera and will encode the video captured.
This callback is triggered when the SDK successfully sends the first video frame to the cloud.
Declaration
void onSendFirstLocalVideoFrame(TRTCVideoStreamType streamType)
Parameters
Type | Name | Description |
---|---|---|
TRTCVideoStreamType | streamType | Video stream type, which may be the big image, small image, or substream image |
onSetMixTranscodingConfig(Int32, String)
Callback for setting On-Cloud MixTranscoding parameters (triggered by the setMixTranscodingConfig()
API in TRTCCloud
)
Declaration
void onSetMixTranscodingConfig(int errCode, String errMsg)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | errCode |
|
String | errMsg | Error message |
onSpeedTest(TRTCSpeedTestResult, Int32, Int32)
Declaration
void onSpeedTest(TRTCSpeedTestResult currentResult, int finishedCount, int totalCount)
Parameters
Type | Name | Description |
---|---|---|
TRTCSpeedTestResult | currentResult | |
System.Int32 | finishedCount | |
System.Int32 | totalCount |
onStartPublishCDNStream(Int32, String)
8.3 Callback for starting relaying to CDN (triggered by the startPublishCDNStream()
API in TRTCCloud
)
Note: If 0
(successful) is returned, it indicates that Tencent Cloud has been notified of the relaying request, but if an error occurs in the target CDN, relaying may still fail.
Declaration
void onStartPublishCDNStream(int errCode, String errMsg)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | errCode |
|
String | errMsg | Error message |
onStartPublishing(Int32, String)
8.1. Callback for starting publishing to Tencent Cloud’s live streaming CDN (triggered by the startPublishing()
API in TRTCCloud
)
Declaration
void onStartPublishing(int errCode, String errMsg)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | errCode |
|
String | errMsg | Error message |
onStatistics(TRTCStatistics)
4.2 Callback of technical metric statistics
If you are familiar with the technical metrics of real-time communication, you can use this callback to get statistics on the SDK’s technical metrics.
If you are building a real-time communication project for the first time, you can use the `onNetworkQuality` callback only.
Declaration
void onStatistics(TRTCStatistics statis)
Parameters
Type | Name | Description |
---|---|---|
TRTCStatistics | statis | Statistics for the local user and remote users |
Remarks
The callback is triggered every 2 seconds.
onStopPublishCDNStream(Int32, String)
8.4 Callback for stopping relaying to CDN
This callback is triggered by the stopPublishCDNStream()
API in TRTCCloud
.
Declaration
void onStopPublishCDNStream(int errCode, String errMsg)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | errCode |
|
String | errMsg | Error message |
onStopPublishing(Int32, String)
8.2. Callback for stopping publishing to Tencent Cloud’s live streaming CDN (triggered by the stopPublishing()
API in TRTCCloud
)
Declaration
void onStopPublishing(int errCode, String errMsg)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | errCode |
|
String | errMsg | Error message |
onSwitchRole(TXLiteAVError, String)
2.3 Callback for switching roles
You can call the `switchRole()` API in `TRTCCloud` to switch between “anchor” and “audience”. This is accompanied by a line switching process. After the switch, the SDK will return the `onSwitchRole()` callback.
Declaration
void onSwitchRole(TXLiteAVError errCode, String errMsg)
Parameters
Type | Name | Description |
---|---|---|
TXLiteAVError | errCode | Error code. |
String | errMsg | Error message |
onSwitchRoom(TXLiteAVError, String)
2.6 Callback for switching rooms (switchRoom
)
Declaration
void onSwitchRoom(TXLiteAVError errCode, string errMsg)
Parameters
Type | Name | Description |
---|---|---|
TXLiteAVError | errCode | Error code. |
System.String | errMsg | Error message |
onTestMicVolume(Int32)
6.5 Callback of mic testing volume
This callback is triggered by the mic testing API `startMicDeviceTest`.
Declaration
void onTestMicVolume(int volume)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | volume | Volume. Value range: 0-100 |
onTestSpeakerVolume(Int32)
6.6 Callback of speaker testing volume
This callback is triggered by the speaker testing API `startSpeakerDeviceTest`.
Declaration
void onTestSpeakerVolume(int volume)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | volume | Volume. Value range: 0-100 |
onTryToReconnect()
5.2 The SDK is reconnecting to the server
Declaration
void onTryToReconnect()
onUserAudioAvailable(String, Boolean)
3.5 Whether a remote user has playable audio data
Declaration
void onUserAudioAvailable(String userId, bool available)
Parameters
Type | Name | Description |
---|---|---|
String | userId | User ID |
System.Boolean | available | Whether the user has enabled audio |
onUserSubStreamAvailable(String, Boolean)
3.4 Whether a user is sharing the screen
Declaration
void onUserSubStreamAvailable(String userId, bool available)
Parameters
Type | Name | Description |
---|---|---|
String | userId | User ID |
System.Boolean | available | Whether the user is sharing the screen |
onUserVideoAvailable(String, Boolean)
3.3 Whether a remote user has a playable primary stream (usually used for camera images)
The `onUserVideoAvailable(userId, YES)` callback indicates that the user has playable video frames.
You can call `startRemoteView(userId)` to load the user’s video.
You will then receive the `onFirstVideoFrame(userId)` callback, which indicates that the first video frame has been rendered.
The `onUserVideoAvailable(userId, NO)` callback indicates that the remote user has disabled video. This may be because the user called `muteLocalVideo()` or `stopLocalPreview()`.
Declaration
void onUserVideoAvailable(String userId, bool available)
Parameters
Type | Name | Description |
---|---|---|
String | userId | User ID |
System.Boolean | available | Whether video is enabled |
onUserVoiceVolume(TRTCVolumeInfo[], UInt32, UInt32)
6.3 Callback of volume (including the volume of each userId
and total remote volume)
You can use the `enableAudioVolumeEvaluation` API in `TRTCCloud` to enable or disable this callback.
After you call `enableAudioVolumeEvaluation` to enable the volume callback, the callback will be triggered at the specified interval regardless of whether there are users speaking in the room.
If no one is speaking, `userVolumes` will be empty, and `totalVolume` will be `0`.
Declaration
void onUserVoiceVolume(TRTCVolumeInfo[] userVolumes, UInt32 userVolumesCount, UInt32 totalVolume)
Parameters
Type | Name | Description |
---|---|---|
TRTCVolumeInfo[] | userVolumes | Volumes of all speaking users in the room. Value range: 0-100 |
UInt32 | userVolumesCount | Number of speaking users in the room |
UInt32 | totalVolume | Total remote volume. Value range: 0-100 |
Remarks
If userId
is null
, volume
indicates the local user’s volume. userVolumes
includes only the volumes of speaking users, i.e., users whose volume is not 0.
onWarning(TXLiteAVWarning, String, IntPtr)
1.2 Callback for warning. This callback alerts you to non-serious problems such as stutter or recoverable decoding failure.
Declaration
void onWarning(TXLiteAVWarning warningCode, String warningMsg, IntPtr arg)
Parameters
Type | Name | Description |
---|---|---|
TXLiteAVWarning | warningCode | Warning code |
String | warningMsg | Warning message |
IntPtr | arg | Extended field. Certain warning codes may carry extra information for troubleshooting. |