CameraCharacteristicsWrapper.Keys


object CameraCharacteristicsWrapper.Keys


Custom Metadata.Key definitions for querying library-defined camera characteristics on a CameraCharacteristicsWrapper.

These keys represent extended or compatibility-wrapped metadata that can be queried from CameraCharacteristicsWrapper using Metadata.get.

Summary

Public properties

AVAILABLE_COLOR_SPACE_PROFILES

Added in 1.7.0-rc01
val AVAILABLE_COLOR_SPACE_PROFILES: Metadata.Key<ColorSpaceProfilesWrapper>

Key for retrieving the ColorSpaceProfilesWrapper supported by the camera device.

AVAILABLE_DYNAMIC_RANGE_PROFILES

Added in 1.7.0-rc01
val AVAILABLE_DYNAMIC_RANGE_PROFILES: Metadata.Key<DynamicRangeProfilesWrapper>

Key for retrieving the DynamicRangeProfilesWrapper supported by the camera device.

STREAM_CONFIGURATION_MAP

Added in 1.7.0-rc01
val STREAM_CONFIGURATION_MAP: Metadata.Key<StreamConfigurationMapWrapper>

Key for StreamConfigurationMapWrapper.

Use this key to query the compatibility wrapper for android.hardware.camera2.params.StreamConfigurationMap.

Prefer using the CameraCharacteristicsWrappers.streamConfigurationMap property to access this value.

import androidx.camera.common.CameraCharacteristicsWrapper
import androidx.camera.common.CameraCharacteristicsWrappers.streamConfigurationMap
import androidx.camera.common.CameraId
import androidx.camera.common.testing.FakeCameraCharacteristics
import androidx.camera.common.testing.FakeStreamConfigurationMap
import androidx.camera.common.testing.FakeStreamConfigurationMap.OutputKey
import androidx.camera.common.testing.FakeStreamConfigurationMap.OutputValues

// Create a fake stream configuration map with custom resolutions and formats.
val fakeStreamConfigurationMap =
    FakeStreamConfigurationMap(
        outputsTable =
            linkedMapOf(
                OutputKey(ImageFormat.YUV_420_888, Size(1920, 1080)) to OutputValues(),
                OutputKey(ImageFormat.JPEG, Size(1920, 1080)) to
                    OutputValues(
                        stallDuration = 200_000_000L // 200ms stall duration
                    ),
            )
    )

// Supply the fake stream configuration map via STREAM_CONFIGURATION_MAP metadata key.
val fakeCharacteristics: CameraCharacteristicsWrapper =
    FakeCameraCharacteristics(
        cameraId = CameraId("0"),
        cameraCharacteristics =
            mapOf(
                CameraCharacteristics.LENS_FACING to CameraCharacteristics.LENS_FACING_BACK,
                CameraCharacteristics.SENSOR_ORIENTATION to 90,
            ),
        cameraMetadata =
            mapOf(
                CameraCharacteristicsWrapper.Keys.STREAM_CONFIGURATION_MAP to
                    fakeStreamConfigurationMap
            ),
    )

// The extension property accesses the wrapped version (STREAM_CONFIGURATION_MAP) first,
// returning the FakeStreamConfigurationMap in unit tests without needing real camera hardware.
val streamConfigMap = checkNotNull(fakeCharacteristics.streamConfigurationMap)
val supportedFormats = streamConfigMap.getOutputFormats()
val yuvSizes = streamConfigMap.getOutputSizes(ImageFormat.YUV_420_888)