Skip to main content

ChainVideoProcessor

The ChainVideoProcessor allows you to link multiple VideoProcessor instances together, applying them sequentially to each video frame. This is incredibly useful for creating complex effects by combining simpler, reusable processors. The frame output by one processor becomes the input for the next one in the chain.

Usage Example

Let's create a chain that first applies a grayscale filter and then adds a watermark.

class GrayScaleVideoProcessor : ChainVideoProcessor() {
override fun onFrameCaptured(frame: VideoFrame?) {
if (frame == null) return

// Apply grayscale logic here...
// val grayFrame = convertToGray(frame)

// Pass processed frame to the next processor
continueChain(frame)
}
}

class WatermarkVideoProcessor : ChainVideoProcessor() {
override fun onFrameCaptured(frame: VideoFrame?) {
if (frame == null) return

// Apply watermark logic here...
// val watermarkedFrame = applyWatermark(frame)

// Pass processed frame to the next processor
continueChain(frame)
}
}

// You can now pass the processor chain to the video processor
val processorChain = GrayScaleVideoProcessor().apply { childVideoProcessor = WatermarkVideoProcessor() }
val meeting = RealtimeKitMeetingBuilder()
.setVideoProcessor(processorChain)
.build(activity)