# CaptureRequestWrapper

Artifact: [androidx.camera:camera-common](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/common/CaptureRequestWrapper.kt+class:androidx.camera.common.CaptureRequestWrapper) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

*** ** * ** ***


```
public interface CaptureRequestWrapper extends CaptureRequestMetadata
```

<br />

Known direct subclasses [FakeCaptureRequest](https://developer.android.com/reference/androidx/camera/common/testing/FakeCaptureRequest)

|---|---|
| `https://developer.android.com/reference/androidx/camera/common/testing/FakeCaptureRequest` | A fake implementation of `https://developer.android.com/reference/androidx/camera/common/CaptureRequestWrapper` designed for unit testing. |

*** ** * ** ***

A wrapper interface representing the settings applied to a specific camera capture request.

This interface provides a unified way to inspect the configuration parameters sent to the camera device during a capture session. It supports querying:

1. Native Camera2 capture request keys via `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.Key.html` (using `https://developer.android.com/reference/androidx/camera/common/CaptureRequestMetadata#get(android.hardware.camera2.CaptureRequest.Key)`).

2. Extension or custom metadata keys via `https://developer.android.com/reference/androidx/camera/common/Metadata.Key` (using `https://developer.android.com/reference/androidx/camera/common/Metadata#get(androidx.camera.common.Metadata.Key)`, inherited from `https://developer.android.com/reference/androidx/camera/common/Metadata`).

**Note:** This interface is not stable for inheritance. Implementations should not be created directly by clients. For testing, use the fakes in the `androidx.camera.common.testing` package (such as `FakeCaptureRequest`).

```kotlin
import androidx.camera.common.CaptureRequestWrapper
import androidx.camera.common.CaptureRequestWrappers
import androidx.camera.common.Metadata

// Wrap a native CaptureRequest into a CaptureRequestWrapper.
val requestWrapper: CaptureRequestWrapper = CaptureRequestWrappers.wrap(captureRequest)

// Query native Camera2 CaptureRequest keys:
val aeMode = requestWrapper[CaptureRequest.CONTROL_AE_MODE]

// Or attach custom library/application metadata to the request:
val customKey = Metadata.Key<String>("com.example.custom_request_tag")
val requestWithMetadata =
    CaptureRequestWrappers.wrap(
        captureRequest,
        metadata = mapOf(customKey to "sample_tag_value"),
    )
val customTagValue = requestWithMetadata[customKey]
```

```kotlin
import androidx.camera.common.CaptureRequestWrapper
import androidx.camera.common.Metadata
import androidx.camera.common.testing.FakeCaptureRequest

val customKey = Metadata.Key<Int>("com.example.custom_request_priority")

// Create a FakeCaptureRequest for unit testing without requiring a Camera2 device.
val fakeRequest: CaptureRequestWrapper =
    FakeCaptureRequest(
        requestParameters =
            mapOf(
                CaptureRequest.CONTROL_AE_MODE to CaptureRequest.CONTROL_AE_MODE_ON,
                CaptureRequest.CONTROL_AF_MODE to
                    CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE,
            ),
        requestMetadata = mapOf(customKey to 1),
    )

// Query values from the fake request in test assertions:
val aeMode = fakeRequest[CaptureRequest.CONTROL_AE_MODE]
val priority = fakeRequest[customKey]
```

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/camera/common/CaptureRequestMetadata` |   |

## Summary

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.Key.html<@https://developer.android.com/reference/androidx/annotation/NonNull ?>>` | `https://developer.android.com/reference/androidx/camera/common/CaptureRequestWrapper#getKeys()()` The list of all `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.Key.html`s that are set or supported by this capture request. |

### Inherited methods

From [androidx.camera.common.CaptureRequestMetadata](https://developer.android.com/reference/androidx/camera/common/CaptureRequestMetadata) `abstract T` `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/camera/common/CaptureRequestMetadata#get(android.hardware.camera2.CaptureRequest.Key)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.Key.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> key)`

Retrieves the value of the specified `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.Key.html`.
`default @https://developer.android.com/reference/androidx/annotation/NonNull T` `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/camera/common/CaptureRequestMetadata#getOrDefault(android.hardware.camera2.CaptureRequest.Key,kotlin.Any)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.Key.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> key,
@https://developer.android.com/reference/androidx/annotation/NonNull T default
)`

Retrieves the value of the specified `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.Key.html`, or returns `https://developer.android.com/reference/androidx/camera/common/CaptureRequestMetadata#getOrDefault(android.hardware.camera2.CaptureRequest.Key,kotlin.Any)` if the key is not present or its value is `null`.
From [androidx.camera.common.Metadata](https://developer.android.com/reference/androidx/camera/common/Metadata) `abstract T` `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/camera/common/Metadata#get(androidx.camera.common.Metadata.Key)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/Metadata.Key<@https://developer.android.com/reference/androidx/annotation/NonNull T> key)`

Retrieves the value associated with the specified `https://developer.android.com/reference/androidx/camera/common/Metadata.Key`.
`abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/Metadata.Key<@https://developer.android.com/reference/androidx/annotation/NonNull ?>>` `https://developer.android.com/reference/androidx/camera/common/Metadata#getMetadataKeys()()`

The set of all custom `https://developer.android.com/reference/androidx/camera/common/Metadata.Key`s currently available in this container.
`default @https://developer.android.com/reference/androidx/annotation/NonNull T` `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/camera/common/Metadata#getOrDefault(androidx.camera.common.Metadata.Key,kotlin.Any)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/Metadata.Key<@https://developer.android.com/reference/androidx/annotation/NonNull T> key,
@https://developer.android.com/reference/androidx/annotation/NonNull T default
)`

Retrieves the value associated with the specified `https://developer.android.com/reference/androidx/camera/common/Metadata.Key`, or returns `https://developer.android.com/reference/androidx/camera/common/Metadata#getOrDefault(androidx.camera.common.Metadata.Key,kotlin.Any)` if the key is not present.
From [androidx.camera.common.UnsafeWrapper](https://developer.android.com/reference/androidx/camera/common/UnsafeWrapper) `abstract T` `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/camera/common/UnsafeWrapper#unwrapAs(java.lang.Class)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> type)`

Attempts to unwrap this object into the specified underlying `https://developer.android.com/reference/androidx/camera/common/UnsafeWrapper#unwrapAs(java.lang.Class)`.

## Public methods

### getKeys

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
abstract @NonNull List<@NonNull CaptureRequest.Key<@NonNull ?>> getKeys()
```

The list of all `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.Key.html`s that are set or supported by this capture request.

| See also |
|---|---|
| `https://developer.android.com/reference/android/hardware/camera2/CaptureRequest.html#getKeys()` |   |