CameraSession

interface CameraSession

Represents a Camera Session.

A Camera Session has CameraSessionConnections to stream from an input device (CameraDevice) to outputs (CameraOutput). It is recommended to configure the session before starting it to avoid reconfiguration hiccups.

val session = VisionCamera.createCameraSession(enableMultiCam = false)
val (controller) = session.configure(
listOf(
CameraSessionConnection(
input = device,
outputs = listOf(
CameraOutputConfiguration(previewOutput),
CameraOutputConfiguration(photoOutput),
),
),
),
)
session.start()

Properties

Link copied to clipboard
abstract val isRunning: Boolean

Whether this CameraSession is currently running.

Functions

Link copied to clipboard
abstract fun addOnErrorListener(onError: (error: Throwable) -> Unit): ListenerSubscription

Adds a listener called when the CameraSession encountered an error.

Link copied to clipboard
abstract fun addOnInterruptionEndedListener(onInterruptionEnded: () -> Unit): ListenerSubscription

Adds a listener called when an interruption has ended and the Camera runs again.

Link copied to clipboard
abstract fun addOnInterruptionStartedListener(onInterruptionStarted: (reason: InterruptionReason) -> Unit): ListenerSubscription

Adds a listener called when the CameraSession was interrupted, for example when the phone overheated, or the user received a call.

Link copied to clipboard
abstract fun addOnStartedListener(onStarted: () -> Unit): ListenerSubscription

Adds a listener called when the CameraSession started running.

Link copied to clipboard
abstract fun addOnStoppedListener(onStopped: () -> Unit): ListenerSubscription

Adds a listener called when the CameraSession stopped running.

Link copied to clipboard
abstract suspend fun configure(connections: List<CameraSessionConnection>, config: CameraSessionConfiguration = CameraSessionConfiguration()): List<CameraController>

Configures the CameraSession with the given connections, and returns one CameraController per CameraSessionConnection.

Link copied to clipboard
abstract suspend fun start()

Starts the CameraSession.

Link copied to clipboard
abstract suspend fun stop()

Stops the CameraSession.