This source file includes following definitions.
- getStateWaiter
- onCaptureStarted
- onCaptureProgressed
- onCaptureCompleted
- onCaptureFailed
- onCaptureSequenceCompleted
- onCaptureSequenceAborted
package com.android.ex.camera2.blocking;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CaptureFailure;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.TotalCaptureResult;
import android.util.Log;
import com.android.ex.camera2.utils.StateChangeListener;
import com.android.ex.camera2.utils.StateWaiter;
public class BlockingCaptureCallback extends CameraCaptureSession.CaptureCallback {
public static final int CAPTURE_STARTED = 0;
public static final int CAPTURE_PROGRESSED = 1;
public static final int CAPTURE_COMPLETED = 2;
public static final int CAPTURE_FAILED = 3;
public static final int CAPTURE_SEQUENCE_COMPLETED = 4;
public static final int CAPTURE_SEQUENCE_ABORTED = 5;
private static final String[] sStateNames = {
"CAPTURE_STARTED",
"CAPTURE_PROGRESSED",
"CAPTURE_COMPLETED",
"CAPTURE_FAILED",
"CAPTURE_SEQUENCE_COMPLETED",
"CAPTURE_SEQUENCE_ABORTED"
};
private static final String TAG = "BlockingCaptureCallback";
private static final boolean VERBOSE = Log.isLoggable(TAG, Log.VERBOSE);
private final CameraCaptureSession.CaptureCallback mProxy;
private final StateWaiter mStateWaiter = new StateWaiter(sStateNames);
private final StateChangeListener mStateChangeListener = mStateWaiter.getListener();
public BlockingCaptureCallback() {
mProxy = null;
}
public BlockingCaptureCallback(CameraCaptureSession.CaptureCallback listener) {
if (listener == null) {
throw new NullPointerException("listener must not be null");
}
mProxy = listener;
}
public StateWaiter getStateWaiter() {
return mStateWaiter;
}
@Override
public void onCaptureStarted(CameraCaptureSession session, CaptureRequest request,
long timestamp, long frameNumber) {
if (mProxy != null) mProxy.onCaptureStarted(session, request, timestamp, frameNumber);
mStateChangeListener.onStateChanged(CAPTURE_STARTED);
}
@Override
public void onCaptureProgressed(CameraCaptureSession session, CaptureRequest request,
CaptureResult partialResult) {
if (mProxy != null) mProxy.onCaptureProgressed(session, request, partialResult);
mStateChangeListener.onStateChanged(CAPTURE_PROGRESSED);
}
@Override
public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
TotalCaptureResult result) {
if (mProxy != null) mProxy.onCaptureCompleted(session, request, result);
mStateChangeListener.onStateChanged(CAPTURE_COMPLETED);
}
@Override
public void onCaptureFailed(CameraCaptureSession session, CaptureRequest request,
CaptureFailure failure) {
if (mProxy != null) mProxy.onCaptureFailed(session, request, failure);
mStateChangeListener.onStateChanged(CAPTURE_FAILED);
}
@Override
public void onCaptureSequenceCompleted(CameraCaptureSession session, int sequenceId,
long frameNumber) {
if (mProxy != null) mProxy.onCaptureSequenceCompleted(session, sequenceId, frameNumber);
mStateChangeListener.onStateChanged(CAPTURE_SEQUENCE_COMPLETED);
}
@Override
public void onCaptureSequenceAborted(CameraCaptureSession session, int sequenceId) {
if (mProxy != null) mProxy.onCaptureSequenceAborted(session, sequenceId);
mStateChangeListener.onStateChanged(CAPTURE_SEQUENCE_ABORTED);
}
}