Home | History | Annotate | Download | only in camera2
      1 /*
      2  * Copyright (C) 2013 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.hardware.camera2;
     18 
     19 import android.hardware.camera2.impl.CameraMetadataNative;
     20 
     21 import java.util.Collections;
     22 import java.util.List;
     23 
     24 /**
     25  * <p>The properties describing a
     26  * {@link CameraDevice CameraDevice}.</p>
     27  *
     28  * <p>These properties are fixed for a given CameraDevice, and can be queried
     29  * through the {@link CameraManager CameraManager}
     30  * interface in addition to through the CameraDevice interface.</p>
     31  *
     32  * @see CameraDevice
     33  * @see CameraManager
     34  */
     35 public final class CameraCharacteristics extends CameraMetadata {
     36 
     37     private final CameraMetadataNative mProperties;
     38     private List<Key<?>> mAvailableRequestKeys;
     39     private List<Key<?>> mAvailableResultKeys;
     40 
     41     /**
     42      * Takes ownership of the passed-in properties object
     43      * @hide
     44      */
     45     public CameraCharacteristics(CameraMetadataNative properties) {
     46         mProperties = properties;
     47     }
     48 
     49     @Override
     50     public <T> T get(Key<T> key) {
     51         return mProperties.get(key);
     52     }
     53 
     54     /**
     55      * Returns the list of keys supported by this {@link CameraDevice} for querying
     56      * with a {@link CaptureRequest}.
     57      *
     58      * <p>The list returned is not modifiable, so any attempts to modify it will throw
     59      * a {@code UnsupportedOperationException}.</p>
     60      *
     61      * <p>Each key is only listed once in the list. The order of the keys is undefined.</p>
     62      *
     63      * <p>Note that there is no {@code getAvailableCameraCharacteristicsKeys()} -- use
     64      * {@link #getKeys()} instead.</p>
     65      *
     66      * @return List of keys supported by this CameraDevice for CaptureRequests.
     67      */
     68     public List<Key<?>> getAvailableCaptureRequestKeys() {
     69         if (mAvailableRequestKeys == null) {
     70             mAvailableRequestKeys = getAvailableKeyList(CaptureRequest.class);
     71         }
     72         return mAvailableRequestKeys;
     73     }
     74 
     75     /**
     76      * Returns the list of keys supported by this {@link CameraDevice} for querying
     77      * with a {@link CaptureResult}.
     78      *
     79      * <p>The list returned is not modifiable, so any attempts to modify it will throw
     80      * a {@code UnsupportedOperationException}.</p>
     81      *
     82      * <p>Each key is only listed once in the list. The order of the keys is undefined.</p>
     83      *
     84      * <p>Note that there is no {@code getAvailableCameraCharacteristicsKeys()} -- use
     85      * {@link #getKeys()} instead.</p>
     86      *
     87      * @return List of keys supported by this CameraDevice for CaptureResults.
     88      */
     89     public List<Key<?>> getAvailableCaptureResultKeys() {
     90         if (mAvailableResultKeys == null) {
     91             mAvailableResultKeys = getAvailableKeyList(CaptureResult.class);
     92         }
     93         return mAvailableResultKeys;
     94     }
     95 
     96     /**
     97      * Returns the list of keys supported by this {@link CameraDevice} by metadataClass.
     98      *
     99      * <p>The list returned is not modifiable, so any attempts to modify it will throw
    100      * a {@code UnsupportedOperationException}.</p>
    101      *
    102      * <p>Each key is only listed once in the list. The order of the keys is undefined.</p>
    103      *
    104      * @param metadataClass The subclass of CameraMetadata that you want to get the keys for.
    105      *
    106      * @return List of keys supported by this CameraDevice for metadataClass.
    107      *
    108      * @throws IllegalArgumentException if metadataClass is not a subclass of CameraMetadata
    109      */
    110     private <T extends CameraMetadata> List<Key<?>> getAvailableKeyList(Class<T> metadataClass) {
    111 
    112         if (metadataClass.equals(CameraMetadata.class)) {
    113             throw new AssertionError(
    114                     "metadataClass must be a strict subclass of CameraMetadata");
    115         } else if (!CameraMetadata.class.isAssignableFrom(metadataClass)) {
    116             throw new AssertionError(
    117                     "metadataClass must be a subclass of CameraMetadata");
    118         }
    119 
    120         return Collections.unmodifiableList(getKeysStatic(metadataClass, /*instance*/null));
    121     }
    122 
    123     /*@O~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~
    124      * The key entries below this point are generated from metadata
    125      * definitions in /system/media/camera/docs. Do not modify by hand or
    126      * modify the comment blocks at the start or end.
    127      *~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~*/
    128 
    129     /**
    130      * <p>
    131      * Which set of antibanding modes are
    132      * supported
    133      * </p>
    134      */
    135     public static final Key<byte[]> CONTROL_AE_AVAILABLE_ANTIBANDING_MODES =
    136             new Key<byte[]>("android.control.aeAvailableAntibandingModes", byte[].class);
    137 
    138     /**
    139      * <p>
    140      * List of frame rate ranges supported by the
    141      * AE algorithm/hardware
    142      * </p>
    143      */
    144     public static final Key<int[]> CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES =
    145             new Key<int[]>("android.control.aeAvailableTargetFpsRanges", int[].class);
    146 
    147     /**
    148      * <p>
    149      * Maximum and minimum exposure compensation
    150      * setting, in counts of
    151      * android.control.aeCompensationStepSize
    152      * </p>
    153      */
    154     public static final Key<int[]> CONTROL_AE_COMPENSATION_RANGE =
    155             new Key<int[]>("android.control.aeCompensationRange", int[].class);
    156 
    157     /**
    158      * <p>
    159      * Smallest step by which exposure compensation
    160      * can be changed
    161      * </p>
    162      */
    163     public static final Key<Rational> CONTROL_AE_COMPENSATION_STEP =
    164             new Key<Rational>("android.control.aeCompensationStep", Rational.class);
    165 
    166     /**
    167      * <p>
    168      * List of AF modes that can be
    169      * selected
    170      * </p>
    171      */
    172     public static final Key<byte[]> CONTROL_AF_AVAILABLE_MODES =
    173             new Key<byte[]>("android.control.afAvailableModes", byte[].class);
    174 
    175     /**
    176      * <p>
    177      * what subset of the full color effect enum
    178      * list is supported
    179      * </p>
    180      */
    181     public static final Key<byte[]> CONTROL_AVAILABLE_EFFECTS =
    182             new Key<byte[]>("android.control.availableEffects", byte[].class);
    183 
    184     /**
    185      * <p>
    186      * what subset of the scene mode enum list is
    187      * supported.
    188      * </p>
    189      */
    190     public static final Key<byte[]> CONTROL_AVAILABLE_SCENE_MODES =
    191             new Key<byte[]>("android.control.availableSceneModes", byte[].class);
    192 
    193     /**
    194      * <p>
    195      * List of video stabilization modes that can
    196      * be supported
    197      * </p>
    198      */
    199     public static final Key<byte[]> CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES =
    200             new Key<byte[]>("android.control.availableVideoStabilizationModes", byte[].class);
    201 
    202     /**
    203      */
    204     public static final Key<byte[]> CONTROL_AWB_AVAILABLE_MODES =
    205             new Key<byte[]>("android.control.awbAvailableModes", byte[].class);
    206 
    207     /**
    208      * <p>
    209      * For AE, AWB, and AF, how many individual
    210      * regions can be listed for metering?
    211      * </p>
    212      */
    213     public static final Key<Integer> CONTROL_MAX_REGIONS =
    214             new Key<Integer>("android.control.maxRegions", int.class);
    215 
    216     /**
    217      * <p>
    218      * Whether this camera has a
    219      * flash
    220      * </p>
    221      * <p>
    222      * If no flash, none of the flash controls do
    223      * anything. All other metadata should return 0
    224      * </p>
    225      */
    226     public static final Key<Byte> FLASH_INFO_AVAILABLE =
    227             new Key<Byte>("android.flash.info.available", byte.class);
    228 
    229     /**
    230      * <p>
    231      * Supported resolutions for the JPEG
    232      * thumbnail
    233      * </p>
    234      */
    235     public static final Key<android.hardware.camera2.Size[]> JPEG_AVAILABLE_THUMBNAIL_SIZES =
    236             new Key<android.hardware.camera2.Size[]>("android.jpeg.availableThumbnailSizes", android.hardware.camera2.Size[].class);
    237 
    238     /**
    239      * <p>
    240      * List of supported aperture
    241      * values
    242      * </p>
    243      * <p>
    244      * If variable aperture not available, only setting
    245      * should be for the fixed aperture
    246      * </p>
    247      */
    248     public static final Key<float[]> LENS_INFO_AVAILABLE_APERTURES =
    249             new Key<float[]>("android.lens.info.availableApertures", float[].class);
    250 
    251     /**
    252      * <p>
    253      * List of supported ND filter
    254      * values
    255      * </p>
    256      * <p>
    257      * If not available, only setting is 0. Otherwise,
    258      * lists the available exposure index values for dimming
    259      * (2 would mean the filter is set to reduce incoming
    260      * light by two stops)
    261      * </p>
    262      */
    263     public static final Key<float[]> LENS_INFO_AVAILABLE_FILTER_DENSITIES =
    264             new Key<float[]>("android.lens.info.availableFilterDensities", float[].class);
    265 
    266     /**
    267      * <p>
    268      * If fitted with optical zoom, what focal
    269      * lengths are available. If not, the static focal
    270      * length
    271      * </p>
    272      * <p>
    273      * If optical zoom not supported, only one value
    274      * should be reported
    275      * </p>
    276      */
    277     public static final Key<float[]> LENS_INFO_AVAILABLE_FOCAL_LENGTHS =
    278             new Key<float[]>("android.lens.info.availableFocalLengths", float[].class);
    279 
    280     /**
    281      * <p>
    282      * List of supported optical image
    283      * stabilization modes
    284      * </p>
    285      */
    286     public static final Key<byte[]> LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION =
    287             new Key<byte[]>("android.lens.info.availableOpticalStabilization", byte[].class);
    288 
    289     /**
    290      * <p>
    291      * Hyperfocal distance for this lens; set to
    292      * 0 if fixed focus
    293      * </p>
    294      * <p>
    295      * The hyperfocal distance is used for the old
    296      * API's 'fixed' setting
    297      * </p>
    298      */
    299     public static final Key<Float> LENS_INFO_HYPERFOCAL_DISTANCE =
    300             new Key<Float>("android.lens.info.hyperfocalDistance", float.class);
    301 
    302     /**
    303      * <p>
    304      * Shortest distance from frontmost surface
    305      * of the lens that can be focused correctly
    306      * </p>
    307      * <p>
    308      * If the lens is fixed-focus, this should be
    309      * 0
    310      * </p>
    311      */
    312     public static final Key<Float> LENS_INFO_MINIMUM_FOCUS_DISTANCE =
    313             new Key<Float>("android.lens.info.minimumFocusDistance", float.class);
    314 
    315     /**
    316      * <p>
    317      * Dimensions of lens shading
    318      * map
    319      * </p>
    320      */
    321     public static final Key<android.hardware.camera2.Size> LENS_INFO_SHADING_MAP_SIZE =
    322             new Key<android.hardware.camera2.Size>("android.lens.info.shadingMapSize", android.hardware.camera2.Size.class);
    323 
    324     /**
    325      * <p>
    326      * Direction the camera faces relative to
    327      * device screen
    328      * </p>
    329      * @see #LENS_FACING_FRONT
    330      * @see #LENS_FACING_BACK
    331      */
    332     public static final Key<Integer> LENS_FACING =
    333             new Key<Integer>("android.lens.facing", int.class);
    334 
    335     /**
    336      * <p>
    337      * How many output streams can be allocated at
    338      * the same time for each type of stream
    339      * </p>
    340      * <p>
    341      * Video snapshot with preview callbacks requires 3
    342      * processed streams (preview, record, app callbacks) and
    343      * one JPEG stream (snapshot)
    344      * </p>
    345      */
    346     public static final Key<int[]> REQUEST_MAX_NUM_OUTPUT_STREAMS =
    347             new Key<int[]>("android.request.maxNumOutputStreams", int[].class);
    348 
    349     /**
    350      * <p>
    351      * List of app-visible formats
    352      * </p>
    353      */
    354     public static final Key<int[]> SCALER_AVAILABLE_FORMATS =
    355             new Key<int[]>("android.scaler.availableFormats", int[].class);
    356 
    357     /**
    358      * <p>
    359      * The minimum frame duration that is supported
    360      * for each resolution in availableJpegSizes. Should
    361      * correspond to the frame duration when only that JPEG
    362      * stream is active and captured in a burst, with all
    363      * processing set to FAST
    364      * </p>
    365      * <p>
    366      * When multiple streams are configured, the minimum
    367      * frame duration will be >= max(individual stream min
    368      * durations)
    369      * </p>
    370      */
    371     public static final Key<long[]> SCALER_AVAILABLE_JPEG_MIN_DURATIONS =
    372             new Key<long[]>("android.scaler.availableJpegMinDurations", long[].class);
    373 
    374     /**
    375      * <p>
    376      * The resolutions available for output from
    377      * the JPEG block. Listed as width x height
    378      * </p>
    379      */
    380     public static final Key<android.hardware.camera2.Size[]> SCALER_AVAILABLE_JPEG_SIZES =
    381             new Key<android.hardware.camera2.Size[]>("android.scaler.availableJpegSizes", android.hardware.camera2.Size[].class);
    382 
    383     /**
    384      * <p>
    385      * The maximum ratio between active area width
    386      * and crop region width, or between active area height and
    387      * crop region height, if the crop region height is larger
    388      * than width
    389      * </p>
    390      */
    391     public static final Key<Float> SCALER_AVAILABLE_MAX_DIGITAL_ZOOM =
    392             new Key<Float>("android.scaler.availableMaxDigitalZoom", float.class);
    393 
    394     /**
    395      * <p>
    396      * The minimum frame duration that is supported
    397      * for each resolution in availableProcessedSizes. Should
    398      * correspond to the frame duration when only that processed
    399      * stream is active, with all processing set to
    400      * FAST
    401      * </p>
    402      * <p>
    403      * When multiple streams are configured, the minimum
    404      * frame duration will be >= max(individual stream min
    405      * durations)
    406      * </p>
    407      */
    408     public static final Key<long[]> SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS =
    409             new Key<long[]>("android.scaler.availableProcessedMinDurations", long[].class);
    410 
    411     /**
    412      * <p>
    413      * The resolutions available for use with
    414      * processed output streams, such as YV12, NV12, and
    415      * platform opaque YUV/RGB streams to the GPU or video
    416      * encoders. Listed as width, height
    417      * </p>
    418      * <p>
    419      * The actual supported resolution list may be limited by
    420      * consumer end points for different use cases. For example, for
    421      * recording use case, the largest supported resolution may be
    422      * limited by max supported size from encoder, for preview use
    423      * case, the largest supported resolution may be limited by max
    424      * resolution SurfaceTexture/SurfaceView can support.
    425      * </p>
    426      */
    427     public static final Key<android.hardware.camera2.Size[]> SCALER_AVAILABLE_PROCESSED_SIZES =
    428             new Key<android.hardware.camera2.Size[]>("android.scaler.availableProcessedSizes", android.hardware.camera2.Size[].class);
    429 
    430     /**
    431      * <p>
    432      * Area of raw data which corresponds to only
    433      * active pixels; smaller or equal to
    434      * pixelArraySize.
    435      * </p>
    436      */
    437     public static final Key<android.graphics.Rect> SENSOR_INFO_ACTIVE_ARRAY_SIZE =
    438             new Key<android.graphics.Rect>("android.sensor.info.activeArraySize", android.graphics.Rect.class);
    439 
    440     /**
    441      * <p>
    442      * Range of valid sensitivities
    443      * </p>
    444      */
    445     public static final Key<int[]> SENSOR_INFO_SENSITIVITY_RANGE =
    446             new Key<int[]>("android.sensor.info.sensitivityRange", int[].class);
    447 
    448     /**
    449      * <p>
    450      * Range of valid exposure
    451      * times
    452      * </p>
    453      */
    454     public static final Key<long[]> SENSOR_INFO_EXPOSURE_TIME_RANGE =
    455             new Key<long[]>("android.sensor.info.exposureTimeRange", long[].class);
    456 
    457     /**
    458      * <p>
    459      * Maximum possible frame duration (minimum frame
    460      * rate)
    461      * </p>
    462      * <p>
    463      * Minimum duration is a function of resolution,
    464      * processing settings. See
    465      * android.scaler.availableProcessedMinDurations
    466      * android.scaler.availableJpegMinDurations
    467      * android.scaler.availableRawMinDurations
    468      * </p>
    469      */
    470     public static final Key<Long> SENSOR_INFO_MAX_FRAME_DURATION =
    471             new Key<Long>("android.sensor.info.maxFrameDuration", long.class);
    472 
    473     /**
    474      * <p>
    475      * The physical dimensions of the full pixel
    476      * array
    477      * </p>
    478      * <p>
    479      * Needed for FOV calculation for old API
    480      * </p>
    481      */
    482     public static final Key<float[]> SENSOR_INFO_PHYSICAL_SIZE =
    483             new Key<float[]>("android.sensor.info.physicalSize", float[].class);
    484 
    485     /**
    486      * <p>
    487      * Gain factor from electrons to raw units when
    488      * ISO=100
    489      * </p>
    490      *
    491      * <b>Optional</b> - This value may be null on some devices.
    492      *
    493      * <b>{@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL_FULL HARDWARE_LEVEL_FULL}</b> -
    494      * Present on all devices that report being FULL level hardware devices in the
    495      * {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL HARDWARE_LEVEL} key.
    496      */
    497     public static final Key<Rational> SENSOR_BASE_GAIN_FACTOR =
    498             new Key<Rational>("android.sensor.baseGainFactor", Rational.class);
    499 
    500     /**
    501      * <p>
    502      * Maximum sensitivity that is implemented
    503      * purely through analog gain
    504      * </p>
    505      * <p>
    506      * For android.sensor.sensitivity values less than or
    507      * equal to this, all applied gain must be analog. For
    508      * values above this, it can be a mix of analog and
    509      * digital
    510      * </p>
    511      *
    512      * <b>Optional</b> - This value may be null on some devices.
    513      *
    514      * <b>{@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL_FULL HARDWARE_LEVEL_FULL}</b> -
    515      * Present on all devices that report being FULL level hardware devices in the
    516      * {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL HARDWARE_LEVEL} key.
    517      */
    518     public static final Key<Integer> SENSOR_MAX_ANALOG_SENSITIVITY =
    519             new Key<Integer>("android.sensor.maxAnalogSensitivity", int.class);
    520 
    521     /**
    522      * <p>
    523      * Clockwise angle through which the output
    524      * image needs to be rotated to be upright on the device
    525      * screen in its native orientation. Also defines the
    526      * direction of rolling shutter readout, which is from top
    527      * to bottom in the sensor's coordinate system
    528      * </p>
    529      */
    530     public static final Key<Integer> SENSOR_ORIENTATION =
    531             new Key<Integer>("android.sensor.orientation", int.class);
    532 
    533     /**
    534      * <p>
    535      * Which face detection modes are available,
    536      * if any
    537      * </p>
    538      * <p>
    539      * OFF means face detection is disabled, it must
    540      * be included in the list.
    541      * </p><p>
    542      * SIMPLE means the device supports the
    543      * android.statistics.faceRectangles and
    544      * android.statistics.faceScores outputs.
    545      * </p><p>
    546      * FULL means the device additionally supports the
    547      * android.statistics.faceIds and
    548      * android.statistics.faceLandmarks outputs.
    549      * </p>
    550      */
    551     public static final Key<byte[]> STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES =
    552             new Key<byte[]>("android.statistics.info.availableFaceDetectModes", byte[].class);
    553 
    554     /**
    555      * <p>
    556      * Maximum number of simultaneously detectable
    557      * faces
    558      * </p>
    559      */
    560     public static final Key<Integer> STATISTICS_INFO_MAX_FACE_COUNT =
    561             new Key<Integer>("android.statistics.info.maxFaceCount", int.class);
    562 
    563     /**
    564      * <p>
    565      * Maximum number of supported points in the
    566      * tonemap curve
    567      * </p>
    568      */
    569     public static final Key<Integer> TONEMAP_MAX_CURVE_POINTS =
    570             new Key<Integer>("android.tonemap.maxCurvePoints", int.class);
    571 
    572     /**
    573      * <p>
    574      * A list of camera LEDs that are available on this system.
    575      * </p>
    576      * @see #LED_AVAILABLE_LEDS_TRANSMIT
    577      *
    578      * @hide
    579      */
    580     public static final Key<int[]> LED_AVAILABLE_LEDS =
    581             new Key<int[]>("android.led.availableLeds", int[].class);
    582 
    583     /**
    584      * <p>
    585      * The camera 3 HAL device can implement one of two possible
    586      * operational modes; limited and full. Full support is
    587      * expected from new higher-end devices. Limited mode has
    588      * hardware requirements roughly in line with those for a
    589      * camera HAL device v1 implementation, and is expected from
    590      * older or inexpensive devices. Full is a strict superset of
    591      * limited, and they share the same essential operational flow.
    592      * </p><p>
    593      * For full details refer to "S3. Operational Modes" in camera3.h
    594      * </p>
    595      * @see #INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED
    596      * @see #INFO_SUPPORTED_HARDWARE_LEVEL_FULL
    597      */
    598     public static final Key<Integer> INFO_SUPPORTED_HARDWARE_LEVEL =
    599             new Key<Integer>("android.info.supportedHardwareLevel", int.class);
    600 
    601     /*~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~
    602      * End generated code
    603      *~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~O@*/
    604 }
    605