Camera2Interop.Extender
public final class Camera2Interop.Extender<T>
Extends a ExtendableBuilder to add Camera2 options.
| Parameters | |
|---|---|
<T> |
the type being built by the extendable builder. |
Summary
Public constructors |
|---|
Extender(@NonNull ExtendableBuilder<T> baseBuilder)Creates an Extender that can be used to add Camera2 options to another Builder. |
Public methods |
|
|---|---|
@NonNull Camera2Interop.Extender<T> |
<ValueT> setCaptureRequestOption(Sets a |
@NonNull Camera2Interop.Extender<T> |
setDeviceStateCallback(Sets a |
@NonNull Camera2Interop.Extender<T> |
@RequiresApi(value = 28)Set the ID of the physical camera to get output from. |
@NonNull Camera2Interop.Extender<T> |
setSessionCaptureCallback( |
@NonNull Camera2Interop.Extender<T> |
setSessionStateCallback( |
@NonNull Camera2Interop.Extender<T> |
@RequiresApi(value = 33)Sets a stream use case flag on the given extendable builder. |
Public constructors
Extender
public Extender(@NonNull ExtendableBuilder<T> baseBuilder)
Creates an Extender that can be used to add Camera2 options to another Builder.
| Parameters | |
|---|---|
@NonNull ExtendableBuilder<T> baseBuilder |
The builder being extended. |
Public methods
setCaptureRequestOption
public @NonNull Camera2Interop.Extender<T> <ValueT> setCaptureRequestOption(
@NonNull CaptureRequest.Key<ValueT> key,
@NonNull ValueT value
)
Sets a CaptureRequest.Key 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 | |
|---|---|
<ValueT> |
The type of the value. |
@NonNull CaptureRequest.Key<ValueT> key |
The |
@NonNull ValueT value |
The value for the key. |
| Returns | |
|---|---|
@NonNull Camera2Interop.Extender<T> |
The current Extender. |
setDeviceStateCallback
public @NonNull Camera2Interop.Extender<T> setDeviceStateCallback(
@NonNull CameraDevice.StateCallback stateCallback
)
Sets a CameraDevice.StateCallback.
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 | |
|---|---|
@NonNull CameraDevice.StateCallback stateCallback |
| Returns | |
|---|---|
@NonNull Camera2Interop.Extender<T> |
The current Extender. |
setPhysicalCameraId
@RequiresApi(value = 28)
public @NonNull Camera2Interop.Extender<T> setPhysicalCameraId(@NonNull 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 IllegalArgumentException will be thrown.
| Returns | |
|---|---|
@NonNull Camera2Interop.Extender<T> |
The current Extender. |
setSessionCaptureCallback
public @NonNull Camera2Interop.Extender<T> setSessionCaptureCallback(
@NonNull CameraCaptureSession.CaptureCallback captureCallback
)
Sets a CameraCaptureSession.CaptureCallback.
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 android.view.Surface 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 | |
|---|---|
@NonNull CameraCaptureSession.CaptureCallback captureCallback |
| Returns | |
|---|---|
@NonNull Camera2Interop.Extender<T> |
The current Extender. |
setSessionStateCallback
public @NonNull Camera2Interop.Extender<T> setSessionStateCallback(
@NonNull CameraCaptureSession.StateCallback stateCallback
)
Sets a CameraCaptureSession.StateCallback.
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 android.view.Surface 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 | |
|---|---|
@NonNull CameraCaptureSession.StateCallback stateCallback |
| Returns | |
|---|---|
@NonNull Camera2Interop.Extender<T> |
The current Extender. |
setStreamUseCase
@RequiresApi(value = 33)
public @NonNull Camera2Interop.Extender<T> 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 SCALER_AVAILABLE_STREAM_USE_CASES
No app should call this without double-checking the supported list first, or at least REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE capability which guarantees quite a few use cases.
See setStreamUseCase to see how Camera2 framework uses this.
| Parameters | |
|---|---|
long streamUseCase |
The stream use case to set. |
| Returns | |
|---|---|
@NonNull Camera2Interop.Extender<T> |
The current Extender. |