Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: talk/app/webrtc/java/android/org/webrtc/CameraEnumerationAndroid.java

Issue 1486423003: Fix error prone code in VideoCapturerAndroid (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // Rounds up |x| to the closest value that is a multiple of |alignment|. 106 // Rounds up |x| to the closest value that is a multiple of |alignment|.
107 private static int roundUp(int x, int alignment) { 107 private static int roundUp(int x, int alignment) {
108 return (int)ceil(x / (double)alignment) * alignment; 108 return (int)ceil(x / (double)alignment) * alignment;
109 } 109 }
110 110
111 @Override 111 @Override
112 public String toString() { 112 public String toString() {
113 return width + "x" + height + "@[" + minFramerate + ":" + maxFramerate + " ]"; 113 return width + "x" + height + "@[" + minFramerate + ":" + maxFramerate + " ]";
114 } 114 }
115 115
116 @Override 116 public boolean isSameFormat(final CaptureFormat that) {
117 public boolean equals(Object that) { 117 if (that == null) {
118 if (!(that instanceof CaptureFormat)) {
119 return false; 118 return false;
120 } 119 }
121 final CaptureFormat c = (CaptureFormat) that; 120 return width == that.width && height == that.height && maxFramerate == tha t.maxFramerate
122 return width == c.width && height == c.height && maxFramerate == c.maxFram erate 121 && minFramerate == that.minFramerate;
123 && minFramerate == c.minFramerate;
124 } 122 }
125 } 123 }
126 124
127 // Returns device names that can be used to create a new VideoCapturerAndroid. 125 // Returns device names that can be used to create a new VideoCapturerAndroid.
128 public static String[] getDeviceNames() { 126 public static String[] getDeviceNames() {
129 String[] names = new String[android.hardware.Camera.getNumberOfCameras()]; 127 String[] names = new String[android.hardware.Camera.getNumberOfCameras()];
130 for (int i = 0; i < android.hardware.Camera.getNumberOfCameras(); ++i) { 128 for (int i = 0; i < android.hardware.Camera.getNumberOfCameras(); ++i) {
131 names[i] = getDeviceName(i); 129 names[i] = getDeviceName(i);
132 } 130 }
133 return names; 131 return names;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 public static int[] getFramerateRange(android.hardware.Camera.Parameters param eters, 194 public static int[] getFramerateRange(android.hardware.Camera.Parameters param eters,
197 final int framerate) { 195 final int framerate) {
198 List<int[]> listFpsRange = parameters.getSupportedPreviewFpsRange(); 196 List<int[]> listFpsRange = parameters.getSupportedPreviewFpsRange();
199 if (listFpsRange.isEmpty()) { 197 if (listFpsRange.isEmpty()) {
200 Logging.w(TAG, "No supported preview fps range"); 198 Logging.w(TAG, "No supported preview fps range");
201 return new int[]{0, 0}; 199 return new int[]{0, 0};
202 } 200 }
203 return Collections.min(listFpsRange, 201 return Collections.min(listFpsRange,
204 new ClosestComparator<int[]>() { 202 new ClosestComparator<int[]>() {
205 @Override int diff(int[] range) { 203 @Override int diff(int[] range) {
204 final int MAX_FPS_WEIGHT = 10;
magjed_webrtc 2015/12/03 11:07:35 Has this anything to do with bug=5282? You should
perkj_webrtc 2015/12/04 07:40:53 Done.
206 return range[android.hardware.Camera.Parameters.PREVIEW_FPS_MIN_INDE X] 205 return range[android.hardware.Camera.Parameters.PREVIEW_FPS_MIN_INDE X]
207 + 10 * abs(framerate 206 + MAX_FPS_WEIGHT * abs(framerate
208 - range[android.hardware.Camera.Parameters.PREVIEW_FPS_MAX_I NDEX]); 207 - range[android.hardware.Camera.Parameters.PREVIEW_FPS_MAX_I NDEX]);
209 } 208 }
210 }); 209 });
211 } 210 }
212 211
213 public static android.hardware.Camera.Size getClosestSupportedSize( 212 public static android.hardware.Camera.Size getClosestSupportedSize(
214 List<android.hardware.Camera.Size> supportedSizes, final int requestedWidt h, 213 List<android.hardware.Camera.Size> supportedSizes, final int requestedWidt h,
215 final int requestedHeight) { 214 final int requestedHeight) {
216 return Collections.min(supportedSizes, 215 return Collections.min(supportedSizes,
217 new ClosestComparator<android.hardware.Camera.Size>() { 216 new ClosestComparator<android.hardware.Camera.Size>() {
(...skipping 11 matching lines...) Expand all
229 if (info.facing == facing) { 228 if (info.facing == facing) {
230 return getDeviceName(i); 229 return getDeviceName(i);
231 } 230 }
232 } catch (Exception e) { 231 } catch (Exception e) {
233 Logging.e(TAG, "getCameraInfo() failed on index " + i, e); 232 Logging.e(TAG, "getCameraInfo() failed on index " + i, e);
234 } 233 }
235 } 234 }
236 return null; 235 return null;
237 } 236 }
238 } 237 }
OLDNEW
« no previous file with comments | « no previous file | talk/app/webrtc/java/android/org/webrtc/VideoCapturerAndroid.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698