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

Unified Diff: talk/app/webrtc/java/android/org/webrtc/CameraEnumerationAndroid.java

Issue 1340923002: Android video capture: Remove duplicated code and fix spelling mistakes (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « talk/app/webrtc/androidtests/src/org/webrtc/VideoCapturerAndroidTest.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/app/webrtc/java/android/org/webrtc/CameraEnumerationAndroid.java
diff --git a/talk/app/webrtc/java/android/org/webrtc/CameraEnumerationAndroid.java b/talk/app/webrtc/java/android/org/webrtc/CameraEnumerationAndroid.java
index 136c232b7f98e92d962eb029870aacfe5ce08af2..11bdb6abb19dc3bff7fc700af377cc7d20d1a2ee 100644
--- a/talk/app/webrtc/java/android/org/webrtc/CameraEnumerationAndroid.java
+++ b/talk/app/webrtc/java/android/org/webrtc/CameraEnumerationAndroid.java
@@ -160,33 +160,13 @@ public class CameraEnumerationAndroid {
// 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() {
- for (int i = 0; i < Camera.getNumberOfCameras(); ++i) {
- Camera.CameraInfo info = new Camera.CameraInfo();
- try {
- Camera.getCameraInfo(i, info);
- if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT)
- return getDeviceName(i);
- } catch (Exception e) {
- Log.e(TAG, "getCameraInfo failed on index " + i, e);
- }
- }
- return null;
+ return getNameOfDevice(Camera.CameraInfo.CAMERA_FACING_FRONT);
}
// Returns the name of the back facing camera. Returns null if the
// camera can not be used or does not exist.
public static String getNameOfBackFacingDevice() {
- for (int i = 0; i < Camera.getNumberOfCameras(); ++i) {
- Camera.CameraInfo info = new Camera.CameraInfo();
- try {
- Camera.getCameraInfo(i, info);
- if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK)
- return getDeviceName(i);
- } catch (Exception e) {
- Log.e(TAG, "getCameraInfo failed on index " + i, e);
- }
- }
- return null;
+ return getNameOfDevice(Camera.CameraInfo.CAMERA_FACING_BACK);
}
public static String getSupportedFormatsAsJson(int id) throws JSONException {
@@ -239,4 +219,19 @@ public class CameraEnumerationAndroid {
}
});
}
+
+ private static String getNameOfDevice(int facing) {
+ final Camera.CameraInfo info = new Camera.CameraInfo();
+ for (int i = 0; i < Camera.getNumberOfCameras(); ++i) {
+ try {
+ Camera.getCameraInfo(i, info);
+ if (info.facing == facing) {
+ return getDeviceName(i);
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "getCameraInfo() failed on index " + i, e);
+ }
+ }
+ return null;
+ }
}
« no previous file with comments | « talk/app/webrtc/androidtests/src/org/webrtc/VideoCapturerAndroidTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698