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      * If set to 1, the HAL will always split result
    338      * metadata for a single capture into multiple buffers,
    339      * returned using multiple process_capture_result calls.
    340      * </p>
    341      * <p>
    342      * Does not need to be listed in static
    343      * metadata. Support for partial results will be reworked in
    344      * future versions of camera service. This quirk will stop
    345      * working at that point; DO NOT USE without careful
    346      * consideration of future support.
    347      * </p>
    348      *
    349      * <b>Optional</b> - This value may be null on some devices.
    350      *
    351      * @hide
    352      */
    353     public static final Key<Byte> QUIRKS_USE_PARTIAL_RESULT =
    354             new Key<Byte>("android.quirks.usePartialResult", byte.class);
    355 
    356     /**
    357      * <p>
    358      * How many output streams can be allocated at
    359      * the same time for each type of stream
    360      * </p>
    361      * <p>
    362      * Video snapshot with preview callbacks requires 3
    363      * processed streams (preview, record, app callbacks) and
    364      * one JPEG stream (snapshot)
    365      * </p>
    366      */
    367     public static final Key<int[]> REQUEST_MAX_NUM_OUTPUT_STREAMS =
    368             new Key<int[]>("android.request.maxNumOutputStreams", int[].class);
    369 
    370     /**
    371      * <p>
    372      * List of app-visible formats
    373      * </p>
    374      */
    375     public static final Key<int[]> SCALER_AVAILABLE_FORMATS =
    376             new Key<int[]>("android.scaler.availableFormats", int[].class);
    377 
    378     /**
    379      * <p>
    380      * The minimum frame duration that is supported
    381      * for each resolution in availableJpegSizes. Should
    382      * correspond to the frame duration when only that JPEG
    383      * stream is active and captured in a burst, with all
    384      * processing set to FAST
    385      * </p>
    386      * <p>
    387      * When multiple streams are configured, the minimum
    388      * frame duration will be >= max(individual stream min
    389      * durations)
    390      * </p>
    391      */
    392     public static final Key<long[]> SCALER_AVAILABLE_JPEG_MIN_DURATIONS =
    393             new Key<long[]>("android.scaler.availableJpegMinDurations", long[].class);
    394 
    395     /**
    396      * <p>
    397      * The resolutions available for output from
    398      * the JPEG block. Listed as width x height
    399      * </p>
    400      */
    401     public static final Key<android.hardware.camera2.Size[]> SCALER_AVAILABLE_JPEG_SIZES =
    402             new Key<android.hardware.camera2.Size[]>("android.scaler.availableJpegSizes", android.hardware.camera2.Size[].class);
    403 
    404     /**
    405      * <p>
    406      * The maximum ratio between active area width
    407      * and crop region width, or between active area height and
    408      * crop region height, if the crop region height is larger
    409      * than width
    410      * </p>
    411      */
    412     public static final Key<Float> SCALER_AVAILABLE_MAX_DIGITAL_ZOOM =
    413             new Key<Float>("android.scaler.availableMaxDigitalZoom", float.class);
    414 
    415     /**
    416      * <p>
    417      * The minimum frame duration that is supported
    418      * for each resolution in availableProcessedSizes. Should
    419      * correspond to the frame duration when only that processed
    420      * stream is active, with all processing set to
    421      * FAST
    422      * </p>
    423      * <p>
    424      * When multiple streams are configured, the minimum
    425      * frame duration will be >= max(individual stream min
    426      * durations)
    427      * </p>
    428      */
    429     public static final Key<long[]> SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS =
    430             new Key<long[]>("android.scaler.availableProcessedMinDurations", long[].class);
    431 
    432     /**
    433      * <p>
    434      * The resolutions available for use with
    435      * processed output streams, such as YV12, NV12, and
    436      * platform opaque YUV/RGB streams to the GPU or video
    437      * encoders. Listed as width, height
    438      * </p>
    439      * <p>
    440      * The actual supported resolution list may be limited by
    441      * consumer end points for different use cases. For example, for
    442      * recording use case, the largest supported resolution may be
    443      * limited by max supported size from encoder, for preview use
    444      * case, the largest supported resolution may be limited by max
    445      * resolution SurfaceTexture/SurfaceView can support.
    446      * </p>
    447      */
    448     public static final Key<android.hardware.camera2.Size[]> SCALER_AVAILABLE_PROCESSED_SIZES =
    449             new Key<android.hardware.camera2.Size[]>("android.scaler.availableProcessedSizes", android.hardware.camera2.Size[].class);
    450 
    451     /**
    452      * <p>
    453      * Area of raw data which corresponds to only
    454      * active pixels; smaller or equal to
    455      * pixelArraySize.
    456      * </p>
    457      */
    458     public static final Key<android.graphics.Rect> SENSOR_INFO_ACTIVE_ARRAY_SIZE =
    459             new Key<android.graphics.Rect>("android.sensor.info.activeArraySize", android.graphics.Rect.class);
    460 
    461     /**
    462      * <p>
    463      * Range of valid sensitivities
    464      * </p>
    465      */
    466     public static final Key<int[]> SENSOR_INFO_SENSITIVITY_RANGE =
    467             new Key<int[]>("android.sensor.info.sensitivityRange", int[].class);
    468 
    469     /**
    470      * <p>
    471      * Range of valid exposure
    472      * times
    473      * </p>
    474      */
    475     public static final Key<long[]> SENSOR_INFO_EXPOSURE_TIME_RANGE =
    476             new Key<long[]>("android.sensor.info.exposureTimeRange", long[].class);
    477 
    478     /**
    479      * <p>
    480      * Maximum possible frame duration (minimum frame
    481      * rate)
    482      * </p>
    483      * <p>
    484      * Minimum duration is a function of resolution,
    485      * processing settings. See
    486      * android.scaler.availableProcessedMinDurations
    487      * android.scaler.availableJpegMinDurations
    488      * android.scaler.availableRawMinDurations
    489      * </p>
    490      */
    491     public static final Key<Long> SENSOR_INFO_MAX_FRAME_DURATION =
    492             new Key<Long>("android.sensor.info.maxFrameDuration", long.class);
    493 
    494     /**
    495      * <p>
    496      * The physical dimensions of the full pixel
    497      * array
    498      * </p>
    499      * <p>
    500      * Needed for FOV calculation for old API
    501      * </p>
    502      */
    503     public static final Key<float[]> SENSOR_INFO_PHYSICAL_SIZE =
    504             new Key<float[]>("android.sensor.info.physicalSize", float[].class);
    505 
    506     /**
    507      * <p>
    508      * Gain factor from electrons to raw units when
    509      * ISO=100
    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<Rational> SENSOR_BASE_GAIN_FACTOR =
    519             new Key<Rational>("android.sensor.baseGainFactor", Rational.class);
    520 
    521     /**
    522      * <p>
    523      * Maximum sensitivity that is implemented
    524      * purely through analog gain
    525      * </p>
    526      * <p>
    527      * For android.sensor.sensitivity values less than or
    528      * equal to this, all applied gain must be analog. For
    529      * values above this, it can be a mix of analog and
    530      * digital
    531      * </p>
    532      *
    533      * <b>Optional</b> - This value may be null on some devices.
    534      *
    535      * <b>{@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL_FULL HARDWARE_LEVEL_FULL}</b> -
    536      * Present on all devices that report being FULL level hardware devices in the
    537      * {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL HARDWARE_LEVEL} key.
    538      */
    539     public static final Key<Integer> SENSOR_MAX_ANALOG_SENSITIVITY =
    540             new Key<Integer>("android.sensor.maxAnalogSensitivity", int.class);
    541 
    542     /**
    543      * <p>
    544      * Clockwise angle through which the output
    545      * image needs to be rotated to be upright on the device
    546      * screen in its native orientation. Also defines the
    547      * direction of rolling shutter readout, which is from top
    548      * to bottom in the sensor's coordinate system
    549      * </p>
    550      */
    551     public static final Key<Integer> SENSOR_ORIENTATION =
    552             new Key<Integer>("android.sensor.orientation", int.class);
    553 
    554     /**
    555      * <p>
    556      * Which face detection modes are available,
    557      * if any
    558      * </p>
    559      * <p>
    560      * OFF means face detection is disabled, it must
    561      * be included in the list.
    562      * </p><p>
    563      * SIMPLE means the device supports the
    564      * android.statistics.faceRectangles and
    565      * android.statistics.faceScores outputs.
    566      * </p><p>
    567      * FULL means the device additionally supports the
    568      * android.statistics.faceIds and
    569      * android.statistics.faceLandmarks outputs.
    570      * </p>
    571      */
    572     public static final Key<byte[]> STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES =
    573             new Key<byte[]>("android.statistics.info.availableFaceDetectModes", byte[].class);
    574 
    575     /**
    576      * <p>
    577      * Maximum number of simultaneously detectable
    578      * faces
    579      * </p>
    580      */
    581     public static final Key<Integer> STATISTICS_INFO_MAX_FACE_COUNT =
    582             new Key<Integer>("android.statistics.info.maxFaceCount", int.class);
    583 
    584     /**
    585      * <p>
    586      * Maximum number of supported points in the
    587      * tonemap curve
    588      * </p>
    589      */
    590     public static final Key<Integer> TONEMAP_MAX_CURVE_POINTS =
    591             new Key<Integer>("android.tonemap.maxCurvePoints", int.class);
    592 
    593     /**
    594      * <p>
    595      * A list of camera LEDs that are available on this system.
    596      * </p>
    597      * @see #LED_AVAILABLE_LEDS_TRANSMIT
    598      *
    599      * @hide
    600      */
    601     public static final Key<int[]> LED_AVAILABLE_LEDS =
    602             new Key<int[]>("android.led.availableLeds", int[].class);
    603 
    604     /**
    605      * <p>
    606      * The camera 3 HAL device can implement one of two possible
    607      * operational modes; limited and full. Full support is
    608      * expected from new higher-end devices. Limited mode has
    609      * hardware requirements roughly in line with those for a
    610      * camera HAL device v1 implementation, and is expected from
    611      * older or inexpensive devices. Full is a strict superset of
    612      * limited, and they share the same essential operational flow.
    613      * </p><p>
    614      * For full details refer to "S3. Operational Modes" in camera3.h
    615      * </p>
    616      * @see #INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED
    617      * @see #INFO_SUPPORTED_HARDWARE_LEVEL_FULL
    618      */
    619     public static final Key<Integer> INFO_SUPPORTED_HARDWARE_LEVEL =
    620             new Key<Integer>("android.info.supportedHardwareLevel", int.class);
    621 
    622     /*~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~
    623      * End generated code
    624      *~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~O@*/
    625 }
    626