public final class

Camera2Interop.Extender<T>

extends java.lang.Object

 java.lang.Object

↳androidx.camera.camera2.interop.Camera2Interop.Extender<T>

Overview

Extends a ExtendableBuilder to add Camera2 options.

Summary

Constructors
publicExtender(ExtendableBuilder<java.lang.Object> baseBuilder)

Creates an Extender that can be used to add Camera2 options to another Builder.

Methods
public Camera2Interop.Extender<java.lang.Object>setCaptureRequestOption(<any> key, java.lang.Object value)

Sets a and Value on the configuration.

public Camera2Interop.Extender<java.lang.Object>setCaptureRequestTemplate(int templateType)

Sets a CameraDevice template on the given configuration.

public Camera2Interop.Extender<java.lang.Object>setDeviceStateCallback(CameraDevice.StateCallback stateCallback)

Sets a .

public Camera2Interop.Extender<java.lang.Object>setPhysicalCameraId(java.lang.String cameraId)

Set the ID of the physical camera to get output from.

public Camera2Interop.Extender<java.lang.Object>setSessionCaptureCallback(CameraCaptureSession.CaptureCallback captureCallback)

Sets a .

public Camera2Interop.Extender<java.lang.Object>setSessionStateCallback(CameraCaptureSession.StateCallback stateCallback)

Sets a .

public Camera2Interop.Extender<java.lang.Object>setStreamUseCase(long streamUseCase)

Sets a stream use case flag on the given extendable builder.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Extender(ExtendableBuilder<java.lang.Object> baseBuilder)

Creates an Extender that can be used to add Camera2 options to another Builder.

Parameters:

baseBuilder: The builder being extended.

Methods

public Camera2Interop.Extender<java.lang.Object> setCaptureRequestOption(<any> key, java.lang.Object value)

Sets a and Value on the configuration.

The value will override any value set by CameraX internally with the risk of interfering with some CameraX CameraControl APIs as well as 3A behavior.

Parameters:

key: The which will be set.
value: The value for the key.

Returns:

The current Extender.

public Camera2Interop.Extender<java.lang.Object> setCaptureRequestTemplate(int templateType)

Sets a CameraDevice template on the given configuration.

See CameraDevice for valid template types. For example, CameraDevice.

Only used by ImageCapture to set the template type used. For all other UseCase this value is ignored.

Parameters:

templateType: The template type to set.

Returns:

The current Extender.

public Camera2Interop.Extender<java.lang.Object> setStreamUseCase(long streamUseCase)

Sets a stream use case flag on the given extendable builder.

Requires API 33 or above.

Calling this method will set the stream use case for all CameraX outputs for the same stream session. Valid use cases available on devices can be found in

No app should call this without double-checking the supported list first, or at least capability which guarantees quite a few use cases.

See to see how Camera2 framework uses this.

Parameters:

streamUseCase: The stream use case to set.

Returns:

The current Extender.

public Camera2Interop.Extender<java.lang.Object> setDeviceStateCallback(CameraDevice.StateCallback stateCallback)

Sets a .

The caller is expected to use the CameraDevice instance accessed through the callback methods responsibly. Generally safe usages include: (1) querying the device for its id, (2) using the callbacks to determine what state the device is currently in. Generally unsafe usages include: (1) creating a new CameraCaptureSession, (2) creating a new CaptureRequest, (3) closing the device. When the caller uses the device beyond the safe usage limits, the usage may still work in conjunction with CameraX, but any strong guarantees provided by CameraX about the validity of the camera state become void.

Parameters:

stateCallback: The .

Returns:

The current Extender.

public Camera2Interop.Extender<java.lang.Object> setSessionStateCallback(CameraCaptureSession.StateCallback stateCallback)

Sets a .

The caller is expected to use the CameraCaptureSession instance accessed through the callback methods responsibly. Generally safe usages include: (1) querying the session for its properties, (2) using the callbacks to determine what state the session is currently in. Generally unsafe usages include: (1) submitting a new CaptureRequest, (2) stopping an existing CaptureRequest, (3) closing the session, (4) attaching a new to the session. When the caller uses the session beyond the safe usage limits, the usage may still work in conjunction with CameraX, but any strong guarantees provided by CameraX about the validity of the camera state become void.

Parameters:

stateCallback: The .

Returns:

The current Extender.

public Camera2Interop.Extender<java.lang.Object> setSessionCaptureCallback(CameraCaptureSession.CaptureCallback captureCallback)

Sets a .

The caller is expected to use the CameraCaptureSession instance accessed through the callback methods responsibly. Generally safe usages include: (1) querying the session for its properties. Generally unsafe usages include: (1) submitting a new CaptureRequest, (2) stopping an existing CaptureRequest, (3) closing the session, (4) attaching a new to the session. When the caller uses the session beyond the safe usage limits, the usage may still work in conjunction with CameraX, but any strong guarantees provided by CameraX about the validity of the camera state become void.

The caller is generally free to use the CaptureRequest and CaptureResult instances accessed through the callback methods.

Parameters:

captureCallback: The .

Returns:

The current Extender.

public Camera2Interop.Extender<java.lang.Object> setPhysicalCameraId(java.lang.String cameraId)

Set the ID of the physical camera to get output from.

In the case one logical camera is made up of multiple physical cameras, this call forces the physical camera with the specified camera ID to produce image.

The valid physical camera IDs can be queried by CameraCharacteristics .getPhysicalCameraIds on API >= 28. Passing in an invalid physical camera ID will be ignored.

On API <= 27, the physical camera ID will be ignored since logical camera is not supported on these API levels.

Currently it doesn't support binding use cases with different physical camera IDs. If use cases with different physical camera IDs are bound at the same time, an java.lang.IllegalArgumentException will be thrown.

Parameters:

cameraId: The desired camera ID.

Returns:

The current Extender.