Screen Sharing

This section introduces screen sharing using the audio/video SDK.

1. Introduction

Screen sharing in a video call or interactive live streaming allows you to share an anchor or other speaker’s screen with the audience and make communication more efficient. It is applicable to the following scenarios:

  • Online meeting: where a speaker can share their local files with others.
  • Online class: where teachers can present their courseware, notes, and lectures to students.

2. Implementation

Before you begin screen sharing, make sure to implement basic real-time audio/video function for your project.

Thunder SDK does not provide an API for screen sharing on Android; however, you can combine it with an Android system API to achieve the same function.

  • Call setCustomVideoSource to set a custom video source.
  • Call MediaProjection to obtain screen data.
  • Take the image data obtained from the callback SurfaceView as the external video source, and send it to the remote user by calling pushExternalVideoFrame.
//set customized data sources, screen recording as the data source
MediaProjectionManager mMediaProjectionManager = (MediaProjectionManager)context.getSystemService(Context.MEDIA_PROJECTION_SERVICE);
MediaProjection mMediaProjection = mMediaProjectionManager.getMediaProjection(resultCode, data);
ScreenRecordSource screenRecordSource = new ScreenRecordSource(mMediaProjection);
ThunderEngine.setCustomVideoSource(screenRecordSource);

ThunderVideoEncoderConfiguration configuration = new ThunderVideoEncoderConfiguration();
//Set video definition
configuration.publishMode = publishMode;

//set a playing mode
configuration.playType = ThunderRtcConstant.ThunderPublishPlayType.THUNDERPUBLISH_PLAY_SCREENCAP;
RoomManager.getInstance(context).setVideoEncoderConfig(configuration);

3. API Reference

4. Notices

  • MediaProjection and other APIs run on Android API level 21+. See Google MediaProjection API documentation for the related usage.
  • Codes in this document are in a lite version. See detailed design and implementation in complete [sample codes].

Was this page helpful?

Helpful Not helpful
Submitted! Your feedback would help us improve the website.
Feedback
Top