SessionConfig.Builder


@ExperimentalSessionConfig
public final class SessionConfig.Builder


Builder for SessionConfig

Summary

Public constructors

Builder(@NonNull UseCase useCases)

Public methods

final @NonNull SessionConfig.Builder

Adds a CameraEffect to be applied on the camera session.

final @NonNull SessionConfig

Builds a SessionConfig from the current configuration.

final @NonNull SessionConfig.Builder

Sets the frame rate range for the camera session.

final @NonNull SessionConfig.Builder

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

final @NonNull SessionConfig.Builder

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

final @NonNull SessionConfig.Builder

Sets the ViewPort to be applied on the camera session.

Public constructors

Builder

public Builder(@NonNull List<@NonNull UseCase> useCases)

Builder

Added in 1.5.0-beta02
public Builder(@NonNull UseCase useCases)

Public methods

addEffect

Added in 1.5.0-beta02
public final @NonNull SessionConfig.Builder addEffect(@NonNull CameraEffect effect)

Adds a CameraEffect to be applied on the camera session.

build

Added in 1.5.0-beta02
public final @NonNull SessionConfig build()

Builds a SessionConfig from the current configuration.

setFrameRateRange

Added in 1.5.0-beta02
public final @NonNull SessionConfig.Builder setFrameRateRange(@NonNull Range<@NonNull Integer> frameRateRange)

Sets the frame rate range for the camera session.

See SessionConfig.frameRateRange for more details.

Parameters
@NonNull Range<@NonNull Integer> frameRateRange

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

setPreferredFeatureGroup

Added in 1.5.0-beta02
public final @NonNull SessionConfig.Builder setPreferredFeatureGroup(@NonNull GroupableFeature features)

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
@NonNull GroupableFeature features

The list of preferred features, ordered by preference.

Returns
@NonNull SessionConfig.Builder

The Builder instance, allowing for method chaining.

See also
GroupableFeature

setRequiredFeatureGroup

Added in 1.5.0-beta02
public final @NonNull SessionConfig.Builder setRequiredFeatureGroup(@NonNull GroupableFeature features)

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
@NonNull GroupableFeature features

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

Returns
@NonNull SessionConfig.Builder

The Builder instance, allowing for method chaining.

See also
GroupableFeature

setViewPort

Added in 1.5.0-beta02
public final @NonNull SessionConfig.Builder setViewPort(@NonNull ViewPort viewPort)

Sets the ViewPort to be applied on the camera session.