use of android.hardware.camera2.CameraCaptureSession.CaptureCallback in project platform_frameworks_base by android.
the class Camera2ReprocessCaptureTest method submitMixedCaptureBurstRequest.
/**
* Submit a burst request mixed with regular and reprocess requests.
*
* @param outputs An array of output surfaces. One output surface will be used in one request
* so the length of the array is the number of requests in a burst request.
* @param inputResults An array of input results. If it's null, all requests are regular
* requests. If an element is null, that element represents a regular
* request. If an element if not null, that element represents a reprocess
* request.
*
*/
private TotalCaptureResult[] submitMixedCaptureBurstRequest(Surface[] outputs, TotalCaptureResult[] inputResults) throws Exception {
if (outputs == null || outputs.length <= 0) {
throw new IllegalArgumentException("outputs must have at least 1 surface");
} else if (inputResults != null && inputResults.length != outputs.length) {
throw new IllegalArgumentException("The lengths of outputs and inputResults " + "don't match");
}
int numReprocessCaptures = 0;
SimpleCaptureCallback captureCallback = new SimpleCaptureCallback();
ArrayList<CaptureRequest> captureRequests = new ArrayList<>(outputs.length);
// is based on inputResults array.
for (int i = 0; i < outputs.length; i++) {
CaptureRequest.Builder builder;
boolean isReprocess = (inputResults != null && inputResults[i] != null);
if (isReprocess) {
builder = mCamera.createReprocessCaptureRequest(inputResults[i]);
numReprocessCaptures++;
} else {
builder = mCamera.createCaptureRequest(CAPTURE_TEMPLATE);
}
builder.addTarget(outputs[i]);
CaptureRequest request = builder.build();
assertTrue("Capture request reprocess type " + request.isReprocess() + " is wrong.", request.isReprocess() == isReprocess);
captureRequests.add(request);
}
if (captureRequests.size() == 1) {
mSession.capture(captureRequests.get(0), captureCallback, mHandler);
} else {
mSession.captureBurst(captureRequests, captureCallback, mHandler);
}
TotalCaptureResult[] results;
if (numReprocessCaptures == 0 || numReprocessCaptures == outputs.length) {
results = new TotalCaptureResult[outputs.length];
// If the requests are not mixed, they should come in order.
for (int i = 0; i < results.length; i++) {
results[i] = captureCallback.getTotalCaptureResultForRequest(captureRequests.get(i), CAPTURE_TIMEOUT_FRAMES);
}
} else {
// If the requests are mixed, they may not come in order.
results = captureCallback.getTotalCaptureResultsForRequests(captureRequests, CAPTURE_TIMEOUT_FRAMES * captureRequests.size());
}
// make sure all input surfaces are released.
for (int i = 0; i < numReprocessCaptures; i++) {
mImageWriterListener.waitForImageReleased(CAPTURE_TIMEOUT_MS);
}
return results;
}
use of android.hardware.camera2.CameraCaptureSession.CaptureCallback in project platform_frameworks_base by android.
the class Camera2Focuser method cancelAutoFocus.
/**
* Cancel ongoing auto focus, unlock the auto-focus if it was locked, and
* resume to passive continuous auto focus.
*
* @throws CameraAccessException
*/
public synchronized void cancelAutoFocus() throws CameraAccessException {
mSuccess = false;
mLocked = false;
// reset the AF regions:
setAfRegions(null);
// Create request builders, the af regions are automatically updated.
mRepeatingBuilder = createRequestBuilder();
CaptureRequest.Builder requestBuilder = createRequestBuilder();
mAutoFocus.setPassiveAutoFocus(/*picture*/
true, mRepeatingBuilder);
mAutoFocus.unlockAutoFocus(mRepeatingBuilder, requestBuilder);
CaptureCallback listener = createCaptureListener();
mSession.setRepeatingRequest(mRepeatingBuilder.build(), listener, mHandler);
mSession.capture(requestBuilder.build(), listener, mHandler);
}
use of android.hardware.camera2.CameraCaptureSession.CaptureCallback in project platform_frameworks_base by android.
the class Camera2Focuser method startAutoFocusFullActiveLocked.
private void startAutoFocusFullActiveLocked() throws CameraAccessException {
// Create request builders, the af regions are automatically updated.
mRepeatingBuilder = createRequestBuilder();
CaptureRequest.Builder requestBuilder = createRequestBuilder();
mAutoFocus.setActiveAutoFocus(mRepeatingBuilder, requestBuilder);
if (mRepeatingBuilder.get(CaptureRequest.CONTROL_AF_TRIGGER) != CaptureRequest.CONTROL_AF_TRIGGER_IDLE) {
throw new AssertionError("Wrong trigger set in repeating request");
}
if (requestBuilder.get(CaptureRequest.CONTROL_AF_TRIGGER) != CaptureRequest.CONTROL_AF_TRIGGER_START) {
throw new AssertionError("Wrong trigger set in queued request");
}
mAutoFocus.resetState();
CaptureCallback listener = createCaptureListener();
mSession.setRepeatingRequest(mRepeatingBuilder.build(), listener, mHandler);
mSession.capture(requestBuilder.build(), listener, mHandler);
}
use of android.hardware.camera2.CameraCaptureSession.CaptureCallback in project platform_frameworks_base by android.
the class CameraCaptureSessionImpl method captureBurst.
@Override
public synchronized int captureBurst(List<CaptureRequest> requests, CaptureCallback callback, Handler handler) throws CameraAccessException {
if (requests == null) {
throw new IllegalArgumentException("Requests must not be null");
} else if (requests.isEmpty()) {
throw new IllegalArgumentException("Requests must have at least one element");
}
for (CaptureRequest request : requests) {
if (request.isReprocess()) {
if (!isReprocessable()) {
throw new IllegalArgumentException("This capture session cannot handle " + "reprocess requests");
} else if (request.getReprocessableSessionId() != mId) {
throw new IllegalArgumentException("Capture request was created for another " + "session");
}
}
}
checkNotClosed();
handler = checkHandler(handler, callback);
if (DEBUG) {
CaptureRequest[] requestArray = requests.toArray(new CaptureRequest[0]);
Log.v(TAG, mIdString + "captureBurst - requests " + Arrays.toString(requestArray) + ", callback " + callback + " handler " + handler);
}
return addPendingSequence(mDeviceImpl.captureBurst(requests, createCaptureCallbackProxy(handler, callback), mDeviceHandler));
}
use of android.hardware.camera2.CameraCaptureSession.CaptureCallback in project android_frameworks_base by DirtyUnicorns.
the class CameraCaptureSessionImpl method setRepeatingBurst.
@Override
public synchronized int setRepeatingBurst(List<CaptureRequest> requests, CaptureCallback callback, Handler handler) throws CameraAccessException {
if (requests == null) {
throw new IllegalArgumentException("requests must not be null");
} else if (requests.isEmpty()) {
throw new IllegalArgumentException("requests must have at least one element");
}
for (CaptureRequest r : requests) {
if (r.isReprocess()) {
throw new IllegalArgumentException("repeating reprocess burst requests are not " + "supported");
}
}
checkNotClosed();
handler = checkHandler(handler, callback);
if (DEBUG) {
CaptureRequest[] requestArray = requests.toArray(new CaptureRequest[0]);
Log.v(TAG, mIdString + "setRepeatingBurst - requests " + Arrays.toString(requestArray) + ", callback " + callback + " handler" + "" + handler);
}
return addPendingSequence(mDeviceImpl.setRepeatingBurst(requests, createCaptureCallbackProxy(handler, callback), mDeviceHandler));
}
Aggregations