setExternalMediaProjection

Configures MediaProjection outside of the SDK to capture screen video streams.

virtual int setExternalMediaProjection(void* mediaProjection) = 0;
Since
v4.5.0
Attention: This method is for Android only.

After successfully calling this method, the external MediaProjection you set will replace the MediaProjection requested by the SDK to capture the screen video stream.

When the screen sharing is stopped or IRtcEngine is destroyed, the SDK will automatically release the MediaProjection.

Applicable scenarios

If you are able to apply for MediaProjection, you can directly use your MediaProjection instead of the one applied for by the SDK. The following lists two applicable scenarios:
  • On custom system devices, it can avoid system pop-ups (such as requiring user permission to capture the screen) and directly start capturing the screen video stream.
  • In a screen sharing process that involves one or more sub-processes, it can help avoid errors that might occur when creating objects within these sub-processes, which could otherwise lead to failures in screen capturing.

Call timing

Call this method after startScreenCapture [1/2].

Restrictions

Before calling this method, you must first apply for MediaProjection permission.

Parameters

mediaProjection
An object used to capture screen video streams.

Returns

  • 0: Success.
  • < 0: Failure.