Skip to main content
Version: 5.x.x

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 VideoSDK class.

Returns​

  • VideoSDK instance

Example​

import live.videosdk.videosdk.VideoSDK

val 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 with room.setVideoProcessor(), using the same name. A name that was never registered throws an error.
  • Your processor implements VideoFrameProcessor from live.videosdk.rtc.android.listeners. Its onFrameCaptured() method receives each camera frame as a videosdk.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.
  • videoProcessor

    • type: VideoFrameProcessor
    • required: true
    • The instance of the processor whose effect you wish to apply.

Returns​

  • void

Example​

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)
}
}

Got a Question? Ask us on discord