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.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.graphics.ImageFormat; | 9 import android.graphics.ImageFormat; |
10 import android.graphics.Rect; | 10 import android.graphics.Rect; |
(...skipping 25 matching lines...) Expand all Loading... |
36 import java.util.List; | 36 import java.util.List; |
37 | 37 |
38 /** | 38 /** |
39 * This class implements Video Capture using Camera2 API, introduced in Android | 39 * This class implements Video Capture using Camera2 API, introduced in Android |
40 * API 21 (L Release). Capture takes place in the current Looper, while pixel | 40 * API 21 (L Release). Capture takes place in the current Looper, while pixel |
41 * download takes place in another thread used by ImageReader. A number of | 41 * download takes place in another thread used by ImageReader. A number of |
42 * static methods are provided to retrieve information on current system cameras | 42 * static methods are provided to retrieve information on current system cameras |
43 * and their capabilities, using android.hardware.camera2.CameraManager. | 43 * and their capabilities, using android.hardware.camera2.CameraManager. |
44 **/ | 44 **/ |
45 @JNINamespace("media") | 45 @JNINamespace("media") |
46 @TargetApi(Build.VERSION_CODES.LOLLIPOP) | 46 @TargetApi(Build.VERSION_CODES.M) |
47 public class VideoCaptureCamera2 extends VideoCapture { | 47 public class VideoCaptureCamera2 extends VideoCapture { |
48 // Inner class to extend a CameraDevice state change listener. | 48 // Inner class to extend a CameraDevice state change listener. |
49 private class CrStateListener extends CameraDevice.StateCallback { | 49 private class CrStateListener extends CameraDevice.StateCallback { |
50 @Override | 50 @Override |
51 public void onOpened(CameraDevice cameraDevice) { | 51 public void onOpened(CameraDevice cameraDevice) { |
52 mCameraDevice = cameraDevice; | 52 mCameraDevice = cameraDevice; |
53 changeCameraStateAndNotify(CameraState.CONFIGURING); | 53 changeCameraStateAndNotify(CameraState.CONFIGURING); |
54 if (!createPreviewObjects()) { | 54 if (!createPreviewObjects()) { |
55 changeCameraStateAndNotify(CameraState.STOPPED); | 55 changeCameraStateAndNotify(CameraState.STOPPED); |
56 nativeOnError(mNativeVideoCaptureDeviceAndroid, "Error configuri
ng camera"); | 56 nativeOnError(mNativeVideoCaptureDeviceAndroid, "Error configuri
ng camera"); |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 ArrayList<Integer> exposureModes = new ArrayList<Integer>(1); | 798 ArrayList<Integer> exposureModes = new ArrayList<Integer>(1); |
799 for (int mode : jniExposureModes) { | 799 for (int mode : jniExposureModes) { |
800 if (mode == CameraMetadata.CONTROL_AE_MODE_ON | 800 if (mode == CameraMetadata.CONTROL_AE_MODE_ON |
801 || mode == CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH | 801 || mode == CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH |
802 || mode == CameraMetadata.CONTROL_AE_MODE_ON_ALWAYS_FLASH | 802 || mode == CameraMetadata.CONTROL_AE_MODE_ON_ALWAYS_FLASH |
803 || mode == CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH_REDE
YE) { | 803 || mode == CameraMetadata.CONTROL_AE_MODE_ON_AUTO_FLASH_REDE
YE) { |
804 exposureModes.add(Integer.valueOf(AndroidMeteringMode.CONTINUOUS
)); | 804 exposureModes.add(Integer.valueOf(AndroidMeteringMode.CONTINUOUS
)); |
805 break; | 805 break; |
806 } | 806 } |
807 } | 807 } |
808 // TODO(mcasas): query |cameraCharacteristics| for CONTROL_AE_LOCK_AVAIL
ABLE (API 23) | 808 if (cameraCharacteristics.get(CameraCharacteristics.CONTROL_AE_LOCK_AVAI
LABLE)) { |
| 809 exposureModes.add(Integer.valueOf(AndroidMeteringMode.FIXED)); |
| 810 } |
809 builder.setExposureModes(integerArrayListToArray(exposureModes)); | 811 builder.setExposureModes(integerArrayListToArray(exposureModes)); |
810 | 812 |
811 int jniExposureMode = AndroidMeteringMode.CONTINUOUS; | 813 int jniExposureMode = AndroidMeteringMode.CONTINUOUS; |
812 if (mPreviewRequest.get(CaptureRequest.CONTROL_AE_MODE) | 814 if (mPreviewRequest.get(CaptureRequest.CONTROL_AE_MODE) |
813 == CameraMetadata.CONTROL_AE_MODE_OFF) { | 815 == CameraMetadata.CONTROL_AE_MODE_OFF) { |
814 jniExposureMode = AndroidMeteringMode.NONE; | 816 jniExposureMode = AndroidMeteringMode.NONE; |
815 } | 817 } |
816 if (mPreviewRequest.get(CaptureRequest.CONTROL_AE_LOCK)) { | 818 if (mPreviewRequest.get(CaptureRequest.CONTROL_AE_LOCK)) { |
817 jniExposureMode = AndroidMeteringMode.FIXED; | 819 jniExposureMode = AndroidMeteringMode.FIXED; |
818 } | 820 } |
(...skipping 12 matching lines...) Expand all Loading... |
831 | 833 |
832 final int[] jniWhiteBalanceMode = | 834 final int[] jniWhiteBalanceMode = |
833 cameraCharacteristics.get(CameraCharacteristics.CONTROL_AWB_AVAI
LABLE_MODES); | 835 cameraCharacteristics.get(CameraCharacteristics.CONTROL_AWB_AVAI
LABLE_MODES); |
834 ArrayList<Integer> whiteBalanceModes = new ArrayList<Integer>(1); | 836 ArrayList<Integer> whiteBalanceModes = new ArrayList<Integer>(1); |
835 for (int mode : jniWhiteBalanceMode) { | 837 for (int mode : jniWhiteBalanceMode) { |
836 if (mode == CameraMetadata.CONTROL_AWB_MODE_AUTO) { | 838 if (mode == CameraMetadata.CONTROL_AWB_MODE_AUTO) { |
837 whiteBalanceModes.add(Integer.valueOf(AndroidMeteringMode.CONTIN
UOUS)); | 839 whiteBalanceModes.add(Integer.valueOf(AndroidMeteringMode.CONTIN
UOUS)); |
838 break; | 840 break; |
839 } | 841 } |
840 } | 842 } |
841 // TODO(mcasas): query |cameraCharacteristics| for CONTROL_AWE_LOCK_AVAI
LABLE (API 23) | 843 if (cameraCharacteristics.get(CameraCharacteristics.CONTROL_AWB_LOCK_AVA
ILABLE)) { |
| 844 whiteBalanceModes.add(Integer.valueOf(AndroidMeteringMode.FIXED)); |
| 845 } |
842 builder.setWhiteBalanceModes(integerArrayListToArray(whiteBalanceModes))
; | 846 builder.setWhiteBalanceModes(integerArrayListToArray(whiteBalanceModes))
; |
843 | 847 |
844 final int whiteBalanceMode = mPreviewRequest.get(CaptureRequest.CONTROL_
AWB_MODE); | 848 final int whiteBalanceMode = mPreviewRequest.get(CaptureRequest.CONTROL_
AWB_MODE); |
845 if (whiteBalanceMode == CameraMetadata.CONTROL_AWB_MODE_OFF) { | 849 if (whiteBalanceMode == CameraMetadata.CONTROL_AWB_MODE_OFF) { |
846 builder.setWhiteBalanceMode(AndroidMeteringMode.NONE); | 850 builder.setWhiteBalanceMode(AndroidMeteringMode.NONE); |
847 } else if (whiteBalanceMode == CameraMetadata.CONTROL_AWB_MODE_AUTO) { | 851 } else if (whiteBalanceMode == CameraMetadata.CONTROL_AWB_MODE_AUTO) { |
848 builder.setWhiteBalanceMode(AndroidMeteringMode.CONTINUOUS); | 852 builder.setWhiteBalanceMode(AndroidMeteringMode.CONTINUOUS); |
849 } else { | 853 } else { |
850 builder.setWhiteBalanceMode(AndroidMeteringMode.FIXED); | 854 builder.setWhiteBalanceMode(AndroidMeteringMode.FIXED); |
851 } | 855 } |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 return false; | 1034 return false; |
1031 } | 1035 } |
1032 return true; | 1036 return true; |
1033 } | 1037 } |
1034 | 1038 |
1035 @Override | 1039 @Override |
1036 public void deallocate() { | 1040 public void deallocate() { |
1037 Log.d(TAG, "deallocate"); | 1041 Log.d(TAG, "deallocate"); |
1038 } | 1042 } |
1039 } | 1043 } |
OLD | NEW |