SessionConfig.Builder


@ExperimentalSessionConfig
class SessionConfig.Builder


Builder for SessionConfig

Summary

Public constructors

Builder(useCases: List<UseCase>)
Builder(vararg useCases: UseCase)

Public functions

SessionConfig.Builder

Adds a CameraEffect to be applied on the camera session.

SessionConfig

Builds a SessionConfig from the current configuration.

SessionConfig.Builder
setFrameRateRange(frameRateRange: Range<Int>)

Sets the frame rate range for the camera session.

SessionConfig.Builder

Sets the list of preferred GroupableFeature, ordered by priority in descending order.

SessionConfig.Builder

Sets the list of GroupableFeature that are mandatory for the camera configuration.

SessionConfig.Builder
setViewPort(viewPort: ViewPort)

Sets the ViewPort to be applied on the camera session.

Public constructors

Builder

Builder(useCases: List<UseCase>)

Builder

Added in 1.5.0-beta02
Builder(vararg useCases: UseCase)

Public functions

addEffect

Added in 1.5.0-beta02
fun addEffect(effect: CameraEffect): SessionConfig.Builder

Adds a CameraEffect to be applied on the camera session.

build

Added in 1.5.0-beta02
fun build(): SessionConfig

Builds a SessionConfig from the current configuration.

setFrameRateRange

Added in 1.5.0-beta02
fun setFrameRateRange(frameRateRange: Range<Int>): SessionConfig.Builder

Sets the frame rate range for the camera session.

See SessionConfig.frameRateRange for more details.

Parameters
frameRateRange: Range<Int>

The frame rate range to be applied on the camera session.

setPreferredFeatureGroup

Added in 1.5.0-beta02
fun setPreferredFeatureGroup(vararg features: GroupableFeature): SessionConfig.Builder

Sets the list of preferred GroupableFeature, ordered by priority in descending order.

Features are evaluated for support based on this specified priority. The feature with a lower index (listed first) is considered higher priority. The system attempts to enable preferred features on a best-effort basis:

  • It starts with the highest priority feature.

  • If a feature is supported (considering device capabilities and any other already selected preferred features or required features), it's added to the selection.

  • If a preferred feature is not supported, it's skipped, and the system proceeds to evaluate the next feature in the preferred list.

For example, consider the following scenarios where SessionConfig.requiredFeatureGroup is empty:

Preferred List Device Support Selected Features
[HDR_HLG10, FPS_60, ULTRA_HDR] HLG10 + 60 FPS not supported [HDR_HLG10, ULTRA_HDR]
[FPS_60, HDR_HLG10, ULTRA_HDR] HLG10 + 60 FPS not supported [FPS_60, ULTRA_HDR]
[HDR_HLG10, FPS_60, ULTRA_HDR] HLG10 is not supported [FPS_60, ULTRA_HDR]
[HDR_HLG10, FPS_60] Both supported together [HDR_HLG10, FPS_60]

The final set of selected features will be notified to the listener set by the SessionConfig.setFeatureSelectionListener API.

Note that CameraEffect or ImageAnalysis use case is currently not supported when a feature is set to a session config.

Parameters
vararg features: GroupableFeature

The list of preferred features, ordered by preference.

Returns
SessionConfig.Builder

The Builder instance, allowing for method chaining.

See also
GroupableFeature

setRequiredFeatureGroup

Added in 1.5.0-beta02
fun setRequiredFeatureGroup(vararg features: GroupableFeature): SessionConfig.Builder

Sets the list of GroupableFeature that are mandatory for the camera configuration.

If any of the features is not supported or if the features are not supported together as a combination, an IllegalArgumentException will be thrown when the SessionConfig is bound to a lifecycle (e.g. when the androidx.camera.lifecycle.ProcessCameraProvider.bindToLifecycle API is invoked).

To avoid setting an unsupported feature as required, the setPreferredFeatureGroup API can be used since the features from the preferred features are selected on a best-effort basis according to the priority defined by the ordering of features in the list. Alternatively, the CameraInfo.isFeatureGroupSupported API can be used before binding to check if the features are supported or not.

Note that CameraEffect or ImageAnalysis use case is currently not supported when a feature is set to a session config. Furthermore, unlike the setPreferredFeatureGroup API, the order of the features doesn't matter for this API since each and every one of these features must be configured.

Parameters
vararg features: GroupableFeature

The vararg of GroupableFeature objects to add to the required features.

Returns
SessionConfig.Builder

The Builder instance, allowing for method chaining.

See also
GroupableFeature

setViewPort

Added in 1.5.0-beta02
fun setViewPort(viewPort: ViewPort): SessionConfig.Builder

Sets the ViewPort to be applied on the camera session.