Skip to content
com.iristick.smartglass.core.camera

Interface CaptureListener

All Known Implementing Classes:
CaptureAdapter, CaptureListener2

public interface CaptureListener

Listener interface for tracking the progress of a sequence of CaptureRequests submitted together to a camera session.

Implementing this interface directly is no longer recommended for new applications. Prefer extending the CaptureListener2 abstract class instead.

When the sequence is processed, the onCaptureCompleted or onCaptureFailed methods are called for each request in the sequence. When all requests are processed, onCaptureSequenceCompleted is called. All these methods are also called if the camera is closed during the processing of the sequence (in which case onCaptureFailed is called for each remaining request).

If the sequence is flushed from the queue before processing has started, only the onCaptureSequenceAborted method is called.

Method Summary

Modifier and Type Method and Description
void onCaptureBufferLost(CaptureSession session, CaptureRequest request, Surface surface, long frameNumber)
Called when a buffer for capture could not be sent to its destination surface.
void onCaptureCompleted(CaptureSession session, CaptureRequest request, CaptureResult result)
Called when an image capture has successfully completed.
void onCaptureFailed(CaptureSession session, CaptureRequest request, CaptureFailure failure)
Called instead of onCaptureCompleted when the session failed to produce a CaptureResult for the request.
void onCaptureSequenceAborted(CaptureSession session, int sequenceId)
Called when a capture sequence aborts before any CaptureResult or CaptureFailure for it have been returned via this listener.
void onCaptureSequenceCompleted(CaptureSession session, int sequenceId, long frameNumber)
Called when a capture sequence finishes and all CaptureResult or CaptureFailure for it have been returned via this listener.
void onCaptureStarted(CaptureSession session, CaptureRequest request, long timestamp, long frameNumber)
Called when an image capture is started.

Method Detail

onCaptureStarted

void onCaptureStarted(@NonNull
                      CaptureSession session,
                      @NonNull
                      CaptureRequest request,
                      long timestamp,
                      long frameNumber)

Called when an image capture is started.

This callback is invoked when the capture of a frame begins, so it is the most appropriate time for playing a shutter sound or triggering UI indicators.

Parameters:
session - The session.
request - The request that was given to session.
timestamp - Deprecated! This timestamp should not be used as it is not related to the CaptureResult.SENSOR_TIMESTAMP value of a completed frame. This argument may be removed in future SDK releases.
frameNumber - The frame number for this capture.

onCaptureBufferLost

void onCaptureBufferLost(@NonNull
                         CaptureSession session,
                         @NonNull
                         CaptureRequest request,
                         @NonNull
                         Surface surface,
                         long frameNumber)

Called when a buffer for capture could not be sent to its destination surface.

When the whole request fails, onCaptureFailed is called instead.

Parameters:
session - The session.
request - The request that was given to session.
surface - The target output surface for which the capture failed.
frameNumber - The frame number for this capture.

onCaptureCompleted

void onCaptureCompleted(@NonNull
                        CaptureSession session,
                        @NonNull
                        CaptureRequest request,
                        @NonNull
                        CaptureResult result)

Called when an image capture has successfully completed.

Parameters:
session - The session.
request - The request that was given to session.
result - The result from the capture, including the frame number.

onCaptureFailed

void onCaptureFailed(@NonNull
                     CaptureSession session,
                     @NonNull
                     CaptureRequest request,
                     @NonNull
                     CaptureFailure failure)

Called instead of onCaptureCompleted when the session failed to produce a CaptureResult for the request.

Other requests are unaffected, and some or all image buffers from the capture may have been pushed to their respective output streams.

Parameters:
session - The session.
request - The request that was given to session.
failure - The output failure from the capture, including the failure reason and the frame number.

onCaptureSequenceCompleted

void onCaptureSequenceCompleted(@NonNull
                                CaptureSession session,
                                int sequenceId,
                                long frameNumber)

Called when a capture sequence finishes and all CaptureResult or CaptureFailure for it have been returned via this listener.

If the capture sequence is aborted before any requests have been processed, onCaptureSequenceAborted is invoked instead.

Parameters:
session - The session.
sequenceId - A sequence ID returned by the CameraSession.capture family of functions.
frameNumber - The last frame number (returned by CaptureResult.getFrameNumber() or CaptureFailure.getFrameNumber()) in the capture sequence.

onCaptureSequenceAborted

void onCaptureSequenceAborted(@NonNull
                              CaptureSession session,
                              int sequenceId)

Called when a capture sequence aborts before any CaptureResult or CaptureFailure for it have been returned via this listener.

Due to the asynchronous nature of the session device, not all submitted captures are immediately processed. Pending requests may be cleared out when the session is closed or gets disconnected. When such an event happens, onCaptureCompleted, onCaptureFailed and onCaptureSequenceCompleted will not be called.

Parameters:
session - The session.
sequenceId - A sequence ID returned by the CameraSession.capture family of functions.