startScreenCaptureByDisplayId abstract method

Future<void> startScreenCaptureByDisplayId({
  1. required int displayId,
  2. required Rectangle regionRect,
  3. required ScreenCaptureParameters captureParams,
})

Starts capturing the video stream of the specified screen.

Captures the video stream of a screen or a specific region of the screen. This method is only applicable to Windows and macOS.

  • displayId Specifies the ID of the screen to be shared. On Windows, if you want to share two screens (primary + secondary) simultaneously, you can set displayId to -1 when calling this method.
  • regionRect (Optional) Specifies the position of the region to be shared relative to the entire screen. To share the entire screen, set to nil. See Rectangle.
  • captureParams Configuration parameters for screen sharing. The default video encoding resolution is 1920 × 1080, i.e., 2,073,600 pixels. This pixel count is used for billing. See ScreenCaptureParameters. The video properties of the screen sharing stream only need to be configured through this parameter and are unrelated to setVideoEncoderConfiguration.

Returns When the method call succeeds, there is no return value; when fails, the AgoraRtcException exception is thrown. You need to catch the exception and handle it accordingly. See Error Codes for details and resolution suggestions.

Implementation

Future<void> startScreenCaptureByDisplayId(
    {required int displayId,
    required Rectangle regionRect,
    required ScreenCaptureParameters captureParams});