This section introduces screen sharing using the audio/video SDK.
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:
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.
MediaProjection
to obtain screen data.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);