| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.media; | 5 package org.chromium.media; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.graphics.ImageFormat; | 8 import android.graphics.ImageFormat; |
| 9 import android.view.Surface; | 9 import android.view.Surface; |
| 10 import android.view.WindowManager; | 10 import android.view.WindowManager; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // In some occasions we need to invert the device rotation readings, see the | 27 // In some occasions we need to invert the device rotation readings, see the |
| 28 // individual implementations. | 28 // individual implementations. |
| 29 protected boolean mInvertDeviceOrientationReadings; | 29 protected boolean mInvertDeviceOrientationReadings; |
| 30 | 30 |
| 31 protected VideoCaptureFormat mCaptureFormat = null; | 31 protected VideoCaptureFormat mCaptureFormat = null; |
| 32 protected final Context mContext; | 32 protected final Context mContext; |
| 33 protected final int mId; | 33 protected final int mId; |
| 34 // Native callback context variable. | 34 // Native callback context variable. |
| 35 protected final long mNativeVideoCaptureDeviceAndroid; | 35 protected final long mNativeVideoCaptureDeviceAndroid; |
| 36 | 36 |
| 37 protected boolean mUseBackgroundThreadForTesting = false; |
| 38 |
| 37 VideoCapture(Context context, int id, long nativeVideoCaptureDeviceAndroid)
{ | 39 VideoCapture(Context context, int id, long nativeVideoCaptureDeviceAndroid)
{ |
| 38 mContext = context; | 40 mContext = context; |
| 39 mId = id; | 41 mId = id; |
| 40 mNativeVideoCaptureDeviceAndroid = nativeVideoCaptureDeviceAndroid; | 42 mNativeVideoCaptureDeviceAndroid = nativeVideoCaptureDeviceAndroid; |
| 41 } | 43 } |
| 42 | 44 |
| 43 // Allocate necessary resources for capture. | 45 // Allocate necessary resources for capture. |
| 44 @CalledByNative | 46 @CalledByNative |
| 45 public abstract boolean allocate(int width, int height, int frameRate); | 47 public abstract boolean allocate(int width, int height, int frameRate); |
| 46 | 48 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 case ImageFormat.YUV_420_888: | 104 case ImageFormat.YUV_420_888: |
| 103 return AndroidImageFormat.YUV_420_888; | 105 return AndroidImageFormat.YUV_420_888; |
| 104 case ImageFormat.NV21: | 106 case ImageFormat.NV21: |
| 105 return AndroidImageFormat.NV21; | 107 return AndroidImageFormat.NV21; |
| 106 case ImageFormat.UNKNOWN: | 108 case ImageFormat.UNKNOWN: |
| 107 default: | 109 default: |
| 108 return AndroidImageFormat.UNKNOWN; | 110 return AndroidImageFormat.UNKNOWN; |
| 109 } | 111 } |
| 110 } | 112 } |
| 111 | 113 |
| 114 @CalledByNative |
| 115 public final void setTestMode() { |
| 116 mUseBackgroundThreadForTesting = true; |
| 117 } |
| 118 |
| 112 protected final int getCameraRotation() { | 119 protected final int getCameraRotation() { |
| 113 int rotation = mInvertDeviceOrientationReadings ? (360 - getDeviceRotati
on()) | 120 int rotation = mInvertDeviceOrientationReadings ? (360 - getDeviceRotati
on()) |
| 114 : getDeviceRotation(); | 121 : getDeviceRotation(); |
| 115 return (mCameraNativeOrientation + rotation) % 360; | 122 return (mCameraNativeOrientation + rotation) % 360; |
| 116 } | 123 } |
| 117 | 124 |
| 118 protected final int getDeviceRotation() { | 125 protected final int getDeviceRotation() { |
| 119 if (mContext == null) return 0; | 126 if (mContext == null) return 0; |
| 120 final int orientation; | 127 final int orientation; |
| 121 WindowManager wm = (WindowManager) mContext.getSystemService(Context.WIN
DOW_SERVICE); | 128 WindowManager wm = (WindowManager) mContext.getSystemService(Context.WIN
DOW_SERVICE); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 146 int uvRowStride, int uvPixelStride, int width, int height, int rotat
ion, | 153 int uvRowStride, int uvPixelStride, int width, int height, int rotat
ion, |
| 147 long timestamp); | 154 long timestamp); |
| 148 | 155 |
| 149 // Method for VideoCapture implementations to signal an asynchronous error. | 156 // Method for VideoCapture implementations to signal an asynchronous error. |
| 150 public native void nativeOnError(long nativeVideoCaptureDeviceAndroid, Strin
g message); | 157 public native void nativeOnError(long nativeVideoCaptureDeviceAndroid, Strin
g message); |
| 151 | 158 |
| 152 // Method for VideoCapture implementations to send Photos back to. | 159 // Method for VideoCapture implementations to send Photos back to. |
| 153 public native void nativeOnPhotoTaken( | 160 public native void nativeOnPhotoTaken( |
| 154 long nativeVideoCaptureDeviceAndroid, long callbackId, byte[] data); | 161 long nativeVideoCaptureDeviceAndroid, long callbackId, byte[] data); |
| 155 } | 162 } |
| OLD | NEW |