TRTCCloud
Copyright (c) 2026 Tencent. All rights reserved.
Module: TRTCCloud @ TXLiteAVSDK
Function: Tencent Cloud TRTC main APIs
Version: 13.5
Tencent Cloud TRTC main APIs. Flutter SDK:
tencent_rtc_sdk. Obtain the singleton via TRTCCloud.sharedInstance() and then call all APIs.Function List
Instance and Event Callbacks
API | Description |
Creates a TRTCCloud instance (singleton mode). | |
Destroys the TRTCCloud instance (singleton mode). | |
Adds a TRTC event listener. | |
Removes a TRTC event listener. |
Room APIs
API | Description |
Enters a room. | |
Exits a room. | |
Switches the role. | |
Switches the room. | |
Requests a cross-room call. | |
Exits a cross-room call. | |
Sets the subscription mode (must be set before entering the room to take effect). |
CDN Publishing and Stream Mixing
API | Description |
Starts publishing media streams. | |
Updates published media streams. | |
Stops publishing media streams. |
Video APIs
API | Description |
Enables the preview of the local camera. | |
Updates the preview of the local camera. | |
Stops the camera preview. | |
Pauses/Resumes publishing the local video stream. | |
Subscribes to the video stream of a remote user and binds a video rendering control. | |
Updates the video rendering control of a remote user. | |
Stops subscribing to the video stream of a remote user and releases the rendering control. | |
Stops subscribing to the video streams of all remote users and releases all rendering resources. | |
Sets the placeholder image displayed while the local video is paused (not supported on Windows/macOS yet). | |
Adds a watermark (not supported on Windows/macOS yet). | |
Pauses/Resumes subscribing to the video stream of a remote user. | |
Pauses/Resumes subscribing to the video streams of all remote users. | |
Sets the encoding parameters of the video encoder. | |
Sets the mirror mode of the encoder output. | |
Sets network quality control parameters. | |
Sets the rendering parameters of the local video. | |
Sets the rendering mode of the remote video. | |
Enables dual-channel encoding mode with big and small images. | |
Switches between the big and small images of a specified remote user. | |
Takes a video screenshot (not supported on Windows/macOS yet). | |
Sets the adaptation mode of G-sensor (mobile only). |
Audio APIs
API | Description |
Enables local audio capturing and publishing. | |
Stops local audio capturing and publishing. | |
Pauses/Resumes publishing the local audio stream. | |
Pauses/Resumes playing back the audio stream of a remote user. | |
Pauses/Resumes playing back the audio streams of all remote users. | |
Sets the playback volume of a remote user. | |
Sets the capture volume of local audio. | |
Gets the capture volume of local audio. | |
Sets the playback volume of remote audio. | |
Gets the playback volume of remote audio. | |
Enables volume reminder. | |
Starts local media recording. | |
Stops local media recording. |
Devices, Beauty Filters and Audio Effects
API | Description |
Gets the device management class (TXDeviceManager). | |
Sets special effects such as beauty, brightening and rosy skin. | |
Gets the audio effect management class (TXAudioEffectManager). | |
Enables system audio capturing (Windows only). | |
Stops system audio capturing (Windows only). | |
Sets the capture volume of system audio (Windows only). |
Screen Sharing
API | Description |
Starts screen sharing. | |
Starts screen sharing via ReplayKit (iOS only). | |
Stops screen sharing. | |
Pauses screen sharing. | |
Resumes screen sharing. | |
Enumerates shareable screens and windows (desktop only). | |
Selects the screen or window to share (desktop only). | |
Adds the specified window to the exclusion list of screen sharing (desktop only). | |
Removes the specified window from the exclusion list (desktop only). | |
Removes all windows from the exclusion list (desktop only). | |
Adds the specified window to the inclusion list of screen sharing (desktop only). | |
Removes the specified window from the inclusion list (desktop only). | |
Removes all windows from the inclusion list (desktop only). | |
Sets the video encoding parameters of screen sharing (i.e., the substream). |
Custom Capturing and Custom Messages
API | Description |
Enables custom audio capturing mode. | |
Delivers self-captured audio data to the SDK. | |
Sets the audio data callback. | |
Sends a custom message to all users in the room via the UDP channel. | |
Sends a custom message to all users in the room via the SEI channel. |
Network Testing
API | Description |
Starts network speed test (used before entering a room). | |
Stops network speed test. |
Debugging APIs
API | Description |
Gets the SDK version information. | |
Sets the log output level. | |
Enables/Disables console log printing. | |
Enables/Disables local log compression. | |
Sets the storage path of local logs. | |
Sets the log callback. | |
Displays the dashboard. | |
Calls experimental APIs. |
AI Capabilities
API | Description |
Gets the AI transcription management class (AITranscriberManager). |
API Details
The following describes the signature, function, parameters, return value and notes of each API, in the order of the function list.
sharedInstance
static Future<TRTCCloud> sharedInstance()
Creates a TRTCCloud instance (singleton mode).
Return Value
Future<TRTCCloud>, which asynchronously returns the TRTCCloud singleton object.Sample Code
TRTCCloud trtcCloud = await TRTCCloud.sharedInstance();
destroySharedInstance
static void destroySharedInstance()
Destroys the TRTCCloud instance (singleton mode).
registerListener
void registerListener(TRTCCloudListener func)
Adds a TRTC event listener.
Through
TRTCCloudListener, you can receive various event notifications from the SDK (such as error codes, warning codes, and audio/video status parameters).Parameter | Type | Description |
func | TRTCCloudListener | Event listener object. For details, see TRTCCloudListener. |
unRegisterListener
void unRegisterListener(TRTCCloudListener func)
Removes a TRTC event listener.
Parameter | Type | Description |
func | TRTCCloudListener | The event listener object to remove. |
enterRoom
void enterRoom(TRTCParams param, TRTCAppScene scene)
Enters a room.
All TRTC users need to enter a room before they can "publish" or "subscribe to" audio/video streams. "Publishing" means pushing your own audio and video to the cloud, and "subscribing" means pulling the audio/video streams of other users in the room from the cloud.
After calling this API, you will receive the
onEnterRoom callback from TRTCCloudListener:If room entry succeeded,
result will be a positive number (result > 0), indicating the time in milliseconds (ms) from the function call to room entry.If room entry failed,
result will be a negative number (result < 0), indicating the error code of the room entry failure.Parameter | Type | Description |
param | Room entry parameters, used to specify the user's identity, role, security credentials and other information. For details, see TRTCParams. | |
scene | Application scenario, used to specify your business scenario. All users in the same room need to set the same TRTCAppScene. |
Description:
1. When you set
scene to TRTCAppScene.live or TRTCAppScene.voiceChatRoom, you must set the role of the current user in the room via the role field in TRTCParams.2. Regardless of whether room entry succeeds,
enterRoom must be paired with exitRoom. Calling enterRoom again before calling exitRoom will cause unexpected errors.Sample Code
TRTCCloud trtcCloud = await TRTCCloud.sharedInstance();TRTCParams params = TRTCParams(sdkAppId: 1400000123,userId: 'denny',userSig: 'xxxxxxx',roomId: 123321,role: TRTCRoleType.anchor,);trtcCloud.enterRoom(params, TRTCAppScene.live);
exitRoom
void exitRoom()
Exits a room.
Calling this API will make the user leave the current audio/video room and release device resources such as the camera, microphone and speaker.
After the resources are released, the SDK will notify you through the
onExitRoom callback in TRTCCloudListener.If you want to call
enterRoom again or switch to an SDK of another provider, it is recommended to wait for the onExitRoom callback before proceeding, so as to avoid the camera or microphone being occupied.switchRole
void switchRole(TRTCRoleType role)
Switches the role.
This API is used to switch the user role between "anchor" and "audience".
As video live streaming and audio chat rooms need to support up to 100,000 concurrent viewers, the rule "only anchors can publish their own audio/video" is in place. Therefore, when some audience members want to publish their own audio/video streams (to interact with anchors), they need to switch their role to "anchor" first.
You can specify the user role in advance via the
role field in TRTCParams when entering a room, or switch the role dynamically via this API after entering the room.Parameter | Type | Description |
role | Role, which is TRTCRoleType.anchor by default.TRTCRoleType.anchor: Anchor, who can publish their own audio/video. Up to 50 anchors can publish audio/video at the same time in one room.TRTCRoleType.audience: Audience, who cannot publish their own audio/video streams and can only watch the audio/video of anchors in the room. To publish their own audio/video, they need to switch to "anchor" via switchRole first. One room can accommodate up to 100,000 audience members at the same time. |
Description:
1. This API applies only to the video live streaming (
TRTCAppScene.live) and audio chat room (TRTCAppScene.voiceChatRoom) scenarios.2. If the
scene you specified when calling enterRoom is TRTCAppScene.videoCall or TRTCAppScene.audioCall, do not call this API.switchRoom
void switchRoom(TRTCSwitchRoomConfig config)
Switches the room.
This API allows a user to quickly switch from one room to another.
If the user is an "audience member", calling this API is equivalent to
exitRoom (current room) + enterRoom (new room).If the user is an "anchor", this API keeps their audio/video publishing status while switching rooms. Therefore, the camera preview and audio capturing will not be interrupted during room switching.
This API is suitable for the online education scenario where a supervising teacher quickly switches between multiple rooms. In this scenario,
switchRoom delivers better smoothness with less code than exitRoom + enterRoom.The result of the API call is returned through the
onSwitchRoom callback in TRTCCloudListener.Parameter | Type | Description |
config |
Description:
For compatibility with earlier SDK versions,
config contains both roomId and strRoomId. Pay special attention to how they are specified:1. If you use
strRoomId, set roomId to 0. If both are specified, roomId takes precedence.2. All rooms must use either
strRoomId or roomId; they cannot be mixed. Otherwise, many unexpected bugs will occur.connectOtherRoom
void connectOtherRoom(String param)
Requests a cross-room call.
In TRTC, anchors in two different rooms can co-anchor across rooms through the "cross-room call" feature, and they can "co-anchor and PK" without leaving their own rooms.
For example, after anchor A in room "001" successfully calls anchor B in room "002" via
connectOtherRoom, all users in room "001" will receive the onRemoteUserEnterRoom(B) and onUserVideoAvailable(B, true) callbacks of anchor B, and all users in room "002" will receive the onRemoteUserEnterRoom(A) and onUserVideoAvailable(A, true) callbacks of anchor A.In short, the essence of a cross-room call is to share the audio/video streams of anchors in two different rooms, so that the audience in each room can see both anchors.
Considering the compatibility of future extension fields, the parameters of cross-room calls currently use a JSON string, which must contain at least the following two fields:
roomId: If anchor A in room "001" wants to co-anchor with anchor B in room "002", anchor A needs to set roomId to 002 when calling connectOtherRoom.userId: If anchor A in room "001" wants to co-anchor with anchor B in room "002", anchor A needs to set userId to the userId of anchor B when calling connectOtherRoom.The result of the cross-room call request will be notified to you through the
onConnectOtherRoom callback in TRTCCloudListener.Parameter | Type | Description |
param | String | You need to pass in a JSON string parameter: roomId (int): Numeric room ID.strRoomId (String): String room ID.userId (String): User ID of the target anchor. |
Sample Code
import 'dart:convert';Map<String, dynamic> object = {'roomId': 155,'userId': '57890',};trtcCloud.connectOtherRoom(jsonEncode(object));
disconnectOtherRoom
void disconnectOtherRoom()
Exits a cross-room call.
The exit result will be notified to you through the
onDisconnectOtherRoom callback in TRTCCloudListener.setDefaultStreamRecvMode
void setDefaultStreamRecvMode(bool autoRecvAudio, bool autoRecvVideo)
Sets the subscription mode (must be set before entering the room to take effect).
You can use this API to switch between "automatic subscription" and "manual subscription" modes:
Automatic subscription: The default mode, in which the user immediately receives the audio/video streams in the room after entering it. Audio is played automatically, and video is decoded automatically (you still need to bind a rendering control via the
startRemoteView API).Manual subscription: After entering the room, the user needs to manually call the
startRemoteView API to start subscribing to and decoding the video stream, and manually call the muteRemoteAudio(false) API to start audio playback.In most scenarios, users subscribe to the audio/video streams of all anchors in the room after entering it. Therefore, TRTC uses the automatic subscription mode by default to achieve the best "instant streaming experience".
If many audio/video streams are published simultaneously in each room in your application scenario, and each user only wants to selectively subscribe to 1-2 of them, the "manual subscription" mode is recommended to save traffic costs.
Parameter | Type | Description |
autoRecvAudio | bool | true: Automatically subscribe to audio.false: Manually call muteRemoteAudio(false) to subscribe to audio.Default value: true. |
autoRecvVideo | bool | true: Automatically subscribe to video.false: Manually call startRemoteView to subscribe to video.Default value: true. |
Description:
1. This configuration takes effect only if called before room entry (
enterRoom).2. In automatic subscription mode, if the user does not call
startRemoteView to subscribe to video streams after entering the room, the SDK will automatically stop subscribing to the video streams to save traffic.startPublishMediaStream
void startPublishMediaStream(TRTCPublishTarget target,TRTCStreamEncoderParam param, TRTCStreamMixingConfig config)
Starts publishing media streams.
This API sends an instruction to the TRTC server, requesting it to relay the current user's audio/video streams (with or without transcoding) to a live streaming CDN, or to transcode them and push them back to a TRTC room. You can specify the publishing mode via TRTCPublishMode in TRTCPublishTarget.
Parameter | Type | Description |
target | Target address for media stream publishing. For details, see TRTCPublishTarget. Relaying/transcoding to Tencent or third-party CDNs is supported, as is transcoding and pushing back to a TRTC room. | |
param | Encoding output parameters of media streams. For details, see TRTCStreamEncoderParam. Required for transcoding and pushing back to a TRTC room. When relaying, it is also recommended to configure it for better relay stability and CDN compatibility. | |
config | On-cloud stream mixing (On-Cloud MixTranscoding) configuration parameters. For details, see TRTCStreamMixingConfig. This parameter is invalid in relay mode, and required when transcoding and publishing to a CDN or pushing back to a TRTC room. |
Description:
1. The SDK returns the identifier of the task started in the backend (i.e., taskId) through the
onStartPublishMediaStream callback in TRTCCloudListener.2. The same publishing task can be started only once. You cannot start two publishing tasks with the same publishing mode and the same CDN publishing URL. Record the returned taskId, which needs to be passed to
updatePublishMediaStream to modify publishing parameters or to stopPublishMediaStream to stop the task.3. Up to 10 CDN URLs can be specified in
target at the same time. Even if one transcoding task has multiple relay addresses, the transcoding fee is charged only once.4. To avoid errors, do not let different publishing tasks use the same URL at the same time. It is recommended to add "sdkappid_roomid_userid_main" to the URL as an identifier to avoid conflicts among your multiple applications.
updatePublishMediaStream
void updatePublishMediaStream(String taskId, TRTCPublishTarget target,TRTCStreamEncoderParam param, TRTCStreamMixingConfig config)
Updates published media streams.
You can use this API to modify the parameters of the publishing task started by
startPublishMediaStream.Parameter | Type | Description |
taskId | String | The identifier of the task started in the backend, returned through the onStartPublishMediaStream callback in TRTCCloudListener. |
target | ||
param | ||
config | On-cloud stream mixing configuration parameters. For details, see TRTCStreamMixingConfig. This parameter is invalid in relay mode. |
Description:
1. You can use this API to add or remove CDN URLs for publishing (up to 10 at the same time), but do not let multiple tasks push to the same URL at the same time.
2. You can use this API to switch between relay tasks and transcoding tasks. For example, in the cross-room co-anchoring scenario, you can start relaying via
startPublishMediaStream first, and when the anchor starts co-anchoring, call this API with the taskId to switch the relay task to a transcoding task. This ensures that the live stream and CDN playback are not interrupted (you need to keep the encoding parameters consistent).3. The same task does not support switching among "audio only", "video only" and "audio and video".
stopPublishMediaStream
void stopPublishMediaStream(String taskId)
Stops publishing media streams.
You can use this API to stop the publishing task started by
startPublishMediaStream.Parameter | Type | Description |
taskId | String | The identifier of the task started in the backend, returned through the onStartPublishMediaStream callback in TRTCCloudListener. |
Description:
1. If your business backend has not saved the
taskId, after your anchor abnormally exits and re-enters the room, you can call startPublishMediaStream again to start the task. The publishing will fail, but the TRTC backend will return the taskId of the previously started task to you.2. If
taskId is an empty string, all media streams started by the user via startPublishMediaStream will be stopped. This approach is recommended if you have started only one task or want to stop all tasks.startLocalPreview
void startLocalPreview(bool frontCamera, int? viewId)
Enables the preview of the local camera.
If this function is called before
enterRoom, the SDK will only turn on the camera and wait until you call enterRoom before starting to push streams.If this function is called after
enterRoom, the SDK will turn on the camera and automatically start pushing video streams.When the first camera frame starts to be rendered, you will receive the
onCameraDidReady callback in TRTCCloudListener.Parameter | Type | Description |
frontCamera | bool | true: Front camera.false: Rear camera.Takes effect only on mobile devices. |
viewId | int? | ID of the rendering control for the video, which is automatically generated by the Flutter framework when TRTCCloudVideoView is created and returned via the onViewCreated callback. It uniquely identifies the native rendering view. |
Description:
If you want to preview the camera image and adjust beauty filter parameters before going live, you can:
Option 1: Call
startLocalPreview before calling enterRoom.Option 2: Call
startLocalPreview + muteLocalVideo(true) after calling enterRoom.Sample Code
TRTCCloudVideoView(key: const ValueKey('local'),onViewCreated: (viewId) {cloud.startLocalPreview(true, viewId);})
updateLocalView
void updateLocalView(int? viewId)
Updates the preview of the local camera.
Parameter | Type | Description |
viewId | int? | ID of the new rendering control for the video, which is automatically generated by the Flutter framework when TRTCCloudVideoView is created and returned via the onViewCreated callback. It uniquely identifies the native rendering view. |
stopLocalPreview
void stopLocalPreview()
Stops the camera preview.
muteLocalVideo
void muteLocalVideo(TRTCVideoStreamType streamType, bool mute)
Pauses/Resumes publishing the local video stream.
This API can pause (or resume) publishing the local video. After pausing, other users in the same room will no longer see your video.
When
TRTCVideoStreamType.big is specified, this API is equivalent to startLocalPreview + stopLocalPreview, but with a faster response. Because startLocalPreview/stopLocalPreview need to turn the camera on and off, which are time-consuming hardware operations, while muteLocalVideo only pauses or allows the data stream at the software level, it is more efficient and more suitable for scenarios requiring frequent toggling.After local video publishing is paused, other members in the same room will receive the
onUserVideoAvailable(userId, false) callback.After local video publishing is resumed, other members in the same room will receive the
onUserVideoAvailable(userId, true) callback.Parameter | Type | Description |
streamType | Type of the video stream to pause/resume. Only TRTCVideoStreamType.big and TRTCVideoStreamType.sub are supported. | |
mute | bool | true: Pause.false: Resume. |
startRemoteView
void startRemoteView(String userId, TRTCVideoStreamType streamType, int? viewId)
Subscribes to the video stream of a remote user and binds a video rendering control.
Calling this API allows the SDK to pull the video stream of the specified
userId and render it on the rendering control specified by viewId. You can set the display mode of the image via setRemoteRenderParams.If you already know the
userId of a user who has a video stream in the room, you can directly call startRemoteView to subscribe to the user's video.If you don't know which users in the room are publishing video, you can wait for the notification from
onUserVideoAvailable after enterRoom.Calling this API only starts pulling the video stream. The image still needs to be loaded and buffered, and you will receive the notification from
onFirstVideoFrame after buffering is completed.Parameter | Type | Description |
userId | String | ID of the specified remote user. |
streamType | Type of the video stream of userId to watch:HD big image: TRTCVideoStreamType.big.LD small image: TRTCVideoStreamType.small (takes effect only after the remote user enables dual-channel encoding via enableSmallVideoStream).Substream image (usually used for screen sharing): TRTCVideoStreamType.sub. | |
viewId | int? | ID of the rendering control for the video, which is automatically generated by the Flutter framework when TRTCCloudVideoView is created and returned via the onViewCreated callback. It uniquely identifies the native rendering view. |
Description:
1. The SDK supports watching the big image and substream image of a
userId at the same time, or the small image and substream image at the same time, but does not support watching the big image and small image at the same time.2. The small image of the specified
userId can be watched only after the user enables dual-channel encoding via enableSmallVideoStream.3. If the small image of the specified
userId does not exist, the SDK switches to the user's big image by default.Sample Code
TRTCCloudVideoView(key: ValueKey('remote_$uid'),onViewCreated: (viewId) {cloud.startRemoteView(uid, TRTCVideoStreamType.big, viewId);})
updateRemoteView
void updateRemoteView(String userId, TRTCVideoStreamType streamType, int? viewId)
Updates the video rendering control of a remote user.
This API can be used to update the rendering control of the remote video, and is often used in interactive scenarios where the display area is switched.
Parameter | Type | Description |
userId | String | ID of the specified remote user. |
streamType | Stream type of the preview window to set (only TRTCVideoStreamType.big and TRTCVideoStreamType.sub are supported). | |
viewId | int? | ID of the rendering control for the video, which is automatically generated by the Flutter framework when TRTCCloudVideoView is created and returned via the onViewCreated callback. It uniquely identifies the native rendering view. |
stopRemoteView
void stopRemoteView(String userId, TRTCVideoStreamType streamType)
Stops subscribing to the video stream of a remote user and releases the rendering control.
Calling this API makes the SDK stop receiving the user's video stream and release the decoding and rendering resources of the stream.
Parameter | Type | Description |
userId | String | ID of the specified remote user. |
streamType | Type of the video stream to stop subscribing to: HD big image: TRTCVideoStreamType.big.LD small image: TRTCVideoStreamType.small.Substream image (usually used for screen sharing): TRTCVideoStreamType.sub. |
stopAllRemoteView
void stopAllRemoteView()
Stops subscribing to the video streams of all remote users and releases all rendering resources.
Calling this API makes the SDK stop receiving all remote video streams and release all decoding and rendering resources.
Description:
If a substream image (screen sharing) is currently being displayed, it will also be stopped.
setVideoMuteImage
void setVideoMuteImage(String imagePath, int fps)
Sets the placeholder image displayed while the local video is paused (not supported on Windows/macOS yet).
When the local video stream is paused (for example, via
muteLocalVideo), the SDK displays the specified image instead of keeping the last video frame.Parameter | Type | Description |
imagePath | String | Image file path. JPG and PNG formats are supported. Example paths: Android: /storage/emulated/0/Android/data/com.tencent.rtc.flutter.example/files/image.jpgiOS: /Library/Caches/image.jpg |
fps | int | Frame rate (fps) at which the placeholder image is displayed. |
setWatermark
void setWatermark(String imagePath, TRTCVideoStreamType streamType,double x, double y, double width)
Adds a watermark (not supported on Windows/macOS yet).
This API adds a watermark to the local video stream. By default, the watermark is displayed in the upper-left corner of the video. You can adjust its position and size via parameters.
Parameter | Type | Description |
imagePath | String | Watermark image file path. JPG and PNG formats are supported. Example paths: Android: /storage/emulated/0/Android/data/com.tencent.rtc.flutter.example/files/watermark.pngiOS: /Library/Caches/watermark.png |
streamType | Type of the video stream to add the watermark to ( TRTCVideoStreamType.big or TRTCVideoStreamType.sub). | |
x | double | X coordinate of the upper-left corner of the watermark, normalized. Value range: 0.0 - 1.0. |
y | double | Y coordinate of the upper-left corner of the watermark, normalized. Value range: 0.0 - 1.0. |
width | double | Width of the watermark, normalized. Value range: 0.0 - 1.0. |
muteRemoteVideoStream
void muteRemoteVideoStream(String userId, TRTCVideoStreamType streamType, bool mute)
Pauses/Resumes subscribing to the video stream of a remote user.
This API only pauses/resumes receiving the video stream of the specified user without releasing the display resources. The video freezes at the last frame before the API call.
Parameter | Type | Description |
userId | String | ID of the specified remote user. |
streamType | Type of the video stream to pause/resume: HD big image: TRTCVideoStreamType.big.LD small image: TRTCVideoStreamType.small.Substream image (usually used for screen sharing): TRTCVideoStreamType.sub. | |
mute | bool | Whether to pause receiving. |
Description:
1. This API can be called before room entry (
enterRoom), and the pause status will be reset after room exit (exitRoom).2. After calling this API to pause receiving the video stream of the specified user, calling
startRemoteView alone cannot play the user's video. You need to call muteRemoteVideoStream(false) or muteAllRemoteVideoStreams(false) to resume.muteAllRemoteVideoStreams
void muteAllRemoteVideoStreams(bool mute)
Pauses/Resumes subscribing to the video streams of all remote users.
This API only pauses/resumes receiving the video streams of all users without releasing the display resources. The video freezes at the last frame before the API call.
Parameter | Type | Description |
mute | bool | Whether to pause receiving. |
Description:
1. This API can be called before room entry (
enterRoom), and the pause status will be reset after room exit (exitRoom).2. After calling this API to pause receiving the video streams of all users, calling
startRemoteView alone cannot play the video of a specified user. You need to call muteRemoteVideoStream(false) or muteAllRemoteVideoStreams(false) to resume.setVideoEncoderParam
void setVideoEncoderParam(TRTCVideoEncParam params)
Sets the encoding parameters of the video encoder.
This setting determines the image quality seen by remote users, as well as the image quality of video files recorded in the cloud.
Parameter | Type | Description |
params |
setVideoEncoderMirror
void setVideoEncoderMirror(bool enable)
Sets the mirror mode of the encoder output.
Parameter | Type | Description |
enable | bool | Whether to enable mirror mode. Default value: false. |
setNetworkQosParam
void setNetworkQosParam(TRTCNetworkQosParam params)
Sets network quality control parameters.
This setting determines the quality control policy under poor network conditions, such as "image quality first" or "smoothness first".
Parameter | Type | Description |
params |
setLocalRenderParams
void setLocalRenderParams(TRTCRenderParams params)
Sets the rendering parameters of the local video.
Configurable parameters include the rotation angle, fill mode and mirroring of the image.
Parameter | Type | Description |
params |
setRemoteRenderParams
void setRemoteRenderParams(String userId, TRTCVideoStreamType streamType,TRTCRenderParams params)
Sets the rendering mode of the remote video.
Configurable parameters include the rotation angle, fill mode and mirroring of the image.
Parameter | Type | Description |
userId | String | ID of the specified remote user. |
streamType | Can be set to TRTCVideoStreamType.big (primary stream) or TRTCVideoStreamType.sub (substream). | |
params |
enableSmallVideoStream
int enableSmallVideoStream(bool enable, TRTCVideoEncParam smallVideoEncParam)
Enables dual-channel encoding mode with big and small images.
After dual-channel encoding is enabled, the current user's encoder outputs two video streams, [HD big image] and [LD small image], at the same time (but only one audio stream).
In this way, other users in the room can subscribe to the [HD big image] or [LD small image] based on their own network conditions or screen size.
Parameter | Type | Description |
enable | bool | Whether to enable small image encoding. Default value: false. |
smallVideoEncParam |
Description:
Dual-channel encoding consumes more CPU and network bandwidth. Therefore, it can be enabled on macOS, Windows or high-performance tablets, but is not recommended on mobile phones.
Return Value
0: Success.
-1: The big image has been set to a low quality, so enabling dual-channel encoding is unnecessary.
setRemoteVideoStreamType
void setRemoteVideoStreamType(String userId, TRTCVideoStreamType streamType)
Switches between the big and small images of a specified remote user.
After an anchor in the room enables dual-channel encoding, the video subscribed to by other users in the room via
startRemoteView is the [HD big image] by default.You can use this API to choose whether to subscribe to the big image or small image. This API takes effect whether called before or after
startRemoteView.Parameter | Type | Description |
userId | String | ID of the specified remote user. |
streamType | Video stream type, i.e., whether to watch the big image or small image. Default value: TRTCVideoStreamType.big. |
Description:
This feature requires the target user to have enabled dual-channel encoding mode via
enableSmallVideoStream in advance; otherwise, this call has no effect.snapshotVideo
void snapshotVideo(String userId, TRTCVideoStreamType streamType,TRTCSnapshotSourceType sourceType, {String? path})
Takes a video screenshot (not supported on Windows/macOS yet).
You can use this API to take screenshots of the local video, the primary stream of a remote user and the substream (screen sharing) of a remote user.
The screenshot result will be notified to you through the
onSnapshotComplete(userId, path, errCode, errMsg) callback in TRTCCloudListener.Parameter | Type | Description |
userId | String | User ID. If empty, the local video is captured. |
streamType | Video stream type. You can choose to capture the primary stream ( TRTCVideoStreamType.big, usually for the camera) or the substream (TRTCVideoStreamType.sub, usually for screen sharing). | |
sourceType | Image source. You can choose to capture the video stream image ( TRTCSnapshotSourceType.stream, usually with higher definition), the rendered video image (TRTCSnapshotSourceType.view) or the captured image (TRTCSnapshotSourceType.capture, with clearer screenshots). | |
path | String? | Storage path of the screenshot file. Optional named parameter. |
setGravitySensorAdaptiveMode
void setGravitySensorAdaptiveMode(TRTCGSensorMode mode)
Sets the adaptation mode of G-sensor (mobile only).
After G-sensor is enabled, if the capturing device rotates, the images on both the capturing side and the audience side will be rendered accordingly to ensure that the image in the field of view is always upright.
This API takes effect only in the scenario where the SDK captures from the built-in camera.
Parameter | Type | Description |
mode | G-sensor mode. Default value: TRTCGSensorMode.uiAutoLayout. |
Description:
1. This API works only on the capturing side. If you only watch the video in the room, enabling this API has no effect.
2. When the capturing device rotates by 90 or 270 degrees, the image seen on the capturing side or by the audience may be cropped to maintain a proper aspect ratio.
startLocalAudio
void startLocalAudio(TRTCAudioQuality quality)
Enables local audio capturing and publishing.
The SDK does not turn on the microphone by default. When the user needs to publish local audio, this API needs to be called to enable microphone capturing, and encode and publish the audio to the current room.
After local audio capturing and publishing are enabled, other users in the room will receive the
onUserAudioAvailable(userId, true) notification.Parameter | Type | Description |
quality | Audio quality: TRTCAudioQuality.speech: Smooth. Sample rate: 16 kHz; mono; audio bitrate: 16 Kbps. Suitable for voice call scenarios such as online meetings and voice calls.TRTCAudioQuality.defaultMode: Default. Sample rate: 48 kHz; mono; audio bitrate: 50 Kbps. The default audio quality of the SDK, recommended if there are no special requirements.TRTCAudioQuality.music: High quality. Sample rate: 48 kHz; stereo + full band; audio bitrate: 128 Kbps. Suitable for scenarios requiring high-fidelity music transmission, such as online karaoke and music live streaming. |
Description:
This function checks the microphone permission. If the current app does not have the microphone permission, the SDK will automatically request it from the user.
stopLocalAudio
void stopLocalAudio()
Stops local audio capturing and publishing.
After local audio capturing and publishing are stopped, other users in the room will receive the
onUserAudioAvailable(userId, false) notification.muteLocalAudio
void muteLocalAudio(bool mute)
Pauses/Resumes publishing the local audio stream.
After you pause publishing the local audio stream, other users in the room will receive the
onUserAudioAvailable(userId, false) notification.After you resume publishing the local audio stream, other users in the room will receive the
onUserAudioAvailable(userId, true) notification.Different from
stopLocalAudio, muteLocalAudio(true) does not release the microphone permission; instead, it continues to send mute packets at an extremely low bitrate.This is very suitable for scenarios requiring cloud recording, because video files in formats such as MP4 have high requirements for audio data continuity, and using
stopLocalAudio may result in recorded MP4 files that are difficult to play. Therefore, muteLocalAudio is recommended in scenarios with high requirements for recording file quality.Parameter | Type | Description |
mute | bool | true: Mute.false: Resume. |
muteRemoteAudio
void muteRemoteAudio(String userId, bool mute)
Pauses/Resumes playing back the audio stream of a remote user.
When you mute the remote audio of a user, the SDK stops playing the user's audio and also stops pulling the user's audio data.
Parameter | Type | Description |
userId | String | ID of the specified remote user. |
mute | bool | true: Mute.false: Unmute. |
Description:
This API takes effect whether called before or after room entry (
enterRoom), and the mute status will be reset to false after room exit (exitRoom).muteAllRemoteAudio
void muteAllRemoteAudio(bool mute)
Pauses/Resumes playing back the audio streams of all remote users.
When you mute the remote audio of all users, the SDK stops playing all remote audio streams and also stops pulling the audio data of all users.
Parameter | Type | Description |
mute | bool | true: Mute.false: Unmute. |
Description:
This API takes effect whether called before or after room entry (
enterRoom), and the mute status will be reset to false after room exit (exitRoom).setRemoteAudioVolume
void setRemoteAudioVolume(String userId, int volume)
Sets the playback volume of a remote user.
You can mute a remote user via
setRemoteAudioVolume(userId, 0).Parameter | Type | Description |
userId | String | ID of the specified remote user. |
volume | int | Volume. 100 is the original volume. Value range: [0, 150]. Default value: 100. |
Description:
If the volume is still too low after setting
volume to 100, you can set volume to up to 150, but this may have side effects.setAudioCaptureVolume
void setAudioCaptureVolume(int volume)
Sets the capture volume of local audio.
Parameter | Type | Description |
volume | int | Volume. 100 is the original volume. Value range: [0, 150]. Default value: 100. |
Description:
If the volume is still too low after setting
volume to 100, you can set volume to up to 150, but this may have side effects.getAudioCaptureVolume
int getAudioCaptureVolume()
Gets the capture volume of local audio.
Return Value
Capture volume.
setAudioPlayoutVolume
void setAudioPlayoutVolume(int volume)
Sets the playback volume of remote audio.
This API controls the volume of the sound finally delivered by the SDK to the system for playback. It affects the volume of local audio recording files, but not the in-ear monitoring volume.
Parameter | Type | Description |
volume | int | Volume. 100 is the original volume. Value range: [0, 150]. Default value: 100. |
Description:
If the volume is still too low after setting
volume to 100, you can set volume to up to 150, but this may have side effects.getAudioPlayoutVolume
int getAudioPlayoutVolume()
Gets the playback volume of remote audio.
Return Value
Playback volume.
enableAudioVolumeEvaluation
void enableAudioVolumeEvaluation(bool enable, TRTCAudioVolumeEvaluateParams params)
Enables volume reminder.
After this feature is enabled, the SDK will report the volume evaluation information of the local pushing user and remote users in the
onUserVoiceVolume callback in TRTCCloudListener.Parameter | Type | Description |
enable | bool | Whether to enable volume reminder. Disabled by default. |
params |
Description:
To enable volume reminder, call this API before calling
startLocalAudio.startLocalRecording
int startLocalRecording(TRTCLocalRecordingParams param)
Starts local media recording.
After it is enabled, the audio/video content during the live stream is recorded to a local file.
Parameter | Type | Description |
param |
Return Value
Result of the API call, returned by the Native SDK.
stopLocalRecording
void stopLocalRecording()
Stops local media recording.
If a recording task has not been stopped via this API before room exit, it will be automatically stopped after room exit.
getDeviceManager
TXDeviceManager getDeviceManager()
Gets the device management class (TXDeviceManager).
Through device management, you can configure audio/video hardware devices such as cameras, microphones and speakers.
Return Value
Device management class
TXDeviceManager.setBeautyStyle
void setBeautyStyle(TRTCBeautyStyle style, int beautyLevel,int whitenessLevel, int ruddinessLevel)
Sets special effects such as beauty, brightening and rosy skin.
The SDK has two built-in skin smoothing algorithms of different styles:
"Smooth" style: A more aggressive algorithm with more obvious effects, suitable for showroom live streaming.
"Nature" style: Retains more facial details with more natural effects, suitable for most live streaming scenarios.
Parameter | Type | Description |
style | Skin smoothing algorithm style. For values, see TRTCBeautyStyle: TRTCBeautyStyle.smooth or TRTCBeautyStyle.nature. | |
beautyLevel | int | Beauty level. Value range: 0 - 9. 0 indicates disabled; the larger the value, the more obvious the effect. |
whitenessLevel | int | Brightening level. Value range: 0 - 9. 0 indicates disabled; the larger the value, the more obvious the effect. |
ruddinessLevel | int | Rosy skin level. Value range: 0 - 9. 0 indicates disabled; the larger the value, the more obvious the effect. |
getAudioEffectManager
TXAudioEffectManager getAudioEffectManager()
Gets the audio effect management class (TXAudioEffectManager).
TXAudioEffectManager is the audio effect management API, which allows you to implement the following features:Background music: Supports online and local music, special effects such as speed and pitch changes, and playing original vocals and accompaniment as well as loop playback.
In-ear monitoring: The sound captured by the microphone is played through earphones in real time, commonly used in music live streaming.
Reverb effects: KTV, small room, great hall, deep, resonant, etc.
Voice changing effects: Little girl, middle-aged man, heavy metal, etc.
Short sound effects: Short sound effect files such as applause and laughter (for files shorter than 10 seconds, set
isShortFile to true).Return Value
Audio effect management class
TXAudioEffectManager.startSystemAudioLoopback
void startSystemAudioLoopback({String? deviceName})
Enables system audio capturing (Windows only).
This API captures audio data from the computer's sound card and mixes it into the current audio data stream of the SDK, so that other users in the room can also hear the sound played on the anchor's computer.
In online education scenarios, teachers can use this feature to have the SDK capture the sound of teaching videos and broadcast it to students in the same room.
In music live streaming scenarios, anchors can use this feature to have the SDK capture the music in a music player to add background music to their live room.
Parameter | Type | Description |
deviceName | String? | Optional named parameter. If empty, the audio of the entire system is captured. |
Description:
On Windows, you can set
deviceName to the absolute path of an application's executable file (such as QQMusic.exe), in which case the SDK captures only the audio of that application (supported by the 32-bit SDK; the 64-bit SDK requires Windows 10.0.19042 or later).You can also set this parameter to the name of a speaker device to capture the audio of a specific speaker (speaker devices of type
TXMediaDeviceType.speaker can be obtained via the getDevicesList API in TXDeviceManager).On Windows, you can also set this parameter to the process ID of a process (in the format of "process_xxx", where xxx is the process ID), in which case the SDK captures only the audio of that process (requires Windows 10.0.19042 or later).
On Windows, you can also set this parameter to the process ID of a process to exclude (in the format of "exclude_process_xxx", where xxx is the process ID), in which case the SDK captures all audio except that of the process (requires Windows 10.0.19042 or later).
stopSystemAudioLoopback
void stopSystemAudioLoopback()
Stops system audio capturing (Windows only).
setSystemAudioLoopbackVolume
void setSystemAudioLoopbackVolume(int volume)
Sets the capture volume of system audio (Windows only).
Parameter | Type | Description |
volume | int | Volume to set. Value range: [0, 150]. Default value: 100. |
startScreenCapture
void startScreenCapture(int? viewId, TRTCVideoStreamType streamType,TRTCVideoEncParam encParam)
Starts screen sharing.
This API can capture the content of the entire screen or the window of a specified application and share it with other users in the same room.
On iOS, this API only supports in-app sharing. To share the entire system screen, use
startScreenCaptureByReplaykit.Parameter | Type | Description |
viewId | int? | ID of the parent control of the rendering control. It can be set to 0, which means the preview of screen sharing is not displayed (currently only Android supports local preview). |
streamType | Channel used for screen sharing, which can be the primary stream ( TRTCVideoStreamType.big) or the substream (TRTCVideoStreamType.sub). | |
encParam | Encoding parameters of screen sharing. It can be left empty, which means letting the SDK choose the optimal encoding parameters (such as resolution and bitrate). |
Description:
1. A user can publish at most one primary stream (
TRTCVideoStreamType.big) and one substream (TRTCVideoStreamType.sub) at the same time.2. By default, screen sharing uses the substream. If you use the primary stream for screen sharing, you need to stop camera capturing via
stopLocalPreview in advance to avoid conflicts.3. Only one user in a room can use the substream for screen sharing at a time, that is, only one user in a room is allowed to enable the substream at the same time.
4. If another user in the room is already using the substream for screen sharing, calling this API will trigger the
onError (ERR_SERVER_CENTER_ANOTHER_USER_PUSH_SUB_VIDEO) callback from TRTCCloudListener.startScreenCaptureByReplaykit
void startScreenCaptureByReplaykit(TRTCVideoStreamType streamType,TRTCVideoEncParam encParam, String? appGroup)
Starts screen sharing via ReplayKit (iOS only).
This API allows you to share the screen of the entire iOS system.
Parameter | Type | Description |
streamType | Channel used for screen sharing, which can be the primary stream ( TRTCVideoStreamType.big) or the substream (TRTCVideoStreamType.sub). | |
encParam | Encoding parameters of screen sharing. It can be left empty, which means letting the SDK choose the optimal encoding parameters (such as resolution and bitrate). | |
appGroup | String? | The Application Group Identifier shared by your app and the screen recording process. It can be set to null, but it is recommended to set it according to the documentation for better reliability. |
stopScreenCapture
void stopScreenCapture()
Stops screen sharing.
pauseScreenCapture
void pauseScreenCapture()
Pauses screen sharing.
resumeScreenCapture
void resumeScreenCapture()
Resumes screen sharing.
getScreenCaptureSources
TRTCScreenCaptureSourceList? getScreenCaptureSources(TRTCSize thumbnail, TRTCSize icon)
Enumerates shareable screens and windows (desktop only).
When integrating the screen sharing feature on desktop systems, you usually need to display a UI for selecting the sharing target, so that users can choose whether to share the entire screen or a specific window.
Through this API, you can query the IDs, names and thumbnails of windows available for sharing in the current system. A default UI implementation is provided in the demo for your reference.
Return Value
Window list (including screens). This API is not supported on Android/iOS and returns
null.selectScreenCaptureTarget
void selectScreenCaptureTarget(TRTCScreenCaptureSourceInfo source,TRTCRect rect, TRTCScreenCaptureProperty property)
Selects the screen or window to share (desktop only).
After obtaining the shareable screens and windows via
getScreenCaptureSources, you can call this API to select the target screen or window to share. During screen sharing, you can also call this API at any time to switch the sharing target.The following four cases are supported:
Share the entire screen: Use a source whose type is Screen in
source, and set rect to {0, 0, 0, 0}.Share a specified area: Use a source whose type is Screen in
source, and set rect to a non-empty value, such as {100, 100, 300, 300}.Share the entire window: Use a source whose type is Window in
source, and set rect to {0, 0, 0, 0}.Share a window area: Use a source whose type is Window in
source, and set rect to a non-empty value, such as {100, 100, 300, 300}.Parameter | Type | Description |
source | ||
rect | Specifies the area to capture. | |
property | Specifies the properties of the screen sharing target, such as capturing the mouse and highlighting the captured window. For details, see TRTCScreenCaptureProperty. |
Description:
The highlight border color and width parameters do not take effect on macOS.
addExcludedShareWindow
void addExcludedShareWindow(int windowID)
Adds the specified window to the exclusion list of screen sharing (desktop only).
Windows in the exclusion list will not be shared. A common usage is to add the window of an application to the exclusion list to avoid privacy issues.
You can set windows to filter out before starting screen sharing, or dynamically add windows to filter out during screen sharing.
Parameter | Type | Description |
windowID | int | The window not to be shared (window ID on macOS, HWND on Windows). |
Description:
1. This API takes effect only when
type in TRTCScreenCaptureSourceInfo is set to the screen type, that is, the feature of excluding specified windows takes effect only when sharing the entire screen.2. Windows added to the exclusion list via this API will be automatically cleared by the SDK after room exit.
3. On macOS, pass in the window ID (i.e., CGWindowID), which can be obtained from the
sourceId member in TRTCScreenCaptureSourceInfo.removeExcludedShareWindow
void removeExcludedShareWindow(int windowID)
Removes the specified window from the exclusion list of screen sharing (desktop only).
Parameter | Type | Description |
windowID | int | ID of the window to remove. |
removeAllExcludedShareWindow
void removeAllExcludedShareWindow()
Removes all windows from the exclusion list of screen sharing (desktop only).
addIncludedShareWindow
void addIncludedShareWindow(int windowID)
Adds the specified window to the inclusion list of screen sharing (desktop only).
This API takes effect only when
type in TRTCScreenCaptureSourceInfo is set to the window type, that is, the feature of additionally including specified windows takes effect only when sharing window content. You can call it before or after startScreenCapture.Parameter | Type | Description |
windowID | int | The window to be shared (window handle HWND on Windows). |
Description:
Windows added to the inclusion list via this method will be automatically cleared by the SDK after room exit.
removeIncludedShareWindow
void removeIncludedShareWindow(int windowID)
Removes the specified window from the inclusion list of screen sharing (desktop only).
This API takes effect only when
type in TRTCScreenCaptureSourceInfo is set to the window type, that is, the feature of additionally including specified windows takes effect only when sharing window content.Parameter | Type | Description |
windowID | int | The window to remove (window ID on macOS, HWND on Windows). |
removeAllIncludedShareWindow
void removeAllIncludedShareWindow()
Removes all windows from the inclusion list of screen sharing (desktop only).
This API takes effect only when
type in TRTCScreenCaptureSourceInfo is set to the window type, that is, the feature of additionally including specified windows takes effect only when sharing window content.setSubStreamEncoderParam
void setSubStreamEncoderParam(TRTCVideoEncParam param)
Sets the video encoding parameters of screen sharing (i.e., the substream) (supported on both desktop and mobile systems).
This API sets the image quality of screen sharing (i.e., the substream) seen by remote users, and also determines the image quality of screen sharing in video files recorded in the cloud.
Note the differences between the following two APIs:
setVideoEncoderParam: Sets the video encoding parameters of the primary stream (TRTCVideoStreamType.big, usually for the camera).setSubStreamEncoderParam: Sets the video encoding parameters of the substream (TRTCVideoStreamType.sub, usually for screen sharing).Parameter | Type | Description |
param |
enableCustomAudioCapture
void enableCustomAudioCapture(bool enable)
Enables custom audio capturing mode.
After this mode is enabled, the SDK no longer runs the original audio capturing process, that is, it no longer captures audio data from the microphone and only retains the audio encoding and sending capabilities. You need to continuously feed your own captured audio data to the SDK via
sendCustomAudioData.Parameter | Type | Description |
enable | bool | Whether to enable. Default value: false. |
Description:
Because acoustic echo cancellation (AEC) requires strict control of the timing of sound capturing and playback, AEC may fail after custom audio capturing is enabled.
sendCustomAudioData
void sendCustomAudioData(TRTCAudioFrame frame)
Delivers self-captured audio data to the SDK.
It is recommended to fill in the TRTCAudioFrame parameters as follows (other fields can be left empty):
audioFormat: Audio data format. Only
TRTCAudioFrameFormat.pcm is supported.data: Audio frame buffer. Audio frame data must be in PCM format, with a frame length of 5 - 100 ms (20 ms recommended). Length calculation: for example, with a sample rate of 48000 and mono, the frame length is
48000 × 0.02s × 1 × 16bit = 15360bit = 1920 bytes.sampleRate: Sample rate. Valid values: 16000, 24000, 32000, 44100, 48000.
channel: Number of channels (if stereo, the data is interleaved). Valid values: 1 (mono), 2 (stereo).
timestamp: Timestamp in milliseconds (ms).
Parameter | Type | Description |
frame |
Description:
Call this API precisely at intervals equal to the duration of each frame. Uneven data delivery intervals can easily cause audio stuttering.
setAudioFrameCallback
int setAudioFrameCallback(TRTCAudioFrameCallback? callback)
Sets the audio data callback.
After this callback is set, the SDK will call back the internal audio data (in PCM format). Setting the callback to
null stops the callback, and setting it to a non-null value starts the callback.Parameter | Type | Description |
callback | TRTCAudioFrameCallback? | Audio frame callback object. Pass null to stop the callback. |
Return Value
0: Set successfully.sendCustomCmdMsg
bool sendCustomCmdMsg(int cmdID, String data, bool reliable, bool ordered)
Sends a custom message to all users in the room via the UDP channel.
This API allows you to broadcast custom data to other users in the current room via TRTC's UDP channel for signaling transmission. Other users in the room can receive the message through the
onRecvCustomCmdMsg callback in TRTCCloudListener.Parameter | Type | Description |
cmdID | int | Message ID. Value range: [1, 10]. |
data | String | Message to send. The maximum length of a single message is 1 KB. |
reliable | bool | Whether to send reliably. Reliable sending achieves a higher success rate but causes a longer receiving delay than unreliable sending. |
ordered | bool | Whether ordering is required, that is, whether the order of data packets on the receiving end must be the same as that on the sending end (this causes a certain receiving delay). |
Description:
1. Messages are sent to all users in the room (Web/Mini Program is not supported yet). Up to 30 messages can be sent per second.
2. Each packet can be up to 1 KB. If exceeded, it is very likely to be discarded by intermediate routers or servers.
3. Each client can send up to 8 KB of data in total per second.
4. Set
reliable and ordered to both true or both false. Cross settings are not supported currently.5. It is strongly recommended to set different
cmdIDs for different types of messages, which reduces message latency when ordering is required.6. Currently, only the anchor role is supported.
Return Value
true: The message has been sent.false: Failed to send the message.sendSEIMsg
bool sendSEIMsg(String data, int repeatCount)
Sends a custom message to all users in the room via the SEI channel.
The header of a video frame has a header data block called SEI. This API works by embedding the custom signaling you want to send into this SEI header data block, so that it is sent together with the video frame.
Therefore, compared with
sendCustomCmdMsg, signaling transmitted via the SEI channel has better compatibility: the signaling can be transmitted along with video frames all the way to the live streaming CDN. However, because the data block in the video frame header cannot be too large, it is recommended to keep the signaling within a few bytes when using this API.The most common usage is to embed custom timestamps into video frames via this API to achieve perfect alignment of messages and images (for example, alignment of courseware and video signals in education scenarios). Other users in the room can receive the message through the
onRecvSEIMsg callback in TRTCCloudListener.Parameter | Type | Description |
data | String | Data to send, up to 1 KB (1000 bytes). |
repeatCount | int | Number of times to send the data. |
Description:
1. Data is not sent immediately after the API is called, but is sent together with video frames starting from the next video frame.
2. Messages are sent to all users in the room. Up to 30 messages can be sent per second (limit shared with
sendCustomCmdMsg).3. Each packet can be up to 1 KB. Sending a large amount of data will increase the video bitrate, which may degrade video quality or even cause stuttering (limit shared with
sendCustomCmdMsg).4. Each client can send up to 8 KB of data in total per second (limit shared with
sendCustomCmdMsg).5. If the data needs to be sent multiple times (i.e.,
repeatCount > 1), it will be inserted into the subsequent repeatCount video frames consecutively, which increases the video bitrate.6. If
repeatCount is greater than 1, the data will be sent multiple times, and duplicate messages may be received in the onRecvSEIMsg callback. Therefore, deduplication is required.Return Value
true: The message is allowed and will be sent with subsequent video frames.false: The message is not allowed to be sent.startSpeedTest
int startSpeedTest(TRTCSpeedTestParams params)
Starts network speed test (used before entering a room).
Parameter | Type | Description |
params | Speed test options. |
Description:
1. The speed test incurs a small amount of basic service fees.
2. Perform the network speed test before entering a room, because testing after entering the room affects normal audio/video transmission, and the result will be inaccurate due to interference in the room.
3. Only one speed test task is allowed to run at a time.
Return Value
Result of the API call.
< 0: Failure.stopSpeedTest
void stopSpeedTest()
Stops network speed test.
getSDKVersion
String getSDKVersion()
Gets the SDK version information.
Return Value
SDK version string.
setLogLevel
void setLogLevel(TRTCLogLevel level)
Sets the log output level.
Parameter | Type | Description |
level | Log level. Default value: TRTCLogLevel.none. |
setConsoleEnabled
void setConsoleEnabled(bool enabled)
Enables/Disables console log printing.
Parameter | Type | Description |
enabled | bool | Specifies whether to enable console log printing. Disabled by default. |
setLogCompressEnabled
void setLogCompressEnabled(bool enabled)
Enables/Disables local log compression.
If compression is enabled, the log size will be significantly reduced, but the logs can be read only after being decompressed with the Python script provided by Tencent Cloud.
If compression is disabled, logs will be stored in plaintext and can be read directly with Notepad, but will take up more storage space.
Parameter | Type | Description |
enabled | bool | Specifies whether to enable log compression. Enabled by default. |
setLogDirPath
void setLogDirPath(String path)
Sets the storage path of local logs.
You can use this API to change the default storage path of the SDK's local logs. The default paths are as follows:
Windows:
C:/Users/[username]/AppData/Roaming/liteav/log, i.e., %appdata%/liteav/log.iOS or macOS: Under the
Documents/log directory of the sandbox.Android: Under the
/app directory/files/log/liteav/ directory.Parameter | Type | Description |
path | String | Log storage path. |
Description:
Be sure to call this API before all other APIs, and make sure that the directory you specify exists and your application has read/write permissions on it.
setLogCallback
void setLogCallback(TRTCLogCallback? callback)
Sets the log callback.
Parameter | Type | Description |
callback | TRTCLogCallback? | Log callback object. Pass null to cancel the callback. |
showDebugView
void showDebugView(int showType)
Displays the dashboard.
The "dashboard" is a semi-transparent floating layer of debugging information on top of the video rendering control. It displays audio/video information and event information to facilitate integration and debugging.
Parameter | Type | Description |
showType | int | 0: Not displayed.1: Display the simplified version (audio/video information only).2: Display the full version (audio/video information and event information). |
callExperimentalAPI
String callExperimentalAPI(String jsonStr)
Calls experimental APIs.
Parameter | Type | Description |
jsonStr | String | Experimental API call parameters in JSON format. |
Return Value
Result string of the API call.
getAITranscriberManager
AITranscriberManager getAITranscriberManager()
Gets the AI transcription management class (AITranscriberManager).
This API returns the
AITranscriberManager singleton, which is used to manage real-time transcription and translation features.Before using AI transcription:
1. Enable the AI recognition features (speech-to-text and real-time translation) in Console > Feature Configuration > Value-added Features.
2. For details, see related documentation.
Return Value
AITranscriberManager singleton object.
