Camera2Source

class Camera2Source(context: Context, val cameraId: String = DEFAULT_CAMERA_ID) : VideoSource

Captures video from an Android Camera2 device.

Grant camera permission before opening the source. Attach it with MediaMixer.attachVideo.

Constructors

Link copied to clipboard
constructor(context: Context, cameraId: String = DEFAULT_CAMERA_ID)

Properties

Link copied to clipboard

The Camera2 device identifier; defaults to "0".

Link copied to clipboard

The orientation of the video image.

Link copied to clipboard

Whether to enable the camera torch when supported by the device.

Link copied to clipboard

Whether the opened camera supports a torch. False before opening.

Link copied to clipboard

Maximum capture dimensions in sensor coordinates, or null for the default selection.

Link copied to clipboard
open override var surface: Surface?

The surface used as the output destination for video frames.

Link copied to clipboard
open val videoCropRect: Rect?

Valid pixels in the underlying hardware buffer, with exclusive right/bottom coordinates. Supply this when a producer crops from a nonzero origin: ImageReader can report only the cropped dimensions and lose that origin. Null uses the reader's reported crop.

Link copied to clipboard
open override var videoSize: Size

The resolution of the video frames produced by this source.

Link copied to clipboard

Requested zoom ratio. Clamped to the camera range when applied.

Link copied to clipboard

Supported zoom ratios of the opened camera; 1x before opening.

Functions

Link copied to clipboard
open suspend override fun close(): Result<Unit>

Closes the source and returns the result of releasing its capture resources.

Link copied to clipboard
open suspend override fun open(mixer: MediaMixer): Result<Unit>

Opens the camera and selects a capture size using the mixer screen dimensions.