CameraCharacteristics.java revision 7a9b30e9e3e45d387d2fc0cb2bd2eb79da7dd268
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
17package android.hardware.camera2;
18
19import android.hardware.camera2.impl.CameraMetadataNative;
20
21import java.util.Collections;
22import 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 */
35public 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>Which set of antibanding modes are
131     * supported</p>
132     */
133    public static final Key<byte[]> CONTROL_AE_AVAILABLE_ANTIBANDING_MODES =
134            new Key<byte[]>("android.control.aeAvailableAntibandingModes", byte[].class);
135
136    /**
137     * <p>List of frame rate ranges supported by the
138     * AE algorithm/hardware</p>
139     */
140    public static final Key<int[]> CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES =
141            new Key<int[]>("android.control.aeAvailableTargetFpsRanges", int[].class);
142
143    /**
144     * <p>Maximum and minimum exposure compensation
145     * setting, in counts of
146     * android.control.aeCompensationStepSize</p>
147     */
148    public static final Key<int[]> CONTROL_AE_COMPENSATION_RANGE =
149            new Key<int[]>("android.control.aeCompensationRange", int[].class);
150
151    /**
152     * <p>Smallest step by which exposure compensation
153     * can be changed</p>
154     */
155    public static final Key<Rational> CONTROL_AE_COMPENSATION_STEP =
156            new Key<Rational>("android.control.aeCompensationStep", Rational.class);
157
158    /**
159     * <p>List of AF modes that can be
160     * selected</p>
161     */
162    public static final Key<byte[]> CONTROL_AF_AVAILABLE_MODES =
163            new Key<byte[]>("android.control.afAvailableModes", byte[].class);
164
165    /**
166     * <p>what subset of the full color effect enum
167     * list is supported</p>
168     */
169    public static final Key<byte[]> CONTROL_AVAILABLE_EFFECTS =
170            new Key<byte[]>("android.control.availableEffects", byte[].class);
171
172    /**
173     * <p>what subset of the scene mode enum list is
174     * supported.</p>
175     */
176    public static final Key<byte[]> CONTROL_AVAILABLE_SCENE_MODES =
177            new Key<byte[]>("android.control.availableSceneModes", byte[].class);
178
179    /**
180     * <p>List of video stabilization modes that can
181     * be supported</p>
182     */
183    public static final Key<byte[]> CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES =
184            new Key<byte[]>("android.control.availableVideoStabilizationModes", byte[].class);
185
186    /**
187     */
188    public static final Key<byte[]> CONTROL_AWB_AVAILABLE_MODES =
189            new Key<byte[]>("android.control.awbAvailableModes", byte[].class);
190
191    /**
192     * <p>For AE, AWB, and AF, how many individual
193     * regions can be listed for metering?</p>
194     */
195    public static final Key<Integer> CONTROL_MAX_REGIONS =
196            new Key<Integer>("android.control.maxRegions", int.class);
197
198    /**
199     * <p>Whether this camera has a
200     * flash</p>
201     * <p>If no flash, none of the flash controls do
202     * anything. All other metadata should return 0</p>
203     */
204    public static final Key<Byte> FLASH_INFO_AVAILABLE =
205            new Key<Byte>("android.flash.info.available", byte.class);
206
207    /**
208     * <p>Supported resolutions for the JPEG
209     * thumbnail</p>
210     */
211    public static final Key<android.hardware.camera2.Size[]> JPEG_AVAILABLE_THUMBNAIL_SIZES =
212            new Key<android.hardware.camera2.Size[]>("android.jpeg.availableThumbnailSizes", android.hardware.camera2.Size[].class);
213
214    /**
215     * <p>List of supported aperture
216     * values</p>
217     * <p>If variable aperture not available, only setting
218     * should be for the fixed aperture</p>
219     */
220    public static final Key<float[]> LENS_INFO_AVAILABLE_APERTURES =
221            new Key<float[]>("android.lens.info.availableApertures", float[].class);
222
223    /**
224     * <p>List of supported ND filter
225     * values</p>
226     * <p>If not available, only setting is 0. Otherwise,
227     * lists the available exposure index values for dimming
228     * (2 would mean the filter is set to reduce incoming
229     * light by two stops)</p>
230     */
231    public static final Key<float[]> LENS_INFO_AVAILABLE_FILTER_DENSITIES =
232            new Key<float[]>("android.lens.info.availableFilterDensities", float[].class);
233
234    /**
235     * <p>If fitted with optical zoom, what focal
236     * lengths are available. If not, the static focal
237     * length</p>
238     * <p>If optical zoom not supported, only one value
239     * should be reported</p>
240     */
241    public static final Key<float[]> LENS_INFO_AVAILABLE_FOCAL_LENGTHS =
242            new Key<float[]>("android.lens.info.availableFocalLengths", float[].class);
243
244    /**
245     * <p>List of supported optical image
246     * stabilization modes</p>
247     */
248    public static final Key<byte[]> LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION =
249            new Key<byte[]>("android.lens.info.availableOpticalStabilization", byte[].class);
250
251    /**
252     * <p>Hyperfocal distance for this lens; set to
253     * 0 if fixed focus</p>
254     * <p>The hyperfocal distance is used for the old
255     * API's 'fixed' setting</p>
256     */
257    public static final Key<Float> LENS_INFO_HYPERFOCAL_DISTANCE =
258            new Key<Float>("android.lens.info.hyperfocalDistance", float.class);
259
260    /**
261     * <p>Shortest distance from frontmost surface
262     * of the lens that can be focused correctly</p>
263     * <p>If the lens is fixed-focus, this should be
264     * 0</p>
265     */
266    public static final Key<Float> LENS_INFO_MINIMUM_FOCUS_DISTANCE =
267            new Key<Float>("android.lens.info.minimumFocusDistance", float.class);
268
269    /**
270     * <p>Dimensions of lens shading map.</p>
271     * <p>The map should be on the order of 30-40 rows and columns, and
272     * must be smaller than 64x64.</p>
273     */
274    public static final Key<android.hardware.camera2.Size> LENS_INFO_SHADING_MAP_SIZE =
275            new Key<android.hardware.camera2.Size>("android.lens.info.shadingMapSize", android.hardware.camera2.Size.class);
276
277    /**
278     * <p>Direction the camera faces relative to
279     * device screen</p>
280     * @see #LENS_FACING_FRONT
281     * @see #LENS_FACING_BACK
282     */
283    public static final Key<Integer> LENS_FACING =
284            new Key<Integer>("android.lens.facing", int.class);
285
286    /**
287     * <p>If set to 1, the HAL will always split result
288     * metadata for a single capture into multiple buffers,
289     * returned using multiple process_capture_result calls.</p>
290     * <p>Does not need to be listed in static
291     * metadata. Support for partial results will be reworked in
292     * future versions of camera service. This quirk will stop
293     * working at that point; DO NOT USE without careful
294     * consideration of future support.</p>
295     *
296     * <b>Optional</b> - This value may be null on some devices.
297     *
298     * @hide
299     */
300    public static final Key<Byte> QUIRKS_USE_PARTIAL_RESULT =
301            new Key<Byte>("android.quirks.usePartialResult", byte.class);
302
303    /**
304     * <p>How many output streams can be allocated at
305     * the same time for each type of stream</p>
306     * <p>Video snapshot with preview callbacks requires 3
307     * processed streams (preview, record, app callbacks) and
308     * one JPEG stream (snapshot)</p>
309     */
310    public static final Key<int[]> REQUEST_MAX_NUM_OUTPUT_STREAMS =
311            new Key<int[]>("android.request.maxNumOutputStreams", int[].class);
312
313    /**
314     * <p>List of app-visible formats</p>
315     */
316    public static final Key<int[]> SCALER_AVAILABLE_FORMATS =
317            new Key<int[]>("android.scaler.availableFormats", int[].class);
318
319    /**
320     * <p>The minimum frame duration that is supported
321     * for each resolution in availableJpegSizes. Should
322     * correspond to the frame duration when only that JPEG
323     * stream is active and captured in a burst, with all
324     * processing set to FAST</p>
325     * <p>When multiple streams are configured, the minimum
326     * frame duration will be &gt;= max(individual stream min
327     * durations)</p>
328     */
329    public static final Key<long[]> SCALER_AVAILABLE_JPEG_MIN_DURATIONS =
330            new Key<long[]>("android.scaler.availableJpegMinDurations", long[].class);
331
332    /**
333     * <p>The resolutions available for output from
334     * the JPEG block. Listed as width x height</p>
335     */
336    public static final Key<android.hardware.camera2.Size[]> SCALER_AVAILABLE_JPEG_SIZES =
337            new Key<android.hardware.camera2.Size[]>("android.scaler.availableJpegSizes", android.hardware.camera2.Size[].class);
338
339    /**
340     * <p>The maximum ratio between active area width
341     * and crop region width, or between active area height and
342     * crop region height, if the crop region height is larger
343     * than width</p>
344     */
345    public static final Key<Float> SCALER_AVAILABLE_MAX_DIGITAL_ZOOM =
346            new Key<Float>("android.scaler.availableMaxDigitalZoom", float.class);
347
348    /**
349     * <p>The minimum frame duration that is supported
350     * for each resolution in availableProcessedSizes. Should
351     * correspond to the frame duration when only that processed
352     * stream is active, with all processing set to
353     * FAST</p>
354     * <p>When multiple streams are configured, the minimum
355     * frame duration will be &gt;= max(individual stream min
356     * durations)</p>
357     */
358    public static final Key<long[]> SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS =
359            new Key<long[]>("android.scaler.availableProcessedMinDurations", long[].class);
360
361    /**
362     * <p>The resolutions available for use with
363     * processed output streams, such as YV12, NV12, and
364     * platform opaque YUV/RGB streams to the GPU or video
365     * encoders. Listed as width, height</p>
366     * <p>The actual supported resolution list may be limited by
367     * consumer end points for different use cases. For example, for
368     * recording use case, the largest supported resolution may be
369     * limited by max supported size from encoder, for preview use
370     * case, the largest supported resolution may be limited by max
371     * resolution SurfaceTexture/SurfaceView can support.</p>
372     */
373    public static final Key<android.hardware.camera2.Size[]> SCALER_AVAILABLE_PROCESSED_SIZES =
374            new Key<android.hardware.camera2.Size[]>("android.scaler.availableProcessedSizes", android.hardware.camera2.Size[].class);
375
376    /**
377     * <p>Area of raw data which corresponds to only
378     * active pixels; smaller or equal to
379     * pixelArraySize.</p>
380     */
381    public static final Key<android.graphics.Rect> SENSOR_INFO_ACTIVE_ARRAY_SIZE =
382            new Key<android.graphics.Rect>("android.sensor.info.activeArraySize", android.graphics.Rect.class);
383
384    /**
385     * <p>Range of valid sensitivities</p>
386     */
387    public static final Key<int[]> SENSOR_INFO_SENSITIVITY_RANGE =
388            new Key<int[]>("android.sensor.info.sensitivityRange", int[].class);
389
390    /**
391     * <p>Range of valid exposure
392     * times</p>
393     */
394    public static final Key<long[]> SENSOR_INFO_EXPOSURE_TIME_RANGE =
395            new Key<long[]>("android.sensor.info.exposureTimeRange", long[].class);
396
397    /**
398     * <p>Maximum possible frame duration (minimum frame
399     * rate)</p>
400     * <p>Minimum duration is a function of resolution,
401     * processing settings. See
402     * android.scaler.availableProcessedMinDurations
403     * android.scaler.availableJpegMinDurations
404     * android.scaler.availableRawMinDurations</p>
405     */
406    public static final Key<Long> SENSOR_INFO_MAX_FRAME_DURATION =
407            new Key<Long>("android.sensor.info.maxFrameDuration", long.class);
408
409    /**
410     * <p>The physical dimensions of the full pixel
411     * array</p>
412     * <p>Needed for FOV calculation for old API</p>
413     */
414    public static final Key<float[]> SENSOR_INFO_PHYSICAL_SIZE =
415            new Key<float[]>("android.sensor.info.physicalSize", float[].class);
416
417    /**
418     * <p>Gain factor from electrons to raw units when
419     * ISO=100</p>
420     *
421     * <b>Optional</b> - This value may be null on some devices.
422     *
423     * <b>{@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL_FULL HARDWARE_LEVEL_FULL}</b> -
424     * Present on all devices that report being FULL level hardware devices in the
425     * {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL HARDWARE_LEVEL} key.
426     */
427    public static final Key<Rational> SENSOR_BASE_GAIN_FACTOR =
428            new Key<Rational>("android.sensor.baseGainFactor", Rational.class);
429
430    /**
431     * <p>Maximum sensitivity that is implemented
432     * purely through analog gain</p>
433     * <p>For android.sensor.sensitivity values less than or
434     * equal to this, all applied gain must be analog. For
435     * values above this, it can be a mix of analog and
436     * digital</p>
437     *
438     * <b>Optional</b> - This value may be null on some devices.
439     *
440     * <b>{@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL_FULL HARDWARE_LEVEL_FULL}</b> -
441     * Present on all devices that report being FULL level hardware devices in the
442     * {@link CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL HARDWARE_LEVEL} key.
443     */
444    public static final Key<Integer> SENSOR_MAX_ANALOG_SENSITIVITY =
445            new Key<Integer>("android.sensor.maxAnalogSensitivity", int.class);
446
447    /**
448     * <p>Clockwise angle through which the output
449     * image needs to be rotated to be upright on the device
450     * screen in its native orientation. Also defines the
451     * direction of rolling shutter readout, which is from top
452     * to bottom in the sensor's coordinate system</p>
453     */
454    public static final Key<Integer> SENSOR_ORIENTATION =
455            new Key<Integer>("android.sensor.orientation", int.class);
456
457    /**
458     * <p>Which face detection modes are available,
459     * if any</p>
460     * <p>OFF means face detection is disabled, it must
461     * be included in the list.</p>
462     * <p>SIMPLE means the device supports the
463     * android.statistics.faceRectangles and
464     * android.statistics.faceScores outputs.</p>
465     * <p>FULL means the device additionally supports the
466     * android.statistics.faceIds and
467     * android.statistics.faceLandmarks outputs.</p>
468     */
469    public static final Key<byte[]> STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES =
470            new Key<byte[]>("android.statistics.info.availableFaceDetectModes", byte[].class);
471
472    /**
473     * <p>Maximum number of simultaneously detectable
474     * faces</p>
475     */
476    public static final Key<Integer> STATISTICS_INFO_MAX_FACE_COUNT =
477            new Key<Integer>("android.statistics.info.maxFaceCount", int.class);
478
479    /**
480     * <p>Maximum number of supported points in the
481     * tonemap curve</p>
482     */
483    public static final Key<Integer> TONEMAP_MAX_CURVE_POINTS =
484            new Key<Integer>("android.tonemap.maxCurvePoints", int.class);
485
486    /**
487     * <p>A list of camera LEDs that are available on this system.</p>
488     * @see #LED_AVAILABLE_LEDS_TRANSMIT
489     *
490     * @hide
491     */
492    public static final Key<int[]> LED_AVAILABLE_LEDS =
493            new Key<int[]>("android.led.availableLeds", int[].class);
494
495    /**
496     * <p>The camera 3 HAL device can implement one of two possible
497     * operational modes; limited and full. Full support is
498     * expected from new higher-end devices. Limited mode has
499     * hardware requirements roughly in line with those for a
500     * camera HAL device v1 implementation, and is expected from
501     * older or inexpensive devices. Full is a strict superset of
502     * limited, and they share the same essential operational flow.</p>
503     * <p>For full details refer to "S3. Operational Modes" in camera3.h</p>
504     * @see #INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED
505     * @see #INFO_SUPPORTED_HARDWARE_LEVEL_FULL
506     */
507    public static final Key<Integer> INFO_SUPPORTED_HARDWARE_LEVEL =
508            new Key<Integer>("android.info.supportedHardwareLevel", int.class);
509
510    /*~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~
511     * End generated code
512     *~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~O@*/
513}
514