Search in sources :

Example 36 with SubmitInfo

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

the class LegacyCameraDevice method submitRequestList.

/**
     * Submit a burst of capture requests.
     *
     * @param requestList a list of capture requests to execute.
     * @param repeating {@code true} if this 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 submitRequestList(CaptureRequest[] requestList, boolean repeating) {
    if (requestList == null || requestList.length == 0) {
        Log.e(TAG, "submitRequestList - Empty/null requests are not allowed");
        throw new ServiceSpecificException(BAD_VALUE, "submitRequestList - Empty/null requests are not allowed");
    }
    List<Long> surfaceIds;
    try {
        surfaceIds = (mConfiguredSurfaces == null) ? new ArrayList<Long>() : getSurfaceIds(mConfiguredSurfaces);
    } catch (BufferQueueAbandonedException e) {
        throw new ServiceSpecificException(BAD_VALUE, "submitRequestList - configured surface is abandoned.");
    }
    // Make sure that there all requests have at least 1 surface; all surfaces are non-null
    for (CaptureRequest request : requestList) {
        if (request.getTargets().isEmpty()) {
            Log.e(TAG, "submitRequestList - " + "Each request must have at least one Surface target");
            throw new ServiceSpecificException(BAD_VALUE, "submitRequestList - " + "Each request must have at least one Surface target");
        }
        for (Surface surface : request.getTargets()) {
            if (surface == null) {
                Log.e(TAG, "submitRequestList - Null Surface targets are not allowed");
                throw new ServiceSpecificException(BAD_VALUE, "submitRequestList - Null Surface targets are not allowed");
            } else if (mConfiguredSurfaces == null) {
                Log.e(TAG, "submitRequestList - must configure " + " device with valid surfaces before submitting requests");
                throw new ServiceSpecificException(INVALID_OPERATION, "submitRequestList - must configure " + " device with valid surfaces before submitting requests");
            } else if (!containsSurfaceId(surface, surfaceIds)) {
                Log.e(TAG, "submitRequestList - cannot use a surface that wasn't configured");
                throw new ServiceSpecificException(BAD_VALUE, "submitRequestList - cannot use a surface that wasn't configured");
            }
        }
    }
    // TODO: further validation of request here
    mIdle.close();
    return mRequestThreadManager.submitCaptureRequests(requestList, repeating);
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) ArrayList(java.util.ArrayList) CaptureRequest(android.hardware.camera2.CaptureRequest) Surface(android.view.Surface)

Example 37 with SubmitInfo

use of android.hardware.camera2.utils.SubmitInfo in project platform_frameworks_base by android.

the class CameraDeviceBinderTest method testWaitUntilIdle.

@SmallTest
public void testWaitUntilIdle() throws Exception {
    CaptureRequest.Builder builder = createDefaultBuilder(/* needStream */
    true);
    SubmitInfo requestInfoStreaming = submitCameraRequest(builder.build(), /* streaming */
    true);
    // Test Bad case first: waitUntilIdle when there is active repeating request
    try {
        mCameraUser.waitUntilIdle();
    } catch (ServiceSpecificException e) {
        assertEquals("waitUntilIdle is invalid operation when there is active repeating request", ICameraService.ERROR_INVALID_OPERATION, e.errorCode);
    }
    // Test good case, waitUntilIdle when there is no active repeating request
    long lastFrameNumber = mCameraUser.cancelRequest(requestInfoStreaming.getRequestId());
    mCameraUser.waitUntilIdle();
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) SubmitInfo(android.hardware.camera2.utils.SubmitInfo) CaptureRequest(android.hardware.camera2.CaptureRequest) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 38 with SubmitInfo

use of android.hardware.camera2.utils.SubmitInfo in project platform_frameworks_base by android.

the class CameraDeviceBinderTest method testSubmitBadRequest.

@SmallTest
public void testSubmitBadRequest() throws Exception {
    CaptureRequest.Builder builder = createDefaultBuilder(/* needStream */
    false);
    CaptureRequest request1 = builder.build();
    try {
        SubmitInfo requestInfo = mCameraUser.submitRequest(request1, /* streaming */
        false);
        fail("Exception expected");
    } catch (ServiceSpecificException e) {
        assertEquals("Expected submitRequest to throw ServiceSpecificException with BAD_VALUE " + "since we had 0 surface targets set.", ICameraService.ERROR_ILLEGAL_ARGUMENT, e.errorCode);
    }
    builder.addTarget(mSurface);
    CaptureRequest request2 = builder.build();
    try {
        SubmitInfo requestInfo = mCameraUser.submitRequest(request2, /* streaming */
        false);
        fail("Exception expected");
    } catch (ServiceSpecificException e) {
        assertEquals("Expected submitRequest to throw ILLEGAL_ARGUMENT " + "ServiceSpecificException since the target wasn't registered with createStream.", ICameraService.ERROR_ILLEGAL_ARGUMENT, e.errorCode);
    }
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) SubmitInfo(android.hardware.camera2.utils.SubmitInfo) CaptureRequest(android.hardware.camera2.CaptureRequest) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 39 with SubmitInfo

use of android.hardware.camera2.utils.SubmitInfo in project platform_frameworks_base by android.

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

use of android.hardware.camera2.utils.SubmitInfo in project platform_frameworks_base by android.

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)

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