@@ -60,8 +60,8 @@ public class CameraOptions {
6060 private float exposureCorrectionMinValue ;
6161 private float exposureCorrectionMaxValue ;
6262 private boolean autoFocusSupported ;
63- private float fpsRangeMinValue ;
64- private float fpsRangeMaxValue ;
63+ private float previewFrameRateMinValue ;
64+ private float previewFrameRateMaxValue ;
6565
6666
6767 public CameraOptions (@ NonNull Camera .Parameters params , int cameraId , boolean flipSizes ) {
@@ -159,9 +159,16 @@ public CameraOptions(@NonNull Camera.Parameters params, int cameraId, boolean fl
159159 }
160160 }
161161
162- //fps range
163- fpsRangeMinValue = 0F ;
164- fpsRangeMaxValue = 0F ;
162+ // Preview FPS
163+ previewFrameRateMinValue = Float .MAX_VALUE ;
164+ previewFrameRateMaxValue = -Float .MAX_VALUE ;
165+ List <int []> fpsRanges = params .getSupportedPreviewFpsRange ();
166+ for (int [] fpsRange : fpsRanges ) {
167+ float lower = (float ) fpsRange [0 ] / 1000F ;
168+ float upper = (float ) fpsRange [1 ] / 1000F ;
169+ previewFrameRateMinValue = Math .min (previewFrameRateMinValue , lower );
170+ previewFrameRateMaxValue = Math .max (previewFrameRateMaxValue , upper );
171+ }
165172 }
166173
167174 // Camera2Engine constructor.
@@ -279,22 +286,19 @@ public CameraOptions(@NonNull CameraManager manager,
279286 }
280287 }
281288
282- //fps Range
283- fpsRangeMinValue = Float .MAX_VALUE ;
284- fpsRangeMaxValue = Float .MIN_VALUE ;
285- Range <Integer >[] range = cameraCharacteristics .get (CameraCharacteristics .CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES );
289+ // Preview FPS
290+ Range <Integer >[] range = cameraCharacteristics .get (
291+ CameraCharacteristics .CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES );
286292 if (range != null ) {
293+ previewFrameRateMinValue = Float .MAX_VALUE ;
294+ previewFrameRateMaxValue = -Float .MAX_VALUE ;
287295 for (Range <Integer > fpsRange : range ) {
288- if (fpsRange .getLower () <= fpsRangeMinValue ) {
289- fpsRangeMinValue = fpsRange .getLower ();
290- }
291- if (fpsRange .getUpper () >= fpsRangeMaxValue ) {
292- fpsRangeMaxValue = fpsRange .getUpper ();
293- }
296+ previewFrameRateMinValue = Math .min (previewFrameRateMinValue , fpsRange .getLower ());
297+ previewFrameRateMaxValue = Math .max (previewFrameRateMaxValue , fpsRange .getUpper ());
294298 }
295299 } else {
296- fpsRangeMinValue = 0F ;
297- fpsRangeMaxValue = 0F ;
300+ previewFrameRateMinValue = 0F ;
301+ previewFrameRateMaxValue = 0F ;
298302 }
299303 }
300304
@@ -308,7 +312,6 @@ public boolean supports(@NonNull Control control) {
308312 return getSupportedControls (control .getClass ()).contains (control );
309313 }
310314
311-
312315 /**
313316 * Shorthand for other methods in this class,
314317 * e.g. supports(GestureAction.ZOOM) == isZoomSupported().
@@ -333,7 +336,6 @@ public boolean supports(@NonNull GestureAction action) {
333336 return false ;
334337 }
335338
336-
337339 @ SuppressWarnings ("unchecked" )
338340 @ NonNull
339341 public <T extends Control > Collection <T > getSupportedControls (@ NonNull Class <T > controlClass ) {
@@ -362,7 +364,6 @@ public <T extends Control> Collection<T> getSupportedControls(@NonNull Class<T>
362364 return Collections .emptyList ();
363365 }
364366
365-
366367 /**
367368 * Set of supported picture sizes for the currently opened camera.
368369 *
@@ -373,7 +374,6 @@ public Collection<Size> getSupportedPictureSizes() {
373374 return Collections .unmodifiableSet (supportedPictureSizes );
374375 }
375376
376-
377377 /**
378378 * Set of supported picture aspect ratios for the currently opened camera.
379379 *
@@ -385,7 +385,6 @@ public Collection<AspectRatio> getSupportedPictureAspectRatios() {
385385 return Collections .unmodifiableSet (supportedPictureAspectRatio );
386386 }
387387
388-
389388 /**
390389 * Set of supported video sizes for the currently opened camera.
391390 *
@@ -396,7 +395,6 @@ public Collection<Size> getSupportedVideoSizes() {
396395 return Collections .unmodifiableSet (supportedVideoSizes );
397396 }
398397
399-
400398 /**
401399 * Set of supported picture aspect ratios for the currently opened camera.
402400 *
@@ -408,7 +406,6 @@ public Collection<AspectRatio> getSupportedVideoAspectRatios() {
408406 return Collections .unmodifiableSet (supportedVideoAspectRatio );
409407 }
410408
411-
412409 /**
413410 * Set of supported facing values.
414411 *
@@ -421,7 +418,6 @@ public Collection<Facing> getSupportedFacing() {
421418 return Collections .unmodifiableSet (supportedFacing );
422419 }
423420
424-
425421 /**
426422 * Set of supported flash values.
427423 *
@@ -436,7 +432,6 @@ public Collection<Flash> getSupportedFlash() {
436432 return Collections .unmodifiableSet (supportedFlash );
437433 }
438434
439-
440435 /**
441436 * Set of supported white balance values.
442437 *
@@ -452,7 +447,6 @@ public Collection<WhiteBalance> getSupportedWhiteBalance() {
452447 return Collections .unmodifiableSet (supportedWhiteBalance );
453448 }
454449
455-
456450 /**
457451 * Set of supported hdr values.
458452 *
@@ -488,7 +482,6 @@ public boolean isAutoFocusSupported() {
488482 return autoFocusSupported ;
489483 }
490484
491-
492485 /**
493486 * Whether exposure correction is supported. If this is false, calling
494487 * {@link CameraView#setExposureCorrection(float)} has no effect.
@@ -501,7 +494,6 @@ public boolean isExposureCorrectionSupported() {
501494 return exposureCorrectionSupported ;
502495 }
503496
504-
505497 /**
506498 * The minimum value of negative exposure correction, in EV stops.
507499 * This is presumably negative or 0 if not supported.
@@ -524,18 +516,20 @@ public float getExposureCorrectionMaxValue() {
524516 }
525517
526518 /**
527- * The minimum value for FPS
519+ * The minimum value for the preview frame rate, in frames per second (FPS).
520+ *
528521 * @return the min value
529522 */
530- public float getFpsRangeMinValue () {
531- return fpsRangeMinValue ;
523+ public float getPreviewFrameRateMinValue () {
524+ return previewFrameRateMinValue ;
532525 }
533526
534527 /**
535- * The maximum value for FPS
528+ * The maximum value for the preview frame rate, in frames per second (FPS).
529+ *
536530 * @return the max value
537531 */
538- public float getFpsRangeMaxValue () {
539- return fpsRangeMaxValue ;
532+ public float getPreviewFrameRateMaxValue () {
533+ return previewFrameRateMaxValue ;
540534 }
541535}
0 commit comments