please select
RTC Engine
  • Overview
  • Web
    • Run Sample Demo
    • Integration
    • Basic Features
      • Screen Sharing
      • Live Streaming
      • Media Device
      • Audio Volume
      • Set Encoding Profile
      • Detect Network Quality
      • Detect Capabilities
    • Advance Features
      • Enable AI Denoiser
      • Enable Audio Mixer
      • Enable Watermark
      • Enable Virtual Background
      • Enable Beauty and Effects
      • Data Messages
      • Custom Capturing and Rendering
    • API List
    • Released Notes
    • Supported Platforms
    • Web FAQs
      • Optimize Multi-Person Video Calls
      • Handle Autoplay Restriction
      • Handle Firewall Restriction
      • Others
  • Android
    • Run Sample Code
    • Integration
    • Basic Features
      • Sensing Network Quality
      • Enabling Screen Sharing
      • Setting Video Quality
      • Rotating Videos
    • Advanced Features
      • Testing Newwork Quality
      • Custom Capturing and Rendering
      • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCStatistics
      • TRTCCloudListener
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • Error Codes
    • Solution
      • Real-Time Chorus (TUIKaraoke)
        • Quick Integration
        • Implementation Steps
        • Song Synchronization
        • Lyric Synchronization
        • Vocal Synchronization
        • Mixing Stream Solution
        • TRTCKaraoke APIs
        • FAQs
    • Release Notes
  • iOS
    • Run Sample Code
    • Integration
    • Basic Features
      • Sensing Network Quality
      • Enabling Screen Sharing
      • Setting Video Quality
      • Rotating Videos
    • Advanced Features
      • Testing Network Quality
      • Custom Capturing and Rendering
      • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCCloudDelegate
      • TRTCStatistics
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • ErrorCode
    • Solution
      • Quick Integration
      • Implementation Steps
      • Song Synchronization
      • Lyric Synchronization
      • Vocal Synchronization
      • Mixing Stream Solution
      • TRTCKaraoke APIs
      • FAQs
    • Release Notes
  • macOS
    • Run Sample Code
    • Integration
    • Basic Features
      • Sensing Network Quality
      • Enabling Screen Sharing
      • Sharing Computer Audio
      • Setting Video Quality
      • Rotating Videos
    • Advanced Features
      • Testing Hardware Devices
      • Testing Network Quality
      • Custom Capturing and Rendering
      • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCCloudDelegate
      • TRTCStatistics
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • ErrorCode
      • Release Notes
    • Release Notes
  • Windows
    • Run Sample Code
    • Integration
    • Basic Features
      • Sensing Network Quality
      • Enabling Screen Sharing
      • Setting Video Quality
      • Rotating Videos
    • Advanced Features
      • Testing Hardware Devices
      • Testing Network Quality
      • Custom Capturing and Rendering
      • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • ITRTCCloud
      • ITRTCStatistics
      • TRTCCloudCallback
      • ITXAudioEffectManager
      • ITXDeviceManager
      • Type Definition
      • Deprecated Interface
      • Error Codes
    • Release Notes
  • Electron
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Client APIs
      • Overview
      • Error Codes
  • Flutter
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Client APIs
      • Overview
      • Error Codes
  • Unity
    • Integration
      • 1.API Examples
      • 2Importing the SDK
    • Client APIs
      • Overview
      • Error Codes
  • Qt
    • Integration
      • 1.Importing the SDK
  • Overview
    • Overview
  • Concepts
  • Features
  • Performance Statistics
  • Pricing
    • Free Minutes
    • RTC-Engine Monthly Packages
    • Billing Explanation for Subscription Package Duration
    • Pay-as-you-go
      • Billing of Audio and Video Duration
      • Billing of On-Cloud Recording and Recording Delivery
      • Billing of MixTranscoding and Relay to CDN
  • FAQs
    • FAQs for Beginners
    • Migration Guide
      • Twilio Video to Tencent RTC
      • Billing
      • Features
      • UserSig
      • Firewall Restrictions
      • How to Downsize Installation Package
      • TRTCCalling for Web
      • Audio and Video Quality
      • Others
RTC Engine

Enabling Screen Sharing

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.

APIs

Description
C++
C#
Electron
Selects a sharing source
selectScreenCaptureTarget
Starts screen sharing
startScreenCapture
Pauses screen sharing
pauseScreenCapture
Resumes screen sharing
resumeScreenCapture
Ends screen sharing
stopScreenCapture

Getting Sharing Sources

You can call getScreenCaptureSources to get a list of sharable sources, which is returned via the response parameter sourceInfoList.
explain
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:
Clarity
Resolution
Frame Rate
Bitrate
FHD
1920 x 1080
10
800 Kbps
HD
1280 x 720
10
600 Kbps
SD
960 x 720
10
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);
}
}

FAQs

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.