tencent_rtc_sdk. Obtain the singleton via TRTCCloud.sharedInstance() and then call all APIs.API | Description |
Creates a TRTCCloud instance (singleton mode). | |
Destroys the TRTCCloud instance (singleton mode). | |
Adds a TRTC event listener. | |
Removes a TRTC event listener. |
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). |
API | Description |
Starts publishing media streams. | |
Updates published media streams. | |
Stops publishing media streams. |
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). |
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. |
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). |
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). |
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. |
API | Description |
Starts network speed test (used before entering a room). | |
Stops network speed test. |
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. |
API | Description |
Gets the AI transcription management class (AITranscriberManager). |
static Future<TRTCCloud> sharedInstance()
Future<TRTCCloud>, which asynchronously returns the TRTCCloud singleton object.TRTCCloud trtcCloud = await TRTCCloud.sharedInstance();
static void destroySharedInstance()
void registerListener(TRTCCloudListener func)
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. |
void unRegisterListener(TRTCCloudListener func)
Parameter | Type | Description |
func | TRTCCloudListener | The event listener object to remove. |
void enterRoom(TRTCParams param, TRTCAppScene scene)
onEnterRoom callback from TRTCCloudListener:result will be a positive number (result > 0), indicating the time in milliseconds (ms) from the function call to room entry.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. |
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.enterRoom must be paired with exitRoom. Calling enterRoom again before calling exitRoom will cause unexpected errors.TRTCCloud trtcCloud = await TRTCCloud.sharedInstance();TRTCParams params = TRTCParams(sdkAppId: 1400000123,userId: 'denny',userSig: 'xxxxxxx',roomId: 123321,role: TRTCRoleType.anchor,);trtcCloud.enterRoom(params, TRTCAppScene.live);
void exitRoom()
onExitRoom callback in TRTCCloudListener.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.void switchRole(TRTCRoleType role)
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. |
TRTCAppScene.live) and audio chat room (TRTCAppScene.voiceChatRoom) scenarios.scene you specified when calling enterRoom is TRTCAppScene.videoCall or TRTCAppScene.audioCall, do not call this API.void switchRoom(TRTCSwitchRoomConfig config)
exitRoom (current room) + enterRoom (new room).switchRoom delivers better smoothness with less code than exitRoom + enterRoom.onSwitchRoom callback in TRTCCloudListener.Parameter | Type | Description |
config |
config contains both roomId and strRoomId. Pay special attention to how they are specified:strRoomId, set roomId to 0. If both are specified, roomId takes precedence.strRoomId or roomId; they cannot be mixed. Otherwise, many unexpected bugs will occur.void connectOtherRoom(String param)
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.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.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. |
import 'dart:convert';Map<String, dynamic> object = {'roomId': 155,'userId': '57890',};trtcCloud.connectOtherRoom(jsonEncode(object));
void disconnectOtherRoom()
onDisconnectOtherRoom callback in TRTCCloudListener.void setDefaultStreamRecvMode(bool autoRecvAudio, bool autoRecvVideo)
startRemoteView API).startRemoteView API to start subscribing to and decoding the video stream, and manually call the muteRemoteAudio(false) API to start audio playback.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. |
enterRoom).startRemoteView to subscribe to video streams after entering the room, the SDK will automatically stop subscribing to the video streams to save traffic.void startPublishMediaStream(TRTCPublishTarget target,TRTCStreamEncoderParam param, TRTCStreamMixingConfig config)
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. |
onStartPublishMediaStream callback in TRTCCloudListener.updatePublishMediaStream to modify publishing parameters or to stopPublishMediaStream to stop the task.target at the same time. Even if one transcoding task has multiple relay addresses, the transcoding fee is charged only once.void updatePublishMediaStream(String taskId, TRTCPublishTarget target,TRTCStreamEncoderParam param, TRTCStreamMixingConfig config)
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. |
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).void stopPublishMediaStream(String taskId)
startPublishMediaStream.Parameter | Type | Description |
taskId | String | The identifier of the task started in the backend, returned through the onStartPublishMediaStream callback in TRTCCloudListener. |
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.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.void startLocalPreview(bool frontCamera, int? viewId)
enterRoom, the SDK will only turn on the camera and wait until you call enterRoom before starting to push streams.enterRoom, the SDK will turn on the camera and automatically start pushing video streams.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. |
startLocalPreview before calling enterRoom.startLocalPreview + muteLocalVideo(true) after calling enterRoom.TRTCCloudVideoView(key: const ValueKey('local'),onViewCreated: (viewId) {cloud.startLocalPreview(true, viewId);})
void updateLocalView(int? viewId)
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. |
void stopLocalPreview()
void muteLocalVideo(TRTCVideoStreamType streamType, bool mute)
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.onUserVideoAvailable(userId, false) callback.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. |
void startRemoteView(String userId, TRTCVideoStreamType streamType, int? viewId)
userId and render it on the rendering control specified by viewId. You can set the display mode of the image via setRemoteRenderParams.userId of a user who has a video stream in the room, you can directly call startRemoteView to subscribe to the user's video.onUserVideoAvailable after enterRoom.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. |
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.userId can be watched only after the user enables dual-channel encoding via enableSmallVideoStream.userId does not exist, the SDK switches to the user's big image by default.TRTCCloudVideoView(key: ValueKey('remote_$uid'),onViewCreated: (viewId) {cloud.startRemoteView(uid, TRTCVideoStreamType.big, viewId);})
void updateRemoteView(String userId, TRTCVideoStreamType streamType, int? viewId)
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. |
void stopRemoteView(String userId, TRTCVideoStreamType streamType)
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. |
void stopAllRemoteView()
void setVideoMuteImage(String imagePath, int fps)
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. |
void setWatermark(String imagePath, TRTCVideoStreamType streamType,double x, double y, double width)
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. |
void muteRemoteVideoStream(String userId, TRTCVideoStreamType streamType, bool mute)
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. |
enterRoom), and the pause status will be reset after room exit (exitRoom).startRemoteView alone cannot play the user's video. You need to call muteRemoteVideoStream(false) or muteAllRemoteVideoStreams(false) to resume.void muteAllRemoteVideoStreams(bool mute)
Parameter | Type | Description |
mute | bool | Whether to pause receiving. |
enterRoom), and the pause status will be reset after room exit (exitRoom).startRemoteView alone cannot play the video of a specified user. You need to call muteRemoteVideoStream(false) or muteAllRemoteVideoStreams(false) to resume.void setVideoEncoderParam(TRTCVideoEncParam params)
Parameter | Type | Description |
params |
void setVideoEncoderMirror(bool enable)
Parameter | Type | Description |
enable | bool | Whether to enable mirror mode. Default value: false. |
void setNetworkQosParam(TRTCNetworkQosParam params)
Parameter | Type | Description |
params |
void setLocalRenderParams(TRTCRenderParams params)
Parameter | Type | Description |
params |
void setRemoteRenderParams(String userId, TRTCVideoStreamType streamType,TRTCRenderParams params)
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 |
int enableSmallVideoStream(bool enable, TRTCVideoEncParam smallVideoEncParam)
Parameter | Type | Description |
enable | bool | Whether to enable small image encoding. Default value: false. |
smallVideoEncParam |
void setRemoteVideoStreamType(String userId, TRTCVideoStreamType streamType)
startRemoteView is the [HD big image] by default.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. |
enableSmallVideoStream in advance; otherwise, this call has no effect.void snapshotVideo(String userId, TRTCVideoStreamType streamType,TRTCSnapshotSourceType sourceType, {String? path})
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. |
void setGravitySensorAdaptiveMode(TRTCGSensorMode mode)
Parameter | Type | Description |
mode | G-sensor mode. Default value: TRTCGSensorMode.uiAutoLayout. |
void startLocalAudio(TRTCAudioQuality quality)
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. |
void stopLocalAudio()
onUserAudioAvailable(userId, false) notification.void muteLocalAudio(bool mute)
onUserAudioAvailable(userId, false) notification.onUserAudioAvailable(userId, true) notification.stopLocalAudio, muteLocalAudio(true) does not release the microphone permission; instead, it continues to send mute packets at an extremely low bitrate.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. |
void muteRemoteAudio(String userId, bool mute)
Parameter | Type | Description |
userId | String | ID of the specified remote user. |
mute | bool | true: Mute.false: Unmute. |
enterRoom), and the mute status will be reset to false after room exit (exitRoom).void muteAllRemoteAudio(bool mute)
Parameter | Type | Description |
mute | bool | true: Mute.false: Unmute. |
enterRoom), and the mute status will be reset to false after room exit (exitRoom).void setRemoteAudioVolume(String userId, int volume)
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. |
volume to 100, you can set volume to up to 150, but this may have side effects.void setAudioCaptureVolume(int volume)
Parameter | Type | Description |
volume | int | Volume. 100 is the original volume. Value range: [0, 150]. Default value: 100. |
volume to 100, you can set volume to up to 150, but this may have side effects.int getAudioCaptureVolume()
void setAudioPlayoutVolume(int volume)
Parameter | Type | Description |
volume | int | Volume. 100 is the original volume. Value range: [0, 150]. Default value: 100. |
volume to 100, you can set volume to up to 150, but this may have side effects.int getAudioPlayoutVolume()
void enableAudioVolumeEvaluation(bool enable, TRTCAudioVolumeEvaluateParams params)
onUserVoiceVolume callback in TRTCCloudListener.Parameter | Type | Description |
enable | bool | Whether to enable volume reminder. Disabled by default. |
params |
startLocalAudio.int startLocalRecording(TRTCLocalRecordingParams param)
Parameter | Type | Description |
param |
void stopLocalRecording()
TXDeviceManager getDeviceManager()
TXDeviceManager.void setBeautyStyle(TRTCBeautyStyle style, int beautyLevel,int whitenessLevel, int ruddinessLevel)
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. |
TXAudioEffectManager getAudioEffectManager()
TXAudioEffectManager is the audio effect management API, which allows you to implement the following features:isShortFile to true).TXAudioEffectManager.void startSystemAudioLoopback({String? deviceName})
Parameter | Type | Description |
deviceName | String? | Optional named parameter. If empty, the audio of the entire system is captured. |
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).TXMediaDeviceType.speaker can be obtained via the getDevicesList API in TXDeviceManager).void stopSystemAudioLoopback()
void setSystemAudioLoopbackVolume(int volume)
Parameter | Type | Description |
volume | int | Volume to set. Value range: [0, 150]. Default value: 100. |
void startScreenCapture(int? viewId, TRTCVideoStreamType streamType,TRTCVideoEncParam encParam)
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). |
TRTCVideoStreamType.big) and one substream (TRTCVideoStreamType.sub) at the same time.stopLocalPreview in advance to avoid conflicts.onError (ERR_SERVER_CENTER_ANOTHER_USER_PUSH_SUB_VIDEO) callback from TRTCCloudListener.void startScreenCaptureByReplaykit(TRTCVideoStreamType streamType,TRTCVideoEncParam encParam, String? appGroup)
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. |
void stopScreenCapture()
void pauseScreenCapture()
void resumeScreenCapture()
TRTCScreenCaptureSourceList? getScreenCaptureSources(TRTCSize thumbnail, TRTCSize icon)
null.void selectScreenCaptureTarget(TRTCScreenCaptureSourceInfo source,TRTCRect rect, TRTCScreenCaptureProperty property)
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.source, and set rect to {0, 0, 0, 0}.source, and set rect to a non-empty value, such as {100, 100, 300, 300}.source, and set rect to {0, 0, 0, 0}.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. |
void addExcludedShareWindow(int windowID)
Parameter | Type | Description |
windowID | int | The window not to be shared (window ID on macOS, HWND on Windows). |
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.sourceId member in TRTCScreenCaptureSourceInfo.void removeExcludedShareWindow(int windowID)
Parameter | Type | Description |
windowID | int | ID of the window to remove. |
void removeAllExcludedShareWindow()
void addIncludedShareWindow(int windowID)
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). |
void removeIncludedShareWindow(int windowID)
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). |
void removeAllIncludedShareWindow()
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.void setSubStreamEncoderParam(TRTCVideoEncParam param)
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 |
void enableCustomAudioCapture(bool enable)
sendCustomAudioData.Parameter | Type | Description |
enable | bool | Whether to enable. Default value: false. |
void sendCustomAudioData(TRTCAudioFrame frame)
TRTCAudioFrameFormat.pcm is supported.48000 × 0.02s × 1 × 16bit = 15360bit = 1920 bytes.Parameter | Type | Description |
frame |
int setAudioFrameCallback(TRTCAudioFrameCallback? callback)
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. |
0: Set successfully.bool sendCustomCmdMsg(int cmdID, String data, bool reliable, bool ordered)
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). |
reliable and ordered to both true or both false. Cross settings are not supported currently.cmdIDs for different types of messages, which reduces message latency when ordering is required.true: The message has been sent.false: Failed to send the message.bool sendSEIMsg(String data, int repeatCount)
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.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. |
sendCustomCmdMsg).sendCustomCmdMsg).sendCustomCmdMsg).repeatCount > 1), it will be inserted into the subsequent repeatCount video frames consecutively, which increases the video bitrate.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.true: The message is allowed and will be sent with subsequent video frames.false: The message is not allowed to be sent.int startSpeedTest(TRTCSpeedTestParams params)
Parameter | Type | Description |
params | Speed test options. |
< 0: Failure.void stopSpeedTest()
String getSDKVersion()
void setLogLevel(TRTCLogLevel level)
Parameter | Type | Description |
level | Log level. Default value: TRTCLogLevel.none. |
void setConsoleEnabled(bool enabled)
Parameter | Type | Description |
enabled | bool | Specifies whether to enable console log printing. Disabled by default. |
void setLogCompressEnabled(bool enabled)
Parameter | Type | Description |
enabled | bool | Specifies whether to enable log compression. Enabled by default. |
void setLogDirPath(String path)
C:/Users/[username]/AppData/Roaming/liteav/log, i.e., %appdata%/liteav/log.Documents/log directory of the sandbox./app directory/files/log/liteav/ directory.Parameter | Type | Description |
path | String | Log storage path. |
void setLogCallback(TRTCLogCallback? callback)
Parameter | Type | Description |
callback | TRTCLogCallback? | Log callback object. Pass null to cancel the callback. |
void showDebugView(int showType)
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). |
String callExperimentalAPI(String jsonStr)
Parameter | Type | Description |
jsonStr | String | Experimental API call parameters in JSON format. |
AITranscriberManager getAITranscriberManager()
AITranscriberManager singleton, which is used to manage real-time transcription and translation features.AITranscriberManager singleton object.Esta página foi útil?
Você também pode entrar em contato com a Equipe de vendas ou Enviar um tíquete em caso de ajuda.
comentários