public static final class CaptureRequest.Builder extends Object
To obtain a builder instance, use the
CameraDevice.createCaptureRequest(int)
method, which initializes the
request fields to one of the templates defined in CameraDevice
.
Constructor and Description |
---|
Builder(CameraMetadataNative template,
boolean reprocess,
int reprocessableSessionId)
Initialize the builder using the template; the request takes
ownership of the template.
|
Modifier and Type | Method and Description |
---|---|
void |
addTarget(Surface outputTarget)
Add a surface to the list of targets for this request
The Surface added must be one of the surfaces included in the most
recent call to
CameraDevice.createCaptureSession(java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler) , when the
request is given to the camera device. |
CaptureRequest |
build()
Build a request using the current target Surfaces and settings.
|
<T> T |
get(CaptureRequest.Key<T> key)
Get a capture request field value.
|
boolean |
isEmpty() |
void |
removeTarget(Surface outputTarget)
Remove a surface from the list of targets for this request.
|
<T> void |
set(CaptureRequest.Key<T> key,
T value)
Set a capture request field to a value.
|
void |
setPartOfCHSRequestList(boolean partOfCHSList)
Mark this request as part of a constrained high speed request list created by
CameraConstrainedHighSpeedCaptureSession.createHighSpeedRequestList(android.hardware.camera2.CaptureRequest) . |
void |
setTag(Object tag)
Set a tag for this request.
|
public Builder(CameraMetadataNative template, boolean reprocess, int reprocessableSessionId)
template
- Template settings for this capture request.reprocess
- Indicates whether to create a reprocess capture request. true
to create a reprocess capture request. false
to create a regular
capture request.reprocessableSessionId
- The ID of the camera capture session this capture is
created for. This is used to validate if the application
submits a reprocess capture request to the same session
where the TotalCaptureResult
, used to create the
reprocess capture, came from.IllegalArgumentException
- If creating a reprocess capture request with an invalid
reprocessableSessionId.public void addTarget(Surface outputTarget)
Add a surface to the list of targets for this request
The Surface added must be one of the surfaces included in the most
recent call to CameraDevice.createCaptureSession(java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler)
, when the
request is given to the camera device.
Adding a target more than once has no effect.
outputTarget
- Surface to use as an output target for this requestpublic void removeTarget(Surface outputTarget)
Remove a surface from the list of targets for this request.
Removing a target that is not currently added has no effect.
outputTarget
- Surface to use as an output target for this requestpublic <T> void set(CaptureRequest.Key<T> key, T value)
CaptureRequest
.
Setting a field to null
will remove that field from the capture request.
Unless the field is optional, removing it will likely produce an error from the camera
device when the request is submitted.
key
- The metadata field to write.value
- The value to set the field to, which must be of a matching
type to the key.public <T> T get(CaptureRequest.Key<T> key)
CaptureRequest
.key
- The metadata field to read.null
if the field is not set.IllegalArgumentException
- if the key was not validpublic void setTag(Object tag)
This tag is not used for anything by the camera device, but can be
used by an application to easily identify a CaptureRequest when it is
returned by
CaptureCallback.onCaptureCompleted
tag
- an arbitrary Object to store with this requestCaptureRequest.getTag()
public void setPartOfCHSRequestList(boolean partOfCHSList)
Mark this request as part of a constrained high speed request list created by
CameraConstrainedHighSpeedCaptureSession.createHighSpeedRequestList(android.hardware.camera2.CaptureRequest)
.
A constrained high speed request list contains some constrained high speed capture
requests with certain interleaved pattern that is suitable for high speed preview/video
streaming.
public CaptureRequest build()
Note that, although it is possible to create a CaptureRequest
with no target
Surface
s, passing such a request into CameraCaptureSession.capture(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler)
,
CameraCaptureSession.captureBurst(java.util.List<android.hardware.camera2.CaptureRequest>, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler)
,
CameraCaptureSession.setRepeatingBurst(java.util.List<android.hardware.camera2.CaptureRequest>, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler)
, or
CameraCaptureSession.setRepeatingRequest(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler)
will cause that method to throw an
IllegalArgumentException
.
public boolean isEmpty()