Search in sources :

Example 21 with SubmitInfo

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

the class CameraDeviceBinderTest method testSubmitGoodRequest.

@SmallTest
public void testSubmitGoodRequest() throws Exception {
    CaptureRequest.Builder builder = createDefaultBuilder(/* needStream */
    true);
    CaptureRequest request = builder.build();
    // Submit valid request twice.
    SubmitInfo requestInfo1 = submitCameraRequest(request, /* streaming */
    false);
    SubmitInfo requestInfo2 = submitCameraRequest(request, /* streaming */
    false);
    assertNotSame("Request IDs should be unique for multiple requests", requestInfo1.getRequestId(), requestInfo2.getRequestId());
}
Also used : SubmitInfo(android.hardware.camera2.utils.SubmitInfo) CaptureRequest(android.hardware.camera2.CaptureRequest) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 22 with SubmitInfo

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

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 23 with SubmitInfo

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

the class CameraDeviceBinderTest method submitCameraRequest.

private SubmitInfo submitCameraRequest(CaptureRequest request, boolean streaming) throws Exception {
    SubmitInfo requestInfo = mCameraUser.submitRequest(request, streaming);
    assertTrue("Request IDs should be non-negative (expected: >= 0, actual: " + requestInfo.getRequestId() + ")", requestInfo.getRequestId() >= 0);
    return requestInfo;
}
Also used : SubmitInfo(android.hardware.camera2.utils.SubmitInfo)

Example 24 with SubmitInfo

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

the class CameraDeviceBinderTest method testFlush.

@SmallTest
public void testFlush() throws Exception {
    int status;
    // Initial flush should work
    long lastFrameNumber = mCameraUser.flush();
    // Then set up a stream
    CaptureRequest request = createDefaultBuilder(/* needStream */
    true).build();
    // Flush should still be a no-op, really
    lastFrameNumber = mCameraUser.flush();
    // 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);
    // Then flush and wait for idle
    lastFrameNumber = mCameraUser.flush();
    verify(mMockCb, timeout(WAIT_FOR_FLUSH_TIMEOUT_MS).times(1)).onDeviceIdle();
    // Now a streaming request
    SubmitInfo streamingInfo = submitCameraRequest(request, /* streaming */
    true);
    // Wait a bit to fill up the queue
    SystemClock.sleep(WAIT_FOR_WORK_MS);
    // Then flush and wait for the idle callback
    lastFrameNumber = mCameraUser.flush();
    verify(mMockCb, timeout(WAIT_FOR_FLUSH_TIMEOUT_MS).times(2)).onDeviceIdle();
// TODO: When errors are hooked up, count that errors + successful
// requests equal to 5.
}
Also used : SubmitInfo(android.hardware.camera2.utils.SubmitInfo) CaptureRequest(android.hardware.camera2.CaptureRequest) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 25 with SubmitInfo

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

the class RequestThreadManager method submitCaptureRequests.

/**
     * Submit the given burst of requests to be captured.
     *
     * <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 SubmitInfo submitCaptureRequests(CaptureRequest[] requests, boolean repeating) {
    Handler handler = mRequestThread.waitAndGetHandler();
    SubmitInfo info;
    synchronized (mIdleLock) {
        info = mRequestQueue.submit(requests, repeating);
        handler.sendEmptyMessage(MSG_SUBMIT_CAPTURE_REQUEST);
    }
    return info;
}
Also used : SubmitInfo(android.hardware.camera2.utils.SubmitInfo) Handler(android.os.Handler)

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