Last updated: 2023-09-28 11:43:41Download PDF
This document describes how to share the screen. Currently, a TRTC room can have only one screen sharing stream at a time.
TRTC supports screen sharing in primary stream and substream modes on Windows.
Substream sharing In TRTC, you can share the screen via a dedicated stream called the substream. In substream sharing, an anchor publishes camera video and screen sharing images at the same time. This is the scheme used by VooV Meeting. You can enable substream sharing by setting the TRTCVideoStreamType parameter to TRTCVideoStreamTypeSub when calling the startScreenCapture API.
Primary stream sharing In TRTC, the image from the user’s camera is published via the primary stream (bigstream). In primary stream sharing, an anchor publishes screen sharing images via the primary stream. Because there is only one stream, an anchor cannot publish both camera video and screen sharing images. You can enable this mode by setting the TRTCVideoStreamType parameter to TRTCVideoStreamTypeBig when calling the startScreenCapture API.


Selects a sharing source
Starts screen sharing
Pauses screen sharing
Resumes screen sharing
Ends screen sharing

Getting Sharing Sources

You can call getScreenCaptureSources to get a list of sharable sources, which is returned via the response parameter sourceInfoList.
On Windows, the desktop also counts as a window. When two monitors are used, each monitor corresponds to a desktop window. The list returned via getScreenCaptureSources includes desktop windows.
Based on the obtained window information, you can display a list of sharable sources on the UI for users to choose from.

Starting Screen Sharing

After selecting a sharing source, you can call the startScreenCapture API to start screen sharing.
During screen sharing, you can call selectScreenCaptureTarget to change the sharing source.
The difference between pauseScreenCapture and stopScreenCapture is that pauseScreenCapture pauses screen capturing and displays the image at the moment it is paused. Remote users see the paused video image until screen capturing is resumed.

Setting Video Quality

You can use the setSubStreamEncoderParam API to set the video quality of screen sharing, including resolution, bitrate, and frame rate. We recommend the following settings:
Frame Rate
1920 x 1080
800 Kbps
1280 x 720
600 Kbps
960 x 720
400 Kbps

Watching Shared Screen

When a user in a room starts screen sharing, the screen will be shared through a substream, and other users in the room will be notified through onUserSubStreamAvailable in ITRTCCloudCallback. Users who want to view the shared screen can start rendering the substream image of the remote user by calling the startRemoteView API.
//Sample code: Watch the shared screen
void CTRTCCloudSDK::onUserSubStreamAvailable(const char * userId, bool available) {
LINFO(L"onUserSubStreamAvailable userId[%s] available[%d]\n", UTF82Wide(userId).c_str(), available);
liteav::ITRTCCloud* trtc_cloud_ = getTRTCShareInstance();
if (available) {
trtc_cloud_->startRemoteView(userId, liteav::TRTCVideoStreamTypeSub, hWnd);
} else {
trtc_cloud_->stopRemoteView(userId, liteav::TRTCVideoStreamTypeSub);


1. Can there be multiple channels of screen sharing streams in a room at the same time?

Currently, a TRTC room can have only one screen sharing stream at a time.

2. When a specified window (SourceTypeWindow) is shared, if the window size changes, will the resolution of the video stream change accordingly?

By default, the SDK automatically adjusts encoding parameters according to the size of the shared window. If you want a fixed resolution, call the setSubStreamEncoderParam API to set encoding parameters for screen sharing or specify the parameters when calling the startScreenCapture API.