SessionConfig.Builder
@ExperimentalSessionConfig
public final class SessionConfig.Builder
Builder for SessionConfig
Summary
Public constructors |
|---|
Public methods |
|
|---|---|
final @NonNull SessionConfig.Builder |
addEffect(@NonNull CameraEffect effect)Adds a |
final @NonNull SessionConfig |
build()Builds a |
final @NonNull SessionConfig.Builder |
setFrameRateRange(@NonNull Range<@NonNull Integer> frameRateRange)Sets the frame rate range for the camera session. |
final @NonNull SessionConfig.Builder |
setPreferredFeatureGroup(@NonNull GroupableFeature... features)Sets the list of preferred |
final @NonNull SessionConfig.Builder |
setRequiredFeatureGroup(@NonNull GroupableFeature... features)Sets the list of |
final @NonNull SessionConfig.Builder |
setViewPort(@NonNull ViewPort viewPort)Sets the |
Public constructors
Public methods
addEffect
public final @NonNull SessionConfig.Builder addEffect(@NonNull CameraEffect effect)
Adds a CameraEffect to be applied on the camera session.
build
public final @NonNull SessionConfig build()
Builds a SessionConfig from the current configuration.
setFrameRateRange
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.
setPreferredFeatureGroup
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 |
| See also | |
|---|---|
GroupableFeature |
setRequiredFeatureGroup
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 |
| Returns | |
|---|---|
@NonNull SessionConfig.Builder |
The |
| See also | |
|---|---|
GroupableFeature |
setViewPort
public final @NonNull SessionConfig.Builder setViewPort(@NonNull ViewPort viewPort)
Sets the ViewPort to be applied on the camera session.