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

Unified Diff: media/base/android/java/src/org/chromium/media/VideoCaptureFactory.java

Issue 611283002: Android Video Capture: Added static methods for device & capabilities enumeration using Camera2 API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 6 years, 1 month 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: media/base/android/java/src/org/chromium/media/VideoCaptureFactory.java
diff --git a/media/base/android/java/src/org/chromium/media/VideoCaptureFactory.java b/media/base/android/java/src/org/chromium/media/VideoCaptureFactory.java
index 8297c8193004c869cb03a95e9b52b80c978e872f..8698311523bee0218779ed5a76b8d2480465bb12 100644
--- a/media/base/android/java/src/org/chromium/media/VideoCaptureFactory.java
+++ b/media/base/android/java/src/org/chromium/media/VideoCaptureFactory.java
@@ -6,6 +6,7 @@ package org.chromium.media;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.os.Build;
import android.util.Log;
import org.chromium.base.CalledByNative;
@@ -67,21 +68,30 @@ class VideoCaptureFactory {
if (PackageManager.PERMISSION_GRANTED
== appContext.getPackageManager().checkPermission(
"android.permission.CAMERA", appContext.getPackageName())) {
- sNumberOfSystemCameras = VideoCaptureAndroid.getNumberOfCameras();
+ if (isLReleaseOrLater()) {
+ sNumberOfSystemCameras =
+ VideoCaptureCamera2.getNumberOfCameras(appContext);
+ } else {
+ sNumberOfSystemCameras = VideoCaptureAndroid.getNumberOfCameras();
+ if (isSpecialDevice()) {
+ Log.d(TAG, "Special device: " + android.os.Build.MODEL);
+ sNumberOfSystemCameras += VideoCaptureTango.numberOfCameras();
+ }
+ }
} else {
sNumberOfSystemCameras = 0;
Log.w(TAG, "Missing android.permission.CAMERA permission, "
+ "no system camera available.");
}
}
- if (!isSpecialDevice()) {
- return sNumberOfSystemCameras;
- }
- Log.d(TAG, "Special device: " + android.os.Build.MODEL);
- return sNumberOfSystemCameras + VideoCaptureTango.numberOfCameras();
+ return sNumberOfSystemCameras;
}
}
+ private static boolean isLReleaseOrLater() {
+ return Build.VERSION.SDK_INT >= Build.VERSION_CODES.L;
+ }
+
// Factory methods.
@CalledByNative
static VideoCapture createVideoCapture(
@@ -101,14 +111,20 @@ class VideoCaptureFactory {
}
@CalledByNative
- static String getDeviceName(int id) {
+ static String getDeviceName(int id, Context appContext) {
+ if (isLReleaseOrLater()) {
+ return VideoCaptureCamera2.getName(id, appContext);
+ }
return (ChromiumCameraInfo.isSpecialCamera(id))
? VideoCaptureTango.getName(ChromiumCameraInfo.toSpecialCameraId(id))
: VideoCaptureAndroid.getName(id);
}
@CalledByNative
- static VideoCapture.CaptureFormat[] getDeviceSupportedFormats(int id) {
+ static VideoCapture.CaptureFormat[] getDeviceSupportedFormats(Context appContext, int id) {
+ if (isLReleaseOrLater()) {
+ return VideoCaptureCamera2.getDeviceSupportedFormats(appContext, id);
+ }
return ChromiumCameraInfo.isSpecialCamera(id)
? VideoCaptureTango.getDeviceSupportedFormats(
ChromiumCameraInfo.toSpecialCameraId(id))

Powered by Google App Engine
This is Rietveld 408576698