1/*
2 * Copyright (C) 2014 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.params;
18
19import android.graphics.ImageFormat;
20import android.graphics.PixelFormat;
21import android.hardware.camera2.CameraCharacteristics;
22import android.hardware.camera2.CameraDevice;
23import android.hardware.camera2.CaptureRequest;
24import android.hardware.camera2.utils.HashCodeHelpers;
25import android.hardware.camera2.legacy.LegacyCameraDevice;
26import android.hardware.camera2.legacy.LegacyMetadataMapper;
27import android.hardware.camera2.legacy.LegacyExceptionUtils.BufferQueueAbandonedException;
28import android.view.Surface;
29import android.util.Log;
30import android.util.Range;
31import android.util.Size;
32
33import java.util.Arrays;
34import java.util.HashMap;
35import java.util.Objects;
36import java.util.Set;
37
38import static com.android.internal.util.Preconditions.*;
39
40/**
41 * Immutable class to store the available stream
42 * {@link CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP configurations} to set up
43 * {@link android.view.Surface Surfaces} for creating a
44 * {@link android.hardware.camera2.CameraCaptureSession capture session} with
45 * {@link android.hardware.camera2.CameraDevice#createCaptureSession}.
46 * <!-- TODO: link to input stream configuration -->
47 *
48 * <p>This is the authoritative list for all <!-- input/ -->output formats (and sizes respectively
49 * for that format) that are supported by a camera device.</p>
50 *
51 * <p>This also contains the minimum frame durations and stall durations for each format/size
52 * combination that can be used to calculate effective frame rate when submitting multiple captures.
53 * </p>
54 *
55 * <p>An instance of this object is available from {@link CameraCharacteristics} using
56 * the {@link CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP} key and the
57 * {@link CameraCharacteristics#get} method.</p>
58 *
59 * <pre><code>{@code
60 * CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraId);
61 * StreamConfigurationMap configs = characteristics.get(
62 *         CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
63 * }</code></pre>
64 *
65 * @see CameraCharacteristics#SCALER_STREAM_CONFIGURATION_MAP
66 * @see CameraDevice#createCaptureSession
67 */
68public final class StreamConfigurationMap {
69
70    private static final String TAG = "StreamConfigurationMap";
71
72    /**
73     * Create a new {@link StreamConfigurationMap}.
74     *
75     * <p>The array parameters ownership is passed to this object after creation; do not
76     * write to them after this constructor is invoked.</p>
77     *
78     * @param configurations a non-{@code null} array of {@link StreamConfiguration}
79     * @param minFrameDurations a non-{@code null} array of {@link StreamConfigurationDuration}
80     * @param stallDurations a non-{@code null} array of {@link StreamConfigurationDuration}
81     * @param highSpeedVideoConfigurations an array of {@link HighSpeedVideoConfiguration}, null if
82     *        camera device does not support high speed video recording
83     *
84     * @throws NullPointerException if any of the arguments except highSpeedVideoConfigurations
85     *         were {@code null} or any subelements were {@code null}
86     *
87     * @hide
88     */
89    public StreamConfigurationMap(
90            StreamConfiguration[] configurations,
91            StreamConfigurationDuration[] minFrameDurations,
92            StreamConfigurationDuration[] stallDurations,
93            HighSpeedVideoConfiguration[] highSpeedVideoConfigurations) {
94
95        mConfigurations = checkArrayElementsNotNull(configurations, "configurations");
96        mMinFrameDurations = checkArrayElementsNotNull(minFrameDurations, "minFrameDurations");
97        mStallDurations = checkArrayElementsNotNull(stallDurations, "stallDurations");
98        if (highSpeedVideoConfigurations == null) {
99            mHighSpeedVideoConfigurations = new HighSpeedVideoConfiguration[0];
100        } else {
101            mHighSpeedVideoConfigurations = checkArrayElementsNotNull(
102                    highSpeedVideoConfigurations, "highSpeedVideoConfigurations");
103        }
104
105        // For each format, track how many sizes there are available to configure
106        for (StreamConfiguration config : configurations) {
107            HashMap<Integer, Integer> map = config.isOutput() ? mOutputFormats : mInputFormats;
108
109            Integer count = map.get(config.getFormat());
110
111            if (count == null) {
112                count = 0;
113            }
114            count = count + 1;
115
116            map.put(config.getFormat(), count);
117        }
118
119        if (!mOutputFormats.containsKey(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED)) {
120            throw new AssertionError(
121                    "At least one stream configuration for IMPLEMENTATION_DEFINED must exist");
122        }
123
124        // For each Size/FPS range, track how many FPS range/Size there are available
125        for (HighSpeedVideoConfiguration config : mHighSpeedVideoConfigurations) {
126            Size size = config.getSize();
127            Range<Integer> fpsRange = config.getFpsRange();
128            Integer fpsRangeCount = mHighSpeedVideoSizeMap.get(size);
129            if (fpsRangeCount == null) {
130                fpsRangeCount = 0;
131            }
132            mHighSpeedVideoSizeMap.put(size, fpsRangeCount + 1);
133            Integer sizeCount = mHighSpeedVideoFpsRangeMap.get(fpsRange);
134            if (sizeCount == null) {
135                sizeCount = 0;
136            }
137            mHighSpeedVideoFpsRangeMap.put(fpsRange, sizeCount + 1);
138        }
139    }
140
141    /**
142     * Get the image {@code format} output formats in this stream configuration.
143     *
144     * <p>All image formats returned by this function will be defined in either {@link ImageFormat}
145     * or in {@link PixelFormat} (and there is no possibility of collision).</p>
146     *
147     * <p>Formats listed in this array are guaranteed to return true if queried with
148     * {@link #isOutputSupportedFor(int)}.</p>
149     *
150     * @return an array of integer format
151     *
152     * @see ImageFormat
153     * @see PixelFormat
154     */
155    public final int[] getOutputFormats() {
156        return getPublicFormats(/*output*/true);
157    }
158
159    /**
160     * Get the image {@code format} input formats in this stream configuration.
161     *
162     * <p>All image formats returned by this function will be defined in either {@link ImageFormat}
163     * or in {@link PixelFormat} (and there is no possibility of collision).</p>
164     *
165     * @return an array of integer format
166     *
167     * @see ImageFormat
168     * @see PixelFormat
169     *
170     * @hide
171     */
172    public final int[] getInputFormats() {
173        return getPublicFormats(/*output*/false);
174    }
175
176    /**
177     * Get the supported input sizes for this input format.
178     *
179     * <p>The format must have come from {@link #getInputFormats}; otherwise
180     * {@code null} is returned.</p>
181     *
182     * @param format a format from {@link #getInputFormats}
183     * @return a non-empty array of sizes, or {@code null} if the format was not available.
184     *
185     * @hide
186     */
187    public Size[] getInputSizes(final int format) {
188        return getPublicFormatSizes(format, /*output*/false);
189    }
190
191    /**
192     * Determine whether or not output surfaces with a particular user-defined format can be passed
193     * {@link CameraDevice#createCaptureSession createCaptureSession}.
194     *
195     * <p>This method determines that the output {@code format} is supported by the camera device;
196     * each output {@code surface} target may or may not itself support that {@code format}.
197     * Refer to the class which provides the surface for additional documentation.</p>
198     *
199     * <p>Formats for which this returns {@code true} are guaranteed to exist in the result
200     * returned by {@link #getOutputSizes}.</p>
201     *
202     * @param format an image format from either {@link ImageFormat} or {@link PixelFormat}
203     * @return
204     *          {@code true} iff using a {@code surface} with this {@code format} will be
205     *          supported with {@link CameraDevice#createCaptureSession}
206     *
207     * @throws IllegalArgumentException
208     *          if the image format was not a defined named constant
209     *          from either {@link ImageFormat} or {@link PixelFormat}
210     *
211     * @see ImageFormat
212     * @see PixelFormat
213     * @see CameraDevice#createCaptureSession
214     */
215    public boolean isOutputSupportedFor(int format) {
216        checkArgumentFormat(format);
217
218        format = imageFormatToInternal(format);
219        return getFormatsMap(/*output*/true).containsKey(format);
220    }
221
222    /**
223     * Determine whether or not output streams can be configured with a particular class
224     * as a consumer.
225     *
226     * <p>The following list is generally usable for outputs:
227     * <ul>
228     * <li>{@link android.media.ImageReader} -
229     * Recommended for image processing or streaming to external resources (such as a file or
230     * network)
231     * <li>{@link android.media.MediaRecorder} -
232     * Recommended for recording video (simple to use)
233     * <li>{@link android.media.MediaCodec} -
234     * Recommended for recording video (more complicated to use, with more flexibility)
235     * <li>{@link android.renderscript.Allocation} -
236     * Recommended for image processing with {@link android.renderscript RenderScript}
237     * <li>{@link android.view.SurfaceHolder} -
238     * Recommended for low-power camera preview with {@link android.view.SurfaceView}
239     * <li>{@link android.graphics.SurfaceTexture} -
240     * Recommended for OpenGL-accelerated preview processing or compositing with
241     * {@link android.view.TextureView}
242     * </ul>
243     * </p>
244     *
245     * <p>Generally speaking this means that creating a {@link Surface} from that class <i>may</i>
246     * provide a producer endpoint that is suitable to be used with
247     * {@link CameraDevice#createCaptureSession}.</p>
248     *
249     * <p>Since not all of the above classes support output of all format and size combinations,
250     * the particular combination should be queried with {@link #isOutputSupportedFor(Surface)}.</p>
251     *
252     * @param klass a non-{@code null} {@link Class} object reference
253     * @return {@code true} if this class is supported as an output, {@code false} otherwise
254     *
255     * @throws NullPointerException if {@code klass} was {@code null}
256     *
257     * @see CameraDevice#createCaptureSession
258     * @see #isOutputSupportedFor(Surface)
259     */
260    public static <T> boolean isOutputSupportedFor(Class<T> klass) {
261        checkNotNull(klass, "klass must not be null");
262
263        if (klass == android.media.ImageReader.class) {
264            return true;
265        } else if (klass == android.media.MediaRecorder.class) {
266            return true;
267        } else if (klass == android.media.MediaCodec.class) {
268            return true;
269        } else if (klass == android.renderscript.Allocation.class) {
270            return true;
271        } else if (klass == android.view.SurfaceHolder.class) {
272            return true;
273        } else if (klass == android.graphics.SurfaceTexture.class) {
274            return true;
275        }
276
277        return false;
278    }
279
280    /**
281     * Determine whether or not the {@code surface} in its current state is suitable to be included
282     * in a {@link CameraDevice#createCaptureSession capture session} as an output.
283     *
284     * <p>Not all surfaces are usable with the {@link CameraDevice}, and not all configurations
285     * of that {@code surface} are compatible. Some classes that provide the {@code surface} are
286     * compatible with the {@link CameraDevice} in general
287     * (see {@link #isOutputSupportedFor(Class)}, but it is the caller's responsibility to put the
288     * {@code surface} into a state that will be compatible with the {@link CameraDevice}.</p>
289     *
290     * <p>Reasons for a {@code surface} being specifically incompatible might be:
291     * <ul>
292     * <li>Using a format that's not listed by {@link #getOutputFormats}
293     * <li>Using a format/size combination that's not listed by {@link #getOutputSizes}
294     * <li>The {@code surface} itself is not in a state where it can service a new producer.</p>
295     * </li>
296     * </ul>
297     *
298     * <p>Surfaces from flexible sources will return true even if the exact size of the Surface does
299     * not match a camera-supported size, as long as the format (or class) is supported and the
300     * camera device supports a size that is equal to or less than 1080p in that format. If such as
301     * Surface is used to create a capture session, it will have its size rounded to the nearest
302     * supported size, below or equal to 1080p. Flexible sources include SurfaceView, SurfaceTexture,
303     * and ImageReader.</p>
304     *
305     * <p>This is not an exhaustive list; see the particular class's documentation for further
306     * possible reasons of incompatibility.</p>
307     *
308     * @param surface a non-{@code null} {@link Surface} object reference
309     * @return {@code true} if this is supported, {@code false} otherwise
310     *
311     * @throws NullPointerException if {@code surface} was {@code null}
312     * @throws IllegalArgumentException if the Surface endpoint is no longer valid
313     *
314     * @see CameraDevice#createCaptureSession
315     * @see #isOutputSupportedFor(Class)
316     */
317    public boolean isOutputSupportedFor(Surface surface) {
318        checkNotNull(surface, "surface must not be null");
319
320        Size surfaceSize;
321        int surfaceFormat = -1;
322        try {
323            surfaceSize = LegacyCameraDevice.getSurfaceSize(surface);
324            surfaceFormat = LegacyCameraDevice.detectSurfaceType(surface);
325        } catch(BufferQueueAbandonedException e) {
326            throw new IllegalArgumentException("Abandoned surface", e);
327        }
328
329        // See if consumer is flexible.
330        boolean isFlexible = LegacyCameraDevice.isFlexibleConsumer(surface);
331
332        // Override RGB formats to IMPLEMENTATION_DEFINED, b/9487482
333        if ((surfaceFormat >= LegacyMetadataMapper.HAL_PIXEL_FORMAT_RGBA_8888 &&
334                        surfaceFormat <= LegacyMetadataMapper.HAL_PIXEL_FORMAT_BGRA_8888)) {
335            surfaceFormat = LegacyMetadataMapper.HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
336        }
337
338        for (StreamConfiguration config : mConfigurations) {
339            if (config.getFormat() == surfaceFormat && config.isOutput()) {
340                // Mathing format, either need exact size match, or a flexible consumer
341                // and a size no bigger than MAX_DIMEN_FOR_ROUNDING
342                if (config.getSize().equals(surfaceSize)) {
343                    return true;
344                } else if (isFlexible &&
345                        (config.getSize().getWidth() <= LegacyCameraDevice.MAX_DIMEN_FOR_ROUNDING)) {
346                    return true;
347                }
348            }
349        }
350        return false;
351    }
352
353    /**
354     * Get a list of sizes compatible with {@code klass} to use as an output.
355     *
356     * <p>Since some of the supported classes may support additional formats beyond
357     * an opaque/implementation-defined (under-the-hood) format; this function only returns
358     * sizes for the implementation-defined format.</p>
359     *
360     * <p>Some classes such as {@link android.media.ImageReader} may only support user-defined
361     * formats; in particular {@link #isOutputSupportedFor(Class)} will return {@code true} for
362     * that class and this method will return an empty array (but not {@code null}).</p>
363     *
364     * <p>If a well-defined format such as {@code NV21} is required, use
365     * {@link #getOutputSizes(int)} instead.</p>
366     *
367     * <p>The {@code klass} should be a supported output, that querying
368     * {@code #isOutputSupportedFor(Class)} should return {@code true}.</p>
369     *
370     * @param klass
371     *          a non-{@code null} {@link Class} object reference
372     * @return
373     *          an array of supported sizes for implementation-defined formats,
374     *          or {@code null} iff the {@code klass} is not a supported output
375     *
376     * @throws NullPointerException if {@code klass} was {@code null}
377     *
378     * @see #isOutputSupportedFor(Class)
379     */
380    public <T> Size[] getOutputSizes(Class<T> klass) {
381        // Image reader is "supported", but never for implementation-defined formats; return empty
382        if (android.media.ImageReader.class.isAssignableFrom(klass)) {
383            return new Size[0];
384        }
385
386        if (isOutputSupportedFor(klass) == false) {
387            return null;
388        }
389
390        return getInternalFormatSizes(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, /*output*/true);
391    }
392
393    /**
394     * Get a list of sizes compatible with the requested image {@code format}.
395     *
396     * <p>The {@code format} should be a supported format (one of the formats returned by
397     * {@link #getOutputFormats}).</p>
398     *
399     * @param format an image format from {@link ImageFormat} or {@link PixelFormat}
400     * @return
401     *          an array of supported sizes,
402     *          or {@code null} if the {@code format} is not a supported output
403     *
404     * @see ImageFormat
405     * @see PixelFormat
406     * @see #getOutputFormats
407     */
408    public Size[] getOutputSizes(int format) {
409        return getPublicFormatSizes(format, /*output*/true);
410    }
411
412    /**
413     * Get a list of supported high speed video recording sizes.
414     *
415     * <p> When HIGH_SPEED_VIDEO is supported in
416     * {@link CameraCharacteristics#CONTROL_AVAILABLE_SCENE_MODES available scene modes}, this
417     * method will list the supported high speed video size configurations. All the sizes listed
418     * will be a subset of the sizes reported by {@link #getOutputSizes} for processed non-stalling
419     * formats (typically ImageFormat#YUV_420_888, ImageFormat#NV21, ImageFormat#YV12)</p>
420     *
421     * <p> To enable high speed video recording, application must set
422     * {@link CaptureRequest#CONTROL_SCENE_MODE} to
423     * {@link CaptureRequest#CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO HIGH_SPEED_VIDEO} in capture
424     * requests and select the video size from this method and
425     * {@link CaptureRequest#CONTROL_AE_TARGET_FPS_RANGE FPS range} from
426     * {@link #getHighSpeedVideoFpsRangesFor} to configure the recording and preview streams and
427     * setup the recording requests. For example, if the application intends to do high speed
428     * recording, it can select the maximum size reported by this method to configure output
429     * streams. Note that for the use case of multiple output streams, application must select one
430     * unique size from this method to use. Otherwise a request error might occur. Once the size is
431     * selected, application can get the supported FPS ranges by
432     * {@link #getHighSpeedVideoFpsRangesFor}, and use these FPS ranges to setup the recording
433     * requests.</p>
434     *
435     * @return
436     *          an array of supported high speed video recording sizes
437     *
438     * @see #getHighSpeedVideoFpsRangesFor(Size)
439     */
440    public Size[] getHighSpeedVideoSizes() {
441        Set<Size> keySet = mHighSpeedVideoSizeMap.keySet();
442        return keySet.toArray(new Size[keySet.size()]);
443    }
444
445    /**
446     * Get the frame per second ranges (fpsMin, fpsMax) for input high speed video size.
447     *
448     * <p> See {@link #getHighSpeedVideoSizes} for how to enable high speed recording.</p>
449     *
450     * <p> For normal video recording use case, where some application will NOT set
451     * {@link CaptureRequest#CONTROL_SCENE_MODE} to
452     * {@link CaptureRequest#CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO HIGH_SPEED_VIDEO} in capture
453     * requests, the {@link CaptureRequest#CONTROL_AE_TARGET_FPS_RANGE FPS ranges} reported in
454     * this method must not be used to setup capture requests, or it will cause request error.</p>
455     *
456     * @param size one of the sizes returned by {@link #getHighSpeedVideoSizes()}
457     * @return
458     *          An array of FPS range to use with
459     *          {@link CaptureRequest#CONTROL_AE_TARGET_FPS_RANGE TARGET_FPS_RANGE} when using
460     *          {@link CaptureRequest#CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO HIGH_SPEED_VIDEO} scene
461     *          mode.
462     *          The upper bound of returned ranges is guaranteed to be larger or equal to 60.
463     *
464     * @throws IllegalArgumentException if input size does not exist in the return value of
465     *         getHighSpeedVideoSizes
466     * @see #getHighSpeedVideoSizes()
467     */
468    public Range<Integer>[] getHighSpeedVideoFpsRangesFor(Size size) {
469        Integer fpsRangeCount = mHighSpeedVideoSizeMap.get(size);
470        if (fpsRangeCount == null || fpsRangeCount == 0) {
471            throw new IllegalArgumentException(String.format(
472                    "Size %s does not support high speed video recording", size));
473        }
474
475        @SuppressWarnings("unchecked")
476        Range<Integer>[] fpsRanges = new Range[fpsRangeCount];
477        int i = 0;
478        for (HighSpeedVideoConfiguration config : mHighSpeedVideoConfigurations) {
479            if (size.equals(config.getSize())) {
480                fpsRanges[i++] = config.getFpsRange();
481            }
482        }
483        return fpsRanges;
484    }
485
486    /**
487     * Get a list of supported high speed video recording FPS ranges.
488     *
489     * <p> When HIGH_SPEED_VIDEO is supported in
490     * {@link CameraCharacteristics#CONTROL_AVAILABLE_SCENE_MODES available scene modes}, this
491     * method will list the supported high speed video FPS range configurations. Application can
492     * then use {@link #getHighSpeedVideoSizesFor} to query available sizes for one of returned
493     * FPS range.</p>
494     *
495     * <p> To enable high speed video recording, application must set
496     * {@link CaptureRequest#CONTROL_SCENE_MODE} to
497     * {@link CaptureRequest#CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO HIGH_SPEED_VIDEO} in capture
498     * requests and select the video size from {@link #getHighSpeedVideoSizesFor} and
499     * {@link CaptureRequest#CONTROL_AE_TARGET_FPS_RANGE FPS range} from
500     * this method to configure the recording and preview streams and setup the recording requests.
501     * For example, if the application intends to do high speed recording, it can select one FPS
502     * range reported by this method, query the video sizes corresponding to this FPS range  by
503     * {@link #getHighSpeedVideoSizesFor} and select one of reported sizes to configure output
504     * streams. Note that for the use case of multiple output streams, application must select one
505     * unique size from {@link #getHighSpeedVideoSizesFor}, and use it for all output streams.
506     * Otherwise a request error might occur when attempting to enable
507     * {@link CaptureRequest#CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO HIGH_SPEED_VIDEO}.
508     * Once the stream is configured, application can set the FPS range in the recording requests.
509     * </p>
510     *
511     * @return
512     *          an array of supported high speed video recording FPS ranges
513     *          The upper bound of returned ranges is guaranteed to be larger or equal to 60.
514     *
515     * @see #getHighSpeedVideoSizesFor
516     */
517    @SuppressWarnings("unchecked")
518    public Range<Integer>[] getHighSpeedVideoFpsRanges() {
519        Set<Range<Integer>> keySet = mHighSpeedVideoFpsRangeMap.keySet();
520        return keySet.toArray(new Range[keySet.size()]);
521    }
522
523    /**
524     * Get the supported video sizes for input FPS range.
525     *
526     * <p> See {@link #getHighSpeedVideoFpsRanges} for how to enable high speed recording.</p>
527     *
528     * <p> For normal video recording use case, where the application will NOT set
529     * {@link CaptureRequest#CONTROL_SCENE_MODE} to
530     * {@link CaptureRequest#CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO HIGH_SPEED_VIDEO} in capture
531     * requests, the {@link CaptureRequest#CONTROL_AE_TARGET_FPS_RANGE FPS ranges} reported in
532     * this method must not be used to setup capture requests, or it will cause request error.</p>
533     *
534     * @param fpsRange one of the FPS range returned by {@link #getHighSpeedVideoFpsRanges()}
535     * @return
536     *          An array of video sizes to configure output stream when using
537     *          {@link CaptureRequest#CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO HIGH_SPEED_VIDEO} scene
538     *          mode.
539     *
540     * @throws IllegalArgumentException if input FPS range does not exist in the return value of
541     *         getHighSpeedVideoFpsRanges
542     * @see #getHighSpeedVideoFpsRanges()
543     */
544    public Size[] getHighSpeedVideoSizesFor(Range<Integer> fpsRange) {
545        Integer sizeCount = mHighSpeedVideoFpsRangeMap.get(fpsRange);
546        if (sizeCount == null || sizeCount == 0) {
547            throw new IllegalArgumentException(String.format(
548                    "FpsRange %s does not support high speed video recording", fpsRange));
549        }
550
551        Size[] sizes = new Size[sizeCount];
552        int i = 0;
553        for (HighSpeedVideoConfiguration config : mHighSpeedVideoConfigurations) {
554            if (fpsRange.equals(config.getFpsRange())) {
555                sizes[i++] = config.getSize();
556            }
557        }
558        return sizes;
559    }
560
561    /**
562     * Get the minimum {@link CaptureRequest#SENSOR_FRAME_DURATION frame duration}
563     * for the format/size combination (in nanoseconds).
564     *
565     * <p>{@code format} should be one of the ones returned by {@link #getOutputFormats()}.</p>
566     * <p>{@code size} should be one of the ones returned by
567     * {@link #getOutputSizes(int)}.</p>
568     *
569     * <p>This should correspond to the frame duration when only that stream is active, with all
570     * processing (typically in {@code android.*.mode}) set to either {@code OFF} or {@code FAST}.
571     * </p>
572     *
573     * <p>When multiple streams are used in a request, the minimum frame duration will be
574     * {@code max(individual stream min durations)}.</p>
575     *
576     * <p>For devices that do not support manual sensor control
577     * ({@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR}),
578     * this function may return 0.</p>
579     *
580     * <!--
581     * TODO: uncomment after adding input stream support
582     * <p>The minimum frame duration of a stream (of a particular format, size) is the same
583     * regardless of whether the stream is input or output.</p>
584     * -->
585     *
586     * @param format an image format from {@link ImageFormat} or {@link PixelFormat}
587     * @param size an output-compatible size
588     * @return a minimum frame duration {@code >} 0 in nanoseconds, or
589     *          0 if the minimum frame duration is not available.
590     *
591     * @throws IllegalArgumentException if {@code format} or {@code size} was not supported
592     * @throws NullPointerException if {@code size} was {@code null}
593     *
594     * @see CaptureRequest#SENSOR_FRAME_DURATION
595     * @see #getOutputStallDuration(int, Size)
596     * @see ImageFormat
597     * @see PixelFormat
598     */
599    public long getOutputMinFrameDuration(int format, Size size) {
600        checkNotNull(size, "size must not be null");
601        checkArgumentFormatSupported(format, /*output*/true);
602
603        return getInternalFormatDuration(imageFormatToInternal(format), size, DURATION_MIN_FRAME);
604    }
605
606    /**
607     * Get the minimum {@link CaptureRequest#SENSOR_FRAME_DURATION frame duration}
608     * for the class/size combination (in nanoseconds).
609     *
610     * <p>This assumes a the {@code klass} is set up to use an implementation-defined format.
611     * For user-defined formats, use {@link #getOutputMinFrameDuration(int, Size)}.</p>
612     *
613     * <p>{@code klass} should be one of the ones which is supported by
614     * {@link #isOutputSupportedFor(Class)}.</p>
615     *
616     * <p>{@code size} should be one of the ones returned by
617     * {@link #getOutputSizes(int)}.</p>
618     *
619     * <p>This should correspond to the frame duration when only that stream is active, with all
620     * processing (typically in {@code android.*.mode}) set to either {@code OFF} or {@code FAST}.
621     * </p>
622     *
623     * <p>When multiple streams are used in a request, the minimum frame duration will be
624     * {@code max(individual stream min durations)}.</p>
625     *
626     * <p>For devices that do not support manual sensor control
627     * ({@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR}),
628     * this function may return 0.</p>
629     *
630     * <!--
631     * TODO: uncomment after adding input stream support
632     * <p>The minimum frame duration of a stream (of a particular format, size) is the same
633     * regardless of whether the stream is input or output.</p>
634     * -->
635     *
636     * @param klass
637     *          a class which is supported by {@link #isOutputSupportedFor(Class)} and has a
638     *          non-empty array returned by {@link #getOutputSizes(Class)}
639     * @param size an output-compatible size
640     * @return a minimum frame duration {@code >} 0 in nanoseconds, or
641     *          0 if the minimum frame duration is not available.
642     *
643     * @throws IllegalArgumentException if {@code klass} or {@code size} was not supported
644     * @throws NullPointerException if {@code size} or {@code klass} was {@code null}
645     *
646     * @see CaptureRequest#SENSOR_FRAME_DURATION
647     * @see ImageFormat
648     * @see PixelFormat
649     */
650    public <T> long getOutputMinFrameDuration(final Class<T> klass, final Size size) {
651        if (!isOutputSupportedFor(klass)) {
652            throw new IllegalArgumentException("klass was not supported");
653        }
654
655        return getInternalFormatDuration(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,
656                size, DURATION_MIN_FRAME);
657    }
658
659    /**
660     * Get the stall duration for the format/size combination (in nanoseconds).
661     *
662     * <p>{@code format} should be one of the ones returned by {@link #getOutputFormats()}.</p>
663     * <p>{@code size} should be one of the ones returned by
664     * {@link #getOutputSizes(int)}.</p>
665     *
666     * <p>
667     * A stall duration is how much extra time would get added to the normal minimum frame duration
668     * for a repeating request that has streams with non-zero stall.
669     *
670     * <p>For example, consider JPEG captures which have the following characteristics:
671     *
672     * <ul>
673     * <li>JPEG streams act like processed YUV streams in requests for which they are not included;
674     * in requests in which they are directly referenced, they act as JPEG streams.
675     * This is because supporting a JPEG stream requires the underlying YUV data to always be ready
676     * for use by a JPEG encoder, but the encoder will only be used (and impact frame duration) on
677     * requests that actually reference a JPEG stream.
678     * <li>The JPEG processor can run concurrently to the rest of the camera pipeline, but cannot
679     * process more than 1 capture at a time.
680     * </ul>
681     *
682     * <p>In other words, using a repeating YUV request would result in a steady frame rate
683     * (let's say it's 30 FPS). If a single JPEG request is submitted periodically,
684     * the frame rate will stay at 30 FPS (as long as we wait for the previous JPEG to return each
685     * time). If we try to submit a repeating YUV + JPEG request, then the frame rate will drop from
686     * 30 FPS.</p>
687     *
688     * <p>In general, submitting a new request with a non-0 stall time stream will <em>not</em> cause a
689     * frame rate drop unless there are still outstanding buffers for that stream from previous
690     * requests.</p>
691     *
692     * <p>Submitting a repeating request with streams (call this {@code S}) is the same as setting
693     * the minimum frame duration from the normal minimum frame duration corresponding to {@code S},
694     * added with the maximum stall duration for {@code S}.</p>
695     *
696     * <p>If interleaving requests with and without a stall duration, a request will stall by the
697     * maximum of the remaining times for each can-stall stream with outstanding buffers.</p>
698     *
699     * <p>This means that a stalling request will not have an exposure start until the stall has
700     * completed.</p>
701     *
702     * <p>This should correspond to the stall duration when only that stream is active, with all
703     * processing (typically in {@code android.*.mode}) set to {@code FAST} or {@code OFF}.
704     * Setting any of the processing modes to {@code HIGH_QUALITY} effectively results in an
705     * indeterminate stall duration for all streams in a request (the regular stall calculation
706     * rules are ignored).</p>
707     *
708     * <p>The following formats may always have a stall duration:
709     * <ul>
710     * <li>{@link ImageFormat#JPEG JPEG}
711     * <li>{@link ImageFormat#RAW_SENSOR RAW16}
712     * </ul>
713     * </p>
714     *
715     * <p>The following formats will never have a stall duration:
716     * <ul>
717     * <li>{@link ImageFormat#YUV_420_888 YUV_420_888}
718     * <li>{@link #isOutputSupportedFor(Class) Implementation-Defined}
719     * </ul></p>
720     *
721     * <p>
722     * All other formats may or may not have an allowed stall duration on a per-capability basis;
723     * refer to {@link CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES
724     * android.request.availableCapabilities} for more details.</p>
725     * </p>
726     *
727     * <p>See {@link CaptureRequest#SENSOR_FRAME_DURATION android.sensor.frameDuration}
728     * for more information about calculating the max frame rate (absent stalls).</p>
729     *
730     * @param format an image format from {@link ImageFormat} or {@link PixelFormat}
731     * @param size an output-compatible size
732     * @return a stall duration {@code >=} 0 in nanoseconds
733     *
734     * @throws IllegalArgumentException if {@code format} or {@code size} was not supported
735     * @throws NullPointerException if {@code size} was {@code null}
736     *
737     * @see CaptureRequest#SENSOR_FRAME_DURATION
738     * @see ImageFormat
739     * @see PixelFormat
740     */
741    public long getOutputStallDuration(int format, Size size) {
742        checkArgumentFormatSupported(format, /*output*/true);
743
744        return getInternalFormatDuration(imageFormatToInternal(format),
745                size, DURATION_STALL);
746    }
747
748    /**
749     * Get the stall duration for the class/size combination (in nanoseconds).
750     *
751     * <p>This assumes a the {@code klass} is set up to use an implementation-defined format.
752     * For user-defined formats, use {@link #getOutputMinFrameDuration(int, Size)}.</p>
753     *
754     * <p>{@code klass} should be one of the ones with a non-empty array returned by
755     * {@link #getOutputSizes(Class)}.</p>
756     *
757     * <p>{@code size} should be one of the ones returned by
758     * {@link #getOutputSizes(Class)}.</p>
759     *
760     * <p>See {@link #getOutputStallDuration(int, Size)} for a definition of a
761     * <em>stall duration</em>.</p>
762     *
763     * @param klass
764     *          a class which is supported by {@link #isOutputSupportedFor(Class)} and has a
765     *          non-empty array returned by {@link #getOutputSizes(Class)}
766     * @param size an output-compatible size
767     * @return a minimum frame duration {@code >=} 0 in nanoseconds
768     *
769     * @throws IllegalArgumentException if {@code klass} or {@code size} was not supported
770     * @throws NullPointerException if {@code size} or {@code klass} was {@code null}
771     *
772     * @see CaptureRequest#SENSOR_FRAME_DURATION
773     * @see ImageFormat
774     * @see PixelFormat
775     */
776    public <T> long getOutputStallDuration(final Class<T> klass, final Size size) {
777        if (!isOutputSupportedFor(klass)) {
778            throw new IllegalArgumentException("klass was not supported");
779        }
780
781        return getInternalFormatDuration(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,
782                size, DURATION_STALL);
783    }
784
785    /**
786     * Check if this {@link StreamConfigurationMap} is equal to another
787     * {@link StreamConfigurationMap}.
788     *
789     * <p>Two vectors are only equal if and only if each of the respective elements is equal.</p>
790     *
791     * @return {@code true} if the objects were equal, {@code false} otherwise
792     */
793    @Override
794    public boolean equals(final Object obj) {
795        if (obj == null) {
796            return false;
797        }
798        if (this == obj) {
799            return true;
800        }
801        if (obj instanceof StreamConfigurationMap) {
802            final StreamConfigurationMap other = (StreamConfigurationMap) obj;
803            // XX: do we care about order?
804            return Arrays.equals(mConfigurations, other.mConfigurations) &&
805                    Arrays.equals(mMinFrameDurations, other.mMinFrameDurations) &&
806                    Arrays.equals(mStallDurations, other.mStallDurations) &&
807                    Arrays.equals(mHighSpeedVideoConfigurations,
808                            other.mHighSpeedVideoConfigurations);
809        }
810        return false;
811    }
812
813    /**
814     * {@inheritDoc}
815     */
816    @Override
817    public int hashCode() {
818        // XX: do we care about order?
819        return HashCodeHelpers.hashCode(
820                mConfigurations, mMinFrameDurations,
821                mStallDurations, mHighSpeedVideoConfigurations);
822    }
823
824    // Check that the argument is supported by #getOutputFormats or #getInputFormats
825    private int checkArgumentFormatSupported(int format, boolean output) {
826        checkArgumentFormat(format);
827
828        int[] formats = output ? getOutputFormats() : getInputFormats();
829        for (int i = 0; i < formats.length; ++i) {
830            if (format == formats[i]) {
831                return format;
832            }
833        }
834
835        throw new IllegalArgumentException(String.format(
836                "format %x is not supported by this stream configuration map", format));
837    }
838
839    /**
840     * Ensures that the format is either user-defined or implementation defined.
841     *
842     * <p>If a format has a different internal representation than the public representation,
843     * passing in the public representation here will fail.</p>
844     *
845     * <p>For example if trying to use {@link ImageFormat#JPEG}:
846     * it has a different public representation than the internal representation
847     * {@code HAL_PIXEL_FORMAT_BLOB}, this check will fail.</p>
848     *
849     * <p>Any invalid/undefined formats will raise an exception.</p>
850     *
851     * @param format image format
852     * @return the format
853     *
854     * @throws IllegalArgumentException if the format was invalid
855     */
856    static int checkArgumentFormatInternal(int format) {
857        switch (format) {
858            case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
859            case HAL_PIXEL_FORMAT_BLOB:
860            case HAL_PIXEL_FORMAT_RAW_OPAQUE:
861                return format;
862            case ImageFormat.JPEG:
863                throw new IllegalArgumentException(
864                        "ImageFormat.JPEG is an unknown internal format");
865            default:
866                return checkArgumentFormat(format);
867        }
868    }
869
870    /**
871     * Ensures that the format is publicly user-defined in either ImageFormat or PixelFormat.
872     *
873     * <p>If a format has a different public representation than the internal representation,
874     * passing in the internal representation here will fail.</p>
875     *
876     * <p>For example if trying to use {@code HAL_PIXEL_FORMAT_BLOB}:
877     * it has a different internal representation than the public representation
878     * {@link ImageFormat#JPEG}, this check will fail.</p>
879     *
880     * <p>Any invalid/undefined formats will raise an exception, including implementation-defined.
881     * </p>
882     *
883     * <p>Note that {@code @hide} and deprecated formats will not pass this check.</p>
884     *
885     * @param format image format
886     * @return the format
887     *
888     * @throws IllegalArgumentException if the format was not user-defined
889     */
890    static int checkArgumentFormat(int format) {
891        if (!ImageFormat.isPublicFormat(format) && !PixelFormat.isPublicFormat(format)) {
892            throw new IllegalArgumentException(String.format(
893                    "format 0x%x was not defined in either ImageFormat or PixelFormat", format));
894        }
895
896        return format;
897    }
898
899    /**
900     * Convert a public-visible {@code ImageFormat} into an internal format
901     * compatible with {@code graphics.h}.
902     *
903     * <p>In particular these formats are converted:
904     * <ul>
905     * <li>HAL_PIXEL_FORMAT_BLOB => ImageFormat.JPEG
906     * </ul>
907     * </p>
908     *
909     * <p>Passing in an implementation-defined format which has no public equivalent will fail;
910     * as will passing in a public format which has a different internal format equivalent.
911     * See {@link #checkArgumentFormat} for more details about a legal public format.</p>
912     *
913     * <p>All other formats are returned as-is, no further invalid check is performed.</p>
914     *
915     * <p>This function is the dual of {@link #imageFormatToInternal}.</p>
916     *
917     * @param format image format from {@link ImageFormat} or {@link PixelFormat}
918     * @return the converted image formats
919     *
920     * @throws IllegalArgumentException
921     *          if {@code format} is {@code HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED} or
922     *          {@link ImageFormat#JPEG}
923     *
924     * @see ImageFormat
925     * @see PixelFormat
926     * @see #checkArgumentFormat
927     */
928    static int imageFormatToPublic(int format) {
929        switch (format) {
930            case HAL_PIXEL_FORMAT_BLOB:
931                return ImageFormat.JPEG;
932            case ImageFormat.JPEG:
933                throw new IllegalArgumentException(
934                        "ImageFormat.JPEG is an unknown internal format");
935            case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
936                throw new IllegalArgumentException(
937                        "IMPLEMENTATION_DEFINED must not leak to public API");
938            default:
939                return format;
940        }
941    }
942
943    /**
944     * Convert image formats from internal to public formats (in-place).
945     *
946     * @param formats an array of image formats
947     * @return {@code formats}
948     *
949     * @see #imageFormatToPublic
950     */
951    static int[] imageFormatToPublic(int[] formats) {
952        if (formats == null) {
953            return null;
954        }
955
956        for (int i = 0; i < formats.length; ++i) {
957            formats[i] = imageFormatToPublic(formats[i]);
958        }
959
960        return formats;
961    }
962
963    /**
964     * Convert a public format compatible with {@code ImageFormat} to an internal format
965     * from {@code graphics.h}.
966     *
967     * <p>In particular these formats are converted:
968     * <ul>
969     * <li>ImageFormat.JPEG => HAL_PIXEL_FORMAT_BLOB
970     * </ul>
971     * </p>
972     *
973     * <p>Passing in an implementation-defined format here will fail (it's not a public format);
974     * as will passing in an internal format which has a different public format equivalent.
975     * See {@link #checkArgumentFormat} for more details about a legal public format.</p>
976     *
977     * <p>All other formats are returned as-is, no invalid check is performed.</p>
978     *
979     * <p>This function is the dual of {@link #imageFormatToPublic}.</p>
980     *
981     * @param format public image format from {@link ImageFormat} or {@link PixelFormat}
982     * @return the converted image formats
983     *
984     * @see ImageFormat
985     * @see PixelFormat
986     *
987     * @throws IllegalArgumentException
988     *              if {@code format} was {@code HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED}
989     */
990    static int imageFormatToInternal(int format) {
991        switch (format) {
992            case ImageFormat.JPEG:
993                return HAL_PIXEL_FORMAT_BLOB;
994            case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
995                throw new IllegalArgumentException(
996                        "IMPLEMENTATION_DEFINED is not allowed via public API");
997            default:
998                return format;
999        }
1000    }
1001
1002    /**
1003     * Convert image formats from public to internal formats (in-place).
1004     *
1005     * @param formats an array of image formats
1006     * @return {@code formats}
1007     *
1008     * @see #imageFormatToInternal
1009     *
1010     * @hide
1011     */
1012    public static int[] imageFormatToInternal(int[] formats) {
1013        if (formats == null) {
1014            return null;
1015        }
1016
1017        for (int i = 0; i < formats.length; ++i) {
1018            formats[i] = imageFormatToInternal(formats[i]);
1019        }
1020
1021        return formats;
1022    }
1023
1024    private Size[] getPublicFormatSizes(int format, boolean output) {
1025        try {
1026            checkArgumentFormatSupported(format, output);
1027        } catch (IllegalArgumentException e) {
1028            return null;
1029        }
1030
1031        format = imageFormatToInternal(format);
1032
1033        return getInternalFormatSizes(format, output);
1034    }
1035
1036    private Size[] getInternalFormatSizes(int format, boolean output) {
1037        HashMap<Integer, Integer> formatsMap = getFormatsMap(output);
1038
1039        Integer sizesCount = formatsMap.get(format);
1040        if (sizesCount == null) {
1041            throw new IllegalArgumentException("format not available");
1042        }
1043
1044        int len = sizesCount;
1045        Size[] sizes = new Size[len];
1046        int sizeIndex = 0;
1047
1048        for (StreamConfiguration config : mConfigurations) {
1049            if (config.getFormat() == format && config.isOutput() == output) {
1050                sizes[sizeIndex++] = config.getSize();
1051            }
1052        }
1053
1054        if (sizeIndex != len) {
1055            throw new AssertionError(
1056                    "Too few sizes (expected " + len + ", actual " + sizeIndex + ")");
1057        }
1058
1059        return sizes;
1060    }
1061
1062    /** Get the list of publically visible output formats; does not include IMPL_DEFINED */
1063    private int[] getPublicFormats(boolean output) {
1064        int[] formats = new int[getPublicFormatCount(output)];
1065
1066        int i = 0;
1067
1068        for (int format : getFormatsMap(output).keySet()) {
1069            if (format != HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED &&
1070                format != HAL_PIXEL_FORMAT_RAW_OPAQUE) {
1071                formats[i++] = format;
1072            }
1073        }
1074
1075        if (formats.length != i) {
1076            throw new AssertionError("Too few formats " + i + ", expected " + formats.length);
1077        }
1078
1079        return imageFormatToPublic(formats);
1080    }
1081
1082    /** Get the format -> size count map for either output or input formats */
1083    private HashMap<Integer, Integer> getFormatsMap(boolean output) {
1084        return output ? mOutputFormats : mInputFormats;
1085    }
1086
1087    private long getInternalFormatDuration(int format, Size size, int duration) {
1088        // assume format is already checked, since its internal
1089
1090        if (!arrayContains(getInternalFormatSizes(format, /*output*/true), size)) {
1091            throw new IllegalArgumentException("size was not supported");
1092        }
1093
1094        StreamConfigurationDuration[] durations = getDurations(duration);
1095
1096        for (StreamConfigurationDuration configurationDuration : durations) {
1097            if (configurationDuration.getFormat() == format &&
1098                    configurationDuration.getWidth() == size.getWidth() &&
1099                    configurationDuration.getHeight() == size.getHeight()) {
1100                return configurationDuration.getDuration();
1101            }
1102        }
1103        // Default duration is '0' (unsupported/no extra stall)
1104        return 0;
1105    }
1106
1107    /**
1108     * Get the durations array for the kind of duration
1109     *
1110     * @see #DURATION_MIN_FRAME
1111     * @see #DURATION_STALL
1112     * */
1113    private StreamConfigurationDuration[] getDurations(int duration) {
1114        switch (duration) {
1115            case DURATION_MIN_FRAME:
1116                return mMinFrameDurations;
1117            case DURATION_STALL:
1118                return mStallDurations;
1119            default:
1120                throw new IllegalArgumentException("duration was invalid");
1121        }
1122    }
1123
1124    /** Count the number of publicly-visible output formats */
1125    private int getPublicFormatCount(boolean output) {
1126        HashMap<Integer, Integer> formatsMap = getFormatsMap(output);
1127
1128        int size = formatsMap.size();
1129        if (formatsMap.containsKey(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED)) {
1130            size -= 1;
1131        }
1132        if (formatsMap.containsKey(HAL_PIXEL_FORMAT_RAW_OPAQUE)) {
1133            size -= 1;
1134        }
1135
1136        return size;
1137    }
1138
1139    private static <T> boolean arrayContains(T[] array, T element) {
1140        if (array == null) {
1141            return false;
1142        }
1143
1144        for (T el : array) {
1145            if (Objects.equals(el, element)) {
1146                return true;
1147            }
1148        }
1149
1150        return false;
1151    }
1152
1153    // from system/core/include/system/graphics.h
1154    private static final int HAL_PIXEL_FORMAT_BLOB = 0x21;
1155    private static final int HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22;
1156    private static final int HAL_PIXEL_FORMAT_RAW_OPAQUE = 0x24;
1157
1158    /**
1159     * @see #getDurations(int)
1160     * @see #getDurationDefault(int)
1161     */
1162    private static final int DURATION_MIN_FRAME = 0;
1163    private static final int DURATION_STALL = 1;
1164
1165    private final StreamConfiguration[] mConfigurations;
1166    private final StreamConfigurationDuration[] mMinFrameDurations;
1167    private final StreamConfigurationDuration[] mStallDurations;
1168    private final HighSpeedVideoConfiguration[] mHighSpeedVideoConfigurations;
1169
1170    /** ImageFormat -> num output sizes mapping */
1171    private final HashMap</*ImageFormat*/Integer, /*Count*/Integer> mOutputFormats =
1172            new HashMap<Integer, Integer>();
1173    /** ImageFormat -> num input sizes mapping */
1174    private final HashMap</*ImageFormat*/Integer, /*Count*/Integer> mInputFormats =
1175            new HashMap<Integer, Integer>();
1176    /** High speed video Size -> FPS range count mapping*/
1177    private final HashMap</*HighSpeedVideoSize*/Size, /*Count*/Integer> mHighSpeedVideoSizeMap =
1178            new HashMap<Size, Integer>();
1179    /** High speed video FPS range -> Size count mapping*/
1180    private final HashMap</*HighSpeedVideoFpsRange*/Range<Integer>, /*Count*/Integer>
1181            mHighSpeedVideoFpsRangeMap = new HashMap<Range<Integer>, Integer>();
1182
1183}
1184