Video receiver
The video receiver feature provides a way to get video data without affecting the actual video stream. This feature allows your application to receive copies of video data and use them for various purposes.
| Supported call type | Minimum SDK version |
|---|---|
| 1-to-1 call, group call (conference) | PlanetKit 7.0 |
Use cases
The main use cases for video receivers are as follows.
- Video analysis and quality monitoring
- Call analytics and metrics collection
- Thumbnail generation
Implementation steps
To implement the video receiver feature, follow these steps.
Note
On Android, the video receiver only supports receiving peers' video.
Implement a video receiver
Create a class that implements the PlanetKitPeerVideoReceiver interface to receive video data through callbacks.
import com.linecorp.planetkit.session.PlanetKitPeerVideoReceiver
import com.linecorp.planetkit.video.PlanetKitVideoFrameData
class VideoFrameReceiver : PlanetKitPeerVideoReceiver {
override fun onPeerVideoReceived(data: PlanetKitVideoFrameData) {
// Access video frame properties
val width = data.width // Int: frame width in pixels
val height = data.height // Int: frame height in pixels
val format = data.format // PlanetKitVideoSourceFormat: frame format
val rotation = data.rotation // PlanetKitVideoRotation: rotation angle
val timestamp = data.timestamp // Long: timestamp in nanoseconds
val buffer = data.buffer // ByteBuffer: video frame data
val size = data.size // Int: size in bytes
val isMirrored = data.isMirrored // Boolean: whether frame is horizontally flipped
// Use the video frame for your use case
// Release the frame when done
data.release()
}
}
Set the video receiver
Register the receiver to start receiving video data from the peer in a 1-to-1 call or group call.
// Create receiver instance
val peerVideoReceiver = VideoFrameReceiver()
// For 1-to-1 call
call.setPeerVideoReceiver(peerVideoReceiver)
// For group call - specify which peer to receive video from
val peerUser = PlanetKitUser(peerId, peerServiceId)
conference.setPeerVideoReceiver(peerUser, peerVideoReceiver)
Clear the video receiver
Unregister the receiver to stop receiving video data and clean up resources.
// For 1-to-1 call
call.clearPeerVideoReceiver()
// For group call
val peerUser = PlanetKitUser(peerId, peerServiceId)
conference.clearPeerVideoReceiver(peerUser)
Related APIs
The APIs related to the video receiver feature are as follows.