tencent_rtc_sdk. After creating a TRTCCloudListener object and registering it via TRTCCloud's registerListener, you can receive various events thrown by the SDK.Callback | Description |
Callback of whether room entry is successful. | |
Callback of exiting a room. | |
Callback of role switching. | |
Callback of the result of room switching. | |
Callback of the result of requesting a cross-room call. | |
Callback of the result of ending a cross-room call. |
Callback | Description |
A user joined the current room. | |
A user left the current room. | |
A remote user published/unpublished the primary video stream. | |
A remote user published/unpublished the substream video. | |
A remote user published/unpublished their audio. | |
The SDK started rendering the first video frame of the local or a remote user. | |
The SDK started playing the first audio frame of a remote user. | |
The first local video frame was published. | |
The first local audio frame was published. | |
Callback of remote video status change. | |
Callback of remote audio status change. | |
Callback of remote video resolution change. |
Callback | Description |
Real-time network quality statistics callback. | |
Real-time callback of audio/video technical metric statistics. | |
Callback of network speed test result. |
Callback | Description |
The SDK was disconnected from the cloud. | |
The SDK is trying to reconnect to the cloud. | |
The SDK is reconnected to the cloud. |
Callback | Description |
The camera is ready. | |
The microphone is ready. | |
The current audio route changed. | |
Volume feedback callback. | |
The system capture volume of the current microphone changed (desktop). | |
The current system playback volume changed (desktop). | |
Callback of whether system audio capturing was enabled successfully (desktop only). | |
Volume callback during microphone test. | |
Volume callback during speaker test. |
Callback | Description |
Callback of receiving a custom message. | |
Callback of losing custom messages. | |
Callback of receiving an SEI message. |
Callback | Description |
Callback of starting to publish media streams. | |
Callback of updating media streams. | |
Callback of stopping media streams. | |
Callback of RTMP/RTMPS push status change. |
Callback | Description |
Callback of screen sharing start. | |
Callback of screen sharing pause. | |
Callback of screen sharing resume. | |
Callback of screen sharing stop. | |
Callback of the target window of screen sharing being covered (Windows only). |
Callback | Description |
Callback of local recording task start. | |
Callback of local recording task progress. | |
Callback of recording segment end. | |
Callback of local recording task end. | |
Callback of local screenshot completion. |
final void Function(int errCode, String errMsg)? onError
Parameter | Type | Description |
errCode | int | Error code. |
errMsg | String | Error message. |
final void Function(int warningCode, String warningMsg)? onWarning
Parameter | Type | Description |
warningCode | int | Warning code. |
warningMsg | String | Warning message. |
final void Function(int result)? onEnterRoom
TRTCCloud to enter a room, you will receive the onEnterRoom(result) callback from the SDK:result will be a positive number (result > 0), indicating the time taken to enter the room in milliseconds (ms).result will be a negative number (result < 0), indicating the error code of the room entry failure.Parameter | Type | Description |
result | int | When result > 0, it is the time taken to enter the room, in milliseconds.When result < 0, it is the room entry error code. |
onEnterRoom(result) callback is thrown only when room entry succeeds, and room entry failure is thrown by the onError() callback.onEnterRoom(result) callback is thrown regardless of whether room entry succeeds or fails, and the onError() callback is also thrown when room entry fails.final void Function(int reason)? onExitRoom
TRTCCloud executes the room exit logic, such as releasing audio/video device resources and codec resources. After all resources occupied by the SDK are released, the SDK will notify you through the onExitRoom() callback.enterRoom() again or switch to another audio/video SDK, wait for the onExitRoom() callback before proceeding. Otherwise, you may encounter problems such as the camera or microphone being occupied.Parameter | Type | Description |
reason | int | Reason for leaving the room. 0: Exited the room by actively calling exitRoom.1: Kicked out of the current room by the server.2: The current room was dismissed. |
final void Function(int errCode, String errMsg)? onSwitchRole
TRTCCloud switches between the anchor and audience roles, which involves a channel switching process. After the SDK completes the switch, it throws the onSwitchRole() event callback.Parameter | Type | Description |
errCode | int | |
errMsg | String | Error message. |
final void Function(int errCode, String errMsg)? onSwitchRoom
TRTCCloud allows a user to switch from one room to another. After the SDK completes the switch, it throws the onSwitchRoom() event callback.Parameter | Type | Description |
errCode | int | |
errMsg | String | Error message. |
final void Function(String userId, int errCode, String errMsg)? onConnectOtherRoom
TRTCCloud connects anchors in two different rooms for a video call, which is the so-called "anchor PK" feature. The caller will receive the onConnectOtherRoom() callback to learn whether the cross-room call is successful.onUserVideoAvailable() callback of the PK anchor from the other room.Parameter | Type | Description |
userId | String | User ID of the anchor in the other room for the cross-room call. |
errCode | int | |
errMsg | String | Error message. |
final void Function(int errCode, String errMsg)? onDisconnectOtherRoom
Parameter | Type | Description |
errCode | int | |
errMsg | String | Error message. |
final void Function(String userId)? onRemoteUserEnterRoom
AppScene, specified by the second parameter of enterRoom):TRTCAppScene.live or TRTCAppScene.voiceChatRoom): Users in these scenarios are divided into anchors and audience members, and this notification is triggered only when an anchor enters the room.TRTCAppScene.videoCall or TRTCAppScene.audioCall): Users in these scenarios have no role distinction (all can be regarded as anchors), and this notification is triggered when any user enters the room.Parameter | Type | Description |
userId | String | User ID of the remote user. |
onRemoteUserEnterRoom event callback only indicates that a user has entered the room, not that the user has enabled audio or video.final void Function(String userId, int reason)? onRemoteUserLeaveRoom
onRemoteUserEnterRoom, the behavior of this callback varies in different application scenarios (i.e., TRTCAppScene, specified by the second parameter of enterRoom):TRTCAppScene.live or TRTCAppScene.voiceChatRoom): This notification is triggered only when an anchor leaves the room.TRTCAppScene.videoCall or TRTCAppScene.audioCall): Users in these scenarios have no role distinction, and this notification is triggered when any user leaves the room.Parameter | Type | Description |
userId | String | User ID of the remote user. |
reason | int | Reason for leaving. 0: The user actively exited the room.1: The user exited due to timeout.2: The user was kicked out of the room.3: The anchor exited the room due to switching to audience. |
final void Function(String userId, bool available)? onUserVideoAvailable
onUserVideoAvailable(userId, true) notification, it indicates that the user has a playable primary stream. At this point, you can call the startRemoteView API to subscribe to the user's remote video. After successful subscription, you will further receive the first-frame rendering callback onFirstVideoFrame(userId) of the user.onUserVideoAvailable(userId, false) notification, it indicates that the remote video has been disabled, possibly because the user called muteLocalVideo or stopLocalPreview.Parameter | Type | Description |
userId | String | User ID of the remote user. |
available | bool | Whether the user published (or unpublished) the primary video stream. true: Published.false: Unpublished. |
final void Function(String userId, bool available)? onUserSubStreamAvailable
onUserSubStreamAvailable(userId, true) notification, it indicates that the user has a playable substream. At this point, you can call the startRemoteView API to subscribe to the user's remote video. After successful subscription, you will further receive the first-frame rendering callback onFirstVideoFrame(userId) of the user.Parameter | Type | Description |
userId | String | User ID of the remote user. |
available | bool | Whether the user published (or unpublished) the substream video. true: Published.false: Unpublished. |
TRTCVideoStreamType.sub for streamType).final void Function(String userId, bool available)? onUserAudioAvailable
onUserAudioAvailable(userId, true) notification, it indicates that the user has published their audio:(userId, false) to play the user's audio.Parameter | Type | Description |
userId | String | User ID of the remote user. |
available | bool | Whether the user published (or unpublished) their audio. true: Published.false: Unpublished. |
final void Function(String userId, TRTCVideoStreamType streamType, int width, int height)? onFirstVideoFrame
userId parameter in the callback to determine whether the event comes from "local" or "remote":userId is empty, the SDK has started rendering the local video, provided that you have called startLocalPreview or startScreenCapture.userId is not empty, the SDK has started rendering the video of a remote user, provided that you have called startRemoteView to subscribe to the user's video.Parameter | Type | Description |
userId | String | User ID of the local or remote user. Empty indicates that the first local video frame has arrived; non-empty indicates that the first video frame of a remote user has arrived. |
streamType | Video stream type: the primary stream is generally used for camera images, and the substream is generally used for screen sharing images. | |
width | int | Width of the video. |
height | int | Height of the video. |
final void Function(String userId)? onFirstAudioFrame
Parameter | Type | Description |
userId | String | User ID of the remote user. |
final void Function(TRTCVideoStreamType streamType)? onSendFirstLocalVideoFrame
onSendFirstLocalVideoFrame event callback.Parameter | Type | Description |
streamType | Video stream type: the primary stream is generally used for camera images, and the substream is generally used for screen sharing images. |
final void Function()? onSendFirstLocalAudioFrame
onSendFirstLocalAudioFrame event callback.final void Function(String userId, TRTCVideoStreamType streamType, TRTCAVStatusType status, TRTCAVStatusChangeReason reason)? onRemoteVideoStatusUpdated
Playing, Loading and Stopped) and display the UI accordingly.Parameter | Type | Description |
userId | String | User ID. |
streamType | Video stream type: the primary stream is generally used for camera images, and the substream is generally used for screen sharing images. | |
status | ||
reason |
final void Function(String userId, TRTCAVStatusType status, TRTCAVStatusChangeReason reason)? onRemoteAudioStatusUpdated
Playing, Loading and Stopped) and display the UI accordingly.Parameter | Type | Description |
userId | String | User ID. |
status | ||
reason |
final void Function(String userId, TRTCVideoStreamType streamType, int newWidth, int newHeight)? onUserVideoSizeChanged
onUserVideoSizeChanged(userId, streamType, newWidth, newHeight) callback, it indicates that the resolution of the video stream has changed, which may be caused by the remote user calling setVideoEncoderParam or setSubStreamEncoderParam.Parameter | Type | Description |
userId | String | User ID. |
streamType | Video stream type: the primary stream is generally used for camera images, and the substream is generally used for screen sharing images. | |
newWidth | int | Width of the video stream. |
newHeight | int | Height of the video stream. |
final void Function(TRTCQualityInfo localQuality, List<TRTCQualityInfo> remoteQuality)? onNetworkQuality
1 (Excellent) means the current network is very good; 6 (Down) means the current network cannot support normal TRTC calls. For values, see TRTCQuality.Parameter | Type | Description |
localQuality | Upstream network quality. | |
remoteQuality | List<TRTCQualityInfo> | Downstream network quality, i.e., the data quality finally measured locally after the data stream passes through the complete transmission link of "remote > cloud > local". Therefore, the downstream network quality here reflects the combined effect of the remote upstream link and the local downstream link. |
final void Function(TRTCStatistics statistics)? onStatistics
resolution), frame rate (FPS), bitrate (bitrate), etc.samplerate), channels (channel), bitrate (bitrate), etc.rtt), packet loss rate (loss), upstream traffic (sentBytes), downstream traffic (receivedBytes), etc.Parameter | Type | Description |
statistics | Statistics, including local statistics and statistics of remote users. |
final void Function(TRTCSpeedTestResult result)? onSpeedTestResult
Parameter | Type | Description |
result | Network speed test data, including packet loss rate, round-trip latency, and upstream and downstream bandwidth. |
final void Function()? onConnectionLost
final void Function()? onTryToReconnect
final void Function()? onConnectionRecovery
final void Function()? onCameraDidReady
final void Function()? onMicDidReady
final void Function(TXAudioRoute newRoute, TXAudioRoute oldRoute)? onAudioRouteChanged
Parameter | Type | Description |
newRoute | ||
oldRoute |
final void Function(List<TRTCVolumeInfo> userVolumes, int totalVolume)? onUserVoiceVolume
Parameter | Type | Description |
userVolumes | List<TRTCVolumeInfo> | Volume of all users who are speaking in the room. |
totalVolume | int | Total volume of all remote users. Value range: 0 - 100. |
userVolumes is an array. For each element in the array, an empty userId indicates the volume of the local user, and a non-empty userId indicates the volume of a remote user.final void Function(int volume, bool muted)? onAudioDeviceCaptureVolumeChanged
Parameter | Type | Description |
volume | int | System capture volume, i.e., the volume users can set in the volume control panel. Value range: 0 - 100. |
muted | bool | Whether the microphone is disabled by the user. true: Disabled.false: Enabled. |
interval > 0 to enable this event callback, or set interval = 0 to disable it.final void Function(int volume, bool muted)? onAudioDevicePlayoutVolumeChanged
Parameter | Type | Description |
volume | int | System playback volume, i.e., the volume users can set in the volume control panel. Value range: 0 - 100. |
muted | bool | Whether the speaker is disabled by the user. true: Disabled.false: Enabled. |
interval > 0 to enable this event callback, or set interval = 0 to disable it.final void Function(int errCode)? onSystemAudioLoopbackError
Parameter | Type | Description |
errCode | int | ERR_NULL indicates that system audio capturing was enabled successfully; otherwise, it failed. |
final void Function(int volume)? onTestMicVolume
volume parameter indicates the volume currently captured by the microphone.volume fluctuates during the test, the microphone is healthy; if the value of volume is always 0, the microphone is abnormal and the user should be prompted to replace it.Parameter | Type | Description |
volume | int | Volume captured by the microphone. Value range: 0 - 100. |
final void Function(int volume)? onTestSpeakerVolume
volume parameter indicates the volume of the sound submitted by the SDK to the system speaker for playback. If the value keeps changing but the user reports hearing no sound, the speaker is abnormal.Parameter | Type | Description |
volume | int | Volume of the sound submitted by the SDK to the speaker for playback. Value range: 0 - 100. |
final void Function(String userId, int cmdId, int seq, String message)? onRecvCustomCmdMsg
onRecvCustomCmdMsg event callback.Parameter | Type | Description |
userId | String | User ID. |
cmdId | int | Command ID. |
seq | int | Message sequence number. |
message | String | Message data. |
final void Function(String userId, int cmdId, int errCode, int missed)? onMissCustomCmdMsg
reliable is true), 100% delivery cannot be guaranteed; the probability of message loss is just very low, which meets the reliability requirements of most scenarios.reliable is true), the SDK uses this callback to notify the receiver of the number of custom messages lost in transit over a past period (usually 5s).Parameter | Type | Description |
userId | String | User ID. |
cmdId | int | Command ID. |
errCode | int | Error code. |
missed | int | Number of lost messages. |
reliable is true).final void Function(String userId, String message)? onRecvSEIMsg
onRecvSEIMsg event callback.Parameter | Type | Description |
userId | String | User ID. |
message | String | Data. |
final void Function(String taskId, int errCode, String errMsg, String extraInfo)? onStartPublishMediaStream
Parameter | Type | Description |
taskId | String | If the request succeeds, the TRTC backend returns the taskId of this task in the callback. You can then use this taskId with updatePublishMediaStream and stopPublishMediaStream to update and stop the task. |
errCode | int | Callback result. 0 indicates success, and other values indicate failure. |
errMsg | String | Detailed callback information. |
extraInfo | String | Extra information. For some error codes, extra information may be provided to help you troubleshoot. |
final void Function(String taskId, int errCode, String errMsg, String extraInfo)? onUpdatePublishMediaStream
Parameter | Type | Description |
taskId | String | The taskId you passed in when calling updatePublishMediaStream, used to identify which request this callback belongs to. |
errCode | int | Callback result. 0 indicates success, and other values indicate failure. |
errMsg | String | Detailed callback information. |
extraInfo | String | Extra information. For some error codes, extra information may be provided to help you troubleshoot. |
final void Function(String taskId, int errCode, String errMsg, String extraInfo)? onStopPublishMediaStream
Parameter | Type | Description |
taskId | String | The taskId you passed in when calling stopPublishMediaStream, used to identify which request this callback belongs to. |
errCode | int | Callback result. 0 indicates success, and other values indicate failure. |
errMsg | String | Detailed callback information. |
extraInfo | String | Extra information. For some error codes, extra information may be provided to help you troubleshoot. |
final void Function(String cdnUrl, int status, int errCode, String errMsg, String extraInfo)? onCdnStreamStateChanged
Parameter | Type | Description |
cdnUrl | String | The URL you passed in through the target push configuration (TRTCPublishTarget) when calling startPublishMediaStream. |
status | int | Push status. For values, see "Push Status Values" below. |
errCode | int | Push result. 0 indicates success, and other values indicate failure. |
errMsg | String | Detailed push information. |
extraInfo | String | Extra information. For some error codes, extra information may be provided to help you troubleshoot. |
Value | Description |
0 | Pushing has not started or has ended. This status is returned when you call stopPublishMediaStream. |
1 | Connecting to the TRTC server and the CDN server. If the connection cannot succeed immediately, the TRTC backend service retries pushing multiple times and returns this status (every 5s). If pushing succeeds, the status changes to 2.If a server error occurs or pushing does not succeed within 60 seconds, the status changes to 4. |
2 | CDN pushing is in progress. This status is returned after pushing succeeds. |
3 | Pushing between the TRTC server and the CDN server is interrupted and is being recovered. When the CDN is abnormal or pushing is interrupted, the TRTC backend service tries to recover pushing and returns this status (every 5s). If pushing is recovered successfully, the status changes to 2.If a server error occurs or recovery does not succeed within 60 seconds, the status changes to 4. |
4 | Pushing between the TRTC server and the CDN server is interrupted, and recovery or connection has timed out, i.e., pushing has failed. You can call updatePublishMediaStream again to retry pushing. |
5 | Disconnecting from the TRTC server and the CDN server. When you call stopPublishMediaStream, the SDK first returns this status and then returns status 0. |
final void Function()? onScreenCaptureStarted
final void Function(int reason)? onScreenCapturePaused
Parameter | Type | Description |
reason | int | Reason for pausing. 0: Paused by the user.1: Paused because the shared window became invisible (Mac), or because screen sharing parameters were being set (Windows).2: Paused because the shared window was minimized (Windows only).3: Paused because the shared window was hidden (Windows only). |
final void Function(int reason)? onScreenCaptureResumed
Parameter | Type | Description |
reason | int | Reason for resuming. 0: Resumed by the user.1: Automatically resumed after the shared window became visible again (Mac), or after screen sharing parameters were set (Windows).2: Automatically resumed after the shared window was restored from being minimized (Windows only).3: Automatically resumed after the shared window was restored from being hidden (Windows only). |
final void Function(int reason)? onScreenCaptureStopped
Parameter | Type | Description |
reason | int | Reason for stopping. 0: Stopped by the user.1: The shared window was closed. |
final void Function()? onScreenCaptureCovered
final void Function(int errCode, String storagePath)? onLocalRecordBegin
Parameter | Type | Description |
errCode | int | Recording status. 0: The recording task started successfully.-1: The recording task failed to start.-2: Unsupported recording format.-6: Recording has already started and needs to be stopped first.-7: The recording file already exists and needs to be deleted first.-8: No write permission on the recording directory. Check the directory permissions. |
storagePath | String | Storage path of the recording file. |
final void Function(int duration, String storagePath)? onLocalRecording
startLocalRecording.Parameter | Type | Description |
duration | int | Accumulated recording duration, in milliseconds. |
storagePath | String | Storage path of the recording file. |
final void Function(String storagePath)? onLocalRecordFragment
Parameter | Type | Description |
storagePath | String | Storage path of the segment file. |
final void Function(int errCode, String storagePath)? onLocalRecordComplete
Parameter | Type | Description |
errCode | int | Recording status. 0: Recording succeeded.-1: Recording failed.-2: Recording ended due to a change in resolution or screen orientation.-3: The recording duration is too short, or no video or audio data was captured. Check the recording duration or whether audio/video capturing has been enabled. |
storagePath | String | Storage path of the recording file. |
final void Function(String userId, String path, int errCode, String errMsg)? onSnapshotComplete
Parameter | Type | Description |
userId | String | User ID corresponding to the screenshot. |
path | String | Path of the screenshot file. |
errCode | int | Error code. |
errMsg | String | Error message. |
lib/trtc_cloud_def.dart. For details, see TRTCCloudDef. Commonly used ones include:Type | Description |
Audio/Video playback status. | |
Reason for playback status change. | |
Network quality. | |
Network quality information. | |
Summary statistics of network and performance. | |
Volume. | |
Network speed test result. | |
Video stream type. | |
Log level. |
TRTCLogCallback({required void Function(String log, TRTCLogLevel level, String module) onLog})
final void Function(String log, TRTCLogLevel level, String module) onLog
Parameter | Type | Description |
log | String | Log content. |
level | Log level. | |
module | String | Reserved field with no specific meaning yet. Currently it is the fixed value TXLiteAVSDK. |
trtcCloud.setLogCallback(TRTCLogCallback(onLog: (String log, TRTCLogLevel level, String module) {debugPrint('[$level] $log');},));
フィードバック