Join Tencent RTC at NAB Show 2024 in Las Vegas!
Learn more 
Only  $9.9! Get 50,000 minutes with our Starter Plan, perfect for your MVP project.
Only $9.9! Get 50,000 minutes with our Starter Plan, perfect for your MVP project.
Grab It Now 
Join Tencent RTC at NAB Show 2024 in Las Vegas!
Learn more 
Only  $9.9! Get 50,000 minutes with our Starter Plan, perfect for your MVP project.
Only $9.9! Get 50,000 minutes with our Starter Plan, perfect for your MVP project.
Grab It Now 
RTC Engine
Overview
  • Web
    • Demo Quick Run
    • SDK Quick Start
    • 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
      • SEI Message
      • Custom Capturing and Rendering
      • Web Beautification Effects
    • Best Practices
      • Optimize Multi-Person Video Calls
      • Handle Autoplay Restriction
      • Handle Firewall Restriction
    • API List
    • Released Notes
    • Supported Platforms
    • Web FAQs
  • Android
    • 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.Setting Video Quality
      • 10.Rotating Videos
    • 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
    • Release Notes
  • iOS
    • 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.Setting Video Quality
      • 10.Rotating Videos
    • 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
  • macOS
    • 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
    • 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 C++
    • 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.Setting Video Quality
      • 10.Rotating Videos
    • 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
  • Pricing
    • RTC-Engine Packages
    • Billing of On-Cloud Recording
    • Billing of MixTranscoding and Relay to CDN
    • Billing Explanation for Subscription Package Duration
    • Billing of Monitoring Dashboard
    • Free Minutes
    • Pay-As-You-Go
  • Concepts
  • Features
  • Performance Statistics
  • 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

8.Enabling Screen Sharing

On macOS, TRTC supports screen sharing via the primary stream and substream:
Substream sharing In TRTC, you can share the screen via a dedicated stream, which is 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. To play substream video, call startRemoteSubStreamView.
Primary stream sharing In TRTC, the channel via which camera images are published is the primary stream (bigstream). In primary stream sharing, an anchor publishes screen sharing images via the primary stream. As 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.

Supported Platforms

iOS
Android
macOS
Windows
Electron
Chrome

Getting Sharable Sources

You can call getScreenCaptureSourcesWithThumbnailSize to enumerate sharable sources. Each sharable source is a TRTCScreenCaptureSourceInfo object.
The desktop of macOS is also a sharable source. The type of sharable windows on macOS is TRTCScreenCaptureSourceTypeWindow, while that of the desktop is TRTCScreenCaptureSourceTypeScreen.
You can find the following information, including type, for each TRTCScreenCaptureSourceInfo object:
Parameter
Type
Description
type
TRTCScreenCaptureSourceType
Capturing source type, which may be window or screen
sourceId
NSString
Capturing source ID. If a window is captured, the value of this parameter is the window handle. If a screen is captured, the value of this parameter is the screen ID.
sourceName
NSString
Window name. If a screen is captured, the value of this parameter is Screen0, Screen1, and so on.
extInfo
NSDictionary
Extra information
Thumbnail
NSImage
Window thumbnail
Icon
NSImage
Window icon
Based on the information, you can display a list of sharable sources on the UI for users to choose from.

Selecting Sharing Source

The TRTC SDK supports three sharing modes, which can be specified via selectScreenCaptureTarget.
Share an entire screen: You can share an entire screen by selecting a source whose type is TRTCScreenCaptureSourceTypeScreen and setting rect to {0, 0, 0, 0}. This mode is supported when you split the screen onto multiple monitors.
Share a portion of a screen: You can share a specific portion of a screen by selecting a source whose type is TRTCScreenCaptureSourceTypeScreen and setting rect to a non-null value, such as {100, 100, 300, 300}.
Share a window: You can share a window by selecting a source whose type is TRTCScreenCaptureSourceTypeWindow and setting rect to {0, 0, 0, 0}.
explain
Two additional parameters:
capturesCursor: specifies whether to capture the cursor.
highlight: specifies whether to highlight the window being shared and remind the user to move the window when it is covered. The relevant UI design is implemented within the SDK.

Starting Screen Sharing

After selecting a sharing source, you can call startScreenCapture to start screen sharing.
The API pauseScreenCapture differs from stopScreenCapture in that it stops screen capturing and displays the image captured at the moment of pausing. As a result, remote users will see a still image until resumeScreenCapture is called.
/**
* 7.6 **Screen Sharing** Start screen sharing
* @param view Parent control of the rendering control
*/
- (void)startScreenCapture:(NSView *)view;

/**
* 7.7 **Screen Sharing** Stop screen sharing
* @return `0`: successful; negative number: failed
*/
- (int)stopScreenCapture;

/**
* 7.8 **Screen Sharing** Pause screen sharing
* @return `0`: successful; negative number: failed
*/
- (int)pauseScreenCapture;

/**
* 7.9 **Screen Sharing** Resume screen sharing
*
* @return `0`: successful; negative number: failed
*/
- (int)resumeScreenCapture;

Setting Video Quality

You can use setSubStreamEncoderParam 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 × 1080
10
800 Kbps
HD
1280 × 720
10
600 Kbps
SD
960 × 720
10
400 Kbps

Watching Shared Screen

Watch screens shared by macOS/Windows users When a macOS/Windows 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 TRTCCloudDelegate. Users who want to watch the shared screen can start rendering the substream image of the remote user by calling the startRemoteSubStreamView API.
Watch screens shared by Android/iOS users When an Android/iOS user starts screen sharing, the screen will be shared through the primary stream, and other users in the room will be notified through onUserVideoAvailable in TRTCCloudDelegate. Users who want to watch the shared screen can start rendering the primary stream of the remote user by calling the startRemoteView API.
//Sample code: watch the shared screen

- (void)onUserSubStreamAvailable:(NSString *)userId available:(BOOL)available {
if (available) {
[self.trtcCloud startRemoteSubStreamView:userId view:self.capturePreviewWindow.contentView];
} else {
[self.trtcCloud stopRemoteSubStreamView:userId];
}
}

FAQs

Can more than one user in a room share their screens at the same time? Currently, a TRTC room can have only one screen sharing stream at a time.
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.