Bug 1441585 - Set picture size to something valid. r=dminor
authorAndreas Pehrson <pehrsons@mozilla.com>
Thu, 05 Apr 2018 17:32:09 +0200
changeset 411982 9505c63348758532f3e268f2066fc7f0f0c8a3a0
parent 411981 be2c7141c619d4173b12ee38f8ba1953651e30aa
child 411983 9cc46ceede5917930db2d560ce0330cc9720a60d
push id33778
push userapavel@mozilla.com
push dateFri, 06 Apr 2018 09:57:38 +0000
treeherdermozilla-central@46a5fc19bd7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdminor
bugs1441585
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1441585 - Set picture size to something valid. r=dminor MozReview-Commit-ID: 13lZcfR9wlC
media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java
--- a/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java
+++ b/media/webrtc/trunk/webrtc/modules/video_capture/android/java/src/org/webrtc/videoengine/VideoCaptureAndroid.java
@@ -192,19 +192,43 @@ public class VideoCaptureAndroid impleme
       }
 
       List<String> focusModes = parameters.getSupportedFocusModes();
       if (focusModes.contains(android.hardware.Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
         Log.d(TAG, "Enable continuous auto focus mode.");
         parameters.setFocusMode(android.hardware.Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
       }
 
-      parameters.setPictureSize(width, height);
+      // (width,height) is a valid preview size. It might not be a valid picture
+      // size.
       parameters.setPreviewSize(width, height);
 
+      List<Camera.Size> supportedPictureSizes =
+        parameters.getSupportedPictureSizes();
+      Camera.Size pictureSize = supportedPictureSizes.get(0);
+      for (Camera.Size size : supportedPictureSizes) {
+        if (size.width < width || size.height < height) {
+          // We want a picture size larger than the preview size
+          continue;
+        }
+        if (pictureSize.width < width || pictureSize.height < height) {
+          // The so-far chosen pictureSize is smaller than the preview size.
+          // `size` is a better fit.
+          pictureSize = size;
+          continue;
+        }
+        if (size.width <= pictureSize.width &&
+            size.height <= pictureSize.height) {
+          // Both the so-far chosen pictureSize and `size` are larger than the
+          // preview size, but `size` is closest, so it's preferred.
+          pictureSize = size;
+        }
+      }
+      parameters.setPictureSize(pictureSize.width, pictureSize.height);
+
       // Check if requested fps range is supported by camera,
       // otherwise calculate frame drop ratio.
       List<int[]> supportedFpsRanges = parameters.getSupportedPreviewFpsRange();
       frameDropRatio = Integer.MAX_VALUE;
       for (int i = 0; i < supportedFpsRanges.size(); i++) {
         int[] range = supportedFpsRanges.get(i);
         if (range[Parameters.PREVIEW_FPS_MIN_INDEX] == min_mfps &&
             range[Parameters.PREVIEW_FPS_MAX_INDEX] == max_mfps) {