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

Unified Diff: webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java

Issue 2024843002: Refactor VideoCapturerAndroid tests in WebRTC. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Reorder imports to match Java style guide Created 4 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java
diff --git a/webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java b/webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java
index 44c850538ef3e3e78beee70a41eb9206b5bf3744..ed93bd12a0fe6af831a4a27db268f86b0deb3791 100644
--- a/webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java
+++ b/webrtc/api/java/android/org/webrtc/CameraEnumerationAndroid.java
@@ -11,10 +11,11 @@
package org.webrtc;
import static java.lang.Math.abs;
-import android.graphics.ImageFormat;
import org.webrtc.Logging;
+import android.graphics.ImageFormat;
+
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -137,6 +138,18 @@ public class CameraEnumerationAndroid {
+ ", Orientation " + info.orientation;
}
+ // Returns the camera index for camera with name |deviceName|, or throws IllegalArgumentException
+ // if no such camera can be found.
+ public static int getCameraIndex(String deviceName) {
+ Logging.d(TAG, "getCameraIndex: " + deviceName);
+ for (int i = 0; i < android.hardware.Camera.getNumberOfCameras(); ++i) {
+ if (deviceName.equals(CameraEnumerationAndroid.getDeviceName(i))) {
+ return i;
+ }
+ }
+ throw new IllegalArgumentException("No such camera: " + deviceName);
+ }
+
// Returns the name of the front facing camera. Returns null if the
// camera can not be used or does not exist.
public static String getNameOfFrontFacingDevice() {

Powered by Google App Engine
This is Rietveld 408576698