Example usage for android.hardware.camera2 CameraCharacteristics SYNC_MAX_LATENCY

List of usage examples for android.hardware.camera2 CameraCharacteristics SYNC_MAX_LATENCY

Introduction

In this page you can find the example usage for android.hardware.camera2 CameraCharacteristics SYNC_MAX_LATENCY.

Prototype

Key SYNC_MAX_LATENCY

To view the source code for android.hardware.camera2 CameraCharacteristics SYNC_MAX_LATENCY.

Click Source Link

Document

The maximum number of frames that can occur after a request (different than the previous) has been submitted, and before the result's state becomes synchronized.

This defines the maximum distance (in number of metadata results), between the frame number of the request that has new controls to apply and the frame number of the result that has all the controls applied.

In other words this acts as an upper boundary for how many frames must occur before the camera device knows for a fact that the new submitted camera settings have been applied in outgoing frames.

Units: Frame counts

Possible values:

  • #SYNC_MAX_LATENCY_PER_FRAME_CONTROL PER_FRAME_CONTROL
  • #SYNC_MAX_LATENCY_UNKNOWN UNKNOWN

Available values for this device:
A positive value, PER_FRAME_CONTROL, or UNKNOWN.

This key is available on all devices.

Usage

From source file:com.example.android.hdrviewfinder.HdrViewfinderActivity.java

private void findAndOpenCamera() {
    boolean cameraPermissions = checkCameraPermissions();
    if (cameraPermissions) {
        String errorMessage = "Unknown error";
        boolean foundCamera = false;
        initializeCamera();//w  w  w . j av  a  2s  .c  o m
        if (cameraPermissions && mCameraOps != null) {
            try {
                // Find first back-facing camera that has necessary capability.
                String[] cameraIds = mCameraManager.getCameraIdList();
                for (String id : cameraIds) {
                    CameraCharacteristics info = mCameraManager.getCameraCharacteristics(id);
                    int facing = info.get(CameraCharacteristics.LENS_FACING);

                    int level = info.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
                    boolean hasFullLevel = (level == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL);

                    int[] capabilities = info.get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES);
                    int syncLatency = info.get(CameraCharacteristics.SYNC_MAX_LATENCY);
                    boolean hasManualControl = hasCapability(capabilities,
                            CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR);
                    boolean hasEnoughCapability = hasManualControl
                            && syncLatency == CameraCharacteristics.SYNC_MAX_LATENCY_PER_FRAME_CONTROL;

                    // All these are guaranteed by
                    // CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL, but checking
                    // for only the things we care about expands range of devices we can run on.
                    // We want:
                    //  - Back-facing camera
                    //  - Manual sensor control
                    //  - Per-frame synchronization (so that exposure can be changed every frame)
                    if (facing == CameraCharacteristics.LENS_FACING_BACK
                            && (hasFullLevel || hasEnoughCapability)) {
                        // Found suitable camera - get info, open, and set up outputs
                        mCameraInfo = info;
                        mCameraOps.openCamera(id);
                        configureSurfaces();
                        foundCamera = true;
                        break;
                    }
                }
                if (!foundCamera) {
                    errorMessage = getString(R.string.camera_no_good);
                }
            } catch (CameraAccessException e) {
                errorMessage = getErrorString(e);
            }
            if (!foundCamera) {
                showErrorDialog(errorMessage);
            }
        }
    }
}