Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROID_SERVERS_CAMERA_CAMERA2CLIENT_H |
| 18 | #define ANDROID_SERVERS_CAMERA_CAMERA2CLIENT_H |
| 19 | |
| 20 | #include "Camera2Device.h" |
| 21 | #include "CameraService.h" |
Eino-Ville Talvala | f69c70d | 2012-05-20 15:59:14 -0700 | [diff] [blame] | 22 | #include "camera/CameraParameters.h" |
Eino-Ville Talvala | d4bcfde | 2012-06-07 17:12:38 -0700 | [diff] [blame] | 23 | #include <binder/MemoryBase.h> |
| 24 | #include <binder/MemoryHeapBase.h> |
| 25 | #include <gui/CpuConsumer.h> |
Eino-Ville Talvala | 78822d7 | 2012-07-18 17:52:18 -0700 | [diff] [blame] | 26 | #include "MediaConsumer.h" |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | /** |
| 31 | * Implements the android.hardware.camera API on top of |
| 32 | * camera device HAL version 2. |
| 33 | */ |
Eino-Ville Talvala | 160d4af | 2012-08-03 09:40:16 -0700 | [diff] [blame] | 34 | class Camera2Client : public CameraService::Client, |
| 35 | public Camera2Device::NotificationListener |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 36 | { |
| 37 | public: |
| 38 | // ICamera interface (see ICamera for details) |
Eino-Ville Talvala | 160d4af | 2012-08-03 09:40:16 -0700 | [diff] [blame] | 39 | |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 40 | virtual void disconnect(); |
| 41 | virtual status_t connect(const sp<ICameraClient>& client); |
| 42 | virtual status_t lock(); |
| 43 | virtual status_t unlock(); |
| 44 | virtual status_t setPreviewDisplay(const sp<Surface>& surface); |
Eino-Ville Talvala | 6db981c | 2012-05-21 18:54:30 -0700 | [diff] [blame] | 45 | virtual status_t setPreviewTexture( |
| 46 | const sp<ISurfaceTexture>& surfaceTexture); |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 47 | virtual void setPreviewCallbackFlag(int flag); |
| 48 | virtual status_t startPreview(); |
| 49 | virtual void stopPreview(); |
| 50 | virtual bool previewEnabled(); |
| 51 | virtual status_t storeMetaDataInBuffers(bool enabled); |
| 52 | virtual status_t startRecording(); |
| 53 | virtual void stopRecording(); |
| 54 | virtual bool recordingEnabled(); |
| 55 | virtual void releaseRecordingFrame(const sp<IMemory>& mem); |
| 56 | virtual status_t autoFocus(); |
| 57 | virtual status_t cancelAutoFocus(); |
| 58 | virtual status_t takePicture(int msgType); |
| 59 | virtual status_t setParameters(const String8& params); |
| 60 | virtual String8 getParameters() const; |
| 61 | virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2); |
| 62 | |
| 63 | // Interface used by CameraService |
Eino-Ville Talvala | 160d4af | 2012-08-03 09:40:16 -0700 | [diff] [blame] | 64 | |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 65 | Camera2Client(const sp<CameraService>& cameraService, |
| 66 | const sp<ICameraClient>& cameraClient, |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 67 | int cameraId, |
| 68 | int cameraFacing, |
| 69 | int clientPid); |
Eino-Ville Talvala | 160d4af | 2012-08-03 09:40:16 -0700 | [diff] [blame] | 70 | virtual ~Camera2Client(); |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 71 | |
Eino-Ville Talvala | f69c70d | 2012-05-20 15:59:14 -0700 | [diff] [blame] | 72 | status_t initialize(camera_module_t *module); |
| 73 | |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 74 | virtual status_t dump(int fd, const Vector<String16>& args); |
| 75 | |
Eino-Ville Talvala | 160d4af | 2012-08-03 09:40:16 -0700 | [diff] [blame] | 76 | // Interface used by CameraDevice |
| 77 | |
| 78 | virtual void notifyError(int errorCode, int arg1, int arg2); |
| 79 | virtual void notifyShutter(int frameNumber, nsecs_t timestamp); |
| 80 | virtual void notifyAutoFocus(uint8_t newState, int triggerId); |
| 81 | virtual void notifyAutoExposure(uint8_t newState, int triggerId); |
| 82 | virtual void notifyAutoWhitebalance(uint8_t newState, int triggerId); |
| 83 | |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 84 | private: |
Eino-Ville Talvala | 4ecfec3 | 2012-06-12 17:13:48 -0700 | [diff] [blame] | 85 | enum State { |
Eino-Ville Talvala | 3a60914 | 2012-07-31 14:36:26 -0700 | [diff] [blame] | 86 | DISCONNECTED, |
Eino-Ville Talvala | 6db981c | 2012-05-21 18:54:30 -0700 | [diff] [blame] | 87 | STOPPED, |
| 88 | WAITING_FOR_PREVIEW_WINDOW, |
Eino-Ville Talvala | 7f61084 | 2012-06-07 10:20:51 -0700 | [diff] [blame] | 89 | PREVIEW, |
| 90 | RECORD, |
Eino-Ville Talvala | d4bcfde | 2012-06-07 17:12:38 -0700 | [diff] [blame] | 91 | STILL_CAPTURE, |
| 92 | VIDEO_SNAPSHOT |
Eino-Ville Talvala | 6db981c | 2012-05-21 18:54:30 -0700 | [diff] [blame] | 93 | } mState; |
| 94 | |
Eino-Ville Talvala | 4ecfec3 | 2012-06-12 17:13:48 -0700 | [diff] [blame] | 95 | static const char *getStateName(State state); |
| 96 | |
Eino-Ville Talvala | 3cca136 | 2012-06-07 10:07:18 -0700 | [diff] [blame] | 97 | /** ICamera interface-related private members */ |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 98 | |
Eino-Ville Talvala | ac45eb3 | 2012-06-07 10:24:51 -0700 | [diff] [blame] | 99 | // Mutex that must be locked by methods implementing the ICamera interface. |
Eino-Ville Talvala | 36cdfb1 | 2012-08-02 17:34:15 -0700 | [diff] [blame] | 100 | // Ensures serialization between incoming ICamera calls. All methods below |
| 101 | // that append 'L' to the name assume that mICameraLock is locked when |
| 102 | // they're called |
Eino-Ville Talvala | ac45eb3 | 2012-06-07 10:24:51 -0700 | [diff] [blame] | 103 | mutable Mutex mICameraLock; |
| 104 | |
Eino-Ville Talvala | 36cdfb1 | 2012-08-02 17:34:15 -0700 | [diff] [blame] | 105 | status_t setPreviewWindowL(const sp<IBinder>& binder, |
Eino-Ville Talvala | be0573b | 2012-06-15 12:42:30 -0700 | [diff] [blame] | 106 | sp<ANativeWindow> window); |
Eino-Ville Talvala | d4bcfde | 2012-06-07 17:12:38 -0700 | [diff] [blame] | 107 | |
Eino-Ville Talvala | 36cdfb1 | 2012-08-02 17:34:15 -0700 | [diff] [blame] | 108 | void stopPreviewL(); |
| 109 | status_t startPreviewL(); |
| 110 | |
James Dong | 8da4cd7 | 2012-08-04 19:58:07 -0700 | [diff] [blame] | 111 | bool recordingEnabledL(); |
| 112 | |
Eino-Ville Talvala | 36cdfb1 | 2012-08-02 17:34:15 -0700 | [diff] [blame] | 113 | // Individual commands for sendCommand() |
| 114 | status_t commandStartSmoothZoomL(); |
| 115 | status_t commandStopSmoothZoomL(); |
| 116 | status_t commandSetDisplayOrientationL(int degrees); |
| 117 | status_t commandEnableShutterSoundL(bool enable); |
| 118 | status_t commandPlayRecordingSoundL(); |
| 119 | status_t commandStartFaceDetectionL(int type); |
| 120 | status_t commandStopFaceDetectionL(); |
| 121 | status_t commandEnableFocusMoveMsgL(bool enable); |
| 122 | status_t commandPingL(); |
| 123 | status_t commandSetVideoBufferCountL(size_t count); |
Eino-Ville Talvala | d4bcfde | 2012-06-07 17:12:38 -0700 | [diff] [blame] | 124 | |
Eino-Ville Talvala | 3cca136 | 2012-06-07 10:07:18 -0700 | [diff] [blame] | 125 | // Current camera state; this is the contents of the CameraParameters object |
| 126 | // in a more-efficient format. The enum values are mostly based off the |
| 127 | // corresponding camera2 enums, not the camera1 strings. A few are defined |
| 128 | // here if they don't cleanly map to camera2 values. |
| 129 | struct Parameters { |
| 130 | int previewWidth, previewHeight; |
Eino-Ville Talvala | 11b7cde | 2012-06-15 12:37:35 -0700 | [diff] [blame] | 131 | int32_t previewFpsRange[2]; |
Eino-Ville Talvala | 3cca136 | 2012-06-07 10:07:18 -0700 | [diff] [blame] | 132 | int previewFps; // deprecated, here only for tracking changes |
| 133 | int previewFormat; |
| 134 | |
Eino-Ville Talvala | 11b7cde | 2012-06-15 12:37:35 -0700 | [diff] [blame] | 135 | int previewTransform; // set by CAMERA_CMD_SET_DISPLAY_ORIENTATION |
| 136 | |
Eino-Ville Talvala | 3cca136 | 2012-06-07 10:07:18 -0700 | [diff] [blame] | 137 | int pictureWidth, pictureHeight; |
| 138 | |
Eino-Ville Talvala | 11b7cde | 2012-06-15 12:37:35 -0700 | [diff] [blame] | 139 | int32_t jpegThumbSize[2]; |
| 140 | int32_t jpegQuality, jpegThumbQuality; |
| 141 | int32_t jpegRotation; |
Eino-Ville Talvala | 3cca136 | 2012-06-07 10:07:18 -0700 | [diff] [blame] | 142 | |
| 143 | bool gpsEnabled; |
Eino-Ville Talvala | 11b7cde | 2012-06-15 12:37:35 -0700 | [diff] [blame] | 144 | double gpsCoordinates[3]; |
Eino-Ville Talvala | 3cca136 | 2012-06-07 10:07:18 -0700 | [diff] [blame] | 145 | int64_t gpsTimestamp; |
| 146 | String8 gpsProcessingMethod; |
| 147 | |
| 148 | int wbMode; |
| 149 | int effectMode; |
| 150 | int antibandingMode; |
| 151 | int sceneMode; |
| 152 | |
| 153 | enum flashMode_t { |
| 154 | FLASH_MODE_OFF = 0, |
| 155 | FLASH_MODE_AUTO, |
| 156 | FLASH_MODE_ON, |
| 157 | FLASH_MODE_TORCH, |
| 158 | FLASH_MODE_RED_EYE = ANDROID_CONTROL_AE_ON_AUTO_FLASH_REDEYE, |
| 159 | FLASH_MODE_INVALID = -1 |
| 160 | } flashMode; |
| 161 | |
| 162 | enum focusMode_t { |
| 163 | FOCUS_MODE_AUTO = ANDROID_CONTROL_AF_AUTO, |
| 164 | FOCUS_MODE_MACRO = ANDROID_CONTROL_AF_MACRO, |
| 165 | FOCUS_MODE_CONTINUOUS_VIDEO = ANDROID_CONTROL_AF_CONTINUOUS_VIDEO, |
| 166 | FOCUS_MODE_CONTINUOUS_PICTURE = |
| 167 | ANDROID_CONTROL_AF_CONTINUOUS_PICTURE, |
| 168 | FOCUS_MODE_EDOF = ANDROID_CONTROL_AF_EDOF, |
| 169 | FOCUS_MODE_INFINITY, |
| 170 | FOCUS_MODE_FIXED, |
| 171 | FOCUS_MODE_INVALID = -1 |
| 172 | } focusMode; |
| 173 | |
| 174 | struct Area { |
| 175 | int left, top, right, bottom; |
| 176 | int weight; |
| 177 | Area() {} |
| 178 | Area(int left, int top, int right, int bottom, int weight): |
| 179 | left(left), top(top), right(right), bottom(bottom), |
| 180 | weight(weight) {} |
| 181 | }; |
| 182 | Vector<Area> focusingAreas; |
| 183 | |
Eino-Ville Talvala | 11b7cde | 2012-06-15 12:37:35 -0700 | [diff] [blame] | 184 | int32_t exposureCompensation; |
Eino-Ville Talvala | 3cca136 | 2012-06-07 10:07:18 -0700 | [diff] [blame] | 185 | bool autoExposureLock; |
| 186 | bool autoWhiteBalanceLock; |
| 187 | |
| 188 | Vector<Area> meteringAreas; |
| 189 | |
| 190 | int zoom; |
| 191 | |
| 192 | int videoWidth, videoHeight; |
| 193 | |
| 194 | bool recordingHint; |
| 195 | bool videoStabilization; |
Eino-Ville Talvala | 78822d7 | 2012-07-18 17:52:18 -0700 | [diff] [blame] | 196 | |
Eino-Ville Talvala | 836b81f | 2012-07-27 11:35:21 -0700 | [diff] [blame] | 197 | String8 paramsFlattened; |
Eino-Ville Talvala | 36cdfb1 | 2012-08-02 17:34:15 -0700 | [diff] [blame] | 198 | |
| 199 | // These parameters are also part of the camera API-visible state, but not directly |
| 200 | // listed in Camera.Parameters |
| 201 | bool storeMetadataInBuffers; |
| 202 | bool playShutterSound; |
Eino-Ville Talvala | 836b81f | 2012-07-27 11:35:21 -0700 | [diff] [blame] | 203 | }; |
| 204 | |
| 205 | class LockedParameters { |
| 206 | public: |
| 207 | class Key { |
| 208 | public: |
| 209 | Key(LockedParameters &p): |
| 210 | mParameters(p.mParameters), |
| 211 | mLockedParameters(p) { |
| 212 | mLockedParameters.mLock.lock(); |
| 213 | } |
| 214 | |
| 215 | ~Key() { |
| 216 | mLockedParameters.mLock.unlock(); |
| 217 | } |
| 218 | Parameters &mParameters; |
| 219 | private: |
| 220 | // Disallow copying, default construction |
| 221 | Key(); |
| 222 | Key(const Key &); |
| 223 | Key &operator=(const Key &); |
| 224 | LockedParameters &mLockedParameters; |
| 225 | }; |
| 226 | class ReadKey { |
| 227 | public: |
| 228 | ReadKey(const LockedParameters &p): |
| 229 | mParameters(p.mParameters), |
| 230 | mLockedParameters(p) { |
| 231 | mLockedParameters.mLock.lock(); |
| 232 | } |
| 233 | |
| 234 | ~ReadKey() { |
| 235 | mLockedParameters.mLock.unlock(); |
| 236 | } |
| 237 | const Parameters &mParameters; |
| 238 | private: |
| 239 | // Disallow copying, default construction |
| 240 | ReadKey(); |
| 241 | ReadKey(const ReadKey &); |
| 242 | ReadKey &operator=(const ReadKey &); |
| 243 | const LockedParameters &mLockedParameters; |
| 244 | }; |
| 245 | |
| 246 | // Only use for dumping or other debugging |
| 247 | const Parameters &unsafeUnlock() { |
| 248 | return mParameters; |
| 249 | } |
| 250 | private: |
| 251 | Parameters mParameters; |
| 252 | mutable Mutex mLock; |
| 253 | |
Eino-Ville Talvala | 3cca136 | 2012-06-07 10:07:18 -0700 | [diff] [blame] | 254 | } mParameters; |
| 255 | |
| 256 | /** Camera device-related private members */ |
| 257 | |
Eino-Ville Talvala | 9cca4c6 | 2012-06-15 15:41:44 -0700 | [diff] [blame] | 258 | class Camera2Heap; |
| 259 | |
| 260 | // Number of zoom steps to simulate |
| 261 | static const unsigned int NUM_ZOOM_STEPS = 10; |
| 262 | // Used with stream IDs |
| 263 | static const int NO_STREAM = -1; |
| 264 | |
| 265 | /* Preview related members */ |
| 266 | |
| 267 | int mPreviewStreamId; |
| 268 | camera_metadata_t *mPreviewRequest; |
| 269 | sp<IBinder> mPreviewSurface; |
| 270 | sp<ANativeWindow> mPreviewWindow; |
Eino-Ville Talvala | 836b81f | 2012-07-27 11:35:21 -0700 | [diff] [blame] | 271 | |
| 272 | status_t updatePreviewRequest(const Parameters ¶ms); |
| 273 | status_t updatePreviewStream(const Parameters ¶ms); |
Eino-Ville Talvala | 9cca4c6 | 2012-06-15 15:41:44 -0700 | [diff] [blame] | 274 | |
| 275 | /* Still image capture related members */ |
| 276 | |
| 277 | int mCaptureStreamId; |
| 278 | sp<CpuConsumer> mCaptureConsumer; |
| 279 | sp<ANativeWindow> mCaptureWindow; |
Eino-Ville Talvala | d4bcfde | 2012-06-07 17:12:38 -0700 | [diff] [blame] | 280 | // Simple listener that forwards frame available notifications from |
| 281 | // a CPU consumer to the capture notification |
| 282 | class CaptureWaiter: public CpuConsumer::FrameAvailableListener { |
| 283 | public: |
| 284 | CaptureWaiter(Camera2Client *parent) : mParent(parent) {} |
| 285 | void onFrameAvailable() { mParent->onCaptureAvailable(); } |
| 286 | private: |
| 287 | Camera2Client *mParent; |
| 288 | }; |
Eino-Ville Talvala | d4bcfde | 2012-06-07 17:12:38 -0700 | [diff] [blame] | 289 | sp<CaptureWaiter> mCaptureWaiter; |
Eino-Ville Talvala | 3cca136 | 2012-06-07 10:07:18 -0700 | [diff] [blame] | 290 | camera_metadata_t *mCaptureRequest; |
Eino-Ville Talvala | 9cca4c6 | 2012-06-15 15:41:44 -0700 | [diff] [blame] | 291 | sp<Camera2Heap> mCaptureHeap; |
| 292 | // Handle captured image buffers |
| 293 | void onCaptureAvailable(); |
Eino-Ville Talvala | 836b81f | 2012-07-27 11:35:21 -0700 | [diff] [blame] | 294 | |
| 295 | status_t updateCaptureRequest(const Parameters ¶ms); |
| 296 | status_t updateCaptureStream(const Parameters ¶ms); |
Eino-Ville Talvala | 9cca4c6 | 2012-06-15 15:41:44 -0700 | [diff] [blame] | 297 | |
| 298 | /* Recording related members */ |
| 299 | |
| 300 | int mRecordingStreamId; |
Eino-Ville Talvala | 78822d7 | 2012-07-18 17:52:18 -0700 | [diff] [blame] | 301 | sp<MediaConsumer> mRecordingConsumer; |
Eino-Ville Talvala | 9cca4c6 | 2012-06-15 15:41:44 -0700 | [diff] [blame] | 302 | sp<ANativeWindow> mRecordingWindow; |
| 303 | // Simple listener that forwards frame available notifications from |
| 304 | // a CPU consumer to the recording notification |
Eino-Ville Talvala | 78822d7 | 2012-07-18 17:52:18 -0700 | [diff] [blame] | 305 | class RecordingWaiter: public MediaConsumer::FrameAvailableListener { |
Eino-Ville Talvala | 9cca4c6 | 2012-06-15 15:41:44 -0700 | [diff] [blame] | 306 | public: |
| 307 | RecordingWaiter(Camera2Client *parent) : mParent(parent) {} |
| 308 | void onFrameAvailable() { mParent->onRecordingFrameAvailable(); } |
| 309 | private: |
| 310 | Camera2Client *mParent; |
| 311 | }; |
| 312 | sp<RecordingWaiter> mRecordingWaiter; |
| 313 | camera_metadata_t *mRecordingRequest; |
| 314 | sp<Camera2Heap> mRecordingHeap; |
| 315 | |
| 316 | // TODO: This needs to be queried from somewhere, or the BufferQueue needs |
Eino-Ville Talvala | 803cbf6 | 2012-07-25 15:23:36 -0700 | [diff] [blame] | 317 | // to be passed all the way to stagefright. Right now, set to a large number |
| 318 | // to avoid starvation of the video encoders. |
James Dong | 983cf23 | 2012-08-01 16:39:55 -0700 | [diff] [blame] | 319 | static const size_t kDefaultRecordingHeapCount = 8; |
| 320 | size_t mRecordingHeapCount; |
Eino-Ville Talvala | 9cca4c6 | 2012-06-15 15:41:44 -0700 | [diff] [blame] | 321 | size_t mRecordingHeapHead, mRecordingHeapFree; |
| 322 | // Handle new recording image buffers |
| 323 | void onRecordingFrameAvailable(); |
Eino-Ville Talvala | 836b81f | 2012-07-27 11:35:21 -0700 | [diff] [blame] | 324 | |
| 325 | status_t updateRecordingRequest(const Parameters ¶ms); |
| 326 | status_t updateRecordingStream(const Parameters ¶ms); |
Eino-Ville Talvala | 9cca4c6 | 2012-06-15 15:41:44 -0700 | [diff] [blame] | 327 | |
| 328 | /** Camera2Device instance wrapping HAL2 entry */ |
Eino-Ville Talvala | 3cca136 | 2012-06-07 10:07:18 -0700 | [diff] [blame] | 329 | |
| 330 | sp<Camera2Device> mDevice; |
| 331 | |
Eino-Ville Talvala | 9cca4c6 | 2012-06-15 15:41:44 -0700 | [diff] [blame] | 332 | /** Utility members */ |
| 333 | |
Eino-Ville Talvala | 3a60914 | 2012-07-31 14:36:26 -0700 | [diff] [blame] | 334 | // Verify that caller is the owner of the camera |
| 335 | status_t checkPid(const char *checkLocation) const; |
| 336 | |
Eino-Ville Talvala | 9cca4c6 | 2012-06-15 15:41:44 -0700 | [diff] [blame] | 337 | // Utility class for managing a set of IMemory blocks |
| 338 | class Camera2Heap : public RefBase { |
| 339 | public: |
| 340 | Camera2Heap(size_t buf_size, uint_t num_buffers = 1, |
| 341 | const char *name = NULL) : |
| 342 | mBufSize(buf_size), |
| 343 | mNumBufs(num_buffers) { |
| 344 | mHeap = new MemoryHeapBase(buf_size * num_buffers, 0, name); |
| 345 | mBuffers = new sp<MemoryBase>[mNumBufs]; |
| 346 | for (uint_t i = 0; i < mNumBufs; i++) |
| 347 | mBuffers[i] = new MemoryBase(mHeap, |
| 348 | i * mBufSize, |
| 349 | mBufSize); |
| 350 | } |
| 351 | |
| 352 | virtual ~Camera2Heap() |
| 353 | { |
| 354 | delete [] mBuffers; |
| 355 | } |
| 356 | |
| 357 | size_t mBufSize; |
| 358 | uint_t mNumBufs; |
| 359 | sp<MemoryHeapBase> mHeap; |
| 360 | sp<MemoryBase> *mBuffers; |
| 361 | }; |
Eino-Ville Talvala | 3cca136 | 2012-06-07 10:07:18 -0700 | [diff] [blame] | 362 | |
| 363 | // Get values for static camera info entry. min/maxCount are used for error |
| 364 | // checking the number of values in the entry. 0 for max/minCount means to |
| 365 | // do no bounds check in that direction. In case of error, the entry data |
| 366 | // pointer is null and the count is 0. |
| 367 | camera_metadata_entry_t staticInfo(uint32_t tag, |
| 368 | size_t minCount=0, size_t maxCount=0); |
| 369 | |
Eino-Ville Talvala | f69c70d | 2012-05-20 15:59:14 -0700 | [diff] [blame] | 370 | // Convert static camera info from a camera2 device to the |
| 371 | // old API parameter map. |
| 372 | status_t buildDefaultParameters(); |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 373 | |
Eino-Ville Talvala | be0573b | 2012-06-15 12:42:30 -0700 | [diff] [blame] | 374 | // Update parameters all requests use, based on mParameters |
Eino-Ville Talvala | 836b81f | 2012-07-27 11:35:21 -0700 | [diff] [blame] | 375 | status_t updateRequestCommon(camera_metadata_t *request, const Parameters ¶ms); |
Eino-Ville Talvala | be0573b | 2012-06-15 12:42:30 -0700 | [diff] [blame] | 376 | |
| 377 | // Update specific metadata entry with new values. Adds entry if it does not |
| 378 | // exist, which will invalidate sorting |
| 379 | static status_t updateEntry(camera_metadata_t *buffer, |
| 380 | uint32_t tag, const void *data, size_t data_count); |
| 381 | |
| 382 | // Remove metadata entry. Will invalidate sorting. If entry does not exist, |
| 383 | // does nothing. |
| 384 | static status_t deleteEntry(camera_metadata_t *buffer, |
| 385 | uint32_t tag); |
| 386 | |
Eino-Ville Talvala | 6861a4e | 2012-06-07 10:32:12 -0700 | [diff] [blame] | 387 | // Convert camera1 preview format string to camera2 enum |
| 388 | static int formatStringToEnum(const char *format); |
Eino-Ville Talvala | 3cca136 | 2012-06-07 10:07:18 -0700 | [diff] [blame] | 389 | static const char *formatEnumToString(int format); |
Eino-Ville Talvala | 6861a4e | 2012-06-07 10:32:12 -0700 | [diff] [blame] | 390 | |
| 391 | static int wbModeStringToEnum(const char *wbMode); |
| 392 | static int effectModeStringToEnum(const char *effectMode); |
| 393 | static int abModeStringToEnum(const char *abMode); |
| 394 | static int sceneModeStringToEnum(const char *sceneMode); |
| 395 | static Parameters::flashMode_t flashModeStringToEnum(const char *flashMode); |
| 396 | static Parameters::focusMode_t focusModeStringToEnum(const char *focusMode); |
| 397 | static status_t parseAreas(const char *areasCStr, |
| 398 | Vector<Parameters::Area> *areas); |
| 399 | static status_t validateAreas(const Vector<Parameters::Area> &areas, |
| 400 | size_t maxRegions); |
| 401 | static bool boolFromString(const char *boolStr); |
Eino-Ville Talvala | c94cd19 | 2012-06-15 12:47:42 -0700 | [diff] [blame] | 402 | |
| 403 | // Map from camera orientation + facing to gralloc transform enum |
| 404 | static int degToTransform(int degrees, bool mirror); |
Eino-Ville Talvala | 160d4af | 2012-08-03 09:40:16 -0700 | [diff] [blame] | 405 | |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 406 | }; |
| 407 | |
| 408 | }; // namespace android |
| 409 | |
| 410 | #endif |