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() { |