startScreenCapture [2/2]
Starts screen capture from the specified video source.
virtual int startScreenCapture(VIDEO_SOURCE_TYPE sourceType, const ScreenCaptureConfiguration& config) = 0;
- Since
- v4.2.0
Attention: This method applies to the macOS and Windows only.
Applicable scenarios
In the screen sharing scenario, you need to call this method to start capturing the screen video stream.
The SDK supports a series of methods for screen capturing, with the following distinctions between them. Please choose according to the actual scenario:
- startScreenCapture [1/2]/startScreenCaptureByDisplayId/startScreenCaptureByWindowId: Only supports capturing a single screen or window, suitable for scenarios where only a single screen is shared.
- startScreenCapture [2/2]: Supports specifying multiple video sources to capture multiple screen sharing streams, used for local video mixing or multi-channel scenarios.
Call timing
You can call this method either before or after joining the channel, with the following differences:
- Call this method first and then call joinChannel [2/2] to join channel and set publishScreenCaptureVideo to
true
to start screen sharing. - Call this method after joining a channel, then call updateChannelMediaOptions and set publishScreenCaptureVideo to
true
to start screen sharing.
Restrictions
- If you start screen capture by calling this method, you need to call stopScreenCapture [2/2] to stop screen capture.
- On the Windows platform, it supports up to four screen capture video streams.
- On the macOS platform, it supports only one screen capture video stream.
Parameters
- sourceType
- The type of the video source. See VIDEO_SOURCE_TYPE.Attention: On the macOS platform, this parameter can only be set to VIDEO_SOURCE_SCREEN (2).
- config
- The configuration of the captured screen. See ScreenCaptureConfiguration.
Returns
- 0: Success.
- < 0: Failure.