blob: e2f5cc464a00d5be3ba6d7571ac5008e977db310 [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,
Eino-Ville Talvalac8474b62012-08-24 16:30:44 -070036 public Camera2Device::NotificationListener
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070037{
38public:
39 // ICamera interface (see ICamera for details)
Eino-Ville Talvala160d4af2012-08-03 09:40:16 -070040
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070041 virtual void disconnect();
42 virtual status_t connect(const sp<ICameraClient>& client);
43 virtual status_t lock();
44 virtual status_t unlock();
45 virtual status_t setPreviewDisplay(const sp<Surface>& surface);
Eino-Ville Talvala6db981c2012-05-21 18:54:30 -070046 virtual status_t setPreviewTexture(
47 const sp<ISurfaceTexture>& surfaceTexture);
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070048 virtual void setPreviewCallbackFlag(int flag);
49 virtual status_t startPreview();
50 virtual void stopPreview();
51 virtual bool previewEnabled();
52 virtual status_t storeMetaDataInBuffers(bool enabled);
53 virtual status_t startRecording();
54 virtual void stopRecording();
55 virtual bool recordingEnabled();
56 virtual void releaseRecordingFrame(const sp<IMemory>& mem);
57 virtual status_t autoFocus();
58 virtual status_t cancelAutoFocus();
59 virtual status_t takePicture(int msgType);
60 virtual status_t setParameters(const String8& params);
61 virtual String8 getParameters() const;
62 virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2);
63
64 // Interface used by CameraService
Eino-Ville Talvala160d4af2012-08-03 09:40:16 -070065
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070066 Camera2Client(const sp<CameraService>& cameraService,
67 const sp<ICameraClient>& cameraClient,
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070068 int cameraId,
69 int cameraFacing,
70 int clientPid);
Eino-Ville Talvala160d4af2012-08-03 09:40:16 -070071 virtual ~Camera2Client();
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070072
Eino-Ville Talvalaf69c70d2012-05-20 15:59:14 -070073 status_t initialize(camera_module_t *module);
74
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070075 virtual status_t dump(int fd, const Vector<String16>& args);
76
Eino-Ville Talvala160d4af2012-08-03 09:40:16 -070077 // Interface used by CameraDevice
78
79 virtual void notifyError(int errorCode, int arg1, int arg2);
80 virtual void notifyShutter(int frameNumber, nsecs_t timestamp);
81 virtual void notifyAutoFocus(uint8_t newState, int triggerId);
82 virtual void notifyAutoExposure(uint8_t newState, int triggerId);
83 virtual void notifyAutoWhitebalance(uint8_t newState, int triggerId);
84
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070085private:
Eino-Ville Talvala4ecfec32012-06-12 17:13:48 -070086 enum State {
Eino-Ville Talvala3a609142012-07-31 14:36:26 -070087 DISCONNECTED,
Eino-Ville Talvala6db981c2012-05-21 18:54:30 -070088 STOPPED,
89 WAITING_FOR_PREVIEW_WINDOW,
Eino-Ville Talvala7f610842012-06-07 10:20:51 -070090 PREVIEW,
91 RECORD,
Eino-Ville Talvalad4bcfde2012-06-07 17:12:38 -070092 STILL_CAPTURE,
93 VIDEO_SNAPSHOT
Eino-Ville Talvala228a5382012-08-13 12:16:06 -070094 };
Eino-Ville Talvala4ecfec32012-06-12 17:13:48 -070095 static const char *getStateName(State state);
96
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -070097 /** ICamera interface-related private members */
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070098
Eino-Ville Talvalaac45eb32012-06-07 10:24:51 -070099 // Mutex that must be locked by methods implementing the ICamera interface.
Eino-Ville Talvala36cdfb12012-08-02 17:34:15 -0700100 // 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 Talvalaac45eb32012-06-07 10:24:51 -0700103 mutable Mutex mICameraLock;
104
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700105 // Mutex that must be locked by methods accessing the base Client's
106 // mCameraClient ICameraClient interface member, for sending notifications
107 // up to the camera user
108 mutable Mutex mICameraClientLock;
109
Eino-Ville Talvala228a5382012-08-13 12:16:06 -0700110 class Parameters;
111
Eino-Ville Talvala36cdfb12012-08-02 17:34:15 -0700112 status_t setPreviewWindowL(const sp<IBinder>& binder,
Eino-Ville Talvalabe0573b2012-06-15 12:42:30 -0700113 sp<ANativeWindow> window);
Eino-Ville Talvala228a5382012-08-13 12:16:06 -0700114 status_t startPreviewL(Parameters &params, bool restart);
115 void stopPreviewL();
116 status_t startRecordingL(Parameters &params, bool restart);
117 bool recordingEnabledL();
James Dong8da4cd72012-08-04 19:58:07 -0700118
Eino-Ville Talvala36cdfb12012-08-02 17:34:15 -0700119 // Individual commands for sendCommand()
120 status_t commandStartSmoothZoomL();
121 status_t commandStopSmoothZoomL();
122 status_t commandSetDisplayOrientationL(int degrees);
123 status_t commandEnableShutterSoundL(bool enable);
124 status_t commandPlayRecordingSoundL();
125 status_t commandStartFaceDetectionL(int type);
Eino-Ville Talvala228a5382012-08-13 12:16:06 -0700126 status_t commandStopFaceDetectionL(Parameters &params);
Eino-Ville Talvala36cdfb12012-08-02 17:34:15 -0700127 status_t commandEnableFocusMoveMsgL(bool enable);
128 status_t commandPingL();
129 status_t commandSetVideoBufferCountL(size_t count);
Eino-Ville Talvalad4bcfde2012-06-07 17:12:38 -0700130
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700131 // Current camera state; this is the contents of the CameraParameters object
132 // in a more-efficient format. The enum values are mostly based off the
133 // corresponding camera2 enums, not the camera1 strings. A few are defined
134 // here if they don't cleanly map to camera2 values.
135 struct Parameters {
136 int previewWidth, previewHeight;
Eino-Ville Talvala11b7cde2012-06-15 12:37:35 -0700137 int32_t previewFpsRange[2];
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700138 int previewFps; // deprecated, here only for tracking changes
139 int previewFormat;
140
Eino-Ville Talvala11b7cde2012-06-15 12:37:35 -0700141 int previewTransform; // set by CAMERA_CMD_SET_DISPLAY_ORIENTATION
142
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700143 int pictureWidth, pictureHeight;
144
Eino-Ville Talvala11b7cde2012-06-15 12:37:35 -0700145 int32_t jpegThumbSize[2];
146 int32_t jpegQuality, jpegThumbQuality;
147 int32_t jpegRotation;
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700148
149 bool gpsEnabled;
Eino-Ville Talvala11b7cde2012-06-15 12:37:35 -0700150 double gpsCoordinates[3];
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700151 int64_t gpsTimestamp;
152 String8 gpsProcessingMethod;
153
Eino-Ville Talvalacab96a42012-08-24 11:29:22 -0700154 uint8_t wbMode;
155 uint8_t effectMode;
156 uint8_t antibandingMode;
157 uint8_t sceneMode;
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700158
159 enum flashMode_t {
160 FLASH_MODE_OFF = 0,
161 FLASH_MODE_AUTO,
162 FLASH_MODE_ON,
163 FLASH_MODE_TORCH,
164 FLASH_MODE_RED_EYE = ANDROID_CONTROL_AE_ON_AUTO_FLASH_REDEYE,
165 FLASH_MODE_INVALID = -1
166 } flashMode;
167
168 enum focusMode_t {
169 FOCUS_MODE_AUTO = ANDROID_CONTROL_AF_AUTO,
170 FOCUS_MODE_MACRO = ANDROID_CONTROL_AF_MACRO,
171 FOCUS_MODE_CONTINUOUS_VIDEO = ANDROID_CONTROL_AF_CONTINUOUS_VIDEO,
172 FOCUS_MODE_CONTINUOUS_PICTURE =
173 ANDROID_CONTROL_AF_CONTINUOUS_PICTURE,
174 FOCUS_MODE_EDOF = ANDROID_CONTROL_AF_EDOF,
175 FOCUS_MODE_INFINITY,
176 FOCUS_MODE_FIXED,
177 FOCUS_MODE_INVALID = -1
178 } focusMode;
179
180 struct Area {
181 int left, top, right, bottom;
182 int weight;
183 Area() {}
184 Area(int left, int top, int right, int bottom, int weight):
185 left(left), top(top), right(right), bottom(bottom),
186 weight(weight) {}
187 };
188 Vector<Area> focusingAreas;
189
Eino-Ville Talvala11b7cde2012-06-15 12:37:35 -0700190 int32_t exposureCompensation;
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700191 bool autoExposureLock;
192 bool autoWhiteBalanceLock;
193
194 Vector<Area> meteringAreas;
195
196 int zoom;
197
198 int videoWidth, videoHeight;
199
200 bool recordingHint;
201 bool videoStabilization;
Eino-Ville Talvala78822d72012-07-18 17:52:18 -0700202
Eino-Ville Talvala836b81f2012-07-27 11:35:21 -0700203 String8 paramsFlattened;
Eino-Ville Talvala36cdfb12012-08-02 17:34:15 -0700204
205 // These parameters are also part of the camera API-visible state, but not directly
206 // listed in Camera.Parameters
207 bool storeMetadataInBuffers;
208 bool playShutterSound;
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700209 bool enableFaceDetect;
Eino-Ville Talvala174181e2012-08-03 13:53:39 -0700210
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700211 bool enableFocusMoveMessages;
Eino-Ville Talvala174181e2012-08-03 13:53:39 -0700212 int afTriggerCounter;
213 int currentAfTriggerId;
214 bool afInMotion;
Eino-Ville Talvala228a5382012-08-13 12:16:06 -0700215
216 uint32_t previewCallbackFlags;
217 bool previewCallbackOneShot;
218
219 // Overall camera state
220 State state;
Eino-Ville Talvala836b81f2012-07-27 11:35:21 -0700221 };
222
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700223 // This class encapsulates the Parameters class so that it can only be accessed
224 // by constructing a Key object, which locks the LockedParameter's mutex.
Eino-Ville Talvala836b81f2012-07-27 11:35:21 -0700225 class LockedParameters {
226 public:
227 class Key {
228 public:
229 Key(LockedParameters &p):
230 mParameters(p.mParameters),
231 mLockedParameters(p) {
232 mLockedParameters.mLock.lock();
233 }
234
235 ~Key() {
236 mLockedParameters.mLock.unlock();
237 }
238 Parameters &mParameters;
239 private:
240 // Disallow copying, default construction
241 Key();
242 Key(const Key &);
243 Key &operator=(const Key &);
244 LockedParameters &mLockedParameters;
245 };
246 class ReadKey {
247 public:
248 ReadKey(const LockedParameters &p):
249 mParameters(p.mParameters),
250 mLockedParameters(p) {
251 mLockedParameters.mLock.lock();
252 }
253
254 ~ReadKey() {
255 mLockedParameters.mLock.unlock();
256 }
257 const Parameters &mParameters;
258 private:
259 // Disallow copying, default construction
260 ReadKey();
261 ReadKey(const ReadKey &);
262 ReadKey &operator=(const ReadKey &);
263 const LockedParameters &mLockedParameters;
264 };
265
266 // Only use for dumping or other debugging
267 const Parameters &unsafeUnlock() {
268 return mParameters;
269 }
270 private:
271 Parameters mParameters;
272 mutable Mutex mLock;
273
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700274 } mParameters;
275
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700276 // Static device information; this is a subset of the information
277 // available through the staticInfo() method, used for frequently-accessed
278 // values or values that have to be calculated from the static information.
279 struct DeviceInfo {
280 int32_t arrayWidth;
281 int32_t arrayHeight;
282 uint8_t bestFaceDetectMode;
283 int32_t maxFaces;
284 };
285 const DeviceInfo *mDeviceInfo;
286
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700287 /** Camera device-related private members */
288
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700289 class Camera2Heap;
290
Eino-Ville Talvala228a5382012-08-13 12:16:06 -0700291 void setPreviewCallbackFlagL(Parameters &params, int flag);
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700292 status_t updateRequests(const Parameters &params);
293
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700294 // Number of zoom steps to simulate
295 static const unsigned int NUM_ZOOM_STEPS = 10;
296 // Used with stream IDs
297 static const int NO_STREAM = -1;
298
Eino-Ville Talvalac8474b62012-08-24 16:30:44 -0700299 /* Output frame metadata processing thread. This thread waits for new
300 * frames from the device, and analyzes them as necessary.
301 */
302 class FrameProcessor: public Thread {
303 public:
304 FrameProcessor(wp<Camera2Client> client);
305 ~FrameProcessor();
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700306
Eino-Ville Talvalac8474b62012-08-24 16:30:44 -0700307 void dump(int fd, const Vector<String16>& args);
308 private:
309 static const nsecs_t kWaitDuration = 10000000; // 10 ms
310 wp<Camera2Client> mClient;
311
312 virtual bool threadLoop();
313
314 void processNewFrames(sp<Camera2Client> &client);
315 status_t processFaceDetect(const CameraMetadata &frame,
316 sp<Camera2Client> &client);
317
318 CameraMetadata mLastFrame;
319 };
320
321 sp<FrameProcessor> mFrameProcessor;
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700322
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700323 /* Preview related members */
324
325 int mPreviewStreamId;
Eino-Ville Talvalacab96a42012-08-24 11:29:22 -0700326 CameraMetadata mPreviewRequest;
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700327 sp<IBinder> mPreviewSurface;
328 sp<ANativeWindow> mPreviewWindow;
Eino-Ville Talvala836b81f2012-07-27 11:35:21 -0700329
330 status_t updatePreviewRequest(const Parameters &params);
331 status_t updatePreviewStream(const Parameters &params);
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700332
Eino-Ville Talvala228a5382012-08-13 12:16:06 -0700333 /** Preview callback related members */
334
335 int mCallbackStreamId;
336 static const size_t kCallbackHeapCount = 6;
337 sp<CpuConsumer> mCallbackConsumer;
338 sp<ANativeWindow> mCallbackWindow;
339 // Simple listener that forwards frame available notifications from
340 // a CPU consumer to the callback notification
341 class CallbackWaiter: public CpuConsumer::FrameAvailableListener {
342 public:
343 CallbackWaiter(Camera2Client *parent) : mParent(parent) {}
344 void onFrameAvailable() { mParent->onCallbackAvailable(); }
345 private:
346 Camera2Client *mParent;
347 };
348 sp<CallbackWaiter> mCallbackWaiter;
349 sp<Camera2Heap> mCallbackHeap;
350 int mCallbackHeapId;
351 size_t mCallbackHeapHead, mCallbackHeapFree;
352 // Handle callback image buffers
353 void onCallbackAvailable();
354
355 status_t updateCallbackStream(const Parameters &params);
356
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700357 /* Still image capture related members */
358
359 int mCaptureStreamId;
360 sp<CpuConsumer> mCaptureConsumer;
361 sp<ANativeWindow> mCaptureWindow;
Eino-Ville Talvalad4bcfde2012-06-07 17:12:38 -0700362 // Simple listener that forwards frame available notifications from
363 // a CPU consumer to the capture notification
364 class CaptureWaiter: public CpuConsumer::FrameAvailableListener {
365 public:
366 CaptureWaiter(Camera2Client *parent) : mParent(parent) {}
367 void onFrameAvailable() { mParent->onCaptureAvailable(); }
368 private:
369 Camera2Client *mParent;
370 };
Eino-Ville Talvalad4bcfde2012-06-07 17:12:38 -0700371 sp<CaptureWaiter> mCaptureWaiter;
Eino-Ville Talvalacab96a42012-08-24 11:29:22 -0700372 CameraMetadata mCaptureRequest;
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700373 sp<Camera2Heap> mCaptureHeap;
374 // Handle captured image buffers
375 void onCaptureAvailable();
Eino-Ville Talvala836b81f2012-07-27 11:35:21 -0700376
377 status_t updateCaptureRequest(const Parameters &params);
378 status_t updateCaptureStream(const Parameters &params);
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700379
380 /* Recording related members */
381
382 int mRecordingStreamId;
Eino-Ville Talvala228a5382012-08-13 12:16:06 -0700383 int mRecordingFrameCount;
Eino-Ville Talvala30e65e72012-08-21 13:30:45 -0700384 sp<BufferItemConsumer> mRecordingConsumer;
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700385 sp<ANativeWindow> mRecordingWindow;
386 // Simple listener that forwards frame available notifications from
387 // a CPU consumer to the recording notification
Eino-Ville Talvala30e65e72012-08-21 13:30:45 -0700388 class RecordingWaiter: public BufferItemConsumer::FrameAvailableListener {
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700389 public:
390 RecordingWaiter(Camera2Client *parent) : mParent(parent) {}
391 void onFrameAvailable() { mParent->onRecordingFrameAvailable(); }
392 private:
393 Camera2Client *mParent;
394 };
395 sp<RecordingWaiter> mRecordingWaiter;
Eino-Ville Talvalacab96a42012-08-24 11:29:22 -0700396 CameraMetadata mRecordingRequest;
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700397 sp<Camera2Heap> mRecordingHeap;
398
James Dong983cf232012-08-01 16:39:55 -0700399 static const size_t kDefaultRecordingHeapCount = 8;
400 size_t mRecordingHeapCount;
Eino-Ville Talvala30e65e72012-08-21 13:30:45 -0700401 Vector<BufferItemConsumer::BufferItem> mRecordingBuffers;
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700402 size_t mRecordingHeapHead, mRecordingHeapFree;
403 // Handle new recording image buffers
404 void onRecordingFrameAvailable();
Eino-Ville Talvala836b81f2012-07-27 11:35:21 -0700405
406 status_t updateRecordingRequest(const Parameters &params);
407 status_t updateRecordingStream(const Parameters &params);
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700408
Eino-Ville Talvala174181e2012-08-03 13:53:39 -0700409 /** Notification-related members */
410
411 bool mAfInMotion;
412
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700413 /** Camera2Device instance wrapping HAL2 entry */
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700414
415 sp<Camera2Device> mDevice;
416
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700417 /** Utility members */
418
Eino-Ville Talvala3a609142012-07-31 14:36:26 -0700419 // Verify that caller is the owner of the camera
420 status_t checkPid(const char *checkLocation) const;
421
Eino-Ville Talvala9cca4c62012-06-15 15:41:44 -0700422 // Utility class for managing a set of IMemory blocks
423 class Camera2Heap : public RefBase {
424 public:
425 Camera2Heap(size_t buf_size, uint_t num_buffers = 1,
426 const char *name = NULL) :
427 mBufSize(buf_size),
428 mNumBufs(num_buffers) {
429 mHeap = new MemoryHeapBase(buf_size * num_buffers, 0, name);
430 mBuffers = new sp<MemoryBase>[mNumBufs];
431 for (uint_t i = 0; i < mNumBufs; i++)
432 mBuffers[i] = new MemoryBase(mHeap,
433 i * mBufSize,
434 mBufSize);
435 }
436
437 virtual ~Camera2Heap()
438 {
439 delete [] mBuffers;
440 }
441
442 size_t mBufSize;
443 uint_t mNumBufs;
444 sp<MemoryHeapBase> mHeap;
445 sp<MemoryBase> *mBuffers;
446 };
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700447
448 // Get values for static camera info entry. min/maxCount are used for error
449 // checking the number of values in the entry. 0 for max/minCount means to
450 // do no bounds check in that direction. In case of error, the entry data
451 // pointer is null and the count is 0.
Eino-Ville Talvalacab96a42012-08-24 11:29:22 -0700452 camera_metadata_ro_entry_t staticInfo(uint32_t tag,
453 size_t minCount=0, size_t maxCount=0) const;
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700454
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700455 // Extract frequently-used camera static information into mDeviceInfo
456 status_t buildDeviceInfo();
Eino-Ville Talvalaf69c70d2012-05-20 15:59:14 -0700457 // Convert static camera info from a camera2 device to the
458 // old API parameter map.
459 status_t buildDefaultParameters();
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -0700460
Eino-Ville Talvalabe0573b2012-06-15 12:42:30 -0700461 // Update parameters all requests use, based on mParameters
Eino-Ville Talvalacab96a42012-08-24 11:29:22 -0700462 status_t updateRequestCommon(CameraMetadata *request, const Parameters &params);
Eino-Ville Talvalabe0573b2012-06-15 12:42:30 -0700463
Eino-Ville Talvala30e65e72012-08-21 13:30:45 -0700464 // Map from sensor active array pixel coordinates to normalized camera
465 // parameter coordinates. The former are (0,0)-(array width - 1, array height
466 // - 1), the latter from (-1000,-1000)-(1000,1000)
Eino-Ville Talvala8ce89d92012-08-10 08:40:26 -0700467 int arrayXToNormalized(int width) const;
468 int arrayYToNormalized(int height) const;
469
Eino-Ville Talvala6861a4e2012-06-07 10:32:12 -0700470 // Convert camera1 preview format string to camera2 enum
471 static int formatStringToEnum(const char *format);
Eino-Ville Talvala3cca1362012-06-07 10:07:18 -0700472 static const char *formatEnumToString(int format);
Eino-Ville Talvala6861a4e2012-06-07 10:32:12 -0700473
474 static int wbModeStringToEnum(const char *wbMode);
475 static int effectModeStringToEnum(const char *effectMode);
476 static int abModeStringToEnum(const char *abMode);
477 static int sceneModeStringToEnum(const char *sceneMode);
478 static Parameters::flashMode_t flashModeStringToEnum(const char *flashMode);
479 static Parameters::focusMode_t focusModeStringToEnum(const char *focusMode);
480 static status_t parseAreas(const char *areasCStr,
481 Vector<Parameters::Area> *areas);
482 static status_t validateAreas(const Vector<Parameters::Area> &areas,
483 size_t maxRegions);
484 static bool boolFromString(const char *boolStr);
Eino-Ville Talvalac94cd192012-06-15 12:47:42 -0700485
486 // Map from camera orientation + facing to gralloc transform enum
487 static int degToTransform(int degrees, bool mirror);
Eino-Ville Talvala160d4af2012-08-03 09:40:16 -0700488
Eino-Ville Talvala228a5382012-08-13 12:16:06 -0700489 static size_t calculateBufferSize(int width, int height,
490 int format, int stride);
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -0700491};
492
493}; // namespace android
494
495#endif