Custom Video Track - React Native
We have introduced the ability to pass a custom video track for the video of the participants. This feature can be used to add custom video encoder config, optimization mode (whether you want to focus on motion, text or detail of the video) and background removal & video filter from external SDK(e.g., Banuba)and send it to other participants.
Creating a Custom Video Track
- You can create a Video Track using
createCameraVideoTrack()
method ofVideoSDK
. - This method can be used to create video track using different encoding parameters & camera facing mode.
Parameters
-
encoderConfig:
- type:
String
- required:
true
- default:
h480p_w640p
- Allowed values :
h144p_w176p
|h240p_w320p
|h480p_w640p
|h480p_w720p
|h720p_w960p
|h1080p_w1440p
|h720p_w1280p
- It will be the encoderConfigs you can want to use for the Video Track.
- type:
Above mentioned encoder configurations are valid for both, landscape as well as portrait mode.
-
facingMode:
- type:
String
- required:
true
- Allowed values :
front
|back
- It will specify wheater to use front or back camera for the video track.
- type:
-
optimizationMode
- type:
CustomStreamTrack.VideoMode
- required:
true
- Allowed values:
motion
|text
|detail
- It will specify the optimization mode for the video track being generated.
- type:
-
context:
- type:
Context
- required:
true
- Pass the Android Context for this parameter.
- type:
-
observer:
- type:
CapturerObserver
- required:
false
- If you want to use video filter from external SDK(e.g., Banuba) then pass instance of
CapturerObserver
in this parameter.
- type:
For Banuba integraion with VideoSDK, please visit Banuba Intergation with VideoSDK
Returns
CustomStreamTrack
Example
- Kotlin
- Java
val videoCustomTrack: CustomStreamTrack = VideoSDK.createCameraVideoTrack("h240p_w320p", "front", CustomStreamTrack.VideoMode.MOTION, this)
CustomStreamTrack customStreamTrack = VideoSDK.createCameraVideoTrack("h240p_w320p", "front", CustomStreamTrack.VideoMode.MOTION, this);
Using Custom Video Track
Custom Track while initializing the meeting
If you are passing webcamEnabled: true
in the initMeeting
of VideoSDK
and want to use custom tracks from start of the meeting, you can pass custom track in the initMeeting
as shown below.
- Kotlin
- Java
override fun onCreate(savedInstanceState: Bundle?) {
//..
val customTracks: MutableMap<String, CustomStreamTrack> = HashMap()
val videoCustomTrack: CustomStreamTrack =
VideoSDK.createCameraVideoTrack("h240p_w320p", "back", false, CustomStreamTrack.VideoMode.MOTION, this)
customTracks["video"] = videoCustomTrack //Key must be "video"
// create a new meeting instance
val meeting = VideoSDK.initMeeting(
this@MainActivity, meetingId, participantName,
//MicEnabled
true,
//WebcamEnabled , If true, it will use the passed custom track to turn webcam on
true,
// ParticipantId
null,
// Mode
null,
//Pass the custom tracks here
customTracks
)
}
@Override
protected void onCreate(Bundle savedInstanceState) {
//..
Map<String, CustomStreamTrack> customTracks = new HashMap<>();
CustomStreamTrack videoCustomTrack = VideoSDK.createCameraVideoTrack("h240p_w320p", "back", CustomStreamTrack.VideoMode.MOTION, this);
customTracks.put("video", videoCustomTrack); //Key must be "video"
// create a new meeting instance
Meeting meeting = VideoSDK.initMeeting(
MainActivity.this, meetingId, participantName,
//MicEnabled
true,
//WebcamEnabled , If true, it will use the passed custom track to turn webcam on
true,
// ParticipantId
null,
// Mode
null,
//Pass the custom tracks here
customTracks
);
}
Custom Track with enableWebcam()
In order to switch tracks during the meeting, you have to pass the CustomStreamTrack
in the enableWebcam()
method of Meeting
.
Make sure to call disableWebcam()
before you create a new track as it may lead to unexpected behavior.
- Kotlin
- Java
val customStreamTrack: CustomStreamTrack = VideoSDK.createCameraVideoTrack("h240p_w320p", "back", CustomStreamTrack.VideoMode.MOTION, this)
meeting!!.enableWebcam(customStreamTrack)
CustomStreamTrack customStreamTrack=VideoSDK.createCameraVideoTrack("h240p_w320p", "back", CustomStreamTrack.VideoMode.MOTION, this);
meeting.enableWebcam(customStreamTrack);
Got a Question? Ask us on discord