ExtensionSessionConfig


class ExtensionSessionConfig : SessionConfig


A SessionConfig for extension sessions.

This class encapsulates the necessary configurations for a extension session. Once configured, this config can be bound to a camera and lifecycle using androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle or androidx.camera.lifecycle.LifecycleCameraProvider.bindToLifecycle.

It consists of a collection of UseCase, session parameters to be applied on the camera session, and common properties like the field-of-view defined by ViewPort. Note that ImageAnalysis is not supported in extension sessions.

Constraints:

  • When used for binding to a camera via androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle or androidx.camera.lifecycle.LifecycleCameraProvider.bindToLifecycle, the list of UseCase provided to the constructor or added via Builder.addUseCase cannot be empty.

Apps can use CameraProvider.getCameraInfo with an ExtensionSessionConfig to obtain the CameraInfo of the camera which can support the given ExtensionSessionConfig.

Usage Example:

// In a coroutine scope
try {
val extensionsManager = ExtensionsManager.getInstanceAsync(context, cameraProvider).await()

val cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA
if (extensionsManager.isExtensionAvailable(cameraSelector, ExtensionMode.NIGHT)) {
// This is the correct time to create an ExtensionSessionConfig
val imageCapture = ImageCapture.Builder().build()
val preview = Preview.Builder().build()

val config = ExtensionSessionConfig.Builder(
ExtensionMode.NIGHT,
extensionsManager
)
.addUseCase(preview)
.addUseCase(imageCapture)
.build()

// Now it's safe to bind the configuration
cameraProvider.bindToLifecycle(lifecycleOwner, cameraSelector, config)
} else {
// Handle the case where the extension is not available.
}
} catch (e: Exception) {
// Handle failure
}
Throws
kotlin.IllegalArgumentException

if the given mode is not a valid extension mode.

Summary

Nested types

Builder for ExtensionSessionConfig.

Public constructors

ExtensionSessionConfig(
    mode: Int,
    extensionsManager: ExtensionsManager,
    vararg useCases: UseCase
)

Creates an ExtensionSessionConfig with a variable number of UseCase instances.

ExtensionSessionConfig(
    mode: Int,
    extensionsManager: ExtensionsManager,
    useCases: List<UseCase>,
    viewPort: ViewPort?,
    effects: List<CameraEffect>
)

Public properties

ExtensionsManager

The ExtensionsManager instance.

Int

The extension mode.

Inherited functions

From androidx.camera.core.SessionConfig
Unit
setFeatureSelectionListener(
    executor: Executor,
    listener: Consumer<Set<GroupableFeature>>
)

Sets a listener to know which features are finally selected when a session config is bound, based on the user-defined priorities/ordering for preferredFeatureGroup and device capabilities.

open String

Inherited properties

From androidx.camera.core.SessionConfig
List<CameraEffect>

The list of CameraEffect to be applied on the camera session.

Consumer<Set<GroupableFeature>>

Gets the feature selection listener set to this session config.

Executor

Gets the executor set to this session config for feature selection listener invocation.

Range<Int>

The desired frame rate range for the camera session.

List<GroupableFeature>

A list of preferred GroupableFeature ordered according to priority in descending order, i.e. a feature with a lower index in the list is considered to have a higher priority.

Set<GroupableFeature>

A set of GroupableFeature that are mandatory for the camera session configuration.

List<UseCase>

The list of UseCase to be attached to the camera and receive camera data.

ViewPort?

The ViewPort to be applied on the camera session.

Public constructors

ExtensionSessionConfig

Added in 1.6.0-alpha02
ExtensionSessionConfig(
    mode: Int,
    extensionsManager: ExtensionsManager,
    vararg useCases: UseCase
)

Creates an ExtensionSessionConfig with a variable number of UseCase instances.

Parameters
mode: Int

The extension mode. See ExtensionMode for the list of available modes.

extensionsManager: ExtensionsManager

The ExtensionsManager instance.

vararg useCases: UseCase

The UseCase instances to be attached to the camera and receive camera data.

Throws
kotlin.IllegalArgumentException

if the given mode is not a valid extension mode.

ExtensionSessionConfig

ExtensionSessionConfig(
    mode: Int,
    extensionsManager: ExtensionsManager,
    useCases: List<UseCase> = emptyList(),
    viewPort: ViewPort? = null,
    effects: List<CameraEffect> = emptyList()
)
Parameters
mode: Int

The extension mode. See ExtensionMode for the list of available modes.

extensionsManager: ExtensionsManager

The ExtensionsManager instance.

useCases: List<UseCase> = emptyList()

The list of UseCase to be attached to the camera and receive camera data.

viewPort: ViewPort? = null

The ViewPort to be applied on the camera session. If not set, the default is no viewport.

effects: List<CameraEffect> = emptyList()

The list of CameraEffect to be applied on the camera session. If not set, the default is no effects.

Public properties

extensionsManager

Added in 1.6.0-alpha02
val extensionsManagerExtensionsManager

The ExtensionsManager instance.

mode

Added in 1.6.0-alpha02
val modeInt

The extension mode. See ExtensionMode for the list of available modes.