Skip to content
com.iristick.smartglass.support.camera2

Interface CameraCaptureSession

All Superinterfaces:
AutoCloseable
All Known Subinterfaces:
CameraConstrainedHighSpeedCaptureSession

Deprecated. 
Not maintained anymore. Please use the com.iristick.smartglass.core.camera package instead.

@Deprecated
public interface CameraCaptureSession
extends AutoCloseable
A configured capture session for a CameraDevice, used for capturing images from the camera or reprocessing images captured from the camera in the same session previously.

A CameraCaptureSession is created by providing a set of target output surfaces to createCaptureSession, or by providing an InputConfiguration and a set of target output surfaces to createReprocessableCaptureSession for a reprocessable capture session. Once created, the session is active until a new session is created by the camera device, or the camera device is closed.

All capture sessions can be used for capturing images from the camera but only reprocessable capture sessions can reprocess images captured from the camera in the same session previously.

Creating a session is an expensive operation and can take several hundred milliseconds, since it requires configuring the camera device's internal pipelines and allocating memory buffers for sending images to the desired targets. Therefore the setup is done asynchronously, and createCaptureSession and createReprocessableCaptureSession will send the ready-to-use CameraCaptureSession to the provided listener's onConfigured callback. If configuration cannot be completed, then the onConfigureFailed is called, and the session will not become active.

If a new session is created by the camera device, then the previous session is closed, and its associated onClosed callback will be invoked. All of the session methods will throw an IllegalStateException if called once the session is closed.

A closed session clears any repeating requests (as if stopRepeating() had been called), but will still complete all of its in-progress capture requests as normal, before a newly created session takes over and reconfigures the camera device.

Since:
Android API level 21

Nested Class Summary

Modifier and Type Interface and Description
static class  CameraCaptureSession.CaptureCallback
Deprecated. 
A callback object for tracking the progress of a CaptureRequest submitted to the camera device.
static class  CameraCaptureSession.StateCallback
Deprecated. 
A callback object for receiving updates about the state of a camera capture session.

Method Summary

Modifier and Type Method and Description
void abortCaptures()
Deprecated. 
Discard all captures currently pending and in-progress as fast as possible.
int capture(CaptureRequest request, CameraCaptureSession.CaptureCallback listener, Handler handler)
Deprecated. 
Submit a request for an image to be captured by the camera device.
int captureBurst(List<CaptureRequest> requests, CameraCaptureSession.CaptureCallback listener, Handler handler)
Deprecated. 
Submit a list of requests to be captured in sequence as a burst.
void close()
Deprecated. 
Close this capture session asynchronously.
void finalizeOutputConfigurations(List<OutputConfiguration> outputConfigs)
Deprecated. 
Finalize the output configurations that now have their deferred and/or extra Surfaces included.
CameraDevice getDevice()
Deprecated. 
Get the camera device that this session is created for.
Surface getInputSurface()
Deprecated. 
Get the input Surface associated with a reprocessable capture session.
boolean isReprocessable()
Deprecated. 
Return if the application can submit reprocess capture requests with this camera capture session.
void prepare(Surface surface)
Deprecated. 
Pre-allocate all buffers for an output Surface.
int setRepeatingBurst(List<CaptureRequest> requests, CameraCaptureSession.CaptureCallback listener, Handler handler)
Deprecated. 
Request endlessly repeating capture of a sequence of images by this capture session.
int setRepeatingRequest(CaptureRequest request, CameraCaptureSession.CaptureCallback listener, Handler handler)
Deprecated. 
Request endlessly repeating capture of images by this capture session.
void stopRepeating()
Deprecated. 

Method Detail

getDevice

CameraDevice getDevice()
Deprecated. 
Get the camera device that this session is created for.
Returns:
The camera device.

prepare

void prepare(Surface surface)
      throws CameraAccessException
Deprecated. 

Pre-allocate all buffers for an output Surface.

Normally, the image buffers for a given output Surface are allocated on-demand, to minimize startup latency and memory overhead.

However, in some cases, it may be desirable for the buffers to be allocated before any requests targeting the Surface are actually submitted to the device. Large buffers may take some time to allocate, which can result in delays in submitting requests until sufficient buffers are allocated to reach steady-state behavior. Such delays can cause bursts to take longer than desired, or cause skips or stutters in preview output.

The prepare() method can be used to perform this preallocation. It may only be called for a given output Surface before that Surface is used as a target for a request. The number of buffers allocated is the sum of the count needed by the consumer providing the output Surface, and the maximum number needed by the camera device to fill its pipeline. Since this may be a larger number than what is actually required for steady-state operation, using prepare may result in higher memory consumption than the normal on-demand behavior results in. Prepare() will also delay the time to first output to a given Surface, in exchange for smoother frame rate once the allocation is complete.

For example, an application that creates an ImageReader with a maxImages argument of 10, but only uses 3 simultaneous Images at once would normally only cause those 3 images to be allocated (plus what is needed by the camera device for smooth operation). But using prepare() on the ImageReader Surface will result in all 10 Images being allocated. So applications using this method should take care to request only the number of buffers actually necessary for their application.

If the same output Surface is used in consecutive sessions (without closing the first session explicitly), then its already-allocated buffers are carried over, and if it was used as a target of a capture request in the first session, prepare cannot be called on it in the second session.

Once allocation is complete, CameraCaptureSession.StateCallback.onSurfacePrepared(com.iristick.smartglass.support.camera2.CameraCaptureSession, android.view.Surface) will be invoked with the Surface provided to this method. Between the prepare call and the onSurfacePrepared call, the Surface provided to prepare must not be used as a target of a CaptureRequest submitted to this session.

Note that if 2 surfaces share the same stream via OutputConfiguration.enableSurfaceSharing() and OutputConfiguration.addSurface(android.view.Surface), prepare() only needs to be called on one surface, and {link StateCallback#onSurfacePrepared} will be triggered for both surfaces.

LEGACY devices cannot pre-allocate output buffers; for those devices, CameraCaptureSession.StateCallback.onSurfacePrepared(com.iristick.smartglass.support.camera2.CameraCaptureSession, android.view.Surface) will be immediately called, and no preallocation is done.

Parameters:
surface - the output Surface for which buffers should be pre-allocated. Must be one of the output Surfaces used to create this session.
Throws:
CameraAccessException - if the camera device is no longer connected or has encountered a fatal error
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.
IllegalArgumentException - if the Surface is invalid, not part of this Session, or has already been used as a target of a CaptureRequest in this session or immediately prior sessions.
Since:
Android API level 23
See Also:
CameraCaptureSession.StateCallback.onSurfacePrepared(com.iristick.smartglass.support.camera2.CameraCaptureSession, android.view.Surface)

finalizeOutputConfigurations

void finalizeOutputConfigurations(List<OutputConfiguration> outputConfigs)
                           throws CameraAccessException
Deprecated. 

Finalize the output configurations that now have their deferred and/or extra Surfaces included.

For camera use cases where a preview and other output configurations need to be configured, it can take some time for the preview Surface to be ready. For example, if the preview Surface is obtained from SurfaceView, the SurfaceView will only be ready after the UI layout is done, potentially delaying camera startup.

To speed up camera startup time, the application can configure the CameraCaptureSession with the eventual preview size (via a deferred OutputConfiguration), and defer the preview output configuration until the Surface is ready. After the CameraCaptureSession is created successfully with this deferred output and other normal outputs, the application can start submitting requests as long as they do not include deferred output Surfaces. Once a deferred Surface is ready, the application can add the Surface to the deferred output configuration with the OutputConfiguration.addSurface(android.view.Surface) method, and then update the deferred output configuration via this method, before it can submit capture requests with this output target.

This function can also be called in case where multiple surfaces share the same OutputConfiguration, and one of the surfaces becomes available after the CameraCaptureSession is created. In that case, the application must first create the OutputConfiguration with the available Surface, then enable furture surface sharing via OutputConfiguration.enableSurfaceSharing(), before creating the CameraCaptureSession. After the CameraCaptureSession is created, and once the extra Surface becomes available, the application must then call OutputConfiguration.addSurface(android.view.Surface) before finalizing the configuration with this method.

If the provided OutputConfigurations are unchanged from session creation, this function call has no effect. This function must only be called once for a particular output configuration.

The output Surfaces included by this list of OutputConfigurations can be used as CaptureRequest targets as soon as this call returns.

This method is not supported by LEGACY-level devices.

Parameters:
outputConfigs - a list of OutputConfigurations that have had addSurface invoked with a valid output Surface after CameraDevice.createCaptureSessionByOutputConfigurations(java.util.List<com.iristick.smartglass.support.camera2.params.OutputConfiguration>, com.iristick.smartglass.support.camera2.CameraCaptureSession.StateCallback, android.os.Handler).
Throws:
CameraAccessException - if the camera device is no longer connected or has encountered a fatal error.
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.
IllegalArgumentException - for invalid output configurations, including ones where the source of the Surface is no longer valid or the Surface is from a unsupported source. Or if one of the output configuration was already finished with an included surface in a prior call.
Since:
Android API level 26

capture

int capture(CaptureRequest request,
            CameraCaptureSession.CaptureCallback listener,
            Handler handler)
     throws CameraAccessException
Deprecated. 

Submit a request for an image to be captured by the camera device.

The request defines all the parameters for capturing the single image, including sensor, lens, flash, and post-processing settings.

Each request will produce one CaptureResult and produce new frames for one or more target Surfaces, set with the CaptureRequest builder's CaptureRequest.Builder.addTarget(android.view.Surface) method. The target surfaces (set with CaptureRequest.Builder.addTarget(android.view.Surface)) must be a subset of the surfaces provided when this capture session was created.

Multiple regular and reprocess requests can be in progress at once. If there are only regular requests or reprocess requests in progress, they are processed in first-in, first-out order. If there are both regular and reprocess requests in progress, regular requests are processed in first-in, first-out order and reprocess requests are processed in first-in, first-out order, respectively. However, the processing order of a regular request and a reprocess request in progress is not specified. In other words, a regular request will always be processed before regular requets that are submitted later. A reprocess request will always be processed before reprocess requests that are submitted later. However, a regular request may not be processed before reprocess requests that are submitted later.

Requests submitted through this method have higher priority than those submitted through setRepeatingRequest(com.iristick.smartglass.support.camera2.CaptureRequest, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler) or setRepeatingBurst(java.util.List<com.iristick.smartglass.support.camera2.CaptureRequest>, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), and will be processed as soon as the current repeat/repeatBurst processing completes.

All capture sessions can be used for capturing images from the camera but only capture sessions created by createReprocessableCaptureSession can submit reprocess capture requests. Submitting a reprocess request to a regular capture session will result in an IllegalArgumentException.

Parameters:
request - the settings for this capture
listener - The callback object to notify once this request has been processed. If null, no metadata will be produced for this capture, although image data will still be produced.
handler - the handler on which the listener should be invoked, or null to use the current thread's looper.
Returns:
int A unique capture sequence ID used by CameraCaptureSession.CaptureCallback.onCaptureSequenceCompleted(com.iristick.smartglass.support.camera2.CameraCaptureSession, int, long).
Throws:
CameraAccessException - if the camera device is no longer connected or has encountered a fatal error
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.
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 in a reprocessable capture session; or a reprocess capture request is submitted in a non-reprocessable capture session; or the reprocess capture request was created with a TotalCaptureResult from a different session; or the capture targets a Surface in the middle of being prepared; or the handler is null, the listener is not null, and the calling thread has no looper.
See Also:
captureBurst(java.util.List<com.iristick.smartglass.support.camera2.CaptureRequest>, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), setRepeatingRequest(com.iristick.smartglass.support.camera2.CaptureRequest, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), setRepeatingBurst(java.util.List<com.iristick.smartglass.support.camera2.CaptureRequest>, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), abortCaptures(), CameraDevice.createReprocessableCaptureSession(com.iristick.smartglass.support.camera2.params.InputConfiguration, java.util.List<android.view.Surface>, com.iristick.smartglass.support.camera2.CameraCaptureSession.StateCallback, android.os.Handler)

captureBurst

int captureBurst(List<CaptureRequest> requests,
                 CameraCaptureSession.CaptureCallback listener,
                 Handler handler)
          throws CameraAccessException
Deprecated. 
Submit a list of requests to be captured in sequence as a burst. The burst will be captured in the minimum amount of time possible, and will not be interleaved with requests submitted by other capture or repeat calls.

Regular and reprocess requests can be mixed together in a single burst. Regular requests will be captured in order and reprocess requests will be processed in order, respectively. However, the processing order between a regular request and a reprocess request is not specified. Each capture produces one CaptureResult and image buffers for one or more target surfaces. The target surfaces (set with CaptureRequest.Builder.addTarget(android.view.Surface)) must be a subset of the surfaces provided when this capture session was created.

The main difference between this method and simply calling capture(com.iristick.smartglass.support.camera2.CaptureRequest, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler) repeatedly is that this method guarantees that no other requests will be interspersed with the burst.

All capture sessions can be used for capturing images from the camera but only capture sessions created by createReprocessableCaptureSession can submit reprocess capture requests. Submitting a reprocess request to a regular capture session will result in an IllegalArgumentException.

Parameters:
requests - the list of settings for this burst capture
listener - The callback object to notify each time one of the requests in the burst has been processed. If null, no metadata will be produced for any requests in this burst, although image data will still be produced.
handler - the handler on which the listener should be invoked, or null to use the current thread's looper.
Returns:
int A unique capture sequence ID used by CameraCaptureSession.CaptureCallback.onCaptureSequenceCompleted(com.iristick.smartglass.support.camera2.CameraCaptureSession, int, long).
Throws:
CameraAccessException - if the camera device is no longer connected or has encountered a fatal error
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.
IllegalArgumentException - If the requests target no Surfaces, or the requests target Surfaces not currently configured as outputs; or one of the requests targets a set of Surfaces that cannot be submitted simultaneously in a reprocessable capture session; or a reprocess capture request is submitted in a non-reprocessable capture session; or one of the reprocess capture requests was created with a TotalCaptureResult from a different session; or one of the captures targets a Surface in the middle of being prepared; or if the handler is null, the listener is not null, and the calling thread has no looper.
See Also:
capture(com.iristick.smartglass.support.camera2.CaptureRequest, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), setRepeatingRequest(com.iristick.smartglass.support.camera2.CaptureRequest, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), setRepeatingBurst(java.util.List<com.iristick.smartglass.support.camera2.CaptureRequest>, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), abortCaptures()

setRepeatingRequest

int setRepeatingRequest(CaptureRequest request,
                        CameraCaptureSession.CaptureCallback listener,
                        Handler handler)
                 throws CameraAccessException
Deprecated. 
Request endlessly repeating capture of images by this capture session.

With this method, the camera device will continually capture images using the settings in the provided CaptureRequest, at the maximum rate possible.

Repeating requests are a simple way for an application to maintain a preview or other continuous stream of frames, without having to continually submit identical requests through capture(com.iristick.smartglass.support.camera2.CaptureRequest, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler).

Repeat requests have lower priority than those submitted through capture(com.iristick.smartglass.support.camera2.CaptureRequest, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler) or captureBurst(java.util.List<com.iristick.smartglass.support.camera2.CaptureRequest>, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), so if capture(com.iristick.smartglass.support.camera2.CaptureRequest, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler) 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 abortCaptures() will also clear the request.

Calling this method will replace any earlier repeating request or burst set up by this method or setRepeatingBurst(java.util.List<com.iristick.smartglass.support.camera2.CaptureRequest>, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), although any in-progress burst will be completed before the new repeat request will be used.

This method does not support reprocess capture requests because each reprocess CaptureRequest must be created from the TotalCaptureResult that matches the input image to be reprocessed. This is either the TotalCaptureResult of capture that is sent for reprocessing, or one of the TotalCaptureResults of a set of captures, when data from the whole set is combined by the application into a single reprocess input image. The request must be capturing images from the camera. If a reprocess capture request is submitted, this method will throw IllegalArgumentException.

Parameters:
request - the request to repeat indefinitely
listener - The callback object to notify every time the request finishes processing. If null, no metadata will be produced for this stream of requests, although image data will still be produced.
handler - the handler on which the listener should be invoked, or null to use the current thread's looper.
Returns:
int A unique capture sequence ID used by CameraCaptureSession.CaptureCallback.onCaptureSequenceCompleted(com.iristick.smartglass.support.camera2.CameraCaptureSession, int, long).
Throws:
CameraAccessException - if the camera device is no longer connected or has encountered a fatal error
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.
IllegalArgumentException - If the request references no Surfaces or references Surfaces that are not currently configured as outputs; or the request is a reprocess capture request; or the capture targets a Surface in the middle of being prepared; or the handler is null, the listener is not null, and the calling thread has no looper; or no requests were passed in.
See Also:
capture(com.iristick.smartglass.support.camera2.CaptureRequest, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), captureBurst(java.util.List<com.iristick.smartglass.support.camera2.CaptureRequest>, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), setRepeatingBurst(java.util.List<com.iristick.smartglass.support.camera2.CaptureRequest>, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), stopRepeating(), abortCaptures()

setRepeatingBurst

int setRepeatingBurst(List<CaptureRequest> requests,
                      CameraCaptureSession.CaptureCallback listener,
                      Handler handler)
               throws CameraAccessException
Deprecated. 

Request endlessly repeating capture of a sequence of images by this capture session.

With this method, the camera device will continually capture images, cycling through the settings in the provided list of CaptureRequests, at the maximum rate possible.

If a request is submitted through capture(com.iristick.smartglass.support.camera2.CaptureRequest, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler) or captureBurst(java.util.List<com.iristick.smartglass.support.camera2.CaptureRequest>, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), the current repetition of the request list will be completed before the higher-priority request is handled. This guarantees that the application always receives a complete repeat burst captured in minimal time, instead of bursts interleaved with higher-priority captures, or incomplete captures.

Repeating burst requests are a simple way for an application to maintain a preview or other continuous stream of frames where each request is different in a predicatable way, without having to continually submit requests through captureBurst(java.util.List<com.iristick.smartglass.support.camera2.CaptureRequest>, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler).

To stop the repeating capture, call stopRepeating(). Any ongoing burst will still be completed, however. Calling abortCaptures() will also clear the request.

Calling this method will replace a previously-set repeating request or burst set up by this method or setRepeatingRequest(com.iristick.smartglass.support.camera2.CaptureRequest, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), although any in-progress burst will be completed before the new repeat burst will be used.

This method does not support reprocess capture requests because each reprocess CaptureRequest must be created from the TotalCaptureResult that matches the input image to be reprocessed. This is either the TotalCaptureResult of capture that is sent for reprocessing, or one of the TotalCaptureResults of a set of captures, when data from the whole set is combined by the application into a single reprocess input image. The request must be capturing images from the camera. If a reprocess capture request is submitted, this method will throw IllegalArgumentException.

Parameters:
requests - the list of requests to cycle through indefinitely
listener - The callback object to notify each time one of the requests in the repeating bursts has finished processing. If null, no metadata will be produced for this stream of requests, although image data will still be produced.
handler - the handler on which the listener should be invoked, or null to use the current thread's looper.
Returns:
int A unique capture sequence ID used by CameraCaptureSession.CaptureCallback.onCaptureSequenceCompleted(com.iristick.smartglass.support.camera2.CameraCaptureSession, int, long).
Throws:
CameraAccessException - if the camera device is no longer connected or has encountered a fatal error
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.
IllegalArgumentException - If the requests reference no Surfaces or reference Surfaces not currently configured as outputs; or one of the requests is a reprocess capture request; or one of the captures targets a Surface in the middle of being prepared; or the handler is null, the listener is not null, and the calling thread has no looper; or no requests were passed in.
See Also:
capture(com.iristick.smartglass.support.camera2.CaptureRequest, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), captureBurst(java.util.List<com.iristick.smartglass.support.camera2.CaptureRequest>, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), setRepeatingRequest(com.iristick.smartglass.support.camera2.CaptureRequest, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), stopRepeating(), abortCaptures()

stopRepeating

void stopRepeating()
            throws CameraAccessException
Deprecated. 

Cancel any ongoing repeating capture set by either setRepeatingRequest or setRepeatingBurst(java.util.List<com.iristick.smartglass.support.camera2.CaptureRequest>, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler). Has no effect on requests submitted through capture or captureBurst.

Any currently in-flight captures will still complete, as will any burst that is mid-capture. To ensure that the device has finished processing all of its capture requests and is in ready state, wait for the CameraCaptureSession.StateCallback.onReady(com.iristick.smartglass.support.camera2.CameraCaptureSession) callback after calling this method.

Throws:
CameraAccessException - if the camera device is no longer connected or has encountered a fatal error
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:
setRepeatingRequest(com.iristick.smartglass.support.camera2.CaptureRequest, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), setRepeatingBurst(java.util.List<com.iristick.smartglass.support.camera2.CaptureRequest>, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), CameraCaptureSession.StateCallback.onReady(com.iristick.smartglass.support.camera2.CameraCaptureSession)

abortCaptures

void abortCaptures()
            throws CameraAccessException
Deprecated. 
Discard all captures currently pending and in-progress as fast as possible.

The camera device will discard all of its current work as fast as possible. Some in-flight captures may complete successfully and call CameraCaptureSession.CaptureCallback.onCaptureCompleted(com.iristick.smartglass.support.camera2.CameraCaptureSession, com.iristick.smartglass.support.camera2.CaptureRequest, com.iristick.smartglass.support.camera2.TotalCaptureResult), while others will trigger their CameraCaptureSession.CaptureCallback.onCaptureFailed(com.iristick.smartglass.support.camera2.CameraCaptureSession, com.iristick.smartglass.support.camera2.CaptureRequest, com.iristick.smartglass.support.camera2.CaptureFailure) callbacks. If a repeating request or a repeating burst is set, it will be cleared.

This method is the fastest way to switch the camera device to a new session with CameraDevice.createCaptureSession(java.util.List<android.view.Surface>, com.iristick.smartglass.support.camera2.CameraCaptureSession.StateCallback, android.os.Handler) or CameraDevice.createReprocessableCaptureSession(com.iristick.smartglass.support.camera2.params.InputConfiguration, java.util.List<android.view.Surface>, com.iristick.smartglass.support.camera2.CameraCaptureSession.StateCallback, android.os.Handler), at the cost of discarding in-progress work. It must be called before the new session is created. Once all pending requests are either completed or thrown away, the CameraCaptureSession.StateCallback.onReady(com.iristick.smartglass.support.camera2.CameraCaptureSession) callback will be called, if the session has not been closed. Otherwise, the CameraCaptureSession.StateCallback.onClosed(com.iristick.smartglass.support.camera2.CameraCaptureSession) callback will be fired when a new session is created by the camera device.

Cancelling will introduce at least a brief pause in the stream of data from the camera device, since once the camera device is emptied, the first new request has to make it through the entire camera pipeline before new output buffers are produced.

This means that using abortCaptures() to simply remove pending requests is not recommended; it's best used for quickly switching output configurations, or for cancelling long in-progress requests (such as a multi-second capture).

Throws:
CameraAccessException - if the camera device is no longer connected or has encountered a fatal error
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:
setRepeatingRequest(com.iristick.smartglass.support.camera2.CaptureRequest, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), setRepeatingBurst(java.util.List<com.iristick.smartglass.support.camera2.CaptureRequest>, com.iristick.smartglass.support.camera2.CameraCaptureSession.CaptureCallback, android.os.Handler), CameraDevice.createCaptureSession(java.util.List<android.view.Surface>, com.iristick.smartglass.support.camera2.CameraCaptureSession.StateCallback, android.os.Handler), CameraDevice.createReprocessableCaptureSession(com.iristick.smartglass.support.camera2.params.InputConfiguration, java.util.List<android.view.Surface>, com.iristick.smartglass.support.camera2.CameraCaptureSession.StateCallback, android.os.Handler)

isReprocessable

boolean isReprocessable()
Deprecated. 
Return if the application can submit reprocess capture requests with this camera capture session.
Returns:
true if the application can submit reprocess capture requests with this camera capture session. false otherwise.
Since:
Android API level 23
See Also:
CameraDevice.createReprocessableCaptureSession(com.iristick.smartglass.support.camera2.params.InputConfiguration, java.util.List<android.view.Surface>, com.iristick.smartglass.support.camera2.CameraCaptureSession.StateCallback, android.os.Handler)

getInputSurface

Surface getInputSurface()
                 throws CameraAccessException
Deprecated. 
Get the input Surface associated with a reprocessable capture session.

Each reprocessable capture session has an input Surface where the reprocess capture requests get the input images from, rather than the camera device. The application can create a ImageWriter with this input Surface and use it to provide input images for reprocess capture requests. When the reprocessable capture session is closed, the input Surface is abandoned and becomes invalid.

Returns:
The Surface where reprocessing capture requests get the input images from. If this is not a reprocess capture session, null will be returned.
Throws:
CameraAccessException - on error.
Since:
Android API level 23
See Also:
CameraDevice.createReprocessableCaptureSession(com.iristick.smartglass.support.camera2.params.InputConfiguration, java.util.List<android.view.Surface>, com.iristick.smartglass.support.camera2.CameraCaptureSession.StateCallback, android.os.Handler), ImageWriter, ImageReader

close

void close()
Deprecated. 
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 CameraDevice.createCaptureSession(java.util.List<android.view.Surface>, com.iristick.smartglass.support.camera2.CameraCaptureSession.StateCallback, android.os.Handler) will close any existing capture session automatically, and call the older session listener's CameraCaptureSession.StateCallback.onClosed(com.iristick.smartglass.support.camera2.CameraCaptureSession) callback. Using CameraDevice.createCaptureSession(java.util.List<android.view.Surface>, com.iristick.smartglass.support.camera2.CameraCaptureSession.StateCallback, android.os.Handler) 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 or bursts are stopped (as if stopRepeating() was called). However, any in-progress capture requests submitted to the session will be completed as normal; once all captures have completed and the session has been torn down, CameraCaptureSession.StateCallback.onClosed(com.iristick.smartglass.support.camera2.CameraCaptureSession) will be called.

Closing a session is idempotent; closing more than once has no effect.

Specified by:
close in interface AutoCloseable