| 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.content.Context; | 8 import android.content.Context; |
| 8 import android.graphics.ImageFormat; | 9 import android.graphics.ImageFormat; |
| 9 import android.hardware.camera2.CameraAccessException; | 10 import android.hardware.camera2.CameraAccessException; |
| 10 import android.hardware.camera2.CameraCaptureSession; | 11 import android.hardware.camera2.CameraCaptureSession; |
| 11 import android.hardware.camera2.CameraCharacteristics; | 12 import android.hardware.camera2.CameraCharacteristics; |
| 12 import android.hardware.camera2.CameraDevice; | 13 import android.hardware.camera2.CameraDevice; |
| 13 import android.hardware.camera2.CameraManager; | 14 import android.hardware.camera2.CameraManager; |
| 14 import android.hardware.camera2.CameraMetadata; | 15 import android.hardware.camera2.CameraMetadata; |
| 15 import android.hardware.camera2.CaptureRequest; | 16 import android.hardware.camera2.CaptureRequest; |
| 16 import android.hardware.camera2.params.StreamConfigurationMap; | 17 import android.hardware.camera2.params.StreamConfigurationMap; |
| 17 import android.media.Image; | 18 import android.media.Image; |
| 18 import android.media.ImageReader; | 19 import android.media.ImageReader; |
| 20 import android.os.Build; |
| 19 import android.os.Handler; | 21 import android.os.Handler; |
| 20 import android.os.HandlerThread; | 22 import android.os.HandlerThread; |
| 21 import android.util.Log; | 23 import android.util.Log; |
| 22 import android.util.Size; | 24 import android.util.Size; |
| 23 import android.view.Surface; | 25 import android.view.Surface; |
| 24 | 26 |
| 25 import org.chromium.base.JNINamespace; | 27 import org.chromium.base.JNINamespace; |
| 26 | 28 |
| 27 import java.nio.ByteBuffer; | 29 import java.nio.ByteBuffer; |
| 28 import java.util.ArrayList; | 30 import java.util.ArrayList; |
| 29 import java.util.Arrays; | 31 import java.util.Arrays; |
| 30 import java.util.List; | 32 import java.util.List; |
| 31 | 33 |
| 32 /** | 34 /** |
| 33 * This class implements Video Capture using Camera2 API, introduced in Android | 35 * This class implements Video Capture using Camera2 API, introduced in Android |
| 34 * API 21 (L Release). Capture takes place in the current Looper, while pixel | 36 * API 21 (L Release). Capture takes place in the current Looper, while pixel |
| 35 * download takes place in another thread used by ImageReader. A number of | 37 * download takes place in another thread used by ImageReader. A number of |
| 36 * static methods are provided to retrieve information on current system cameras | 38 * static methods are provided to retrieve information on current system cameras |
| 37 * and their capabilities, using android.hardware.camera2.CameraManager. | 39 * and their capabilities, using android.hardware.camera2.CameraManager. |
| 38 **/ | 40 **/ |
| 39 @JNINamespace("media") | 41 @JNINamespace("media") |
| 42 @TargetApi(Build.VERSION_CODES.LOLLIPOP) |
| 40 public class VideoCaptureCamera2 extends VideoCapture { | 43 public class VideoCaptureCamera2 extends VideoCapture { |
| 41 | 44 |
| 42 // Inner class to extend a CameraDevice state change listener. | 45 // Inner class to extend a CameraDevice state change listener. |
| 43 private class CrStateListener extends CameraDevice.StateCallback { | 46 private class CrStateListener extends CameraDevice.StateCallback { |
| 44 @Override | 47 @Override |
| 45 public void onOpened(CameraDevice cameraDevice) { | 48 public void onOpened(CameraDevice cameraDevice) { |
| 46 mCameraDevice = cameraDevice; | 49 mCameraDevice = cameraDevice; |
| 47 mOpeningCamera = false; | 50 mOpeningCamera = false; |
| 48 mConfiguringCamera = true; | 51 mConfiguringCamera = true; |
| 49 if (!createCaptureObjects()) { | 52 if (!createCaptureObjects()) { |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 mCameraDevice.close(); | 427 mCameraDevice.close(); |
| 425 | 428 |
| 426 return true; | 429 return true; |
| 427 } | 430 } |
| 428 | 431 |
| 429 @Override | 432 @Override |
| 430 public void deallocate() { | 433 public void deallocate() { |
| 431 Log.d(TAG, "deallocate"); | 434 Log.d(TAG, "deallocate"); |
| 432 } | 435 } |
| 433 } | 436 } |
| OLD | NEW |