Skip to main content
Version: 0.1.x

Custom Screen Share Track - React Native

We have introduced the ability to pass a custom Screen Share track while sharing the screen of participants. This feature can be used to add custom video encoder config,background removal & video filter from external SDK(e.g., Banuba) and send it to other participants.

Creating a Custom Screen Share Track

  • You can create a Screen Share track using createScreenShareVideoTrack() method of VideoSDK.
  • This method can be used to create screen share track using different encoding parameters.

Parameters

  • encoderConfig:

    • type: String
    • required: true
    • default: h720p_15fps
    • Allowed values : h360p_30fps | h720p_5fps | h720p_15fps | h1080p_15fps | h1080p_30fps
    • It will be the encoderConfigs you can want to use for the Screen Share Track.
note

Above mentioned encoder configurations are valid for both, landscape as well as portrait mode.

  • data

    • type: Intent
    • required: true
    • It is Intent received from onActivityResult when user provide permission for ScreenShare.
  • context

    • type: Context
    • required: true
    • Pass the Android Context for this parameter.
  • listener

    • type: CustomTrackListener
    • required: true
    • Callback to this listener will be made when track is ready with CustomTrack as parameter.

Example

// data is received from onActivityResult method.
VideoSDK.createScreenShareVideoTrack("h720p_5fps", data, this) { track ->
meeting!!.enableScreenShare(track)
}

Using Custom Screen Share Track

Custom Track with enableScreenShare()

In order to switch tracks during the meeting, you have to pass the CustomStreamTrack in the enableScreenShare() method of Meeting.

note

Make sure to call disableScreenShare() before you create a new track as it may lead to unexpected behavior.

@TargetApi(21)
private fun askPermissionForScreenShare() {
val mediaProjectionManager = application.getSystemService<Any>(
Context.MEDIA_PROJECTION_SERVICE
) as MediaProjectionManager
startActivityForResult(
mediaProjectionManager.createScreenCaptureIntent(), CAPTURE_PERMISSION_REQUEST_CODE
)
}

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode != CAPTURE_PERMISSION_REQUEST_CODE) return
if (resultCode == RESULT_OK) {
VideoSDK.createScreenShareVideoTrack("h720p_5fps", data, this) { track ->
meeting!!.enableScreenShare(track)
}
}
}

Got a Question? Ask us on discord