VideoSDK Class Native Android Methods - Flutter
You call these methods from your app's Android code. Import the class as live.videosdk.videosdk.VideoSDK.
getInstance()
- This method is used to get an instance of the
VideoSDKclass.
Returns
VideoSDKinstance
Example
- Kotlin
- Java
import live.videosdk.videosdk.VideoSDK
val videoSDK = VideoSDK.getInstance()
import live.videosdk.videosdk.VideoSDK;
VideoSDK videoSDK = VideoSDK.getInstance();
registerVideoProcessor()
- This method is used to register your custom video processor during app initialization. It takes a string representing the unique processor name along with an instance of your processor to complete the registration.
- Register it in your
MainActivity. Then apply it from Dart withroom.setVideoProcessor(), using the same name. A name that was never registered throws an error. - Your processor implements
VideoFrameProcessorfromlive.videosdk.rtc.android.listeners. ItsonFrameCaptured()method receives each camera frame as avideosdk.org.webrtc.VideoFrame, and returns the frame to send: the same frame, or a new one. - The SDK releases both the frame it passes in and the frame you return, so do not call
release()on either.
Parameters
-
videoProcessorName
- type:
String - required:
true - The name of the processor whose effect you wish to apply.
- type:
-
videoProcessor
- type:
VideoFrameProcessor - required:
true - The instance of the processor whose effect you wish to apply.
- type:
Returns
void
Example
- Kotlin
- Java
MainActivity.kt
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import live.videosdk.rtc.android.listeners.VideoFrameProcessor
import live.videosdk.videosdk.VideoSDK
import videosdk.org.webrtc.VideoFrame
class CustomVideoProcessor : VideoFrameProcessor {
override fun onFrameCaptured(videoFrame: VideoFrame): VideoFrame {
// Apply your effect here, and return the frame to send.
return videoFrame
}
}
class MainActivity : FlutterActivity() {
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
val customVideoProcessor = CustomVideoProcessor()
val videoSDK = VideoSDK.getInstance()
videoSDK.registerVideoProcessor("customVideoProcessorName", customVideoProcessor)
}
}
MainActivity.java
import androidx.annotation.NonNull;
import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
import live.videosdk.rtc.android.listeners.VideoFrameProcessor;
import live.videosdk.videosdk.VideoSDK;
import videosdk.org.webrtc.VideoFrame;
public class MainActivity extends FlutterActivity {
@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
super.configureFlutterEngine(flutterEngine);
CustomVideoProcessor customVideoProcessor = new CustomVideoProcessor();
VideoSDK videoSDK = VideoSDK.getInstance();
videoSDK.registerVideoProcessor("customVideoProcessorName", customVideoProcessor);
}
}
class CustomVideoProcessor implements VideoFrameProcessor {
@Override
public VideoFrame onFrameCaptured(VideoFrame videoFrame) {
// Apply your effect here, and return the frame to send.
return videoFrame;
}
}
Got a Question? Ask us on discord

