Search in sources :

Example 11 with SubmitInfo

use of android.hardware.camera2.utils.SubmitInfo in project android_frameworks_base by DirtyUnicorns.

the class CameraDeviceBinderTest method testCaptureStartedCallbacks.

@SmallTest
public void testCaptureStartedCallbacks() throws Exception {
    CaptureRequest request = createDefaultBuilder(/* needStream */
    true).build();
    ArgumentCaptor<Long> timestamps = ArgumentCaptor.forClass(Long.class);
    // Test both single request and streaming request.
    SubmitInfo requestInfo1 = submitCameraRequest(request, /* streaming */
    false);
    verify(mMockCb, timeout(WAIT_FOR_COMPLETE_TIMEOUT_MS).times(1)).onCaptureStarted(any(CaptureResultExtras.class), anyLong());
    SubmitInfo streamingInfo = submitCameraRequest(request, /* streaming */
    true);
    verify(mMockCb, timeout(WAIT_FOR_COMPLETE_TIMEOUT_MS).atLeast(NUM_CALLBACKS_CHECKED)).onCaptureStarted(any(CaptureResultExtras.class), timestamps.capture());
    // All timestamps should be larger than 0.
    long timestamp = 0;
    for (Long nextTimestamp : timestamps.getAllValues()) {
        Log.v(TAG, "next t: " + nextTimestamp + " current t: " + timestamp);
        assertTrue("Captures are out of order", timestamp < nextTimestamp);
        timestamp = nextTimestamp;
    }
}
Also used : SubmitInfo(android.hardware.camera2.utils.SubmitInfo) CaptureResultExtras(android.hardware.camera2.impl.CaptureResultExtras) CaptureRequest(android.hardware.camera2.CaptureRequest) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 12 with SubmitInfo

use of android.hardware.camera2.utils.SubmitInfo in project android_frameworks_base by DirtyUnicorns.

the class CameraDeviceBinderTest method testIdleCallback.

@SmallTest
public void testIdleCallback() throws Exception {
    int status;
    CaptureRequest request = createDefaultBuilder(/* needStream */
    true).build();
    // Try streaming
    SubmitInfo streamingInfo = submitCameraRequest(request, /* streaming */
    true);
    // Wait a bit to fill up the queue
    SystemClock.sleep(WAIT_FOR_WORK_MS);
    // Cancel and make sure we eventually quiesce
    long lastFrameNumber = mCameraUser.cancelRequest(streamingInfo.getRequestId());
    verify(mMockCb, timeout(WAIT_FOR_IDLE_TIMEOUT_MS).times(1)).onDeviceIdle();
    // Submit a few capture requests
    SubmitInfo requestInfo1 = submitCameraRequest(request, /* streaming */
    false);
    SubmitInfo requestInfo2 = submitCameraRequest(request, /* streaming */
    false);
    SubmitInfo requestInfo3 = submitCameraRequest(request, /* streaming */
    false);
    SubmitInfo requestInfo4 = submitCameraRequest(request, /* streaming */
    false);
    SubmitInfo requestInfo5 = submitCameraRequest(request, /* streaming */
    false);
    // And wait for more idle
    verify(mMockCb, timeout(WAIT_FOR_IDLE_TIMEOUT_MS).times(2)).onDeviceIdle();
}
Also used : SubmitInfo(android.hardware.camera2.utils.SubmitInfo) CaptureRequest(android.hardware.camera2.CaptureRequest) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 13 with SubmitInfo

use of android.hardware.camera2.utils.SubmitInfo in project android_frameworks_base by DirtyUnicorns.

the class RequestQueue method submit.

/**
     * Add a the given burst to the queue.
     *
     * <p>If the burst is repeating, replace the current repeating burst.</p>
     *
     * @param requests the burst of requests to add to the queue.
     * @param repeating true if the burst is repeating.
     * @return the submission info, including the new request id, and the last frame number, which
     *   contains either the frame number of the last frame that will be returned for this request,
     *   or the frame number of the last frame that will be returned for the current repeating
     *   request if this burst is set to be repeating.
     */
public synchronized SubmitInfo submit(CaptureRequest[] requests, boolean repeating) {
    int requestId = mCurrentRequestId++;
    BurstHolder burst = new BurstHolder(requestId, repeating, requests, mJpegSurfaceIds);
    long lastFrame = INVALID_FRAME;
    if (burst.isRepeating()) {
        Log.i(TAG, "Repeating capture request set.");
        if (mRepeatingRequest != null) {
            lastFrame = (mCurrentRepeatingFrameNumber == INVALID_FRAME) ? INVALID_FRAME : mCurrentRepeatingFrameNumber - 1;
        }
        mCurrentRepeatingFrameNumber = INVALID_FRAME;
        mRepeatingRequest = burst;
    } else {
        mRequestQueue.offer(burst);
        lastFrame = calculateLastFrame(burst.getRequestId());
    }
    SubmitInfo info = new SubmitInfo(requestId, lastFrame);
    return info;
}
Also used : SubmitInfo(android.hardware.camera2.utils.SubmitInfo)

Example 14 with SubmitInfo

use of android.hardware.camera2.utils.SubmitInfo in project android_frameworks_base by DirtyUnicorns.

the class CameraDeviceImpl method submitCaptureRequest.

private int submitCaptureRequest(List<CaptureRequest> requestList, CaptureCallback callback, Handler handler, boolean repeating) throws CameraAccessException {
    // Need a valid handler, or current thread needs to have a looper, if
    // callback is valid
    handler = checkHandler(handler, callback);
    // Make sure that there all requests have at least 1 surface; all surfaces are non-null
    for (CaptureRequest request : requestList) {
        if (request.getTargets().isEmpty()) {
            throw new IllegalArgumentException("Each request must have at least one Surface target");
        }
        for (Surface surface : request.getTargets()) {
            if (surface == null) {
                throw new IllegalArgumentException("Null Surface targets are not allowed");
            }
        }
    }
    synchronized (mInterfaceLock) {
        checkIfCameraClosedOrInError();
        if (repeating) {
            stopRepeating();
        }
        SubmitInfo requestInfo;
        CaptureRequest[] requestArray = requestList.toArray(new CaptureRequest[requestList.size()]);
        requestInfo = mRemoteDevice.submitRequestList(requestArray, repeating);
        if (DEBUG) {
            Log.v(TAG, "last frame number " + requestInfo.getLastFrameNumber());
        }
        if (callback != null) {
            mCaptureCallbackMap.put(requestInfo.getRequestId(), new CaptureCallbackHolder(callback, requestList, handler, repeating, mNextSessionId - 1));
        } else {
            if (DEBUG) {
                Log.d(TAG, "Listen for request " + requestInfo.getRequestId() + " is null");
            }
        }
        if (repeating) {
            if (mRepeatingRequestId != REQUEST_ID_NONE) {
                checkEarlyTriggerSequenceComplete(mRepeatingRequestId, requestInfo.getLastFrameNumber());
            }
            mRepeatingRequestId = requestInfo.getRequestId();
        } else {
            mRequestLastFrameNumbersList.add(new RequestLastFrameNumbersHolder(requestList, requestInfo));
        }
        if (mIdle) {
            mDeviceHandler.post(mCallOnActive);
        }
        mIdle = false;
        return requestInfo.getRequestId();
    }
}
Also used : SubmitInfo(android.hardware.camera2.utils.SubmitInfo) CaptureRequest(android.hardware.camera2.CaptureRequest) Surface(android.view.Surface)

Example 15 with SubmitInfo

use of android.hardware.camera2.utils.SubmitInfo in project android_frameworks_base by AOSPA.

the class CameraDeviceBinderTest method testIdleCallback.

@SmallTest
public void testIdleCallback() throws Exception {
    int status;
    CaptureRequest request = createDefaultBuilder(/* needStream */
    true).build();
    // Try streaming
    SubmitInfo streamingInfo = submitCameraRequest(request, /* streaming */
    true);
    // Wait a bit to fill up the queue
    SystemClock.sleep(WAIT_FOR_WORK_MS);
    // Cancel and make sure we eventually quiesce
    long lastFrameNumber = mCameraUser.cancelRequest(streamingInfo.getRequestId());
    verify(mMockCb, timeout(WAIT_FOR_IDLE_TIMEOUT_MS).times(1)).onDeviceIdle();
    // Submit a few capture requests
    SubmitInfo requestInfo1 = submitCameraRequest(request, /* streaming */
    false);
    SubmitInfo requestInfo2 = submitCameraRequest(request, /* streaming */
    false);
    SubmitInfo requestInfo3 = submitCameraRequest(request, /* streaming */
    false);
    SubmitInfo requestInfo4 = submitCameraRequest(request, /* streaming */
    false);
    SubmitInfo requestInfo5 = submitCameraRequest(request, /* streaming */
    false);
    // And wait for more idle
    verify(mMockCb, timeout(WAIT_FOR_IDLE_TIMEOUT_MS).times(2)).onDeviceIdle();
}
Also used : SubmitInfo(android.hardware.camera2.utils.SubmitInfo) CaptureRequest(android.hardware.camera2.CaptureRequest) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

SubmitInfo (android.hardware.camera2.utils.SubmitInfo)55 CaptureRequest (android.hardware.camera2.CaptureRequest)45 SmallTest (android.test.suitebuilder.annotation.SmallTest)35 ServiceSpecificException (android.os.ServiceSpecificException)20 Surface (android.view.Surface)10 CaptureResultExtras (android.hardware.camera2.impl.CaptureResultExtras)5 Handler (android.os.Handler)5 ArrayList (java.util.ArrayList)5