summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclamy <clamy@chromium.org>2016-02-19 06:42:00 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-19 14:43:14 +0000
commit5f5cab50b44307c6ce1fde3d1a7b13be913d3304 (patch)
treeca815bf4b43372f3416e96eb0f595c41cc644045
parentb7b11b629858f322c3de1ae9478d74a64f9d4820 (diff)
downloadchromium_src-5f5cab50b44307c6ce1fde3d1a7b13be913d3304.zip
chromium_src-5f5cab50b44307c6ce1fde3d1a7b13be913d3304.tar.gz
chromium_src-5f5cab50b44307c6ce1fde3d1a7b13be913d3304.tar.bz2
Revert of Move VideoCapture* files from media/base/android/... to media/capture/video/android/java/... (patchset #2 id:70001 of https://codereview.chromium.org/1705333003/ )
Reason for revert: Android WebView tests started failing after 4 CLs landed including this one, and it seems like the most likely culprit. See https://build.chromium.org/p/chromium.android/builders/Android%20Webview%20L%20%28dbg%29/builds/9568 and https://build.chromium.org/p/chromium.android/builders/Android%20Webview%20M%20%28dbg%29/builds/5214. Original issue's description: > Move VideoCapture* files from media/base/android/... to media/capture/video/android/java/... > > ** No code changes (except git cl format kicked by presbumit). ** > > This CL refactors the VideoCapture*java classes > from being under media/base/android/java/... into > media/capture/video/android/java/... with the idea > of bringing all such classes under a single roof > as a preparation for http://crbug.com/584797 (CL > http://crrev.com/1699553002) which creates an entity > (very similar to media/cast/ and media/midi/) with > its own .gn and .gyp. > > BUG=587693, 584797 > NOTRY=true > > Committed: https://crrev.com/157c17e6d77e64efee6b82947506f544aac3b79f > Cr-Commit-Position: refs/heads/master@{#376409} TBR=qinmin@chromium.org,dalecurtis@chromium.org,avi@chromium.org,dtrainor@chromium.org,mcasas@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=587693, 584797 Review URL: https://codereview.chromium.org/1710373002 Cr-Commit-Position: refs/heads/master@{#376438}
-rw-r--r--chrome/android/BUILD.gn2
-rw-r--r--content/public/android/BUILD.gn4
-rw-r--r--content/shell/android/BUILD.gn6
-rw-r--r--content/test/BUILD.gn2
-rw-r--r--media/BUILD.gn4
-rw-r--r--media/base/BUILD.gn2
-rw-r--r--media/base/android/BUILD.gn25
-rw-r--r--media/base/android/java/src/org/chromium/media/OWNERS2
-rw-r--r--media/base/android/java/src/org/chromium/media/VideoCapture.java (renamed from media/capture/video/android/java/src/org/chromium/media/VideoCapture.java)20
-rw-r--r--media/base/android/java/src/org/chromium/media/VideoCaptureAndroid.java (renamed from media/capture/video/android/java/src/org/chromium/media/VideoCaptureAndroid.java)39
-rw-r--r--media/base/android/java/src/org/chromium/media/VideoCaptureCamera.java (renamed from media/capture/video/android/java/src/org/chromium/media/VideoCaptureCamera.java)54
-rw-r--r--media/base/android/java/src/org/chromium/media/VideoCaptureCamera2.java (renamed from media/capture/video/android/java/src/org/chromium/media/VideoCaptureCamera2.java)54
-rw-r--r--media/base/android/java/src/org/chromium/media/VideoCaptureFactory.java (renamed from media/capture/video/android/java/src/org/chromium/media/VideoCaptureFactory.java)26
-rw-r--r--media/base/android/java/src/org/chromium/media/VideoCaptureFormat.java (renamed from media/capture/video/android/java/src/org/chromium/media/VideoCaptureFormat.java)3
-rw-r--r--media/base/android/java/src/org/chromium/media/VideoCaptureTango.java (renamed from media/capture/video/android/java/src/org/chromium/media/VideoCaptureTango.java)44
-rw-r--r--media/capture/video/android/BUILD.gn36
-rw-r--r--media/capture/video/android/java/src/org/chromium/media/OWNERS2
-rw-r--r--media/media.gyp6
18 files changed, 189 insertions, 142 deletions
diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn
index 5bc69aa..6cf137e 100644
--- a/chrome/android/BUILD.gn
+++ b/chrome/android/BUILD.gn
@@ -136,7 +136,7 @@ android_library("chrome_java") {
"//components/web_contents_delegate_android:web_contents_delegate_android_java",
"//components/web_restrictions:web_restrictions_java",
"//content/public/android:content_java",
- "//media/capture/video/android:media_java",
+ "//media/base/android:media_java",
"//media/midi:midi_java",
"//net/android:net_java",
"//printing:printing_java",
diff --git a/content/public/android/BUILD.gn b/content/public/android/BUILD.gn
index 67838f0..e726c46 100644
--- a/content/public/android/BUILD.gn
+++ b/content/public/android/BUILD.gn
@@ -38,7 +38,7 @@ android_library("content_java") {
"//device/usb:java",
"//device/vibration:mojo_bindings_java",
"//device/vibration/android:vibration_manager_android",
- "//media/capture/video/android:media_java",
+ "//media/base/android:media_java",
"//media/midi:midi_java",
"//mojo/android:system_java",
"//mojo/public/java:bindings",
@@ -176,7 +176,7 @@ android_library("content_javatests") {
"//content/shell/android:content_shell_test_java",
"//device/vibration:mojo_bindings_java",
"//device/vibration/android:vibration_manager_android",
- "//media/capture/video/android:media_java",
+ "//media/base/android:media_java",
"//mojo/android:system_java",
"//mojo/public/interfaces/bindings/tests:test_interfaces_java",
"//mojo/public/java:bindings",
diff --git a/content/shell/android/BUILD.gn b/content/shell/android/BUILD.gn
index 6a20d79..3c6af4d 100644
--- a/content/shell/android/BUILD.gn
+++ b/content/shell/android/BUILD.gn
@@ -45,7 +45,7 @@ android_library("content_shell_java") {
":content_shell_java_resources",
"//base:base_java",
"//content/public/android:content_java",
- "//media/capture/video/android:media_java",
+ "//media/base/android:media_java",
"//mojo/public/java:system",
"//net/android:net_java",
"//ui/android:ui_java",
@@ -79,7 +79,7 @@ android_library("content_shell_apk_java") {
":content_shell_java",
"//base:base_java",
"//content/public/android:content_java",
- "//media/capture/video/android:media_java",
+ "//media/base/android:media_java",
"//net/android:net_java",
"//ui/android:ui_java",
]
@@ -109,7 +109,7 @@ android_apk("content_shell_apk") {
":libcontent_shell_content_view",
"//base:base_java",
"//content/public/android:content_java",
- "//media/capture/video/android:media_java",
+ "//media/base/android:media_java",
"//net/android:net_java",
"//third_party/mesa:osmesa",
"//ui/android:ui_java",
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn
index 4ad3c61..4aa5d41 100644
--- a/content/test/BUILD.gn
+++ b/content/test/BUILD.gn
@@ -924,7 +924,7 @@ if (is_android) {
deps += [
"//gpu:test_support",
"//media/base/android",
- "//media/capture/video/android:media_java",
+ "//media/base/android:media_java",
"//testing/gmock",
"//ui/android:ui_java",
]
diff --git a/media/BUILD.gn b/media/BUILD.gn
index 813aa64..b1686f4 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -403,8 +403,7 @@ component("media") {
deps += [
"//media/base/android",
"//media/base/android:media_jni_headers",
- "//media/capture/video/android:media_java",
- "//media/capture/video/android:video_capture_jni_headers",
+ "//media/base/android:video_capture_jni_headers",
]
# Only 64 bit builds are using android-21 NDK library, check common.gypi
@@ -720,6 +719,7 @@ test("media_unittests") {
"filters/decrypting_video_decoder_unittest.cc",
]
deps += [
+ "//media/base/android:media_java",
"//media/base/android:unittests",
"//ui/android:ui_java",
]
diff --git a/media/base/BUILD.gn b/media/base/BUILD.gn
index 9c4177f..1d1747c 100644
--- a/media/base/BUILD.gn
+++ b/media/base/BUILD.gn
@@ -249,7 +249,9 @@ source_set("base") {
if (is_android) {
public_deps = [
"//media/base/android",
+ "//media/base/android:media_java",
"//media/base/android:media_jni_headers",
+ "//media/base/android:video_capture_jni_headers",
]
allow_circular_includes_from += [ "//media/base/android" ]
}
diff --git a/media/base/android/BUILD.gn b/media/base/android/BUILD.gn
index 9e5b914..10bfdfe 100644
--- a/media/base/android/BUILD.gn
+++ b/media/base/android/BUILD.gn
@@ -114,3 +114,28 @@ generate_jni("media_jni_headers") {
]
jni_package = "media"
}
+
+generate_jni("video_capture_jni_headers") {
+ sources = [
+ "java/src/org/chromium/media/VideoCapture.java",
+ "java/src/org/chromium/media/VideoCaptureFactory.java",
+ ]
+ jni_package = "media"
+}
+
+java_cpp_enum("media_java_enums_srcjar") {
+ sources = [
+ "//media/capture/video/android/video_capture_device_android.h",
+ "//media/capture/video/video_capture_device.h",
+ ]
+}
+
+android_library("media_java") {
+ deps = [
+ "//base:base_java",
+ ]
+
+ srcjar_deps = [ ":media_java_enums_srcjar" ]
+
+ DEPRECATED_java_in_dir = "java/src"
+}
diff --git a/media/base/android/java/src/org/chromium/media/OWNERS b/media/base/android/java/src/org/chromium/media/OWNERS
new file mode 100644
index 0000000..85e4365
--- /dev/null
+++ b/media/base/android/java/src/org/chromium/media/OWNERS
@@ -0,0 +1,2 @@
+# VideoCapture classes under Android
+per-file VideoCapture*.java=mcasas@chromium.org
diff --git a/media/capture/video/android/java/src/org/chromium/media/VideoCapture.java b/media/base/android/java/src/org/chromium/media/VideoCapture.java
index 2e2a289..bc8351f 100644
--- a/media/capture/video/android/java/src/org/chromium/media/VideoCapture.java
+++ b/media/base/android/java/src/org/chromium/media/VideoCapture.java
@@ -19,6 +19,7 @@ import org.chromium.base.annotations.JNINamespace;
**/
@JNINamespace("media")
public abstract class VideoCapture {
+
// The angle (0, 90, 180, 270) that the image needs to be rotated to show in
// the display's native orientation.
protected int mCameraNativeOrientation;
@@ -32,7 +33,9 @@ public abstract class VideoCapture {
// Native callback context variable.
protected final long mNativeVideoCaptureDeviceAndroid;
- VideoCapture(Context context, int id, long nativeVideoCaptureDeviceAndroid) {
+ VideoCapture(Context context,
+ int id,
+ long nativeVideoCaptureDeviceAndroid) {
mContext = context;
mId = id;
mNativeVideoCaptureDeviceAndroid = nativeVideoCaptureDeviceAndroid;
@@ -84,8 +87,8 @@ public abstract class VideoCapture {
}
protected final int getCameraRotation() {
- int rotation = mInvertDeviceOrientationReadings ? (360 - getDeviceRotation())
- : getDeviceRotation();
+ int rotation = mInvertDeviceOrientationReadings
+ ? (360 - getDeviceRotation()) : getDeviceRotation();
return (mCameraNativeOrientation + rotation) % 360;
}
@@ -93,7 +96,7 @@ public abstract class VideoCapture {
if (mContext == null) return 0;
final int orientation;
WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
- switch (wm.getDefaultDisplay().getRotation()) {
+ switch(wm.getDefaultDisplay().getRotation()) {
case Surface.ROTATION_90:
orientation = 90;
break;
@@ -112,9 +115,12 @@ public abstract class VideoCapture {
}
// Method for VideoCapture implementations to call back native code.
- public native void nativeOnFrameAvailable(
- long nativeVideoCaptureDeviceAndroid, byte[] data, int length, int rotation);
+ public native void nativeOnFrameAvailable(long nativeVideoCaptureDeviceAndroid,
+ byte[] data,
+ int length,
+ int rotation);
// Method for VideoCapture implementations to signal an asynchronous error.
- public native void nativeOnError(long nativeVideoCaptureDeviceAndroid, String message);
+ public native void nativeOnError(long nativeVideoCaptureDeviceAndroid,
+ String message);
}
diff --git a/media/capture/video/android/java/src/org/chromium/media/VideoCaptureAndroid.java b/media/base/android/java/src/org/chromium/media/VideoCaptureAndroid.java
index ce384d1..35ec09f 100644
--- a/media/capture/video/android/java/src/org/chromium/media/VideoCaptureAndroid.java
+++ b/media/base/android/java/src/org/chromium/media/VideoCaptureAndroid.java
@@ -20,14 +20,18 @@ import java.util.List;
**/
@SuppressWarnings("deprecation")
public class VideoCaptureAndroid extends VideoCaptureCamera {
+
// Some devices don't support YV12 format correctly, even with JELLY_BEAN or
// newer OS. To work around the issues on those devices, we have to request
// NV21. This is supposed to be a temporary hack.
private static class BuggyDeviceHack {
private static final String[] COLORSPACE_BUGGY_DEVICE_LIST = {
- "SAMSUNG-SGH-I747", "ODROID-U2",
- // See https://crbug.com/577435 for more info.
- "XT1092", "XT1095", "XT1096",
+ "SAMSUNG-SGH-I747",
+ "ODROID-U2",
+ // See https://crbug.com/577435 for more info.
+ "XT1092",
+ "XT1095",
+ "XT1096",
};
static int getImageFormat() {
@@ -59,10 +63,8 @@ public class VideoCaptureAndroid extends VideoCaptureCamera {
android.hardware.Camera.CameraInfo cameraInfo = VideoCaptureCamera.getCameraInfo(id);
if (cameraInfo == null) return null;
- return "camera " + id + ", facing "
- + (cameraInfo.facing == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT
- ? "front"
- : "back");
+ return "camera " + id + ", facing " + (cameraInfo.facing
+ == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT ? "front" : "back");
}
static VideoCaptureFormat[] getDeviceSupportedFormats(int id) {
@@ -115,8 +117,10 @@ public class VideoCaptureAndroid extends VideoCaptureCamera {
supportedSizes.add(camera.new Size(0, 0));
}
for (android.hardware.Camera.Size size : supportedSizes) {
- formatList.add(new VideoCaptureFormat(
- size.width, size.height, (fpsRange[1] + 999) / 1000, pixelFormat));
+ formatList.add(new VideoCaptureFormat(size.width,
+ size.height,
+ (fpsRange[1] + 999) / 1000,
+ pixelFormat));
}
}
}
@@ -124,15 +128,20 @@ public class VideoCaptureAndroid extends VideoCaptureCamera {
return formatList.toArray(new VideoCaptureFormat[formatList.size()]);
}
- VideoCaptureAndroid(Context context, int id, long nativeVideoCaptureDeviceAndroid) {
+ VideoCaptureAndroid(Context context,
+ int id,
+ long nativeVideoCaptureDeviceAndroid) {
super(context, id, nativeVideoCaptureDeviceAndroid);
}
@Override
- protected void setCaptureParameters(int width, int height, int frameRate,
+ protected void setCaptureParameters(
+ int width,
+ int height,
+ int frameRate,
android.hardware.Camera.Parameters cameraParameters) {
- mCaptureFormat =
- new VideoCaptureFormat(width, height, frameRate, BuggyDeviceHack.getImageFormat());
+ mCaptureFormat = new VideoCaptureFormat(
+ width, height, frameRate, BuggyDeviceHack.getImageFormat());
}
@Override
@@ -158,8 +167,8 @@ public class VideoCaptureAndroid extends VideoCaptureCamera {
return;
}
if (data.length == mExpectedFrameSize) {
- nativeOnFrameAvailable(mNativeVideoCaptureDeviceAndroid, data, mExpectedFrameSize,
- getCameraRotation());
+ nativeOnFrameAvailable(mNativeVideoCaptureDeviceAndroid,
+ data, mExpectedFrameSize, getCameraRotation());
}
} finally {
mPreviewBufferLock.unlock();
diff --git a/media/capture/video/android/java/src/org/chromium/media/VideoCaptureCamera.java b/media/base/android/java/src/org/chromium/media/VideoCaptureCamera.java
index afe58d3..9e10c68 100644
--- a/media/capture/video/android/java/src/org/chromium/media/VideoCaptureCamera.java
+++ b/media/base/android/java/src/org/chromium/media/VideoCaptureCamera.java
@@ -24,10 +24,11 @@ import java.util.concurrent.locks.ReentrantLock;
**/
@JNINamespace("media")
@SuppressWarnings("deprecation")
-// TODO: is this class only used on ICS MR1 (or some later version) and above?
+//TODO: is this class only used on ICS MR1 (or some later version) and above?
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
-public abstract class VideoCaptureCamera
- extends VideoCapture implements android.hardware.Camera.PreviewCallback {
+public abstract class VideoCaptureCamera extends VideoCapture
+ implements android.hardware.Camera.PreviewCallback {
+
protected android.hardware.Camera mCamera;
// Lock to mutually exclude execution of OnPreviewFrame() and {start/stop}Capture().
protected ReentrantLock mPreviewBufferLock = new ReentrantLock();
@@ -41,7 +42,8 @@ public abstract class VideoCaptureCamera
private static final String TAG = "cr.media";
protected static android.hardware.Camera.CameraInfo getCameraInfo(int id) {
- android.hardware.Camera.CameraInfo cameraInfo = new android.hardware.Camera.CameraInfo();
+ android.hardware.Camera.CameraInfo cameraInfo =
+ new android.hardware.Camera.CameraInfo();
try {
android.hardware.Camera.getCameraInfo(id, cameraInfo);
} catch (RuntimeException ex) {
@@ -64,7 +66,9 @@ public abstract class VideoCaptureCamera
return parameters;
}
- VideoCaptureCamera(Context context, int id, long nativeVideoCaptureDeviceAndroid) {
+ VideoCaptureCamera(Context context,
+ int id,
+ long nativeVideoCaptureDeviceAndroid) {
super(context, id, nativeVideoCaptureDeviceAndroid);
}
@@ -109,9 +113,8 @@ public abstract class VideoCaptureCamera
// Use the first range as the default chosen range.
int[] chosenFpsRange = listFpsRange.get(0);
int frameRateNearest = Math.abs(frameRateScaled - chosenFpsRange[0])
- < Math.abs(frameRateScaled - chosenFpsRange[1])
- ? chosenFpsRange[0]
- : chosenFpsRange[1];
+ < Math.abs(frameRateScaled - chosenFpsRange[1])
+ ? chosenFpsRange[0] : chosenFpsRange[1];
int chosenFrameRate = (frameRateNearest + 999) / 1000;
int fpsRangeSize = Integer.MAX_VALUE;
for (int[] fpsRange : listFpsRange) {
@@ -122,16 +125,18 @@ public abstract class VideoCaptureCamera
fpsRangeSize = fpsRange[1] - fpsRange[0];
}
}
- Log.d(TAG, "allocate: fps set to %d, [%d-%d]", chosenFrameRate, chosenFpsRange[0],
- chosenFpsRange[1]);
+ Log.d(TAG, "allocate: fps set to %d, [%d-%d]", chosenFrameRate,
+ chosenFpsRange[0], chosenFpsRange[1]);
// Calculate size.
- List<android.hardware.Camera.Size> listCameraSize = parameters.getSupportedPreviewSizes();
+ List<android.hardware.Camera.Size> listCameraSize =
+ parameters.getSupportedPreviewSizes();
int minDiff = Integer.MAX_VALUE;
int matchedWidth = width;
int matchedHeight = height;
for (android.hardware.Camera.Size size : listCameraSize) {
- int diff = Math.abs(size.width - width) + Math.abs(size.height - height);
+ int diff = Math.abs(size.width - width)
+ + Math.abs(size.height - height);
Log.d(TAG, "allocate: supported (%d, %d), diff=%d", size.width, size.height, diff);
// TODO(wjia): Remove this hack (forcing width to be multiple
// of 32) by supporting stride in video frame buffer.
@@ -151,14 +156,14 @@ public abstract class VideoCaptureCamera
if (parameters.isVideoStabilizationSupported()) {
Log.d(TAG, "Image stabilization supported, currently: "
- + parameters.getVideoStabilization() + ", setting it.");
+ + parameters.getVideoStabilization() + ", setting it.");
parameters.setVideoStabilization(true);
} else {
Log.d(TAG, "Image stabilization not supported.");
}
if (parameters.getSupportedFocusModes().contains(
- android.hardware.Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
+ android.hardware.Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
parameters.setFocusMode(android.hardware.Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
} else {
Log.d(TAG, "Continuous focus mode not supported.");
@@ -183,15 +188,15 @@ public abstract class VideoCaptureCamera
GLES20.glGenTextures(1, mGlTextures, 0);
GLES20.glBindTexture(GL_TEXTURE_EXTERNAL_OES, mGlTextures[0]);
// No mip-mapping with camera source.
- GLES20.glTexParameterf(
- GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
- GLES20.glTexParameterf(
- GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
+ GLES20.glTexParameterf(GL_TEXTURE_EXTERNAL_OES,
+ GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
+ GLES20.glTexParameterf(GL_TEXTURE_EXTERNAL_OES,
+ GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
// Clamp to edge is only option.
- GLES20.glTexParameteri(
- GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
- GLES20.glTexParameteri(
- GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
+ GLES20.glTexParameteri(GL_TEXTURE_EXTERNAL_OES,
+ GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
+ GLES20.glTexParameteri(GL_TEXTURE_EXTERNAL_OES,
+ GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
mSurfaceTexture = new SurfaceTexture(mGlTextures[0]);
mSurfaceTexture.setOnFrameAvailableListener(null);
@@ -277,7 +282,10 @@ public abstract class VideoCaptureCamera
// Local hook to allow derived classes to fill capture format and modify
// camera parameters as they see fit.
- abstract void setCaptureParameters(int width, int height, int frameRate,
+ abstract void setCaptureParameters(
+ int width,
+ int height,
+ int frameRate,
android.hardware.Camera.Parameters cameraParameters);
// Local method to be overriden with the particular setPreviewCallback to be
diff --git a/media/capture/video/android/java/src/org/chromium/media/VideoCaptureCamera2.java b/media/base/android/java/src/org/chromium/media/VideoCaptureCamera2.java
index 5851027..0c66ede 100644
--- a/media/capture/video/android/java/src/org/chromium/media/VideoCaptureCamera2.java
+++ b/media/base/android/java/src/org/chromium/media/VideoCaptureCamera2.java
@@ -40,6 +40,7 @@ import java.util.List;
@JNINamespace("media")
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class VideoCaptureCamera2 extends VideoCapture {
+
// Inner class to extend a CameraDevice state change listener.
private class CrStateListener extends CameraDevice.StateCallback {
@Override
@@ -48,7 +49,8 @@ public class VideoCaptureCamera2 extends VideoCapture {
changeCameraStateAndNotify(CameraState.CONFIGURING);
if (!createCaptureObjects()) {
changeCameraStateAndNotify(CameraState.STOPPED);
- nativeOnError(mNativeVideoCaptureDeviceAndroid, "Error configuring camera");
+ nativeOnError(mNativeVideoCaptureDeviceAndroid,
+ "Error configuring camera");
}
}
@@ -65,7 +67,7 @@ public class VideoCaptureCamera2 extends VideoCapture {
mCameraDevice = null;
changeCameraStateAndNotify(CameraState.STOPPED);
nativeOnError(mNativeVideoCaptureDeviceAndroid,
- "Camera device error " + Integer.toString(error));
+ "Camera device error " + Integer.toString(error));
}
};
@@ -84,7 +86,8 @@ public class VideoCaptureCamera2 extends VideoCapture {
// TODO(mcasas): When signalling error, C++ will tear us down. Is there need for
// cleanup?
changeCameraStateAndNotify(CameraState.STOPPED);
- nativeOnError(mNativeVideoCaptureDeviceAndroid, "Camera session configuration error");
+ nativeOnError(mNativeVideoCaptureDeviceAndroid,
+ "Camera session configuration error");
}
};
@@ -97,9 +100,10 @@ public class VideoCaptureCamera2 extends VideoCapture {
try {
image = reader.acquireLatestImage();
if (image == null) return;
- if (image.getFormat() != ImageFormat.YUV_420_888 || image.getPlanes().length != 3) {
- Log.e(TAG, "Unexpected image format: %d or #planes: %d", image.getFormat(),
- image.getPlanes().length);
+ if (image.getFormat() != ImageFormat.YUV_420_888
+ || image.getPlanes().length != 3) {
+ Log.e(TAG, "Unexpected image format: %d or #planes: %d",
+ image.getFormat(), image.getPlanes().length);
return;
}
@@ -110,8 +114,10 @@ public class VideoCaptureCamera2 extends VideoCapture {
+ "x" + image.getHeight());
}
readImageIntoBuffer(image, mCapturedData);
- nativeOnFrameAvailable(mNativeVideoCaptureDeviceAndroid, mCapturedData,
- mCapturedData.length, getCameraRotation());
+ nativeOnFrameAvailable(mNativeVideoCaptureDeviceAndroid,
+ mCapturedData,
+ mCapturedData.length,
+ getCameraRotation());
} catch (IllegalStateException ex) {
Log.e(TAG, "acquireLatestImage():" + ex);
return;
@@ -133,7 +139,7 @@ public class VideoCaptureCamera2 extends VideoCapture {
private static final double kNanoSecondsToFps = 1.0E-9;
private static final String TAG = "cr.media";
- private static enum CameraState { OPENING, CONFIGURING, STARTED, STOPPED }
+ private static enum CameraState {OPENING, CONFIGURING, STARTED, STOPPED}
private CameraState mCameraState = CameraState.STOPPED;
private final Object mCameraStateLock = new Object();
@@ -157,12 +163,15 @@ public class VideoCaptureCamera2 extends VideoCapture {
// readback take place on its own thread.
final int maxImages = 2;
mImageReader = ImageReader.newInstance(mCaptureFormat.getWidth(),
- mCaptureFormat.getHeight(), mCaptureFormat.getPixelFormat(), maxImages);
+ mCaptureFormat.getHeight(),
+ mCaptureFormat.getPixelFormat(),
+ maxImages);
HandlerThread thread = new HandlerThread("CameraPreview");
thread.start();
final Handler backgroundHandler = new Handler(thread.getLooper());
final CrImageReaderListener imageReaderListener = new CrImageReaderListener();
- mImageReader.setOnImageAvailableListener(imageReaderListener, backgroundHandler);
+ mImageReader.setOnImageAvailableListener(imageReaderListener,
+ backgroundHandler);
// The Preview template specifically means "high frame rate is given
// priority over the highest-quality post-processing".
@@ -186,12 +195,13 @@ public class VideoCaptureCamera2 extends VideoCapture {
mPreviewBuilder.addTarget(mImageReader.getSurface());
// A series of configuration options in the PreviewBuilder
- mPreviewBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);
- mPreviewBuilder.set(
- CaptureRequest.NOISE_REDUCTION_MODE, CameraMetadata.NOISE_REDUCTION_MODE_FAST);
+ mPreviewBuilder.set(CaptureRequest.CONTROL_MODE,
+ CameraMetadata.CONTROL_MODE_AUTO);
+ mPreviewBuilder.set(CaptureRequest.NOISE_REDUCTION_MODE,
+ CameraMetadata.NOISE_REDUCTION_MODE_FAST);
mPreviewBuilder.set(CaptureRequest.EDGE_MODE, CameraMetadata.EDGE_MODE_FAST);
mPreviewBuilder.set(CaptureRequest.CONTROL_VIDEO_STABILIZATION_MODE,
- CameraMetadata.CONTROL_VIDEO_STABILIZATION_MODE_ON);
+ CameraMetadata.CONTROL_VIDEO_STABILIZATION_MODE_ON);
// SENSOR_EXPOSURE_TIME ?
List<Surface> surfaceList = new ArrayList<Surface>(1);
@@ -308,8 +318,8 @@ public class VideoCaptureCamera2 extends VideoCapture {
return CaptureApiType.API_TYPE_UNKNOWN;
}
- final int supportedHWLevel =
- cameraCharacteristics.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
+ final int supportedHWLevel = cameraCharacteristics.get(
+ CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
switch (supportedHWLevel) {
case CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY:
return CaptureApiType.API2_LEGACY;
@@ -336,8 +346,8 @@ public class VideoCaptureCamera2 extends VideoCapture {
getCameraCharacteristics(appContext, id);
if (cameraCharacteristics == null) return null;
- final int[] capabilities =
- cameraCharacteristics.get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES);
+ final int[] capabilities = cameraCharacteristics.get(
+ CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES);
// Per-format frame rate via getOutputMinFrameDuration() is only available if the
// property REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR is set.
boolean minFrameDurationAvailable = false;
@@ -374,7 +384,9 @@ public class VideoCaptureCamera2 extends VideoCapture {
return formatList.toArray(new VideoCaptureFormat[formatList.size()]);
}
- VideoCaptureCamera2(Context context, int id, long nativeVideoCaptureDeviceAndroid) {
+ VideoCaptureCamera2(Context context,
+ int id,
+ long nativeVideoCaptureDeviceAndroid) {
super(context, id, nativeVideoCaptureDeviceAndroid);
}
@@ -423,7 +435,7 @@ public class VideoCaptureCamera2 extends VideoCapture {
// but NOT for N7 with a dev Build. Figure out which one to support.
mInvertDeviceOrientationReadings =
cameraCharacteristics.get(CameraCharacteristics.LENS_FACING)
- == CameraCharacteristics.LENS_FACING_BACK;
+ == CameraCharacteristics.LENS_FACING_BACK;
return true;
}
diff --git a/media/capture/video/android/java/src/org/chromium/media/VideoCaptureFactory.java b/media/base/android/java/src/org/chromium/media/VideoCaptureFactory.java
index c88f9f7..7c70c9d 100644
--- a/media/capture/video/android/java/src/org/chromium/media/VideoCaptureFactory.java
+++ b/media/base/android/java/src/org/chromium/media/VideoCaptureFactory.java
@@ -25,13 +25,14 @@ import org.chromium.base.annotations.JNINamespace;
@JNINamespace("media")
@SuppressWarnings("deprecation")
class VideoCaptureFactory {
+
// Internal class to encapsulate camera device id manipulations.
static class ChromiumCameraInfo {
// Special devices have more cameras than usual. Those devices are
// identified by model & device. Currently only the Tango is supported.
// Note that these devices have no Camera.CameraInfo.
private static final String[][] SPECIAL_DEVICE_LIST = {
- {"Peanut", "peanut"},
+ {"Peanut", "peanut"},
};
private static int sNumberOfSystemCameras = -1;
private static final String TAG = "cr.media";
@@ -70,10 +71,11 @@ class VideoCaptureFactory {
!= PackageManager.PERMISSION_GRANTED) {
sNumberOfSystemCameras = 0;
Log.w(TAG, "Missing android.permission.CAMERA permission, "
- + "no system camera available.");
+ + "no system camera available.");
} else {
if (isLReleaseOrLater()) {
- sNumberOfSystemCameras = VideoCaptureCamera2.getNumberOfCameras(appContext);
+ sNumberOfSystemCameras =
+ VideoCaptureCamera2.getNumberOfCameras(appContext);
} else {
sNumberOfSystemCameras = VideoCaptureAndroid.getNumberOfCameras();
if (isSpecialDevice()) {
@@ -96,13 +98,18 @@ class VideoCaptureFactory {
static VideoCapture createVideoCapture(
Context context, int id, long nativeVideoCaptureDeviceAndroid) {
if (isLReleaseOrLater() && !VideoCaptureCamera2.isLegacyDevice(context, id)) {
- return new VideoCaptureCamera2(context, id, nativeVideoCaptureDeviceAndroid);
+ return new VideoCaptureCamera2(context,
+ id,
+ nativeVideoCaptureDeviceAndroid);
}
if (!ChromiumCameraInfo.isSpecialCamera(id)) {
- return new VideoCaptureAndroid(context, id, nativeVideoCaptureDeviceAndroid);
+ return new VideoCaptureAndroid(context,
+ id,
+ nativeVideoCaptureDeviceAndroid);
}
- return new VideoCaptureTango(
- context, ChromiumCameraInfo.toSpecialCameraId(id), nativeVideoCaptureDeviceAndroid);
+ return new VideoCaptureTango(context,
+ ChromiumCameraInfo.toSpecialCameraId(id),
+ nativeVideoCaptureDeviceAndroid);
}
@CalledByNative
@@ -115,7 +122,8 @@ class VideoCaptureFactory {
if (isLReleaseOrLater()) {
return VideoCaptureCamera2.getCaptureApiType(id, appContext);
} else if (ChromiumCameraInfo.isSpecialCamera(id)) {
- return VideoCaptureTango.getCaptureApiType(ChromiumCameraInfo.toSpecialCameraId(id));
+ return VideoCaptureTango.getCaptureApiType(
+ ChromiumCameraInfo.toSpecialCameraId(id));
} else {
return VideoCaptureAndroid.getCaptureApiType(id);
}
@@ -138,7 +146,7 @@ class VideoCaptureFactory {
}
return ChromiumCameraInfo.isSpecialCamera(id)
? VideoCaptureTango.getDeviceSupportedFormats(
- ChromiumCameraInfo.toSpecialCameraId(id))
+ ChromiumCameraInfo.toSpecialCameraId(id))
: VideoCaptureAndroid.getDeviceSupportedFormats(id);
}
diff --git a/media/capture/video/android/java/src/org/chromium/media/VideoCaptureFormat.java b/media/base/android/java/src/org/chromium/media/VideoCaptureFormat.java
index a875843..6eb3f78 100644
--- a/media/capture/video/android/java/src/org/chromium/media/VideoCaptureFormat.java
+++ b/media/base/android/java/src/org/chromium/media/VideoCaptureFormat.java
@@ -10,7 +10,8 @@ class VideoCaptureFormat {
final int mFramerate;
final int mPixelFormat;
- public VideoCaptureFormat(int width, int height, int framerate, int pixelformat) {
+ public VideoCaptureFormat(
+ int width, int height, int framerate, int pixelformat) {
mWidth = width;
mHeight = height;
mFramerate = framerate;
diff --git a/media/capture/video/android/java/src/org/chromium/media/VideoCaptureTango.java b/media/base/android/java/src/org/chromium/media/VideoCaptureTango.java
index b48539e..c85cf0f 100644
--- a/media/capture/video/android/java/src/org/chromium/media/VideoCaptureTango.java
+++ b/media/base/android/java/src/org/chromium/media/VideoCaptureTango.java
@@ -22,6 +22,7 @@ import java.util.Arrays;
**/
@SuppressWarnings("deprecation")
public class VideoCaptureTango extends VideoCaptureCamera {
+
private static class CamParams {
final int mId;
final String mName;
@@ -45,7 +46,7 @@ public class VideoCaptureTango extends VideoCaptureCamera {
private static final CamParams CAM_PARAMS[] = {
new CamParams(DEPTH_CAMERA_ID, "depth", 320, 240),
new CamParams(FISHEYE_CAMERA_ID, "fisheye", 640, 480),
- new CamParams(FOURMP_CAMERA_ID, "4MP", 1280, 720)};
+ new CamParams(FOURMP_CAMERA_ID, "4MP", 1280, 720) };
// SuperFrame size definitions. Note that total size is the amount of lines
// multiplied by 3/2 due to Chroma components following.
@@ -54,9 +55,9 @@ public class VideoCaptureTango extends VideoCaptureCamera {
private static final int SF_FULL_HEIGHT = SF_HEIGHT * 3 / 2;
private static final int SF_LINES_HEADER = 16;
private static final int SF_LINES_FISHEYE = 240;
- private static final int SF_LINES_RESERVED = 80; // Spec says 96.
+ private static final int SF_LINES_RESERVED = 80; // Spec says 96.
private static final int SF_LINES_DEPTH = 60;
- private static final int SF_LINES_DEPTH_PADDED = 112; // Spec says 96.
+ private static final int SF_LINES_DEPTH_PADDED = 112; // Spec says 96.
private static final int SF_LINES_BIGIMAGE = 720;
private static final int SF_OFFSET_4MP_CHROMA = 112;
@@ -91,17 +92,24 @@ public class VideoCaptureTango extends VideoCaptureCamera {
return formatList.toArray(new VideoCaptureFormat[formatList.size()]);
}
- VideoCaptureTango(Context context, int id, long nativeVideoCaptureDeviceAndroid) {
+ VideoCaptureTango(Context context,
+ int id,
+ long nativeVideoCaptureDeviceAndroid) {
// All Tango cameras are like the back facing one for the generic VideoCapture code.
super(context, 0, nativeVideoCaptureDeviceAndroid);
mTangoCameraId = id;
}
@Override
- protected void setCaptureParameters(int width, int height, int frameRate,
+ protected void setCaptureParameters(
+ int width,
+ int height,
+ int frameRate,
android.hardware.Camera.Parameters cameraParameters) {
mCaptureFormat = new VideoCaptureFormat(CAM_PARAMS[mTangoCameraId].mWidth,
- CAM_PARAMS[mTangoCameraId].mHeight, frameRate, ImageFormat.YV12);
+ CAM_PARAMS[mTangoCameraId].mHeight,
+ frameRate,
+ ImageFormat.YV12);
// Connect Tango SuperFrame mode. Available sf modes are "all",
// "big-rgb", "small-rgb", "depth", "ir".
cameraParameters.set("sf-mode", "all");
@@ -109,8 +117,8 @@ public class VideoCaptureTango extends VideoCaptureCamera {
@Override
protected void allocateBuffers() {
- mFrameBuffer =
- ByteBuffer.allocateDirect(mCaptureFormat.mWidth * mCaptureFormat.mHeight * 3 / 2);
+ mFrameBuffer = ByteBuffer.allocateDirect(
+ mCaptureFormat.mWidth * mCaptureFormat.mHeight * 3 / 2);
// Prefill Chroma to their zero-equivalent for the cameras that only
// provide Luma component.
Arrays.fill(mFrameBuffer.array(), CHROMA_ZERO_LEVEL);
@@ -152,8 +160,8 @@ public class VideoCaptureTango extends VideoCaptureCamera {
// them explicitly since they're filled to 128 on creation.
ByteBuffer.wrap(data, startY, sizeY).get(mFrameBuffer.array(), 0, sizeY);
} else if (mTangoCameraId == FOURMP_CAMERA_ID) {
- int startY = SF_WIDTH * (SF_LINES_HEADER + SF_LINES_FISHEYE + SF_LINES_RESERVED
- + SF_LINES_DEPTH_PADDED);
+ int startY = SF_WIDTH * (SF_LINES_HEADER + SF_LINES_FISHEYE
+ + SF_LINES_RESERVED + SF_LINES_DEPTH_PADDED);
int sizeY = SF_WIDTH * SF_LINES_BIGIMAGE;
// The spec is completely inaccurate on the location, sizes
@@ -166,17 +174,21 @@ public class VideoCaptureTango extends VideoCaptureCamera {
// Equivalent to the following |for| loop but much faster:
// for (int i = START; i < START + SIZE; ++i)
// mFrameBuffer.put(data[i]);
- ByteBuffer.wrap(data, startY, sizeY).get(mFrameBuffer.array(), 0, sizeY);
- ByteBuffer.wrap(data, startU, sizeU).get(mFrameBuffer.array(), sizeY, sizeU);
+ ByteBuffer.wrap(data, startY, sizeY)
+ .get(mFrameBuffer.array(), 0, sizeY);
+ ByteBuffer.wrap(data, startU, sizeU)
+ .get(mFrameBuffer.array(), sizeY, sizeU);
ByteBuffer.wrap(data, startV, sizeV)
- .get(mFrameBuffer.array(), sizeY + sizeU, sizeV);
+ .get(mFrameBuffer.array(), sizeY + sizeU, sizeV);
} else {
Log.e(TAG, "Unknown camera, #id: %d", mTangoCameraId);
return;
}
- mFrameBuffer.rewind(); // Important!
- nativeOnFrameAvailable(mNativeVideoCaptureDeviceAndroid, mFrameBuffer.array(),
- mFrameBuffer.capacity(), getCameraRotation());
+ mFrameBuffer.rewind(); // Important!
+ nativeOnFrameAvailable(mNativeVideoCaptureDeviceAndroid,
+ mFrameBuffer.array(),
+ mFrameBuffer.capacity(),
+ getCameraRotation());
}
} finally {
mPreviewBufferLock.unlock();
diff --git a/media/capture/video/android/BUILD.gn b/media/capture/video/android/BUILD.gn
deleted file mode 100644
index 5eab88e..0000000
--- a/media/capture/video/android/BUILD.gn
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("//build/config/android/config.gni")
-import("//build/config/android/rules.gni")
-import("//build/config/arm.gni")
-import("//build/config/ui.gni")
-import("//media/media_options.gni")
-
-assert(is_android)
-
-generate_jni("video_capture_jni_headers") {
- sources = [
- "java/src/org/chromium/media/VideoCapture.java",
- "java/src/org/chromium/media/VideoCaptureFactory.java",
- ]
- jni_package = "media"
-}
-
-java_cpp_enum("media_java_enums_srcjar") {
- sources = [
- "../video_capture_device.h",
- "video_capture_device_android.h",
- ]
-}
-
-android_library("media_java") {
- deps = [
- "//base:base_java",
- ]
-
- srcjar_deps = [ ":media_java_enums_srcjar" ]
-
- DEPRECATED_java_in_dir = "java/src"
-}
diff --git a/media/capture/video/android/java/src/org/chromium/media/OWNERS b/media/capture/video/android/java/src/org/chromium/media/OWNERS
deleted file mode 100644
index 66e61fe..0000000
--- a/media/capture/video/android/java/src/org/chromium/media/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-mcasas@chromium.org
-qinmin@chromium.org
diff --git a/media/media.gyp b/media/media.gyp
index 79f97b4..638f9e8 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -1866,8 +1866,8 @@
'target_name': 'video_capture_android_jni_headers',
'type': 'none',
'sources': [
- 'capture/video/android/java/src/org/chromium/media/VideoCapture.java',
- 'capture/video/android/java/src/org/chromium/media/VideoCaptureFactory.java',
+ 'base/android/java/src/org/chromium/media/VideoCapture.java',
+ 'base/android/java/src/org/chromium/media/VideoCaptureFactory.java',
],
'variables': {
'jni_gen_package': 'media',
@@ -1972,7 +1972,7 @@
'../base/base.gyp:base',
],
'variables': {
- 'java_in_dir': 'capture/video/android/java',
+ 'java_in_dir': 'base/android/java',
},
'includes': ['../build/java.gypi'],
},