public class CameraDeviceImpl extends CameraDevice implements IBinder.DeathRecipient
Modifier and Type | Class and Description |
---|---|
class |
CameraDeviceImpl.CameraDeviceCallbacks |
static class |
CameraDeviceImpl.CaptureCallback
A callback for tracking the progress of a
CaptureRequest
submitted to the camera device. |
class |
CameraDeviceImpl.FrameNumberTracker
This class tracks the last frame number for submitted requests.
|
static class |
CameraDeviceImpl.StateCallbackKK
A callback for notifications about the state of a camera device, adding in the callbacks that
were part of the earlier KK API design, but now only used internally.
|
CameraDevice.RequestTemplate, CameraDevice.StateCallback, CameraDevice.StateListener
TEMPLATE_MANUAL, TEMPLATE_PREVIEW, TEMPLATE_RECORD, TEMPLATE_STILL_CAPTURE, TEMPLATE_VIDEO_SNAPSHOT, TEMPLATE_ZERO_SHUTTER_LAG
Constructor and Description |
---|
CameraDeviceImpl(String cameraId,
CameraDevice.StateCallback callback,
Handler handler,
CameraCharacteristics characteristics) |
Modifier and Type | Method and Description |
---|---|
void |
binderDied()
Listener for binder death.
|
int |
capture(CaptureRequest request,
CameraDeviceImpl.CaptureCallback callback,
Handler handler) |
int |
captureBurst(List<CaptureRequest> requests,
CameraDeviceImpl.CaptureCallback callback,
Handler handler) |
void |
close()
Close the connection to this camera device as quickly as possible.
|
void |
configureOutputs(List<Surface> outputs) |
boolean |
configureStreamsChecked(InputConfiguration inputConfig,
List<OutputConfiguration> outputs,
boolean isConstrainedHighSpeed)
Attempt to configure the input and outputs; the device goes to idle and then configures the
new input and outputs if possible.
|
CaptureRequest.Builder |
createCaptureRequest(int templateType)
Create a
CaptureRequest.Builder for new capture requests,
initialized with template for a target use case. |
void |
createCaptureSession(List<Surface> outputs,
CameraCaptureSession.StateCallback callback,
Handler handler)
Create a new camera capture session by providing the target output set of Surfaces to the
camera device.
|
void |
createCaptureSessionByOutputConfigurations(List<OutputConfiguration> outputConfigurations,
CameraCaptureSession.StateCallback callback,
Handler handler)
Create a new camera capture session by providing the target output set of Surfaces and
its corresponding surface configuration to the camera device.
|
void |
createConstrainedHighSpeedCaptureSession(List<Surface> outputs,
CameraCaptureSession.StateCallback callback,
Handler handler)
Create a new constrained high speed capture session.
|
void |
createReprocessableCaptureSession(InputConfiguration inputConfig,
List<Surface> outputs,
CameraCaptureSession.StateCallback callback,
Handler handler)
Create a new reprocessable camera capture session by providing the desired reprocessing
input Surface configuration and the target output set of Surfaces to the camera device.
|
void |
createReprocessableCaptureSessionByConfigurations(InputConfiguration inputConfig,
List<OutputConfiguration> outputs,
CameraCaptureSession.StateCallback callback,
Handler handler)
Create a new reprocessable camera capture session by providing the desired reprocessing
input configuration and output
OutputConfiguration
to the camera device. |
CaptureRequest.Builder |
createReprocessCaptureRequest(TotalCaptureResult inputResult)
|
protected void |
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
void |
finishDeferredConfig(List<OutputConfiguration> deferredConfigs) |
void |
flush() |
CameraDeviceImpl.CameraDeviceCallbacks |
getCallbacks() |
String |
getId()
Get the ID of this camera device.
|
void |
prepare(int maxCount,
Surface surface) |
void |
prepare(Surface surface) |
void |
setRemoteDevice(ICameraDeviceUser remoteDevice)
Set remote device, which triggers initial onOpened/onUnconfigured callbacks
This function may post onDisconnected and throw CAMERA_DISCONNECTED if remoteDevice dies
during setup.
|
void |
setRemoteFailure(ServiceSpecificException failure)
Call to indicate failed connection to a remote camera device.
|
int |
setRepeatingBurst(List<CaptureRequest> requests,
CameraDeviceImpl.CaptureCallback callback,
Handler handler) |
int |
setRepeatingRequest(CaptureRequest request,
CameraDeviceImpl.CaptureCallback callback,
Handler handler) |
void |
setSessionListener(CameraDeviceImpl.StateCallbackKK sessionCallback)
For use by backwards-compatibility code only.
|
void |
stopRepeating() |
void |
tearDown(Surface surface) |
public CameraDeviceImpl(String cameraId, CameraDevice.StateCallback callback, Handler handler, CameraCharacteristics characteristics)
public CameraDeviceImpl.CameraDeviceCallbacks getCallbacks()
public void setRemoteDevice(ICameraDeviceUser remoteDevice) throws CameraAccessException
This function may post onDisconnected and throw CAMERA_DISCONNECTED if remoteDevice dies during setup.
CameraAccessException
public void setRemoteFailure(ServiceSpecificException failure)
This places the camera device in the error state and informs the callback. Use in place of setRemoteDevice() when startup fails.
public String getId()
CameraDevice
This matches the ID given to CameraManager.openCamera(java.lang.String, android.hardware.camera2.CameraDevice.StateCallback, android.os.Handler)
to instantiate this
this camera device.
This ID can be used to query the camera device's fixed properties
with CameraManager.getCameraCharacteristics(java.lang.String)
.
This method can be called even if the device has been closed or has encountered a serious error.
getId
in class CameraDevice
CameraManager.getCameraCharacteristics(java.lang.String)
,
CameraManager.getCameraIdList()
public void configureOutputs(List<Surface> outputs) throws CameraAccessException
CameraAccessException
public boolean configureStreamsChecked(InputConfiguration inputConfig, List<OutputConfiguration> outputs, boolean isConstrainedHighSpeed) throws CameraAccessException
The configuration may gracefully fail, if input configuration is not supported,
if there are too many outputs, if the formats are not supported, or if the sizes for that
format is not supported. In this case this function will return false
and the
unconfigured callback will be fired.
If the configuration succeeds (with 1 or more outputs with or without an input), then the idle callback is fired. Unconfiguring the device always fires the idle callback.
inputConfig
- input configuration or null
for no inputoutputs
- a list of one or more surfaces, or null
to unconfigureisConstrainedHighSpeed
- If the streams configuration is for constrained high speed output.CameraAccessException
- if there were any unexpected problems during configurationpublic void createCaptureSession(List<Surface> outputs, CameraCaptureSession.StateCallback callback, Handler handler) throws CameraAccessException
CameraDevice
Create a new camera capture session by providing the target output set of Surfaces to the camera device.
The active capture session determines the set of potential output Surfaces for
the camera device for each capture request. A given request may use all
or only some of the outputs. Once the CameraCaptureSession is created, requests can be
submitted with capture
,
captureBurst
,
setRepeatingRequest
, or
setRepeatingBurst
.
Surfaces suitable for inclusion as a camera output can be created for various use cases and targets:
SurfaceView
: Once the SurfaceView's
Surface is created
, set the size
of the Surface with SurfaceHolder.setFixedSize(int, int)
to be one of the sizes
returned by getOutputSizes(SurfaceHolder.class)
and then obtain the Surface by calling SurfaceHolder.getSurface()
. If the size is not set by the application, it will
be rounded to the nearest supported size less than 1080p, by the camera device.SurfaceTexture
: Set the size of the SurfaceTexture with SurfaceTexture.setDefaultBufferSize(int, int)
to be one of the sizes returned by
getOutputSizes(SurfaceTexture.class)
before creating a Surface from the SurfaceTexture with Surface.Surface(long)
. If the size
is not set by the application, it will be set to be the smallest supported size less than
1080p, by the camera device.MediaCodec
: Call
MediaCodec.createInputSurface()
after configuring
the media codec to use one of the sizes returned by
getOutputSizes(MediaCodec.class)
MediaRecorder
: Call
MediaRecorder.getSurface()
after configuring the media recorder to use
one of the sizes returned by
getOutputSizes(MediaRecorder.class)
,
or configuring it to use one of the supported
CamcorderProfiles
.android.renderscript
:
Create a RenderScript
Allocation
with a supported YUV
type, the IO_INPUT flag, and one of the sizes returned by
getOutputSizes(Allocation.class)
,
Then obtain the Surface with
Allocation.getSurface()
.ImageReader
object with one of the supported output formats given by
StreamConfigurationMap.getOutputFormats()
, setting its size to one of the
corresponding supported sizes by passing the chosen output format into
StreamConfigurationMap.getOutputSizes(int)
. Then obtain a
Surface
from it with ImageReader.getSurface()
.
If the ImageReader size is not set to a supported size, it will be rounded to a supported
size less than 1080p by the camera device.
The camera device will query each Surface's size and formats upon this call, so they must be set to a valid setting at this time.
It can take several hundred milliseconds for the session's configuration to complete,
since camera hardware may need to be powered on or reconfigured. Once the configuration is
complete and the session is ready to actually capture data, the provided
CameraCaptureSession.StateCallback
's
CameraCaptureSession.StateCallback.onConfigured(android.hardware.camera2.CameraCaptureSession)
callback will be called.
If a prior CameraCaptureSession already exists when this method is called, the previous
session will no longer be able to accept new capture requests and will be closed. Any
in-progress capture requests made on the prior session will be completed before it's closed.
CameraCaptureSession.StateCallback.onConfigured(android.hardware.camera2.CameraCaptureSession)
for the new session may be invoked
before CameraCaptureSession.StateCallback.onClosed(android.hardware.camera2.CameraCaptureSession)
is invoked for the prior
session. Once the new session is configured
, it is able to start capturing its own requests. To minimize the transition time,
the CameraCaptureSession.abortCaptures()
call can be used to discard the remaining
requests for the prior capture session before a new one is created. Note that once the new
session is created, the old one can no longer have its captures aborted.
Using larger resolution outputs, or more outputs, can result in slower output rate from the device.
Configuring a session with an empty or null list will close the current session, if any. This can be used to release the current session's target surfaces for another use.
While any of the sizes from StreamConfigurationMap.getOutputSizes(java.lang.Class<T>)
can be used when
a single output stream is configured, a given camera device may not be able to support all
combination of sizes, formats, and targets when multiple outputs are configured at once. The
tables below list the maximum guaranteed resolutions for combinations of streams and targets,
given the capabilities of the camera device.
If an application tries to create a session using a set of targets that exceed the limits
described in the below tables, one of three possibilities may occur. First, the session may
be successfully created and work normally. Second, the session may be successfully created,
but the camera device won't meet the frame rate guarantees as described in
StreamConfigurationMap.getOutputMinFrameDuration(int, android.util.Size)
. Or third, if the output set
cannot be used at all, session creation will fail entirely, with
CameraCaptureSession.StateCallback.onConfigureFailed(android.hardware.camera2.CameraCaptureSession)
being invoked.
For the type column, PRIV
refers to any target whose available sizes are found
using StreamConfigurationMap.getOutputSizes(Class)
with no direct application-visible
format, YUV
refers to a target Surface using the
ImageFormat.YUV_420_888
format, JPEG
refers to the
ImageFormat.JPEG
format, and RAW
refers to the
ImageFormat.RAW_SENSOR
format.
For the maximum size column, PREVIEW
refers to the best size match to the
device's screen resolution, or to 1080p (1920x1080
), whichever is
smaller. RECORD
refers to the camera device's maximum supported recording resolution,
as determined by CamcorderProfile
. And MAXIMUM
refers to the
camera device's maximum output resolution for that format or target from
StreamConfigurationMap.getOutputSizes(java.lang.Class<T>)
.
To use these tables, determine the number and the formats/targets of outputs needed, and
find the row(s) of the table with those targets. The sizes indicate the maximum set of sizes
that can be used; it is guaranteed that for those targets, the listed sizes and anything
smaller from the list given by StreamConfigurationMap.getOutputSizes(java.lang.Class<T>)
can be
successfully used to create a session. For example, if a row indicates that a 8 megapixel
(MP) YUV_420_888 output can be used together with a 2 MP PRIV
output, then a session
can be created with targets [8 MP YUV, 2 MP PRIV]
or targets [2 MP YUV, 2 MP
PRIV]
; but a session with targets [8 MP YUV, 4 MP PRIV]
, targets [4 MP YUV, 4
MP PRIV]
, or targets [8 MP PRIV, 2 MP YUV]
would not be guaranteed to work, unless
some other row of the table lists such a combination.
Legacy devices (CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL
==
LEGACY
) support at
least the following stream combinations:
LEGACY-level guaranteed configurations | ||||||
---|---|---|---|---|---|---|
Target 1 | Target 2 | Target 3 | Sample use case(s) | |||
Type | Max size | Type | Max size | Type | Max size | |
PRIV | MAXIMUM | Simple preview, GPU video processing, or no-preview video recording. | ||||
JPEG | MAXIMUM | No-viewfinder still image capture. | ||||
YUV | MAXIMUM | In-application video/image processing. | ||||
PRIV | PREVIEW | JPEG | MAXIMUM | Standard still imaging. | ||
YUV | PREVIEW | JPEG | MAXIMUM | In-app processing plus still capture. | ||
PRIV | PREVIEW | PRIV | PREVIEW | Standard recording. | ||
PRIV | PREVIEW | YUV | PREVIEW | Preview plus in-app processing. | ||
PRIV | PREVIEW | YUV | PREVIEW | JPEG | MAXIMUM | Still capture plus in-app processing. |
Limited-level (CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL
==
LIMITED
) devices
support at least the following stream combinations in addition to those for
LEGACY
devices:
LIMITED-level additional guaranteed configurations | ||||||
---|---|---|---|---|---|---|
Target 1 | Target 2 | Target 3 | Sample use case(s) | |||
Type | Max size | Type | Max size | Type | Max size | |
PRIV | PREVIEW | PRIV | RECORD | High-resolution video recording with preview. | ||
PRIV | PREVIEW | YUV | RECORD | High-resolution in-app video processing with preview. | ||
YUV | PREVIEW | YUV | RECORD | Two-input in-app video processing. | ||
PRIV | PREVIEW | PRIV | RECORD | JPEG | RECORD | High-resolution recording with video snapshot. |
PRIV | PREVIEW | YUV | RECORD | JPEG | RECORD | High-resolution in-app processing with video snapshot. |
YUV | PREVIEW | YUV | PREVIEW | JPEG | MAXIMUM | Two-input in-app processing with still capture. |
FULL-level (CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL
==
FULL
) devices
support at least the following stream combinations in addition to those for
LIMITED
devices:
FULL-level additional guaranteed configurations | ||||||
---|---|---|---|---|---|---|
Target 1 | Target 2 | Target 3 | Sample use case(s) | |||
Type | Max size | Type | Max size | Type | Max size | |
PRIV | PREVIEW | PRIV | MAXIMUM | Maximum-resolution GPU processing with preview. | ||
PRIV | PREVIEW | YUV | MAXIMUM | Maximum-resolution in-app processing with preview. | ||
YUV | PREVIEW | YUV | MAXIMUM | Maximum-resolution two-input in-app processsing. | ||
PRIV | PREVIEW | PRIV | PREVIEW | JPEG | MAXIMUM | Video recording with maximum-size video snapshot |
YUV | 640x480 | PRIV | PREVIEW | YUV | MAXIMUM | Standard video recording plus maximum-resolution in-app processing. |
YUV | 640x480 | YUV | PREVIEW | YUV | MAXIMUM | Preview plus two-input maximum-resolution in-app processing. |
RAW-capability (CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES
includes
RAW
) devices additionally support
at least the following stream combinations on both
FULL
and
LIMITED
devices:
RAW-capability additional guaranteed configurations | ||||||
---|---|---|---|---|---|---|
Target 1 | Target 2 | Target 3 | Sample use case(s) | |||
Type | Max size | Type | Max size | Type | Max size | |
RAW | MAXIMUM | No-preview DNG capture. | ||||
PRIV | PREVIEW | RAW | MAXIMUM | Standard DNG capture. | ||
YUV | PREVIEW | RAW | MAXIMUM | In-app processing plus DNG capture. | ||
PRIV | PREVIEW | PRIV | PREVIEW | RAW | MAXIMUM | Video recording with DNG capture. |
PRIV | PREVIEW | YUV | PREVIEW | RAW | MAXIMUM | Preview with in-app processing and DNG capture. |
YUV | PREVIEW | YUV | PREVIEW | RAW | MAXIMUM | Two-input in-app processing plus DNG capture. |
PRIV | PREVIEW | JPEG | MAXIMUM | RAW | MAXIMUM | Still capture with simultaneous JPEG and DNG. |
YUV | PREVIEW | JPEG | MAXIMUM | RAW | MAXIMUM | In-app processing with simultaneous JPEG and DNG. |
BURST-capability (CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES
includes
BURST_CAPTURE
) devices
support at least the below stream combinations in addition to those for
LIMITED
devices. Note that all
FULL-level devices support the BURST capability, and the below list is a strict subset of the
list for FULL-level devices, so this table is only relevant for LIMITED-level devices that
support the BURST_CAPTURE capability.
BURST-capability additional guaranteed configurations | ||||
---|---|---|---|---|
Target 1 | Target 2 | Sample use case(s) | ||
Type | Max size | Type | Max size | |
PRIV | PREVIEW | PRIV | MAXIMUM | Maximum-resolution GPU processing with preview. |
PRIV | PREVIEW | YUV | MAXIMUM | Maximum-resolution in-app processing with preview. |
YUV | PREVIEW | YUV | MAXIMUM | Maximum-resolution two-input in-app processsing. |
LEVEL-3 (CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL
==
LEVEL_3
)
support at least the following stream combinations in addition to the combinations for
FULL
and for
RAW capability (CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES
includes
RAW
):
LEVEL-3 additional guaranteed configurations | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Target 1 | Target 2 | Target 3 | Target 4 | Sample use case(s) | ||||||
Type | Max size | Type | Max size | Type | Max size | Type | Max size | |||
PRIV | PREVIEW | PRIV | 640x480 | YUV | MAXIMUM | RAW | MAXIMUM | In-app viewfinder analysis with dynamic selection of output format. | ||
PRIV | PREVIEW | PRIV | 640x480 | JPEG | MAXIMUM | RAW | MAXIMUM | In-app viewfinder analysis with dynamic selection of output format. |
Since the capabilities of camera devices vary greatly, a given camera device may support target combinations with sizes outside of these guarantees, but this can only be tested for by attempting to create a session with such targets.
createCaptureSession
in class CameraDevice
outputs
- The new set of Surfaces that should be made available as
targets for captured image data.callback
- The callback to notify about the status of the new capture session.handler
- The handler on which the callback should be invoked, or null
to use
the current thread's looper
.CameraAccessException
- if the camera device is no longer connected or has
encountered a fatal errorCameraCaptureSession
,
StreamConfigurationMap.getOutputFormats()
,
StreamConfigurationMap.getOutputSizes(int)
,
StreamConfigurationMap.getOutputSizes(Class)
public void createCaptureSessionByOutputConfigurations(List<OutputConfiguration> outputConfigurations, CameraCaptureSession.StateCallback callback, Handler handler) throws CameraAccessException
CameraDevice
Create a new camera capture session by providing the target output set of Surfaces and its corresponding surface configuration to the camera device.
public void createReprocessableCaptureSession(InputConfiguration inputConfig, List<Surface> outputs, CameraCaptureSession.StateCallback callback, Handler handler) throws CameraAccessException
CameraDevice
If a camera device supports YUV reprocessing
(CameraMetadata.REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING
) or PRIVATE
reprocessing
(CameraMetadata.REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING
), besides
the capture session created via createCaptureSession
, the
application can also create a reprocessable capture session to submit reprocess capture
requests in addition to regular capture requests. A reprocess capture request takes the next
available buffer from the session's input Surface, and sends it through the camera device's
processing pipeline again, to produce buffers for the request's target output Surfaces. No
new image data is captured for a reprocess request. However the input buffer provided by
the application must be captured previously by the same camera device in the same session
directly (e.g. for Zero-Shutter-Lag use case) or indirectly (e.g. combining multiple output
images).
The active reprocessable capture session determines an input Surface
and the set
of potential output Surfaces for the camera devices for each capture request. The application
can use createCaptureRequest
to create regular capture requests
to capture new images from the camera device, and use createReprocessCaptureRequest
to create reprocess capture requests to process buffers from
the input Surface
. Some combinations of output Surfaces in a session may not be used
in a request simultaneously. The guaranteed combinations of output Surfaces that can be used
in a request simultaneously are listed in the tables under createCaptureSession
. All the output Surfaces in one capture request will come from the
same source, either from a new capture by the camera device, or from the input Surface
depending on if the request is a reprocess capture request.
Input formats and sizes supported by the camera device can be queried via
StreamConfigurationMap.getInputFormats()
and
StreamConfigurationMap.getInputSizes(int)
. For each supported input format, the camera
device supports a set of output formats and sizes for reprocessing that can be queried via
StreamConfigurationMap.getValidOutputFormatsForInput(int)
and
StreamConfigurationMap.getOutputSizes(java.lang.Class<T>)
. While output Surfaces with formats that
aren't valid reprocess output targets for the input configuration can be part of a session,
they cannot be used as targets for a reprocessing request.
Since the application cannot access ImageFormat.PRIVATE
images
directly, an output Surface created by ImageReader.newInstance(int, int, int, int)
with
ImageFormat.PRIVATE
as the format will be considered as intended to
be used for reprocessing input and thus the ImageReader
size must
match one of the supported input sizes for ImageFormat.PRIVATE
format. Otherwise, creating a reprocessable capture session will fail.
The guaranteed stream configurations listed in
createCaptureSession
are also guaranteed to work for
createReprocessableCaptureSession
. In addition,
the configurations in the tables below are also guaranteed for creating a reprocessable
capture session if the camera device supports YUV reprocessing or PRIVATE reprocessing.
However, not all output targets used to create a reprocessable session may be used in a
CaptureRequest
simultaneously. For devices that support only 1 output target in a
reprocess CaptureRequest
, submitting a reprocess CaptureRequest
with multiple
output targets will result in a CaptureFailure
. For devices that support multiple
output targets in a reprocess CaptureRequest
, the guaranteed output targets that can
be included in a CaptureRequest
simultaneously are listed in the tables under
createCaptureSession
. For example, with a FULL-capability
(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL
==
FULL
) device that supports PRIVATE
reprocessing, an application can create a reprocessable capture session with 1 input,
(PRIV
, MAXIMUM
), and 3 outputs, (PRIV
, MAXIMUM
),
(PRIV
, PREVIEW
), and (YUV
, MAXIMUM
). However, it's not
guaranteed that an application can submit a regular or reprocess capture with (PRIV
,
MAXIMUM
) and (YUV
, MAXIMUM
) outputs based on the table listed under
createCaptureSession
. In other words, use the tables below to
determine the guaranteed stream configurations for creating a reprocessable capture session,
and use the tables under createCaptureSession
to determine the
guaranteed output targets that can be submitted in a regular or reprocess
CaptureRequest
simultaneously.
LIMITED-level (CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL
==
LIMITED
) devices
support at least the following stream combinations for creating a reprocessable capture
session in addition to those listed in createCaptureSession
for
LIMITED
devices:
LIMITED-level additional guaranteed configurations for creating a reprocessable capture session ( PRIV input is guaranteed only if PRIVATE reprocessing is supported. YUV input is guaranteed only if YUV reprocessing is supported) | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Input | Target 1 | Target 2 | Target 3 | Target 4 | Sample use case(s) | |||||
Type | Max size | Type | Max size | Type | Max size | Type | Max size | Type | Max size | |
PRIV /YUV | MAXIMUM | Same as input | MAXIMUM | JPEG | MAXIMUM | No-viewfinder still image reprocessing. | ||||
PRIV /YUV | MAXIMUM | Same as input | MAXIMUM | PRIV | PREVIEW | JPEG | MAXIMUM | ZSL(Zero-Shutter-Lag) still imaging. | ||
PRIV /YUV | MAXIMUM | Same as input | MAXIMUM | YUV | PREVIEW | JPEG | MAXIMUM | ZSL still and in-app processing imaging. | ||
PRIV /YUV | MAXIMUM | Same as input | MAXIMUM | YUV | PREVIEW | YUV | PREVIEW | JPEG | MAXIMUM | ZSL in-app processing with still capture. |
FULL-level (CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL
==
FULL
) devices
support at least the following stream combinations for creating a reprocessable capture
session in addition to those for
LIMITED
devices:
FULL-level additional guaranteed configurations for creating a reprocessable capture session ( PRIV input is guaranteed only if PRIVATE reprocessing is supported. YUV input is guaranteed only if YUV reprocessing is supported) | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Input | Target 1 | Target 2 | Target 3 | Target 4 | Sample use case(s) | |||||
Type | Max size | Type | Max size | Type | Max size | Type | Max size | Type | Max size | |
YUV | MAXIMUM | YUV | MAXIMUM | PRIV | PREVIEW | Maximum-resolution multi-frame image fusion in-app processing with regular preview. | ||||
YUV | MAXIMUM | YUV | MAXIMUM | YUV | PREVIEW | Maximum-resolution multi-frame image fusion two-input in-app processing. | ||||
PRIV /YUV | MAXIMUM | Same as input | MAXIMUM | PRIV | PREVIEW | YUV | RECORD | High-resolution ZSL in-app video processing with regular preview. | ||
PRIV | MAXIMUM | PRIV | MAXIMUM | PRIV | PREVIEW | YUV | MAXIMUM | Maximum-resolution ZSL in-app processing with regular preview. | ||
PRIV | MAXIMUM | PRIV | MAXIMUM | YUV | PREVIEW | YUV | MAXIMUM | Maximum-resolution two-input ZSL in-app processing. | ||
PRIV /YUV | MAXIMUM | Same as input | MAXIMUM | PRIV | PREVIEW | YUV | PREVIEW | JPEG | MAXIMUM | ZSL still capture and in-app processing. |
RAW-capability (CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES
includes
RAW
) devices additionally support
at least the following stream combinations for creating a reprocessable capture session
on both FULL
and
LIMITED
devices
RAW-capability additional guaranteed configurations for creating a reprocessable capture session ( PRIV input is guaranteed only if PRIVATE reprocessing is supported. YUV input is guaranteed only if YUV reprocessing is supported) | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Input | Target 1 | Target 2 | Target 3 | Target 4 | Sample use case(s) | |||||
Type | Max size | Type | Max size | Type | Max size | Type | Max size | Type | Max size | |
PRIV /YUV | MAXIMUM | Same as input | MAXIMUM | YUV | PREVIEW | RAW | MAXIMUM | Mutually exclusive ZSL in-app processing and DNG capture. | ||
PRIV /YUV | MAXIMUM | Same as input | MAXIMUM | PRIV | PREVIEW | YUV | PREVIEW | RAW | MAXIMUM | Mutually exclusive ZSL in-app processing and preview with DNG capture. |
PRIV /YUV | MAXIMUM | Same as input | MAXIMUM | YUV | PREVIEW | YUV | PREVIEW | RAW | MAXIMUM | Mutually exclusive ZSL two-input in-app processing and DNG capture. |
PRIV /YUV | MAXIMUM | Same as input | MAXIMUM | PRIV | PREVIEW | JPEG | MAXIMUM | RAW | MAXIMUM | Mutually exclusive ZSL still capture and preview with DNG capture. |
PRIV /YUV | MAXIMUM | Same as input | MAXIMUM | YUV | PREVIEW | JPEG | MAXIMUM | RAW | MAXIMUM | Mutually exclusive ZSL in-app processing with still capture and DNG capture. |
LEVEL-3 (CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL
==
LEVEL_3
) devices
support at least the following stream combinations for creating a reprocessable capture
session in addition to those for
FULL
devices. Note that while
the second configuration allows for configuring MAXIMUM
YUV
and JPEG
outputs at the same time, that configuration is not listed for regular capture sessions, and
therefore simultaneous output to both targets is not allowed.
LEVEL-3 additional guaranteed configurations for creating a reprocessable capture session ( PRIV input is guaranteed only if PRIVATE reprocessing is supported. YUV input is always guaranteed. | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Input | Target 1 | Target 2 | Target 3 | Target 4 | Target 5 | Sample use case(s) | ||||||
Type | Max size | Type | Max size | Type | Max size | Type | Max size | Type | Max size | Type | Max size | |
YUV | MAXIMUM | YUV | MAXIMUM | PRIV | PREVIEW | PRIV | 640x480 | RAW | MAXIMUM | In-app viewfinder analysis with ZSL and RAW. | ||
PRIV /YUV | MAXIMUM | Same as input | MAXIMUM | PRIV | PREVIEW | PRIV | 640x480 | RAW | MAXIMUM | JPEG | MAXIMUM | In-app viewfinder analysis with ZSL, RAW, and JPEG reprocessing output. |
createReprocessableCaptureSession
in class CameraDevice
inputConfig
- The configuration for the input Surface
outputs
- The new set of Surfaces that should be made available as
targets for captured image data.callback
- The callback to notify about the status of the new capture session.handler
- The handler on which the callback should be invoked, or null
to use
the current thread's looper
.CameraAccessException
- if the camera device is no longer connected or has
encountered a fatal errorCameraDevice.createCaptureSession(java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler)
,
CameraCaptureSession
,
StreamConfigurationMap.getInputFormats()
,
StreamConfigurationMap.getInputSizes(int)
,
StreamConfigurationMap.getValidOutputFormatsForInput(int)
,
StreamConfigurationMap.getOutputSizes(java.lang.Class<T>)
,
ImageWriter
,
ImageReader
public void createReprocessableCaptureSessionByConfigurations(InputConfiguration inputConfig, List<OutputConfiguration> outputs, CameraCaptureSession.StateCallback callback, Handler handler) throws CameraAccessException
CameraDevice
OutputConfiguration
to the camera device.createReprocessableCaptureSessionByConfigurations
in class CameraDevice
CameraAccessException
CameraDevice.createReprocessableCaptureSession(android.hardware.camera2.params.InputConfiguration, java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler)
,
OutputConfiguration
public void createConstrainedHighSpeedCaptureSession(List<Surface> outputs, CameraCaptureSession.StateCallback callback, Handler handler) throws CameraAccessException
CameraDevice
Create a new constrained high speed capture session.
The application can use normal capture session (created via CameraDevice.createCaptureSession(java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler)
)
for high speed capture if the desired high speed FPS ranges are advertised by
CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES
, in which case all API
semantics associated with normal capture sessions applies.
The method creates a specialized capture session that is only targeted at high speed
video recording (>=120fps) use case if the camera device supports high speed video
capability (i.e., CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES
contains
CameraMetadata.REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO
).
Therefore, it has special characteristics compared with a normal capture session:
CameraDevice.createCaptureSession(java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler)
method, an active high speed capture session will support up
to 2 output Surfaces, though the application might choose to configure just one Surface
(e.g., preview only). All Surfaces must be either video encoder surfaces (acquired by
MediaRecorder.getSurface()
or
MediaCodec.createInputSurface()
) or preview surfaces (obtained from
SurfaceView
, SurfaceTexture
via
Surface.Surface(android.graphics.SurfaceTexture)
). The Surface sizes
must be one of the sizes reported by StreamConfigurationMap.getHighSpeedVideoSizes()
.
When multiple Surfaces are configured, their size must be same.CameraConstrainedHighSpeedCaptureSession.createHighSpeedRequestList(android.hardware.camera2.CaptureRequest)
, and the
request list can only be submitted to this session via
captureBurst
, or
setRepeatingBurst
.StreamConfigurationMap.getHighSpeedVideoFpsRangesFor(android.util.Size)
. The application can still use
CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE
to control the desired FPS range.
Switching to an FPS range that has different
maximum FPS
may trigger some camera device
reconfigurations, which may introduce extra latency. It is recommended that the
application avoids unnecessary maximum target FPS changes as much as possible during high
speed streaming.control mode
, auto-exposure (AE), auto-white balance
(AWB) and auto-focus (AF) to CameraMetadata.CONTROL_MODE_AUTO
,
CameraMetadata.CONTROL_AE_MODE_ON
, CameraMetadata.CONTROL_AWB_MODE_AUTO
and CameraMetadata.CONTROL_AF_MODE_CONTINUOUS_VIDEO
, respectively. All
post-processing block mode controls will be overridden to be FAST. Therefore, no manual
control of capture and post-processing parameters is possible. Beside these, only a subset
of controls will work, see
CameraMetadata.REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO
for
more details.createConstrainedHighSpeedCaptureSession
in class CameraDevice
outputs
- The new set of Surfaces that should be made available as
targets for captured high speed image data.callback
- The callback to notify about the status of the new capture session.handler
- The handler on which the callback should be invoked, or null
to use
the current thread's looper
.CameraAccessException
- if the camera device is no longer connected or has
encountered a fatal errorCameraDevice.createCaptureSession(java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler)
,
CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE
,
StreamConfigurationMap.getHighSpeedVideoSizes()
,
StreamConfigurationMap.getHighSpeedVideoFpsRangesFor(android.util.Size)
,
CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES
,
CameraMetadata.REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO
,
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)
,
CameraConstrainedHighSpeedCaptureSession.createHighSpeedRequestList(android.hardware.camera2.CaptureRequest)
public void setSessionListener(CameraDeviceImpl.StateCallbackKK sessionCallback)
public CaptureRequest.Builder createCaptureRequest(int templateType) throws CameraAccessException
CameraDevice
Create a CaptureRequest.Builder
for new capture requests,
initialized with template for a target use case. The settings are chosen
to be the best options for the specific camera device, so it is not
recommended to reuse the same request for a different camera device;
create a builder specific for that device and template and override the
settings as desired, instead.
createCaptureRequest
in class CameraDevice
templateType
- An enumeration selecting the use case for this
request; one of the CameraDevice.TEMPLATE_ values. Not all template
types are supported on every device. See the documentation for each
template type for details.CameraAccessException
- if the camera device is no longer connected or has
encountered a fatal errorCameraDevice.TEMPLATE_PREVIEW
,
CameraDevice.TEMPLATE_RECORD
,
CameraDevice.TEMPLATE_STILL_CAPTURE
,
CameraDevice.TEMPLATE_VIDEO_SNAPSHOT
,
CameraDevice.TEMPLATE_MANUAL
public CaptureRequest.Builder createReprocessCaptureRequest(TotalCaptureResult inputResult) throws CameraAccessException
CameraDevice
Create a CaptureRequest.Builder
for a new reprocess CaptureRequest
from a
TotalCaptureResult
.
Each reprocess CaptureRequest
processes one buffer from
CameraCaptureSession
's input Surface
to all output Surfaces
included in the reprocess capture request. The reprocess input images must be generated from
one or multiple output images captured from the same camera device. The application can
provide input images to camera device via ImageWriter.queueInputImage(android.media.Image)
.
The application must use the capture result of one of those output images to create a
reprocess capture request so that the camera device can use the information to achieve
optimal reprocess image quality. For camera devices that support only 1 output
Surface
, submitting a reprocess CaptureRequest
with multiple
output targets will result in a CaptureFailure
.
createReprocessCaptureRequest
in class CameraDevice
inputResult
- The capture result of the output image or one of the output images used
to generate the reprocess input image for this capture request.CameraAccessException
- if the camera device is no longer connected or has
encountered a fatal errorCaptureRequest.Builder
,
TotalCaptureResult
,
CameraDevice.createReprocessableCaptureSession(android.hardware.camera2.params.InputConfiguration, java.util.List<android.view.Surface>, android.hardware.camera2.CameraCaptureSession.StateCallback, android.os.Handler)
,
ImageWriter
public void prepare(Surface surface) throws CameraAccessException
CameraAccessException
public void prepare(int maxCount, Surface surface) throws CameraAccessException
CameraAccessException
public void tearDown(Surface surface) throws CameraAccessException
CameraAccessException
public void finishDeferredConfig(List<OutputConfiguration> deferredConfigs) throws CameraAccessException
CameraAccessException
public int capture(CaptureRequest request, CameraDeviceImpl.CaptureCallback callback, Handler handler) throws CameraAccessException
CameraAccessException
public int captureBurst(List<CaptureRequest> requests, CameraDeviceImpl.CaptureCallback callback, Handler handler) throws CameraAccessException
CameraAccessException
public int setRepeatingRequest(CaptureRequest request, CameraDeviceImpl.CaptureCallback callback, Handler handler) throws CameraAccessException
CameraAccessException
public int setRepeatingBurst(List<CaptureRequest> requests, CameraDeviceImpl.CaptureCallback callback, Handler handler) throws CameraAccessException
CameraAccessException
public void stopRepeating() throws CameraAccessException
CameraAccessException
public void flush() throws CameraAccessException
CameraAccessException
public void close()
CameraDevice
Immediately after this call, all calls to the camera device or active session interface
will throw a IllegalStateException
, except for calls to close(). Once the device has
fully shut down, the CameraDevice.StateCallback.onClosed(android.hardware.camera2.CameraDevice)
callback will be called, and the camera
is free to be re-opened.
Immediately after this call, besides the final CameraDevice.StateCallback.onClosed(android.hardware.camera2.CameraDevice)
calls, no
further callbacks from the device or the active session will occur, and any remaining
submitted capture requests will be discarded, as if
CameraCaptureSession.abortCaptures()
had been called, except that no success or failure
callbacks will be invoked.
close
in interface AutoCloseable
close
in class CameraDevice
protected void finalize() throws Throwable
Object
finalize
method to dispose of
system resources or to perform other cleanup.
The general contract of finalize
is that it is invoked
if and when the JavaTM virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The finalize
method may take any action, including
making this object available again to other threads; the usual purpose
of finalize
, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.
The finalize
method of class Object
performs no
special action; it simply returns normally. Subclasses of
Object
may override this definition.
The Java programming language does not guarantee which thread will
invoke the finalize
method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.
After the finalize
method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.
The finalize
method is never invoked more than once by a Java
virtual machine for any given object.
Any exception thrown by the finalize
method causes
the finalization of this object to be halted, but is otherwise
ignored.
public void binderDied()
Handle binder death for ICameraDeviceUser. Trigger onError.
binderDied
in interface IBinder.DeathRecipient