ScreenCapturerAndroid

An implementation of VideoCapturer to capture the screen content as a video stream. Capturing is done by MediaProjection on a SurfaceTexture. We interact with this SurfaceTexture using a SurfaceTextureHelper. The SurfaceTextureHelper is created by the native code and passed to this capturer in VideoCapturer.initialize(). On receiving a new frame, this capturer passes it as a texture to the native code via CapturerObserver.onFrameCaptured(). This takes place on the HandlerThread of the given SurfaceTextureHelper. When done with each frame, the native code returns the buffer to the SurfaceTextureHelper to be used for new frames. At any time, at most one frame is being processed.

Constructors

Link copied to clipboard
constructor(mediaProjectionPermissionResultData: Intent, mediaProjectionCallback: MediaProjection.Callback)
Constructs a new Screen Capturer.

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open fun changeCaptureFormat(width: Int, height: Int, ignoredFramerate: Int)
Changes output video format.
Link copied to clipboard
open fun dispose()
Perform any final cleanup here.
Link copied to clipboard
open fun initialize(surfaceTextureHelper: SurfaceTextureHelper, applicationContext: Context, capturerObserver: CapturerObserver)
This function is used to initialize the camera thread, the android application context, and the capture observer.
Link copied to clipboard
open fun isScreencast(): Boolean
Link copied to clipboard
open fun onFrame(frame: VideoFrame)
Implementations should call frame.retain() if they need to hold a reference to the frame after this function returns.
Link copied to clipboard
open fun startCapture(width: Int, height: Int, ignoredFramerate: Int)
Start capturing frames in a format that is as close as possible to width x height and framerate.
Link copied to clipboard
open fun stopCapture()
Stop capturing.