Commit 96b7b47e authored by mcasas's avatar mcasas Committed by Commit bot

Android Video Capture: Refactor VideoCapture class hierarchy

This CL refactors the current class hierarchy, currently looking sth like:

VideoCapture (abstract)
    ^    ^--- VideoCaptureAndroid
    +-------- VideoCaptureTango

into:

VideoCapture (abstract)
    ^    ^---VideoCaptureCamera (abstract)
    |           ^    ^--- VideoCaptureAndroid
    |           +-------- VideoCaptureTango
    |
    +--------VideoCaptureCamera2  (To be introduced in parallel CLs(*))

(*) Note that http://crrev.com/611283002 only introduces static
methods, so this "plugging" into this new hierarchy can be done
afterwards.

Some operators are also moved from end of line to beginning of the next
one following presubmit warnings.

Also some accessing qualifiers are revisited, and some static methods
consolidated at the top of the class declaration, where they seem to belong.

BUG=418052

Review URL: https://codereview.chromium.org/656323004

Cr-Commit-Position: refs/heads/master@{#301113}
parent 70aed720
...@@ -12,13 +12,13 @@ import java.util.ArrayList; ...@@ -12,13 +12,13 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* This class extends the VideoCapture base class for manipulating normal video * This class extends the VideoCaptureCamera base class for manipulating normal
* capture devices in Android, including receiving copies of preview frames via * video capture devices in Android, including receiving copies of preview
* Java-allocated buffers. It also includes class BuggyDeviceHack to deal with * frames via Java-allocated buffers. It also includes class BuggyDeviceHack to
* troublesome devices. * deal with troublesome devices.
**/ **/
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class VideoCaptureAndroid extends VideoCapture { public class VideoCaptureAndroid extends VideoCaptureCamera {
// Some devices don't support YV12 format correctly, even with JELLY_BEAN or // 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 // newer OS. To work around the issues on those devices, we have to request
...@@ -51,8 +51,8 @@ public class VideoCaptureAndroid extends VideoCapture { ...@@ -51,8 +51,8 @@ public class VideoCaptureAndroid extends VideoCapture {
static void applyMinDimensions(CaptureFormat format) { static void applyMinDimensions(CaptureFormat format) {
// NOTE: this can discard requested aspect ratio considerations. // NOTE: this can discard requested aspect ratio considerations.
for (IdAndSizes buggyDevice : CAPTURESIZE_BUGGY_DEVICE_LIST) { for (IdAndSizes buggyDevice : CAPTURESIZE_BUGGY_DEVICE_LIST) {
if (buggyDevice.mModel.contentEquals(android.os.Build.MODEL) && if (buggyDevice.mModel.contentEquals(android.os.Build.MODEL)
buggyDevice.mDevice.contentEquals(android.os.Build.DEVICE)) { && buggyDevice.mDevice.contentEquals(android.os.Build.DEVICE)) {
format.mWidth = (buggyDevice.mMinWidth > format.mWidth) format.mWidth = (buggyDevice.mMinWidth > format.mWidth)
? buggyDevice.mMinWidth : format.mWidth; ? buggyDevice.mMinWidth : format.mWidth;
format.mHeight = (buggyDevice.mMinHeight > format.mHeight) format.mHeight = (buggyDevice.mMinHeight > format.mHeight)
...@@ -84,10 +84,10 @@ public class VideoCaptureAndroid extends VideoCapture { ...@@ -84,10 +84,10 @@ public class VideoCaptureAndroid extends VideoCapture {
} }
static String getName(int id) { static String getName(int id) {
android.hardware.Camera.CameraInfo cameraInfo = VideoCapture.getCameraInfo(id); android.hardware.Camera.CameraInfo cameraInfo = VideoCaptureCamera.getCameraInfo(id);
if (cameraInfo == null) return null; if (cameraInfo == null) return null;
return "camera " + id + ", facing " + (cameraInfo.facing == return "camera " + id + ", facing " + (cameraInfo.facing
android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT ? "front" : "back"); == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT ? "front" : "back");
} }
static CaptureFormat[] getDeviceSupportedFormats(int id) { static CaptureFormat[] getDeviceSupportedFormats(int id) {
...@@ -172,8 +172,8 @@ public class VideoCaptureAndroid extends VideoCapture { ...@@ -172,8 +172,8 @@ public class VideoCaptureAndroid extends VideoCapture {
@Override @Override
protected void allocateBuffers() { protected void allocateBuffers() {
mExpectedFrameSize = mCaptureFormat.mWidth * mCaptureFormat.mHeight * mExpectedFrameSize = mCaptureFormat.mWidth * mCaptureFormat.mHeight
ImageFormat.getBitsPerPixel(mCaptureFormat.mPixelFormat) / 8; * ImageFormat.getBitsPerPixel(mCaptureFormat.mPixelFormat) / 8;
for (int i = 0; i < NUM_CAPTURE_BUFFERS; i++) { for (int i = 0; i < NUM_CAPTURE_BUFFERS; i++) {
byte[] buffer = new byte[mExpectedFrameSize]; byte[] buffer = new byte[mExpectedFrameSize];
mCamera.addCallbackBuffer(buffer); mCamera.addCallbackBuffer(buffer);
......
...@@ -20,9 +20,9 @@ import java.util.Arrays; ...@@ -20,9 +20,9 @@ import java.util.Arrays;
* |s_CAM_PARAMS|; all devices |id| are index 0 towards the parent VideoCapture. * |s_CAM_PARAMS|; all devices |id| are index 0 towards the parent VideoCapture.
**/ **/
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class VideoCaptureTango extends VideoCapture { public class VideoCaptureTango extends VideoCaptureCamera {
static class CamParams { private static class CamParams {
final int mId; final int mId;
final String mName; final String mName;
final int mWidth; final int mWidth;
...@@ -161,8 +161,8 @@ public class VideoCaptureTango extends VideoCapture { ...@@ -161,8 +161,8 @@ public class VideoCaptureTango extends VideoCapture {
// them explicitly since they're filled to 128 on creation. // them explicitly since they're filled to 128 on creation.
ByteBuffer.wrap(data, startY, sizeY).get(mFrameBuffer.array(), 0, sizeY); ByteBuffer.wrap(data, startY, sizeY).get(mFrameBuffer.array(), 0, sizeY);
} else if (mTangoCameraId == FOURMP_CAMERA_ID) { } else if (mTangoCameraId == FOURMP_CAMERA_ID) {
int startY = SF_WIDTH * (SF_LINES_HEADER + SF_LINES_FISHEYE + int startY = SF_WIDTH * (SF_LINES_HEADER + SF_LINES_FISHEYE
SF_LINES_RESERVED + SF_LINES_DEPTH_PADDED); + SF_LINES_RESERVED + SF_LINES_DEPTH_PADDED);
int sizeY = SF_WIDTH * SF_LINES_BIGIMAGE; int sizeY = SF_WIDTH * SF_LINES_BIGIMAGE;
// The spec is completely inaccurate on the location, sizes // The spec is completely inaccurate on the location, sizes
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment