CameraExtensionSession
abstract class CameraExtensionSession : AutoCloseable
kotlin.Any | |
↳ | android.hardware.camera2.CameraExtensionSession |
A camera capture session that enables access to device-specific camera extensions, which often use multi-frame bursts and sophisticated post-process algorithms for image capture.
The capture session will be returned after a successful call to CameraDevice.createExtensionSession
as part of the argument in the registered state callback StateCallback.onConfigured
method.
Note that CameraExtensionSession is currently limited to a maximum of two output surfaces for continuous repeating and multi-frame processing respectively. Some features such as capture settings will not be supported as the device-specific Extension is allowed to override all capture parameters.
Information about support for specific device-specific extensions can be queried from CameraExtensionCharacteristics
.
Summary
Nested classes | |
---|---|
abstract |
A callback object for tracking the progress of a |
abstract |
A callback object for receiving updates about the state of a camera extension session. |
Realtime calculated still |
Public methods | |
---|---|
open Int |
capture(request: CaptureRequest, executor: Executor, listener: CameraExtensionSession.ExtensionCaptureCallback) Submit a request for device-specific processing using input from the camera device, to produce a single high-quality output result. |
open Unit |
close() Close this capture session asynchronously. |
open CameraDevice |
Get the camera device that this session is created for. |
open CameraExtensionSession.StillCaptureLatency? |
Return the realtime still |
open Int |
setRepeatingRequest(request: CaptureRequest, executor: Executor, listener: CameraExtensionSession.ExtensionCaptureCallback) Request endlessly repeating device-specific extension processing of camera images. |
open Unit |
Cancel any ongoing repeating capture set by |
Public methods
capture
open fun capture(
request: CaptureRequest,
executor: Executor,
listener: CameraExtensionSession.ExtensionCaptureCallback
): Int
Submit a request for device-specific processing using input from the camera device, to produce a single high-quality output result.
Note that single capture requests currently do not support client parameters except for controls advertised in CameraExtensionCharacteristics.getAvailableCaptureRequestKeys
. The rest of the settings included in the request will be entirely overridden by the device-specific extension.
If CameraExtensionCharacteristics.isPostviewAvailable
returns false, the CaptureRequest.Builder.addTarget
will support only one ImageFormat.YUV_420_888 or ImageFormat.JPEG target surface. CaptureRequest
arguments that include further targets will cause IllegalArgumentException to be thrown. If postview is available, CaptureRequest.Builder.addTarget
will support up to two ImageFormat.YUV_420_888 or ImageFormat.JPEG target surfaces for the still capture and postview. IllegalArgumentException will be thrown if a postview target is added without a still capture target, if more than two target surfaces are added, or if the surface formats for postview and capture are not equivalent.
Starting with Android android.os.Build.VERSION_CODES#TIRAMISU
single capture requests will also support the preview android.graphics.ImageFormat#PRIVATE
target surface. These can typically be used for enabling AF/AE triggers. Do note, that single capture requests referencing both output surfaces remain unsupported.
Each request will produce one new frame for one target Surface, set with the CaptureRequest builder's CaptureRequest.Builder.addTarget
method.
Multiple requests can be in progress at once. Requests are processed in first-in, first-out order.
Requests submitted through this method have higher priority than those submitted through setRepeatingRequest
, and will be processed as soon as the current repeat processing completes.
Parameters | |
---|---|
request |
CaptureRequest: the settings for this capture This value cannot be null . |
executor |
Executor: the executor which will be used for invoking the listener. This value cannot be null . |
listener |
CameraExtensionSession.ExtensionCaptureCallback: The callback object to notify once this request has been processed. This value cannot be null . |
Return | |
---|---|
Int |
int A unique capture sequence ID used by ExtensionCaptureCallback.onCaptureSequenceCompleted . |
Exceptions | |
---|---|
android.hardware.camera2.CameraAccessException |
if the camera device is no longer connected or has encountered a fatal error |
java.lang.IllegalStateException |
if this session is no longer active, either because the session was explicitly closed, a new session has been created or the camera device has been closed. |
java.lang.IllegalArgumentException |
if the request targets no Surfaces or Surfaces that are not configured as outputs for this session; or the request targets a set of Surfaces that cannot be submitted simultaneously. |
close
open fun close(): Unit
Close this capture session asynchronously.
Closing a session frees up the target output Surfaces of the session for reuse with either a new session, or to other APIs that can draw to Surfaces.
Note that creating a new capture session with android.hardware.camera2.CameraDevice#createCaptureSession or android.hardware.camera2.CameraDevice#createExtensionSession
will close any existing capture session automatically, and call the older session listener's StateCallback.onClosed
callback. Using android.hardware.camera2.CameraDevice#createCaptureSession or android.hardware.camera2.CameraDevice#createExtensionSession
directly without closing is the recommended approach for quickly switching to a new session, since unchanged target outputs can be reused more efficiently.
Once a session is closed, all methods on it will throw an IllegalStateException, and any repeating requests are stopped (as if stopRepeating()
was called).
Closing a session is idempotent; closing more than once has no effect.
Exceptions | |
---|---|
java.lang.Exception |
if this resource cannot be closed |
getDevice
open fun getDevice(): CameraDevice
Get the camera device that this session is created for.
Return | |
---|---|
CameraDevice |
This value cannot be null . |
getRealtimeStillCaptureLatency
open fun getRealtimeStillCaptureLatency(): CameraExtensionSession.StillCaptureLatency?
Return the realtime still capture
latency.
The estimations will take into account the current environment conditions, the camera state and will include the time spent processing the multi-frame capture request along with any additional time for encoding of the processed buffer if necessary.
Return | |
---|---|
CameraExtensionSession.StillCaptureLatency? |
The realtime still capture latency, or null if the estimation is not supported. |
setRepeatingRequest
open fun setRepeatingRequest(
request: CaptureRequest,
executor: Executor,
listener: CameraExtensionSession.ExtensionCaptureCallback
): Int
Request endlessly repeating device-specific extension processing of camera images.
With this method, the camera device will continually capture images and process them using the device-specific extension at the maximum rate possible.
Note that repeating capture requests currently do not support client parameters except for controls advertised in CameraExtensionCharacteristics.getAvailableCaptureRequestKeys
. The rest of the settings included in the request will be entirely overridden by the device-specific extension.
The CaptureRequest.Builder.addTarget
supports only one target surface. CaptureRequest
arguments that include further targets will cause IllegalArgumentException to be thrown.
Repeating requests are a simple way for an application to maintain a preview or other continuous stream of frames.
Repeat requests have lower priority than those submitted through capture
, so if capture
is called when a repeating request is active, the capture request will be processed before any further repeating requests are processed.
To stop the repeating capture, call stopRepeating
.
Calling this method will replace any earlier repeating request.
Parameters | |
---|---|
request |
CaptureRequest: the request to repeat indefinitely This value cannot be null . |
executor |
Executor: the executor which will be used for invoking the listener. This value cannot be null . |
listener |
CameraExtensionSession.ExtensionCaptureCallback: The callback object to notify every time the request finishes processing. This value cannot be null . |
Return | |
---|---|
Int |
int A unique capture sequence ID used by ExtensionCaptureCallback.onCaptureSequenceCompleted . |
Exceptions | |
---|---|
android.hardware.camera2.CameraAccessException |
if the camera device is no longer connected or has encountered a fatal error |
java.lang.IllegalStateException |
if this session is no longer active, either because the session was explicitly closed, a new session has been created or the camera device has been closed. |
java.lang.IllegalArgumentException |
If the request references no Surfaces or references Surfaces that are not currently configured as outputs. |
See Also
stopRepeating
open fun stopRepeating(): Unit
Cancel any ongoing repeating capture set by setRepeatingRequest
. Has no effect on requests submitted through capture
.
Any currently in-flight captures will still complete.
Exceptions | |
---|---|
android.hardware.camera2.CameraAccessException |
if the camera device is no longer connected or has encountered a fatal error |
java.lang.IllegalStateException |
if this session is no longer active, either because the session was explicitly closed, a new session has been created or the camera device has been closed. |
See Also