Java Code Examples for android.hardware.camera2.CameraCaptureSession#SESSION_ID_NONE

The following examples show how to use android.hardware.camera2.CameraCaptureSession#SESSION_ID_NONE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CameraDeviceImpl.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
public CaptureRequest.Builder createCaptureRequest(int templateType)
        throws CameraAccessException {
    synchronized(mInterfaceLock) {
        checkIfCameraClosedOrInError();

        CameraMetadataNative templatedRequest = null;

        templatedRequest = mRemoteDevice.createDefaultRequest(templateType);

        // If app target SDK is older than O, or it's not a still capture template, enableZsl
        // must be false in the default request.
        if (mAppTargetSdkVersion < Build.VERSION_CODES.O ||
                templateType != TEMPLATE_STILL_CAPTURE) {
            overrideEnableZsl(templatedRequest, false);
        }

        CaptureRequest.Builder builder = new CaptureRequest.Builder(
                templatedRequest, /*reprocess*/false, CameraCaptureSession.SESSION_ID_NONE,
                getId(), /*physicalCameraIdSet*/ null);

        return builder;
    }
}
 
Example 2
Source File: CameraDeviceImpl.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public CaptureRequest.Builder createCaptureRequest(int templateType,
        Set<String> physicalCameraIdSet)
        throws CameraAccessException {
    synchronized(mInterfaceLock) {
        checkIfCameraClosedOrInError();

        for (String physicalId : physicalCameraIdSet) {
            if (physicalId == getId()) {
                throw new IllegalStateException("Physical id matches the logical id!");
            }
        }

        CameraMetadataNative templatedRequest = null;

        templatedRequest = mRemoteDevice.createDefaultRequest(templateType);

        // If app target SDK is older than O, or it's not a still capture template, enableZsl
        // must be false in the default request.
        if (mAppTargetSdkVersion < Build.VERSION_CODES.O ||
                templateType != TEMPLATE_STILL_CAPTURE) {
            overrideEnableZsl(templatedRequest, false);
        }

        CaptureRequest.Builder builder = new CaptureRequest.Builder(
                templatedRequest, /*reprocess*/false, CameraCaptureSession.SESSION_ID_NONE,
                getId(), physicalCameraIdSet);

        return builder;
    }
}
 
Example 3
Source File: CameraConstrainedHighSpeedCaptureSessionImpl.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public List<CaptureRequest> createHighSpeedRequestList(CaptureRequest request)
        throws CameraAccessException {
    if (request == null) {
        throw new IllegalArgumentException("Input capture request must not be null");
    }
    Collection<Surface> outputSurfaces = request.getTargets();
    Range<Integer> fpsRange = request.get(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE);

    StreamConfigurationMap config =
            mCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
    SurfaceUtils.checkConstrainedHighSpeedSurfaces(outputSurfaces, fpsRange, config);

    // Request list size: to limit the preview to 30fps, need use maxFps/30; to maximize
    // the preview frame rate, should use maxBatch size for that high speed stream
    // configuration. We choose the former for now.
    int requestListSize = fpsRange.getUpper() / 30;
    List<CaptureRequest> requestList = new ArrayList<CaptureRequest>();

    // Prepare the Request builders: need carry over the request controls.
    // First, create a request builder that will only include preview or recording target.
    CameraMetadataNative requestMetadata = new CameraMetadataNative(request.getNativeCopy());
    // Note that after this step, the requestMetadata is mutated (swapped) and can not be used
    // for next request builder creation.
    CaptureRequest.Builder singleTargetRequestBuilder = new CaptureRequest.Builder(
            requestMetadata, /*reprocess*/false, CameraCaptureSession.SESSION_ID_NONE,
            request.getLogicalCameraId(), /*physicalCameraIdSet*/ null);
    // Carry over userTag, as native metadata doesn't have this field.
    singleTargetRequestBuilder.setTag(request.getTag());

    // Overwrite the capture intent to make sure a good value is set.
    Iterator<Surface> iterator = outputSurfaces.iterator();
    Surface firstSurface = iterator.next();
    Surface secondSurface = null;
    if (outputSurfaces.size() == 1 && SurfaceUtils.isSurfaceForHwVideoEncoder(firstSurface)) {
        singleTargetRequestBuilder.set(CaptureRequest.CONTROL_CAPTURE_INTENT,
                CaptureRequest.CONTROL_CAPTURE_INTENT_PREVIEW);
    } else {
        // Video only, or preview + video
        singleTargetRequestBuilder.set(CaptureRequest.CONTROL_CAPTURE_INTENT,
                CaptureRequest.CONTROL_CAPTURE_INTENT_VIDEO_RECORD);
    }
    singleTargetRequestBuilder.setPartOfCHSRequestList(/*partOfCHSList*/true);

    // Second, Create a request builder that will include both preview and recording targets.
    CaptureRequest.Builder doubleTargetRequestBuilder = null;
    if (outputSurfaces.size() == 2) {
        // Have to create a new copy, the original one was mutated after a new
        // CaptureRequest.Builder creation.
        requestMetadata = new CameraMetadataNative(request.getNativeCopy());
        doubleTargetRequestBuilder = new CaptureRequest.Builder(
                requestMetadata, /*reprocess*/false, CameraCaptureSession.SESSION_ID_NONE,
                request.getLogicalCameraId(), /*physicalCameraIdSet*/null);
        doubleTargetRequestBuilder.setTag(request.getTag());
        doubleTargetRequestBuilder.set(CaptureRequest.CONTROL_CAPTURE_INTENT,
                CaptureRequest.CONTROL_CAPTURE_INTENT_VIDEO_RECORD);
        doubleTargetRequestBuilder.addTarget(firstSurface);
        secondSurface = iterator.next();
        doubleTargetRequestBuilder.addTarget(secondSurface);
        doubleTargetRequestBuilder.setPartOfCHSRequestList(/*partOfCHSList*/true);
        // Make sure singleTargetRequestBuilder contains only recording surface for
        // preview + recording case.
        Surface recordingSurface = firstSurface;
        if (!SurfaceUtils.isSurfaceForHwVideoEncoder(recordingSurface)) {
            recordingSurface = secondSurface;
        }
        singleTargetRequestBuilder.addTarget(recordingSurface);
    } else {
        // Single output case: either recording or preview.
        singleTargetRequestBuilder.addTarget(firstSurface);
    }

    // Generate the final request list.
    for (int i = 0; i < requestListSize; i++) {
        if (i == 0 && doubleTargetRequestBuilder != null) {
            // First request should be recording + preview request
            requestList.add(doubleTargetRequestBuilder.build());
        } else {
            requestList.add(singleTargetRequestBuilder.build());
        }
    }

    return Collections.unmodifiableList(requestList);
}