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

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

Issue 2983473002: Android Tango depth camera capture support.
Patch Set: Created 3 years, 5 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: media/capture/video/android/java/src/org/chromium/media/VideoCaptureFactory.java
diff --git a/media/capture/video/android/java/src/org/chromium/media/VideoCaptureFactory.java b/media/capture/video/android/java/src/org/chromium/media/VideoCaptureFactory.java
index 2b4a301c6c7158df253329d55396604c615f774c..76fd843536f2f2930ee4621c17ff0023eade525d 100644
--- a/media/capture/video/android/java/src/org/chromium/media/VideoCaptureFactory.java
+++ b/media/capture/video/android/java/src/org/chromium/media/VideoCaptureFactory.java
@@ -15,10 +15,12 @@ import org.chromium.base.annotations.JNINamespace;
/**
* This class implements a factory of Android Video Capture objects for Chrome.
- * Cameras are identified by |id|. Video Capture objects allocated via
+ * The createVideoCapture() returns either a "standard" VideoCaptureCamera or a
+ * VideoCaptureTango. Cameras are identified by |id|, where Tango cameras have
+ * |id| above the standard ones. Video Capture objects allocated via
* createVideoCapture() are explicitly owned by the caller. ChromiumCameraInfo
- * is an internal class with some static methods needed from the rest of the
- * class to manipulate the |id|s of devices.
+ * is an internal class with static methods used by the rest of the class to
+ * manipulate the |id|s of cameras.
**/
@JNINamespace("media")
@SuppressWarnings("deprecation")
@@ -28,6 +30,16 @@ class VideoCaptureFactory {
private static int sNumberOfSystemCameras = -1;
private static final String TAG = "cr.media";
+ private static boolean isTangoCamera(int id) {
+ // Tango cameras' Id range is above standard cameras Id range.
+ return id >= sNumberOfSystemCameras;
+ }
+
+ private static int toTangoCameraId(int id) {
+ assert isTangoCamera(id);
+ return id - sNumberOfSystemCameras;
+ }
+
private static int getNumberOfCameras() {
if (sNumberOfSystemCameras == -1) {
// getNumberOfCameras() would not fail due to lack of permission, but the
@@ -53,7 +65,7 @@ class VideoCaptureFactory {
}
}
}
- return sNumberOfSystemCameras;
+ return sNumberOfSystemCameras + VideoCaptureTango.getNumberOfCameras();
}
}
@@ -69,6 +81,10 @@ class VideoCaptureFactory {
// Factory methods.
@CalledByNative
static VideoCapture createVideoCapture(int id, long nativeVideoCaptureDeviceAndroid) {
+ if (ChromiumCameraInfo.isTangoCamera(id)) {
+ return new VideoCaptureTango(
+ ChromiumCameraInfo.toTangoCameraId(id), nativeVideoCaptureDeviceAndroid);
+ }
if (isLReleaseOrLater() && !VideoCaptureCamera2.isLegacyDevice(id)) {
return new VideoCaptureCamera2(id, nativeVideoCaptureDeviceAndroid);
}
@@ -82,14 +98,21 @@ class VideoCaptureFactory {
@CalledByNative
static int getCaptureApiType(int id) {
+ if (ChromiumCameraInfo.isTangoCamera(id)) {
+ return VideoCaptureTango.getCaptureApiType(ChromiumCameraInfo.toTangoCameraId(id));
+ }
if (isLReleaseOrLater()) {
return VideoCaptureCamera2.getCaptureApiType(id);
+ } else {
+ return VideoCaptureCamera.getCaptureApiType(id);
}
- return VideoCaptureCamera.getCaptureApiType(id);
}
@CalledByNative
static String getDeviceName(int id) {
+ if (ChromiumCameraInfo.isTangoCamera(id)) {
+ return VideoCaptureTango.getName(ChromiumCameraInfo.toTangoCameraId(id));
+ }
if (isLReleaseOrLater() && !VideoCaptureCamera2.isLegacyDevice(id)) {
return VideoCaptureCamera2.getName(id);
}
@@ -98,6 +121,10 @@ class VideoCaptureFactory {
@CalledByNative
static VideoCaptureFormat[] getDeviceSupportedFormats(int id) {
+ if (ChromiumCameraInfo.isTangoCamera(id)) {
+ return VideoCaptureTango.getDeviceSupportedFormats(
+ ChromiumCameraInfo.toTangoCameraId(id));
+ }
if (isLReleaseOrLater() && !VideoCaptureCamera2.isLegacyDevice(id)) {
return VideoCaptureCamera2.getDeviceSupportedFormats(id);
}

Powered by Google App Engine
This is Rietveld 408576698