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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 return ImageFormat.YV12; | 79 return ImageFormat.YV12; |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 private int mExpectedFrameSize; | 83 private int mExpectedFrameSize; |
84 private final Object mPhotoTakenCallbackLock = new Object(); | 84 private final Object mPhotoTakenCallbackLock = new Object(); |
85 | 85 |
86 // Storage of takePicture() callback Id. There can be one such request in fl
ight at most, and | 86 // Storage of takePicture() callback Id. There can be one such request in fl
ight at most, and |
87 // needs to be exercised either in case of error or sucess. | 87 // needs to be exercised either in case of error or sucess. |
88 private long mPhotoTakenCallbackId = 0; | 88 private long mPhotoTakenCallbackId; |
89 private int mPhotoWidth = 0; | 89 private int mPhotoWidth; |
90 private int mPhotoHeight = 0; | 90 private int mPhotoHeight; |
91 private android.hardware.Camera.Area mAreaOfInterest; | 91 private android.hardware.Camera.Area mAreaOfInterest; |
92 | 92 |
93 private android.hardware.Camera mCamera; | 93 private android.hardware.Camera mCamera; |
94 // Lock to mutually exclude execution of OnPreviewFrame() and {start/stop}Ca
pture(). | 94 // Lock to mutually exclude execution of OnPreviewFrame() and {start/stop}Ca
pture(). |
95 private ReentrantLock mPreviewBufferLock = new ReentrantLock(); | 95 private ReentrantLock mPreviewBufferLock = new ReentrantLock(); |
96 // True when native code has started capture. | 96 // True when native code has started capture. |
97 private boolean mIsRunning = false; | 97 private boolean mIsRunning; |
98 | 98 |
99 private int[] mGlTextures = null; | 99 private int[] mGlTextures; |
100 private SurfaceTexture mSurfaceTexture = null; | 100 private SurfaceTexture mSurfaceTexture; |
101 | 101 |
102 private static android.hardware.Camera.CameraInfo getCameraInfo(int id) { | 102 private static android.hardware.Camera.CameraInfo getCameraInfo(int id) { |
103 android.hardware.Camera.CameraInfo cameraInfo = new android.hardware.Cam
era.CameraInfo(); | 103 android.hardware.Camera.CameraInfo cameraInfo = new android.hardware.Cam
era.CameraInfo(); |
104 try { | 104 try { |
105 android.hardware.Camera.getCameraInfo(id, cameraInfo); | 105 android.hardware.Camera.getCameraInfo(id, cameraInfo); |
106 } catch (RuntimeException ex) { | 106 } catch (RuntimeException ex) { |
107 Log.e(TAG, "getCameraInfo: Camera.getCameraInfo: " + ex); | 107 Log.e(TAG, "getCameraInfo: Camera.getCameraInfo: " + ex); |
108 return null; | 108 return null; |
109 } | 109 } |
110 return cameraInfo; | 110 return cameraInfo; |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 getCameraRotation()); | 794 getCameraRotation()); |
795 } | 795 } |
796 } finally { | 796 } finally { |
797 mPreviewBufferLock.unlock(); | 797 mPreviewBufferLock.unlock(); |
798 if (camera != null) { | 798 if (camera != null) { |
799 camera.addCallbackBuffer(data); | 799 camera.addCallbackBuffer(data); |
800 } | 800 } |
801 } | 801 } |
802 } | 802 } |
803 } | 803 } |
OLD | NEW |