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