DefaultCameraCaptureSource

class DefaultCameraCaptureSource @JvmOverloads constructor(context: Context, logger: Logger, surfaceTextureCaptureSourceFactory: SurfaceTextureCaptureSourceFactory, cameraManager: CameraManager = context.getSystemService( Context.CAMERA_SERVICE ) as CameraManager) : CameraCaptureSource, VideoSink

DefaultCameraCaptureSource will configure a reasonably standard capture stream which will use the Surface provided by the capture source provided by a SurfaceTextureCaptureSourceFactory

Constructors

Link copied to clipboard
constructor(context: Context, logger: Logger, surfaceTextureCaptureSourceFactory: SurfaceTextureCaptureSourceFactory, cameraManager: CameraManager = context.getSystemService( Context.CAMERA_SERVICE ) as CameraManager)

Properties

Link copied to clipboard
open override val contentHint: VideoContentHint

Content hint for downstream processing

Link copied to clipboard
open override var device: MediaDevice?

Current camera device. This is only null if the phone/device doesn't have any cameras May be called regardless of whether start or stop has been called.

Link copied to clipboard
open override var format: VideoCaptureFormat

Current camera capture format. Actual format may be adjusted to use supported camera formats. May be called regardless of whether start or stop has been called.

Link copied to clipboard
open override var torchEnabled: Boolean

Toggle for torch on the current device. Will succeed if current device has access to flashlight, otherwise will stay false. May be called regardless of whether start or stop has been called.

Functions

Link copied to clipboard
open override fun addCaptureSourceObserver(observer: CaptureSourceObserver)

Add a capture source observer to receive callbacks from the source on lifecycle events which can be used to trigger UI. This observer is entirely optional.

Link copied to clipboard
open override fun addVideoSink(sink: VideoSink)

Add a video sink which will immediately begin to receive new frames.

Link copied to clipboard
open override fun onVideoFrameReceived(frame: VideoFrame)

Receive a video frame from some upstream source. The VideoSink may render, store, process, and forward the frame, among other applications.

Link copied to clipboard
fun release()
Link copied to clipboard

Remove a capture source observer

Link copied to clipboard
open override fun removeVideoSink(sink: VideoSink)

Remove a video sink which will no longer receive new frames on return

Link copied to clipboard
open override fun setMaxResolution(maxResolution: VideoResolution)

Set max resolution for video capture source DefaultCameraCaptureSource and DefaultScreenCaptureSource call this function to set max resolution for camera and screen capture

Link copied to clipboard
open override fun start()

Start capturing on this source and emitting video frames

Link copied to clipboard
open override fun stop()

Stop capturing on this source and cease emitting video frames

Link copied to clipboard
open override fun switchCamera()

Helper function to switch from front to back cameras or reverse. This also switches from any external cameras to the front camera.