blob: e03aaba05f908f840ac05c447e156013c8171169 [file] [log] [blame]
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -07001/*
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 Talvalaf69c70d2012-05-20 15:59:14 -070022#include "camera/CameraParameters.h"
Eino-Ville Talvalad4bcfde2012-06-07 17:12:38 -070023#include <binder/MemoryBase.h>
24#include <binder/MemoryHeapBase.h>
25#include <gui/CpuConsumer.h>
Eino-Ville Talvala30e65e72012-08-21 13:30:45 -070026#include <gui/BufferItemConsumer.h>
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070027
28namespace android {
29
30/**
31 * Implements the android.hardware.camera API on top of
32 * camera device HAL version 2.
33 */
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -070034class Camera2Client :
35 public CameraService::Client,
36 public Camera2Device::NotificationListener,
37 public Camera2Device::FrameListener
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070038{
39public:
40 // ICamera interface (see ICamera for details)
Eino-Ville Talvala160d4af2012-08-03 09:40:16 -070041
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070042 virtual void disconnect();
43 virtual status_t connect(const sp<ICameraClient>& client);
44 virtual status_t lock();
45 virtual status_t unlock();
46 virtual status_t setPreviewDisplay(const sp<Surface>& surface);
Eino-Ville Talvala6db981c2012-05-21 18:54:30 -070047 virtual status_t setPreviewTexture(
48 const sp<ISurfaceTexture>& surfaceTexture);
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070049 virtual void setPreviewCallbackFlag(int flag);
50 virtual status_t startPreview();
51 virtual void stopPreview();
52 virtual bool previewEnabled();
53 virtual status_t storeMetaDataInBuffers(bool enabled);
54 virtual status_t startRecording();
55 virtual void stopRecording();
56 virtual bool recordingEnabled();
57 virtual void releaseRecordingFrame(const sp<IMemory>& mem);
58 virtual status_t autoFocus();
59 virtual status_t cancelAutoFocus();
60 virtual status_t takePicture(int msgType);
61 virtual status_t setParameters(const String8& params);
62 virtual String8 getParameters() const;
63 virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2);
64
65 // Interface used by CameraService
Eino-Ville Talvala160d4af2012-08-03 09:40:16 -070066
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070067 Camera2Client(const sp<CameraService>& cameraService,
68 const sp<ICameraClient>& cameraClient,
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070069 int cameraId,
70 int cameraFacing,
71 int clientPid);
Eino-Ville Talvala160d4af2012-08-03 09:40:16 -070072 virtual ~Camera2Client();
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070073
Eino-Ville Talvalaf69c70d2012-05-20 15:59:14 -070074 status_t initialize(camera_module_t *module);
75
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070076 virtual status_t dump(int fd, const Vector<String16>& args);
77
Eino-Ville Talvala160d4af2012-08-03 09:40:16 -070078 // Interface used by CameraDevice
79
80 virtual void notifyError(int errorCode, int arg1, int arg2);
81 virtual void notifyShutter(int frameNumber, nsecs_t timestamp);
82 virtual void notifyAutoFocus(uint8_t newState, int triggerId);
83 virtual void notifyAutoExposure(uint8_t newState, int triggerId);
84 virtual void notifyAutoWhitebalance(uint8_t newState, int triggerId);
85
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -070086 virtual void onNewFrameAvailable();
Eino-Ville Talvalacab96a42012-08-24 11:29:22 -070087
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070088private:
Eino-Ville Talvala4ecfec32012-06-12 17:13:48 -070089 enum State {
Eino-Ville Talvala3a609142012-07-31 14:36:26 -070090 DISCONNECTED,
Eino-Ville Talvala6db981c2012-05-21 18:54:30 -070091 STOPPED,
92 WAITING_FOR_PREVIEW_WINDOW,
Eino-Ville Talvala7f610842012-06-07 10:20:51 -070093 PREVIEW,
94 RECORD,
Eino-Ville Talvalad4bcfde2012-06-07 17:12:38 -070095 STILL_CAPTURE,
96 VIDEO_SNAPSHOT
Eino-Ville Talvala228a5382012-08-13 12:16:06 -070097 };
Eino-Ville Talvala4ecfec32012-06-12 17:13:48 -070098 static const char *getStateName(State state);
99
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700100 /** ICamera interface-related private members */
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -0700101
Eino-Ville Talvalaac45eb32012-06-07 10:24:51 -0700102 // Mutex that must be locked by methods implementing the ICamera interface.
Eino-Ville Talvala36cdfb12012-08-02 17:34:15 -0700103 // Ensures serialization between incoming ICamera calls. All methods below
104 // that append 'L' to the name assume that mICameraLock is locked when
105 // they're called
Eino-Ville Talvalaac45eb32012-06-07 10:24:51 -0700106 mutable Mutex mICameraLock;
107
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700108 // Mutex that must be locked by methods accessing the base Client's
109 // mCameraClient ICameraClient interface member, for sending notifications
110 // up to the camera user
111 mutable Mutex mICameraClientLock;
112
Eino-Ville Talvala228a5382012-08-13 12:16:06 -0700113 class Parameters;
114
Eino-Ville Talvala36cdfb12012-08-02 17:34:15 -0700115 status_t setPreviewWindowL(const sp<IBinder>& binder,
Eino-Ville Talvalabe0573b2012-06-15 12:42:30 -0700116 sp<ANativeWindow> window);
Eino-Ville Talvala228a5382012-08-13 12:16:06 -0700117 status_t startPreviewL(Parameters &params, bool restart);
118 void stopPreviewL();
119 status_t startRecordingL(Parameters &params, bool restart);
120 bool recordingEnabledL();
James Dong8da4cd72012-08-04 19:58:07 -0700121
Eino-Ville Talvala36cdfb12012-08-02 17:34:15 -0700122 // Individual commands for sendCommand()
123 status_t commandStartSmoothZoomL();
124 status_t commandStopSmoothZoomL();
125 status_t commandSetDisplayOrientationL(int degrees);
126 status_t commandEnableShutterSoundL(bool enable);
127 status_t commandPlayRecordingSoundL();
128 status_t commandStartFaceDetectionL(int type);
Eino-Ville Talvala228a5382012-08-13 12:16:06 -0700129 status_t commandStopFaceDetectionL(Parameters &params);
Eino-Ville Talvala36cdfb12012-08-02 17:34:15 -0700130 status_t commandEnableFocusMoveMsgL(bool enable);
131 status_t commandPingL();
132 status_t commandSetVideoBufferCountL(size_t count);
Eino-Ville Talvalad4bcfde2012-06-07 17:12:38 -0700133
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700134 // Current camera state; this is the contents of the CameraParameters object
135 // in a more-efficient format. The enum values are mostly based off the
136 // corresponding camera2 enums, not the camera1 strings. A few are defined
137 // here if they don't cleanly map to camera2 values.
138 struct Parameters {
139 int previewWidth, previewHeight;
Eino-Ville Talvala11b7cde2012-06-15 12:37:35 -0700140 int32_t previewFpsRange[2];
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700141 int previewFps; // deprecated, here only for tracking changes
142 int previewFormat;
143
Eino-Ville Talvala11b7cde2012-06-15 12:37:35 -0700144 int previewTransform; // set by CAMERA_CMD_SET_DISPLAY_ORIENTATION
145
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700146 int pictureWidth, pictureHeight;
147
Eino-Ville Talvala11b7cde2012-06-15 12:37:35 -0700148 int32_t jpegThumbSize[2];
149 int32_t jpegQuality, jpegThumbQuality;
150 int32_t jpegRotation;
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700151
152 bool gpsEnabled;
Eino-Ville Talvala11b7cde2012-06-15 12:37:35 -0700153 double gpsCoordinates[3];
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700154 int64_t gpsTimestamp;
155 String8 gpsProcessingMethod;
156
Eino-Ville Talvalacab96a42012-08-24 11:29:22 -0700157 uint8_t wbMode;
158 uint8_t effectMode;
159 uint8_t antibandingMode;
160 uint8_t sceneMode;
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700161
162 enum flashMode_t {
163 FLASH_MODE_OFF = 0,
164 FLASH_MODE_AUTO,
165 FLASH_MODE_ON,
166 FLASH_MODE_TORCH,
167 FLASH_MODE_RED_EYE = ANDROID_CONTROL_AE_ON_AUTO_FLASH_REDEYE,
168 FLASH_MODE_INVALID = -1
169 } flashMode;
170
171 enum focusMode_t {
172 FOCUS_MODE_AUTO = ANDROID_CONTROL_AF_AUTO,
173 FOCUS_MODE_MACRO = ANDROID_CONTROL_AF_MACRO,
174 FOCUS_MODE_CONTINUOUS_VIDEO = ANDROID_CONTROL_AF_CONTINUOUS_VIDEO,
175 FOCUS_MODE_CONTINUOUS_PICTURE =
176 ANDROID_CONTROL_AF_CONTINUOUS_PICTURE,
177 FOCUS_MODE_EDOF = ANDROID_CONTROL_AF_EDOF,
178 FOCUS_MODE_INFINITY,
179 FOCUS_MODE_FIXED,
180 FOCUS_MODE_INVALID = -1
181 } focusMode;
182
183 struct Area {
184 int left, top, right, bottom;
185 int weight;
186 Area() {}
187 Area(int left, int top, int right, int bottom, int weight):
188 left(left), top(top), right(right), bottom(bottom),
189 weight(weight) {}
190 };
191 Vector<Area> focusingAreas;
192
Eino-Ville Talvala11b7cde2012-06-15 12:37:35 -0700193 int32_t exposureCompensation;
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700194 bool autoExposureLock;
195 bool autoWhiteBalanceLock;
196
197 Vector<Area> meteringAreas;
198
199 int zoom;
200
201 int videoWidth, videoHeight;
202
203 bool recordingHint;
204 bool videoStabilization;
Eino-Ville Talvala78822d72012-07-18 17:52:18 -0700205
Eino-Ville Talvala836b81f2012-07-27 11:35:21 -0700206 String8 paramsFlattened;
Eino-Ville Talvala36cdfb12012-08-02 17:34:15 -0700207
208 // These parameters are also part of the camera API-visible state, but not directly
209 // listed in Camera.Parameters
210 bool storeMetadataInBuffers;
211 bool playShutterSound;
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700212 bool enableFaceDetect;
Eino-Ville Talvala174181e2012-08-03 13:53:39 -0700213
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700214 bool enableFocusMoveMessages;
Eino-Ville Talvala174181e2012-08-03 13:53:39 -0700215 int afTriggerCounter;
216 int currentAfTriggerId;
217 bool afInMotion;
Eino-Ville Talvala228a5382012-08-13 12:16:06 -0700218
219 uint32_t previewCallbackFlags;
220 bool previewCallbackOneShot;
221
222 // Overall camera state
223 State state;
Eino-Ville Talvala836b81f2012-07-27 11:35:21 -0700224 };
225
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700226 // This class encapsulates the Parameters class so that it can only be accessed
227 // by constructing a Key object, which locks the LockedParameter's mutex.
Eino-Ville Talvala836b81f2012-07-27 11:35:21 -0700228 class LockedParameters {
229 public:
230 class Key {
231 public:
232 Key(LockedParameters &p):
233 mParameters(p.mParameters),
234 mLockedParameters(p) {
235 mLockedParameters.mLock.lock();
236 }
237
238 ~Key() {
239 mLockedParameters.mLock.unlock();
240 }
241 Parameters &mParameters;
242 private:
243 // Disallow copying, default construction
244 Key();
245 Key(const Key &);
246 Key &operator=(const Key &);
247 LockedParameters &mLockedParameters;
248 };
249 class ReadKey {
250 public:
251 ReadKey(const LockedParameters &p):
252 mParameters(p.mParameters),
253 mLockedParameters(p) {
254 mLockedParameters.mLock.lock();
255 }
256
257 ~ReadKey() {
258 mLockedParameters.mLock.unlock();
259 }
260 const Parameters &mParameters;
261 private:
262 // Disallow copying, default construction
263 ReadKey();
264 ReadKey(const ReadKey &);
265 ReadKey &operator=(const ReadKey &);
266 const LockedParameters &mLockedParameters;
267 };
268
269 // Only use for dumping or other debugging
270 const Parameters &unsafeUnlock() {
271 return mParameters;
272 }
273 private:
274 Parameters mParameters;
275 mutable Mutex mLock;
276
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700277 } mParameters;
278
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700279 // Static device information; this is a subset of the information
280 // available through the staticInfo() method, used for frequently-accessed
281 // values or values that have to be calculated from the static information.
282 struct DeviceInfo {
283 int32_t arrayWidth;
284 int32_t arrayHeight;
285 uint8_t bestFaceDetectMode;
286 int32_t maxFaces;
287 };
288 const DeviceInfo *mDeviceInfo;
289
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700290 /** Camera device-related private members */
291
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700292 class Camera2Heap;
293
Eino-Ville Talvala228a5382012-08-13 12:16:06 -0700294 void setPreviewCallbackFlagL(Parameters &params, int flag);
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700295 status_t updateRequests(const Parameters &params);
296
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700297 // Number of zoom steps to simulate
298 static const unsigned int NUM_ZOOM_STEPS = 10;
299 // Used with stream IDs
300 static const int NO_STREAM = -1;
301
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700302 /* Output frame metadata processing methods */
303
Eino-Ville Talvalacab96a42012-08-24 11:29:22 -0700304 status_t processFrameFaceDetect(const CameraMetadata &frame);
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700305
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700306 /* Preview related members */
307
308 int mPreviewStreamId;
Eino-Ville Talvalacab96a42012-08-24 11:29:22 -0700309 CameraMetadata mPreviewRequest;
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700310 sp<IBinder> mPreviewSurface;
311 sp<ANativeWindow> mPreviewWindow;
Eino-Ville Talvala836b81f2012-07-27 11:35:21 -0700312
313 status_t updatePreviewRequest(const Parameters &params);
314 status_t updatePreviewStream(const Parameters &params);
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700315
Eino-Ville Talvala228a5382012-08-13 12:16:06 -0700316 /** Preview callback related members */
317
318 int mCallbackStreamId;
319 static const size_t kCallbackHeapCount = 6;
320 sp<CpuConsumer> mCallbackConsumer;
321 sp<ANativeWindow> mCallbackWindow;
322 // Simple listener that forwards frame available notifications from
323 // a CPU consumer to the callback notification
324 class CallbackWaiter: public CpuConsumer::FrameAvailableListener {
325 public:
326 CallbackWaiter(Camera2Client *parent) : mParent(parent) {}
327 void onFrameAvailable() { mParent->onCallbackAvailable(); }
328 private:
329 Camera2Client *mParent;
330 };
331 sp<CallbackWaiter> mCallbackWaiter;
332 sp<Camera2Heap> mCallbackHeap;
333 int mCallbackHeapId;
334 size_t mCallbackHeapHead, mCallbackHeapFree;
335 // Handle callback image buffers
336 void onCallbackAvailable();
337
338 status_t updateCallbackStream(const Parameters &params);
339
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700340 /* Still image capture related members */
341
342 int mCaptureStreamId;
343 sp<CpuConsumer> mCaptureConsumer;
344 sp<ANativeWindow> mCaptureWindow;
Eino-Ville Talvalad4bcfde2012-06-07 17:12:38 -0700345 // Simple listener that forwards frame available notifications from
346 // a CPU consumer to the capture notification
347 class CaptureWaiter: public CpuConsumer::FrameAvailableListener {
348 public:
349 CaptureWaiter(Camera2Client *parent) : mParent(parent) {}
350 void onFrameAvailable() { mParent->onCaptureAvailable(); }
351 private:
352 Camera2Client *mParent;
353 };
Eino-Ville Talvalad4bcfde2012-06-07 17:12:38 -0700354 sp<CaptureWaiter> mCaptureWaiter;
Eino-Ville Talvalacab96a42012-08-24 11:29:22 -0700355 CameraMetadata mCaptureRequest;
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700356 sp<Camera2Heap> mCaptureHeap;
357 // Handle captured image buffers
358 void onCaptureAvailable();
Eino-Ville Talvala836b81f2012-07-27 11:35:21 -0700359
360 status_t updateCaptureRequest(const Parameters &params);
361 status_t updateCaptureStream(const Parameters &params);
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700362
363 /* Recording related members */
364
365 int mRecordingStreamId;
Eino-Ville Talvala228a5382012-08-13 12:16:06 -0700366 int mRecordingFrameCount;
Eino-Ville Talvala30e65e72012-08-21 13:30:45 -0700367 sp<BufferItemConsumer> mRecordingConsumer;
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700368 sp<ANativeWindow> mRecordingWindow;
369 // Simple listener that forwards frame available notifications from
370 // a CPU consumer to the recording notification
Eino-Ville Talvala30e65e72012-08-21 13:30:45 -0700371 class RecordingWaiter: public BufferItemConsumer::FrameAvailableListener {
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700372 public:
373 RecordingWaiter(Camera2Client *parent) : mParent(parent) {}
374 void onFrameAvailable() { mParent->onRecordingFrameAvailable(); }
375 private:
376 Camera2Client *mParent;
377 };
378 sp<RecordingWaiter> mRecordingWaiter;
Eino-Ville Talvalacab96a42012-08-24 11:29:22 -0700379 CameraMetadata mRecordingRequest;
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700380 sp<Camera2Heap> mRecordingHeap;
381
James Dong983cf232012-08-01 16:39:55 -0700382 static const size_t kDefaultRecordingHeapCount = 8;
383 size_t mRecordingHeapCount;
Eino-Ville Talvala30e65e72012-08-21 13:30:45 -0700384 Vector<BufferItemConsumer::BufferItem> mRecordingBuffers;
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700385 size_t mRecordingHeapHead, mRecordingHeapFree;
386 // Handle new recording image buffers
387 void onRecordingFrameAvailable();
Eino-Ville Talvala836b81f2012-07-27 11:35:21 -0700388
389 status_t updateRecordingRequest(const Parameters &params);
390 status_t updateRecordingStream(const Parameters &params);
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700391
Eino-Ville Talvala174181e2012-08-03 13:53:39 -0700392 /** Notification-related members */
393
394 bool mAfInMotion;
395
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700396 /** Camera2Device instance wrapping HAL2 entry */
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700397
398 sp<Camera2Device> mDevice;
399
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700400 /** Utility members */
401
Eino-Ville Talvala3a609142012-07-31 14:36:26 -0700402 // Verify that caller is the owner of the camera
403 status_t checkPid(const char *checkLocation) const;
404
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700405 // Utility class for managing a set of IMemory blocks
406 class Camera2Heap : public RefBase {
407 public:
408 Camera2Heap(size_t buf_size, uint_t num_buffers = 1,
409 const char *name = NULL) :
410 mBufSize(buf_size),
411 mNumBufs(num_buffers) {
412 mHeap = new MemoryHeapBase(buf_size * num_buffers, 0, name);
413 mBuffers = new sp<MemoryBase>[mNumBufs];
414 for (uint_t i = 0; i < mNumBufs; i++)
415 mBuffers[i] = new MemoryBase(mHeap,
416 i * mBufSize,
417 mBufSize);
418 }
419
420 virtual ~Camera2Heap()
421 {
422 delete [] mBuffers;
423 }
424
425 size_t mBufSize;
426 uint_t mNumBufs;
427 sp<MemoryHeapBase> mHeap;
428 sp<MemoryBase> *mBuffers;
429 };
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700430
431 // Get values for static camera info entry. min/maxCount are used for error
432 // checking the number of values in the entry. 0 for max/minCount means to
433 // do no bounds check in that direction. In case of error, the entry data
434 // pointer is null and the count is 0.
Eino-Ville Talvalacab96a42012-08-24 11:29:22 -0700435 camera_metadata_ro_entry_t staticInfo(uint32_t tag,
436 size_t minCount=0, size_t maxCount=0) const;
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700437
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700438 // Extract frequently-used camera static information into mDeviceInfo
439 status_t buildDeviceInfo();
Eino-Ville Talvalaf69c70d2012-05-20 15:59:14 -0700440 // Convert static camera info from a camera2 device to the
441 // old API parameter map.
442 status_t buildDefaultParameters();
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -0700443
Eino-Ville Talvalabe0573b2012-06-15 12:42:30 -0700444 // Update parameters all requests use, based on mParameters
Eino-Ville Talvalacab96a42012-08-24 11:29:22 -0700445 status_t updateRequestCommon(CameraMetadata *request, const Parameters &params);
Eino-Ville Talvalabe0573b2012-06-15 12:42:30 -0700446
Eino-Ville Talvala30e65e72012-08-21 13:30:45 -0700447 // Map from sensor active array pixel coordinates to normalized camera
448 // parameter coordinates. The former are (0,0)-(array width - 1, array height
449 // - 1), the latter from (-1000,-1000)-(1000,1000)
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700450 int arrayXToNormalized(int width) const;
451 int arrayYToNormalized(int height) const;
452
Eino-Ville Talvala6861a4e2012-06-07 10:32:12 -0700453 // Convert camera1 preview format string to camera2 enum
454 static int formatStringToEnum(const char *format);
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700455 static const char *formatEnumToString(int format);
Eino-Ville Talvala6861a4e2012-06-07 10:32:12 -0700456
457 static int wbModeStringToEnum(const char *wbMode);
458 static int effectModeStringToEnum(const char *effectMode);
459 static int abModeStringToEnum(const char *abMode);
460 static int sceneModeStringToEnum(const char *sceneMode);
461 static Parameters::flashMode_t flashModeStringToEnum(const char *flashMode);
462 static Parameters::focusMode_t focusModeStringToEnum(const char *focusMode);
463 static status_t parseAreas(const char *areasCStr,
464 Vector<Parameters::Area> *areas);
465 static status_t validateAreas(const Vector<Parameters::Area> &areas,
466 size_t maxRegions);
467 static bool boolFromString(const char *boolStr);
Eino-Ville Talvalac94cd192012-06-15 12:47:42 -0700468
469 // Map from camera orientation + facing to gralloc transform enum
470 static int degToTransform(int degrees, bool mirror);
Eino-Ville Talvala160d4af2012-08-03 09:40:16 -0700471
Eino-Ville Talvala228a5382012-08-13 12:16:06 -0700472 static size_t calculateBufferSize(int width, int height,
473 int format, int stride);
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -0700474};
475
476}; // namespace android
477
478#endif