blob: 833ba76d6375e0c70fdd2e73aa18a3294aa3bf5c [file] [log] [blame]
Eino-Ville Talvalac2d64272012-05-15 15:38:27 -07001/*
2 * Copyright (C) 2008 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_HARDWARE_CAMERA_PARAMETERS_H
18#define ANDROID_HARDWARE_CAMERA_PARAMETERS_H
19
20#include <utils/KeyedVector.h>
Igor Murashkin9078a1b2014-03-18 18:15:23 -070021#include <utils/Vector.h>
Eino-Ville Talvalac2d64272012-05-15 15:38:27 -070022#include <utils/String8.h>
23
24namespace android {
25
26struct Size {
27 int width;
28 int height;
29
30 Size() {
31 width = 0;
32 height = 0;
33 }
34
35 Size(int w, int h) {
36 width = w;
37 height = h;
38 }
39};
40
41class CameraParameters
42{
43public:
44 CameraParameters();
45 CameraParameters(const String8 &params) { unflatten(params); }
46 ~CameraParameters();
47
48 String8 flatten() const;
49 void unflatten(const String8 &params);
50
51 void set(const char *key, const char *value);
52 void set(const char *key, int value);
53 void setFloat(const char *key, float value);
Igor Murashkin9078a1b2014-03-18 18:15:23 -070054 // Look up string value by key.
55 // -- The string remains valid until the next set/remove of the same key,
56 // or until the map gets cleared.
Eino-Ville Talvalac2d64272012-05-15 15:38:27 -070057 const char *get(const char *key) const;
58 int getInt(const char *key) const;
59 float getFloat(const char *key) const;
60
Igor Murashkin9078a1b2014-03-18 18:15:23 -070061 // Compare the order that key1 was set vs the order that key2 was set.
62 //
63 // Sets the order parameter to an integer less than, equal to, or greater
64 // than zero if key1's set order was respectively, to be less than, to
65 // match, or to be greater than key2's set order.
66 //
67 // Error codes:
68 // * NAME_NOT_FOUND - if either key has not been set previously
69 // * BAD_VALUE - if any of the parameters are NULL
70 status_t compareSetOrder(const char *key1, const char *key2,
71 /*out*/
72 int *order) const;
73
Eino-Ville Talvalac2d64272012-05-15 15:38:27 -070074 void remove(const char *key);
75
76 void setPreviewSize(int width, int height);
77 void getPreviewSize(int *width, int *height) const;
78 void getSupportedPreviewSizes(Vector<Size> &sizes) const;
79
80 // Set the dimensions in pixels to the given width and height
81 // for video frames. The given width and height must be one
82 // of the supported dimensions returned from
83 // getSupportedVideoSizes(). Must not be called if
84 // getSupportedVideoSizes() returns an empty Vector of Size.
85 void setVideoSize(int width, int height);
86 // Retrieve the current dimensions (width and height)
87 // in pixels for video frames, which must be one of the
88 // supported dimensions returned from getSupportedVideoSizes().
89 // Must not be called if getSupportedVideoSizes() returns an
90 // empty Vector of Size.
91 void getVideoSize(int *width, int *height) const;
92 // Retrieve a Vector of supported dimensions (width and height)
93 // in pixels for video frames. If sizes returned from the method
94 // is empty, the camera does not support calls to setVideoSize()
95 // or getVideoSize(). In adddition, it also indicates that
96 // the camera only has a single output, and does not have
97 // separate output for video frames and preview frame.
98 void getSupportedVideoSizes(Vector<Size> &sizes) const;
99 // Retrieve the preferred preview size (width and height) in pixels
100 // for video recording. The given width and height must be one of
101 // supported preview sizes returned from getSupportedPreviewSizes().
102 // Must not be called if getSupportedVideoSizes() returns an empty
103 // Vector of Size. If getSupportedVideoSizes() returns an empty
104 // Vector of Size, the width and height returned from this method
105 // is invalid, and is "-1x-1".
106 void getPreferredPreviewSizeForVideo(int *width, int *height) const;
107
108 void setPreviewFrameRate(int fps);
109 int getPreviewFrameRate() const;
110 void getPreviewFpsRange(int *min_fps, int *max_fps) const;
Igor Murashkin9078a1b2014-03-18 18:15:23 -0700111 void setPreviewFpsRange(int min_fps, int max_fps);
Eino-Ville Talvalac2d64272012-05-15 15:38:27 -0700112 void setPreviewFormat(const char *format);
113 const char *getPreviewFormat() const;
114 void setPictureSize(int width, int height);
115 void getPictureSize(int *width, int *height) const;
116 void getSupportedPictureSizes(Vector<Size> &sizes) const;
117 void setPictureFormat(const char *format);
118 const char *getPictureFormat() const;
119
120 void dump() const;
121 status_t dump(int fd, const Vector<String16>& args) const;
122
123 // Parameter keys to communicate between camera application and driver.
124 // The access (read/write, read only, or write only) is viewed from the
125 // perspective of applications, not driver.
126
127 // Preview frame size in pixels (width x height).
128 // Example value: "480x320". Read/Write.
129 static const char KEY_PREVIEW_SIZE[];
130 // Supported preview frame sizes in pixels.
131 // Example value: "800x600,480x320". Read only.
132 static const char KEY_SUPPORTED_PREVIEW_SIZES[];
133 // The current minimum and maximum preview fps. This controls the rate of
134 // preview frames received (CAMERA_MSG_PREVIEW_FRAME). The minimum and
135 // maximum fps must be one of the elements from
136 // KEY_SUPPORTED_PREVIEW_FPS_RANGE parameter.
137 // Example value: "10500,26623"
138 static const char KEY_PREVIEW_FPS_RANGE[];
139 // The supported preview fps (frame-per-second) ranges. Each range contains
140 // a minimum fps and maximum fps. If minimum fps equals to maximum fps, the
141 // camera outputs frames in fixed frame rate. If not, the camera outputs
142 // frames in auto frame rate. The actual frame rate fluctuates between the
143 // minimum and the maximum. The list has at least one element. The list is
144 // sorted from small to large (first by maximum fps and then minimum fps).
145 // Example value: "(10500,26623),(15000,26623),(30000,30000)"
146 static const char KEY_SUPPORTED_PREVIEW_FPS_RANGE[];
147 // The image format for preview frames. See CAMERA_MSG_PREVIEW_FRAME in
148 // frameworks/av/include/camera/Camera.h. The default is
149 // PIXEL_FORMAT_YUV420SP. Example value: "yuv420sp" or PIXEL_FORMAT_XXX
150 // constants. Read/write.
151 static const char KEY_PREVIEW_FORMAT[];
152 // Supported image formats for preview frames.
153 // Example value: "yuv420sp,yuv422i-yuyv". Read only.
154 static const char KEY_SUPPORTED_PREVIEW_FORMATS[];
155 // Number of preview frames per second. This is the target frame rate. The
156 // actual frame rate depends on the driver.
157 // Example value: "15". Read/write.
158 static const char KEY_PREVIEW_FRAME_RATE[];
159 // Supported number of preview frames per second.
160 // Example value: "24,15,10". Read.
161 static const char KEY_SUPPORTED_PREVIEW_FRAME_RATES[];
162 // The dimensions for captured pictures in pixels (width x height).
163 // Example value: "1024x768". Read/write.
164 static const char KEY_PICTURE_SIZE[];
165 // Supported dimensions for captured pictures in pixels.
166 // Example value: "2048x1536,1024x768". Read only.
167 static const char KEY_SUPPORTED_PICTURE_SIZES[];
168 // The image format for captured pictures. See CAMERA_MSG_COMPRESSED_IMAGE
169 // in frameworks/base/include/camera/Camera.h.
170 // Example value: "jpeg" or PIXEL_FORMAT_XXX constants. Read/write.
171 static const char KEY_PICTURE_FORMAT[];
172 // Supported image formats for captured pictures.
173 // Example value: "jpeg,rgb565". Read only.
174 static const char KEY_SUPPORTED_PICTURE_FORMATS[];
175 // The width (in pixels) of EXIF thumbnail in Jpeg picture.
176 // Example value: "512". Read/write.
177 static const char KEY_JPEG_THUMBNAIL_WIDTH[];
178 // The height (in pixels) of EXIF thumbnail in Jpeg picture.
179 // Example value: "384". Read/write.
180 static const char KEY_JPEG_THUMBNAIL_HEIGHT[];
181 // Supported EXIF thumbnail sizes (width x height). 0x0 means not thumbnail
182 // in EXIF.
183 // Example value: "512x384,320x240,0x0". Read only.
184 static const char KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES[];
185 // The quality of the EXIF thumbnail in Jpeg picture. The range is 1 to 100,
186 // with 100 being the best.
187 // Example value: "90". Read/write.
188 static const char KEY_JPEG_THUMBNAIL_QUALITY[];
189 // Jpeg quality of captured picture. The range is 1 to 100, with 100 being
190 // the best.
191 // Example value: "90". Read/write.
192 static const char KEY_JPEG_QUALITY[];
193 // The rotation angle in degrees relative to the orientation of the camera.
194 // This affects the pictures returned from CAMERA_MSG_COMPRESSED_IMAGE. The
195 // camera driver may set orientation in the EXIF header without rotating the
196 // picture. Or the driver may rotate the picture and the EXIF thumbnail. If
197 // the Jpeg picture is rotated, the orientation in the EXIF header will be
198 // missing or 1 (row #0 is top and column #0 is left side).
199 //
200 // Note that the JPEG pictures of front-facing cameras are not mirrored
201 // as in preview display.
202 //
203 // For example, suppose the natural orientation of the device is portrait.
204 // The device is rotated 270 degrees clockwise, so the device orientation is
205 // 270. Suppose a back-facing camera sensor is mounted in landscape and the
206 // top side of the camera sensor is aligned with the right edge of the
207 // display in natural orientation. So the camera orientation is 90. The
208 // rotation should be set to 0 (270 + 90).
209 //
210 // Example value: "0" or "90" or "180" or "270". Write only.
211 static const char KEY_ROTATION[];
212 // GPS latitude coordinate. GPSLatitude and GPSLatitudeRef will be stored in
213 // JPEG EXIF header.
214 // Example value: "25.032146" or "-33.462809". Write only.
215 static const char KEY_GPS_LATITUDE[];
216 // GPS longitude coordinate. GPSLongitude and GPSLongitudeRef will be stored
217 // in JPEG EXIF header.
218 // Example value: "121.564448" or "-70.660286". Write only.
219 static const char KEY_GPS_LONGITUDE[];
220 // GPS altitude. GPSAltitude and GPSAltitudeRef will be stored in JPEG EXIF
221 // header.
222 // Example value: "21.0" or "-5". Write only.
223 static const char KEY_GPS_ALTITUDE[];
224 // GPS timestamp (UTC in seconds since January 1, 1970). This should be
225 // stored in JPEG EXIF header.
226 // Example value: "1251192757". Write only.
227 static const char KEY_GPS_TIMESTAMP[];
228 // GPS Processing Method
229 // Example value: "GPS" or "NETWORK". Write only.
230 static const char KEY_GPS_PROCESSING_METHOD[];
231 // Current white balance setting.
232 // Example value: "auto" or WHITE_BALANCE_XXX constants. Read/write.
233 static const char KEY_WHITE_BALANCE[];
234 // Supported white balance settings.
235 // Example value: "auto,incandescent,daylight". Read only.
236 static const char KEY_SUPPORTED_WHITE_BALANCE[];
237 // Current color effect setting.
238 // Example value: "none" or EFFECT_XXX constants. Read/write.
239 static const char KEY_EFFECT[];
240 // Supported color effect settings.
241 // Example value: "none,mono,sepia". Read only.
242 static const char KEY_SUPPORTED_EFFECTS[];
243 // Current antibanding setting.
244 // Example value: "auto" or ANTIBANDING_XXX constants. Read/write.
245 static const char KEY_ANTIBANDING[];
246 // Supported antibanding settings.
247 // Example value: "auto,50hz,60hz,off". Read only.
248 static const char KEY_SUPPORTED_ANTIBANDING[];
249 // Current scene mode.
250 // Example value: "auto" or SCENE_MODE_XXX constants. Read/write.
251 static const char KEY_SCENE_MODE[];
252 // Supported scene mode settings.
253 // Example value: "auto,night,fireworks". Read only.
254 static const char KEY_SUPPORTED_SCENE_MODES[];
255 // Current flash mode.
256 // Example value: "auto" or FLASH_MODE_XXX constants. Read/write.
257 static const char KEY_FLASH_MODE[];
258 // Supported flash modes.
259 // Example value: "auto,on,off". Read only.
260 static const char KEY_SUPPORTED_FLASH_MODES[];
261 // Current focus mode. This will not be empty. Applications should call
262 // CameraHardwareInterface.autoFocus to start the focus if focus mode is
263 // FOCUS_MODE_AUTO or FOCUS_MODE_MACRO.
264 // Example value: "auto" or FOCUS_MODE_XXX constants. Read/write.
265 static const char KEY_FOCUS_MODE[];
266 // Supported focus modes.
267 // Example value: "auto,macro,fixed". Read only.
268 static const char KEY_SUPPORTED_FOCUS_MODES[];
269 // The maximum number of focus areas supported. This is the maximum length
270 // of KEY_FOCUS_AREAS.
271 // Example value: "0" or "2". Read only.
272 static const char KEY_MAX_NUM_FOCUS_AREAS[];
273 // Current focus areas.
274 //
275 // Before accessing this parameter, apps should check
276 // KEY_MAX_NUM_FOCUS_AREAS first to know the maximum number of focus areas
277 // first. If the value is 0, focus area is not supported.
278 //
279 // Each focus area is a five-element int array. The first four elements are
280 // the rectangle of the area (left, top, right, bottom). The direction is
281 // relative to the sensor orientation, that is, what the sensor sees. The
282 // direction is not affected by the rotation or mirroring of
283 // CAMERA_CMD_SET_DISPLAY_ORIENTATION. Coordinates range from -1000 to 1000.
284 // (-1000,-1000) is the upper left point. (1000, 1000) is the lower right
285 // point. The width and height of focus areas cannot be 0 or negative.
286 //
287 // The fifth element is the weight. Values for weight must range from 1 to
288 // 1000. The weight should be interpreted as a per-pixel weight - all
289 // pixels in the area have the specified weight. This means a small area
290 // with the same weight as a larger area will have less influence on the
291 // focusing than the larger area. Focus areas can partially overlap and the
292 // driver will add the weights in the overlap region.
293 //
294 // A special case of single focus area (0,0,0,0,0) means driver to decide
295 // the focus area. For example, the driver may use more signals to decide
296 // focus areas and change them dynamically. Apps can set (0,0,0,0,0) if they
297 // want the driver to decide focus areas.
298 //
299 // Focus areas are relative to the current field of view (KEY_ZOOM). No
300 // matter what the zoom level is, (-1000,-1000) represents the top of the
301 // currently visible camera frame. The focus area cannot be set to be
302 // outside the current field of view, even when using zoom.
303 //
304 // Focus area only has effect if the current focus mode is FOCUS_MODE_AUTO,
305 // FOCUS_MODE_MACRO, FOCUS_MODE_CONTINUOUS_VIDEO, or
306 // FOCUS_MODE_CONTINUOUS_PICTURE.
307 // Example value: "(-10,-10,0,0,300),(0,0,10,10,700)". Read/write.
308 static const char KEY_FOCUS_AREAS[];
309 // Focal length in millimeter.
310 // Example value: "4.31". Read only.
311 static const char KEY_FOCAL_LENGTH[];
312 // Horizontal angle of view in degrees.
313 // Example value: "54.8". Read only.
314 static const char KEY_HORIZONTAL_VIEW_ANGLE[];
315 // Vertical angle of view in degrees.
316 // Example value: "42.5". Read only.
317 static const char KEY_VERTICAL_VIEW_ANGLE[];
318 // Exposure compensation index. 0 means exposure is not adjusted.
James Paintere5382062012-09-05 18:02:32 -0700319 // Example value: "-5" or "5". Read/write.
Eino-Ville Talvalac2d64272012-05-15 15:38:27 -0700320 static const char KEY_EXPOSURE_COMPENSATION[];
321 // The maximum exposure compensation index (>=0).
322 // Example value: "6". Read only.
323 static const char KEY_MAX_EXPOSURE_COMPENSATION[];
324 // The minimum exposure compensation index (<=0).
325 // Example value: "-6". Read only.
326 static const char KEY_MIN_EXPOSURE_COMPENSATION[];
327 // The exposure compensation step. Exposure compensation index multiply by
James Paintere5382062012-09-05 18:02:32 -0700328 // step eqals to EV. Ex: if exposure compensation index is -6 and step is
Eino-Ville Talvalac2d64272012-05-15 15:38:27 -0700329 // 0.3333, EV is -2.
330 // Example value: "0.333333333" or "0.5". Read only.
331 static const char KEY_EXPOSURE_COMPENSATION_STEP[];
332 // The state of the auto-exposure lock. "true" means that
333 // auto-exposure is locked to its current value and will not
334 // change. "false" means the auto-exposure routine is free to
335 // change exposure values. If auto-exposure is already locked,
336 // setting this to true again has no effect (the driver will not
337 // recalculate exposure values). Changing exposure compensation
338 // settings will still affect the exposure settings while
339 // auto-exposure is locked. Stopping preview or taking a still
340 // image will not change the lock. In conjunction with
341 // exposure compensation, this allows for capturing multi-exposure
342 // brackets with known relative exposure values. Locking
343 // auto-exposure after open but before the first call to
344 // startPreview may result in severely over- or under-exposed
345 // images. The driver will not change the AE lock after
346 // auto-focus completes.
347 static const char KEY_AUTO_EXPOSURE_LOCK[];
348 // Whether locking the auto-exposure is supported. "true" means it is, and
349 // "false" or this key not existing means it is not supported.
350 static const char KEY_AUTO_EXPOSURE_LOCK_SUPPORTED[];
351 // The state of the auto-white balance lock. "true" means that
352 // auto-white balance is locked to its current value and will not
353 // change. "false" means the auto-white balance routine is free to
354 // change white balance values. If auto-white balance is already
355 // locked, setting this to true again has no effect (the driver
356 // will not recalculate white balance values). Stopping preview or
357 // taking a still image will not change the lock. In conjunction
358 // with exposure compensation, this allows for capturing
359 // multi-exposure brackets with fixed white balance. Locking
360 // auto-white balance after open but before the first call to
361 // startPreview may result in severely incorrect color. The
362 // driver will not change the AWB lock after auto-focus
363 // completes.
364 static const char KEY_AUTO_WHITEBALANCE_LOCK[];
365 // Whether locking the auto-white balance is supported. "true"
366 // means it is, and "false" or this key not existing means it is
367 // not supported.
368 static const char KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED[];
369
370 // The maximum number of metering areas supported. This is the maximum
371 // length of KEY_METERING_AREAS.
372 // Example value: "0" or "2". Read only.
373 static const char KEY_MAX_NUM_METERING_AREAS[];
374 // Current metering areas. Camera driver uses these areas to decide
375 // exposure.
376 //
377 // Before accessing this parameter, apps should check
378 // KEY_MAX_NUM_METERING_AREAS first to know the maximum number of metering
379 // areas first. If the value is 0, metering area is not supported.
380 //
381 // Each metering area is a rectangle with specified weight. The direction is
382 // relative to the sensor orientation, that is, what the sensor sees. The
383 // direction is not affected by the rotation or mirroring of
384 // CAMERA_CMD_SET_DISPLAY_ORIENTATION. Coordinates of the rectangle range
385 // from -1000 to 1000. (-1000, -1000) is the upper left point. (1000, 1000)
386 // is the lower right point. The width and height of metering areas cannot
387 // be 0 or negative.
388 //
389 // The fifth element is the weight. Values for weight must range from 1 to
390 // 1000. The weight should be interpreted as a per-pixel weight - all
391 // pixels in the area have the specified weight. This means a small area
392 // with the same weight as a larger area will have less influence on the
393 // metering than the larger area. Metering areas can partially overlap and
394 // the driver will add the weights in the overlap region.
395 //
396 // A special case of all-zero single metering area means driver to decide
397 // the metering area. For example, the driver may use more signals to decide
398 // metering areas and change them dynamically. Apps can set all-zero if they
399 // want the driver to decide metering areas.
400 //
401 // Metering areas are relative to the current field of view (KEY_ZOOM).
402 // No matter what the zoom level is, (-1000,-1000) represents the top of the
403 // currently visible camera frame. The metering area cannot be set to be
404 // outside the current field of view, even when using zoom.
405 //
406 // No matter what metering areas are, the final exposure are compensated
407 // by KEY_EXPOSURE_COMPENSATION.
408 // Example value: "(-10,-10,0,0,300),(0,0,10,10,700)". Read/write.
409 static const char KEY_METERING_AREAS[];
410 // Current zoom value.
411 // Example value: "0" or "6". Read/write.
412 static const char KEY_ZOOM[];
413 // Maximum zoom value.
414 // Example value: "6". Read only.
415 static const char KEY_MAX_ZOOM[];
416 // The zoom ratios of all zoom values. The zoom ratio is in 1/100
417 // increments. Ex: a zoom of 3.2x is returned as 320. The number of list
418 // elements is KEY_MAX_ZOOM + 1. The first element is always 100. The last
419 // element is the zoom ratio of zoom value KEY_MAX_ZOOM.
420 // Example value: "100,150,200,250,300,350,400". Read only.
421 static const char KEY_ZOOM_RATIOS[];
422 // Whether zoom is supported. Zoom is supported if the value is "true". Zoom
423 // is not supported if the value is not "true" or the key does not exist.
424 // Example value: "true". Read only.
425 static const char KEY_ZOOM_SUPPORTED[];
426 // Whether if smooth zoom is supported. Smooth zoom is supported if the
427 // value is "true". It is not supported if the value is not "true" or the
428 // key does not exist.
429 // See CAMERA_CMD_START_SMOOTH_ZOOM, CAMERA_CMD_STOP_SMOOTH_ZOOM, and
430 // CAMERA_MSG_ZOOM in frameworks/base/include/camera/Camera.h.
431 // Example value: "true". Read only.
432 static const char KEY_SMOOTH_ZOOM_SUPPORTED[];
433
434 // The distances (in meters) from the camera to where an object appears to
435 // be in focus. The object is sharpest at the optimal focus distance. The
436 // depth of field is the far focus distance minus near focus distance.
437 //
438 // Focus distances may change after starting auto focus, canceling auto
439 // focus, or starting the preview. Applications can read this anytime to get
440 // the latest focus distances. If the focus mode is FOCUS_MODE_CONTINUOUS,
441 // focus distances may change from time to time.
442 //
443 // This is intended to estimate the distance between the camera and the
444 // subject. After autofocus, the subject distance may be within near and far
445 // focus distance. However, the precision depends on the camera hardware,
446 // autofocus algorithm, the focus area, and the scene. The error can be
447 // large and it should be only used as a reference.
448 //
449 // Far focus distance > optimal focus distance > near focus distance. If
450 // the far focus distance is infinity, the value should be "Infinity" (case
451 // sensitive). The format is three float values separated by commas. The
452 // first is near focus distance. The second is optimal focus distance. The
453 // third is far focus distance.
454 // Example value: "0.95,1.9,Infinity" or "0.049,0.05,0.051". Read only.
455 static const char KEY_FOCUS_DISTANCES[];
456
457 // The current dimensions in pixels (width x height) for video frames.
458 // The width and height must be one of the supported sizes retrieved
459 // via KEY_SUPPORTED_VIDEO_SIZES.
460 // Example value: "1280x720". Read/write.
461 static const char KEY_VIDEO_SIZE[];
462 // A list of the supported dimensions in pixels (width x height)
463 // for video frames. See CAMERA_MSG_VIDEO_FRAME for details in
464 // frameworks/base/include/camera/Camera.h.
465 // Example: "176x144,1280x720". Read only.
466 static const char KEY_SUPPORTED_VIDEO_SIZES[];
467
468 // The maximum number of detected faces supported by hardware face
469 // detection. If the value is 0, hardware face detection is not supported.
470 // Example: "5". Read only
471 static const char KEY_MAX_NUM_DETECTED_FACES_HW[];
472
473 // The maximum number of detected faces supported by software face
474 // detection. If the value is 0, software face detection is not supported.
475 // Example: "5". Read only
476 static const char KEY_MAX_NUM_DETECTED_FACES_SW[];
477
478 // Preferred preview frame size in pixels for video recording.
479 // The width and height must be one of the supported sizes retrieved
480 // via KEY_SUPPORTED_PREVIEW_SIZES. This key can be used only when
481 // getSupportedVideoSizes() does not return an empty Vector of Size.
482 // Camcorder applications are recommended to set the preview size
483 // to a value that is not larger than the preferred preview size.
484 // In other words, the product of the width and height of the
485 // preview size should not be larger than that of the preferred
486 // preview size. In addition, we recommend to choos a preview size
487 // that has the same aspect ratio as the resolution of video to be
488 // recorded.
489 // Example value: "800x600". Read only.
490 static const char KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO[];
491
492 // The image format for video frames. See CAMERA_MSG_VIDEO_FRAME in
493 // frameworks/base/include/camera/Camera.h.
494 // Example value: "yuv420sp" or PIXEL_FORMAT_XXX constants. Read only.
495 static const char KEY_VIDEO_FRAME_FORMAT[];
496
497 // Sets the hint of the recording mode. If this is true, MediaRecorder.start
498 // may be faster or has less glitches. This should be called before starting
499 // the preview for the best result. But it is allowed to change the hint
500 // while the preview is active. The default value is false.
501 //
502 // The apps can still call Camera.takePicture when the hint is true. The
503 // apps can call MediaRecorder.start when the hint is false. But the
504 // performance may be worse.
505 // Example value: "true" or "false". Read/write.
506 static const char KEY_RECORDING_HINT[];
507
508 // Returns true if video snapshot is supported. That is, applications
509 // can call Camera.takePicture during recording. Applications do not need to
510 // call Camera.startPreview after taking a picture. The preview will be
511 // still active. Other than that, taking a picture during recording is
512 // identical to taking a picture normally. All settings and methods related
513 // to takePicture work identically. Ex: KEY_PICTURE_SIZE,
514 // KEY_SUPPORTED_PICTURE_SIZES, KEY_JPEG_QUALITY, KEY_ROTATION, and etc.
515 // The picture will have an EXIF header. FLASH_MODE_AUTO and FLASH_MODE_ON
516 // also still work, but the video will record the flash.
517 //
518 // Applications can set shutter callback as null to avoid the shutter
519 // sound. It is also recommended to set raw picture and post view callbacks
520 // to null to avoid the interrupt of preview display.
521 //
522 // Field-of-view of the recorded video may be different from that of the
523 // captured pictures.
524 // Example value: "true" or "false". Read only.
525 static const char KEY_VIDEO_SNAPSHOT_SUPPORTED[];
526
527 // The state of the video stabilization. If set to true, both the
528 // preview stream and the recorded video stream are stabilized by
529 // the camera. Only valid to set if KEY_VIDEO_STABILIZATION_SUPPORTED is
530 // set to true.
531 //
532 // The value of this key can be changed any time the camera is
533 // open. If preview or recording is active, it is acceptable for
534 // there to be a slight video glitch when video stabilization is
535 // toggled on and off.
536 //
537 // This only stabilizes video streams (between-frames stabilization), and
538 // has no effect on still image capture.
539 static const char KEY_VIDEO_STABILIZATION[];
540
541 // Returns true if video stabilization is supported. That is, applications
542 // can set KEY_VIDEO_STABILIZATION to true and have a stabilized preview
543 // stream and record stabilized videos.
544 static const char KEY_VIDEO_STABILIZATION_SUPPORTED[];
545
James Paintere5382062012-09-05 18:02:32 -0700546 // Supported modes for special effects with light.
547 // Example values: "lowlight,hdr".
548 static const char KEY_LIGHTFX[];
549
Eino-Ville Talvalac2d64272012-05-15 15:38:27 -0700550 // Value for KEY_ZOOM_SUPPORTED or KEY_SMOOTH_ZOOM_SUPPORTED.
551 static const char TRUE[];
552 static const char FALSE[];
553
554 // Value for KEY_FOCUS_DISTANCES.
555 static const char FOCUS_DISTANCE_INFINITY[];
556
557 // Values for white balance settings.
558 static const char WHITE_BALANCE_AUTO[];
559 static const char WHITE_BALANCE_INCANDESCENT[];
560 static const char WHITE_BALANCE_FLUORESCENT[];
561 static const char WHITE_BALANCE_WARM_FLUORESCENT[];
562 static const char WHITE_BALANCE_DAYLIGHT[];
563 static const char WHITE_BALANCE_CLOUDY_DAYLIGHT[];
564 static const char WHITE_BALANCE_TWILIGHT[];
565 static const char WHITE_BALANCE_SHADE[];
566
567 // Values for effect settings.
568 static const char EFFECT_NONE[];
569 static const char EFFECT_MONO[];
570 static const char EFFECT_NEGATIVE[];
571 static const char EFFECT_SOLARIZE[];
572 static const char EFFECT_SEPIA[];
573 static const char EFFECT_POSTERIZE[];
574 static const char EFFECT_WHITEBOARD[];
575 static const char EFFECT_BLACKBOARD[];
576 static const char EFFECT_AQUA[];
577
578 // Values for antibanding settings.
579 static const char ANTIBANDING_AUTO[];
580 static const char ANTIBANDING_50HZ[];
581 static const char ANTIBANDING_60HZ[];
582 static const char ANTIBANDING_OFF[];
583
584 // Values for flash mode settings.
585 // Flash will not be fired.
586 static const char FLASH_MODE_OFF[];
587 // Flash will be fired automatically when required. The flash may be fired
588 // during preview, auto-focus, or snapshot depending on the driver.
589 static const char FLASH_MODE_AUTO[];
590 // Flash will always be fired during snapshot. The flash may also be
591 // fired during preview or auto-focus depending on the driver.
592 static const char FLASH_MODE_ON[];
593 // Flash will be fired in red-eye reduction mode.
594 static const char FLASH_MODE_RED_EYE[];
595 // Constant emission of light during preview, auto-focus and snapshot.
596 // This can also be used for video recording.
597 static const char FLASH_MODE_TORCH[];
598
599 // Values for scene mode settings.
600 static const char SCENE_MODE_AUTO[];
601 static const char SCENE_MODE_ACTION[];
602 static const char SCENE_MODE_PORTRAIT[];
603 static const char SCENE_MODE_LANDSCAPE[];
604 static const char SCENE_MODE_NIGHT[];
605 static const char SCENE_MODE_NIGHT_PORTRAIT[];
606 static const char SCENE_MODE_THEATRE[];
607 static const char SCENE_MODE_BEACH[];
608 static const char SCENE_MODE_SNOW[];
609 static const char SCENE_MODE_SUNSET[];
610 static const char SCENE_MODE_STEADYPHOTO[];
611 static const char SCENE_MODE_FIREWORKS[];
612 static const char SCENE_MODE_SPORTS[];
613 static const char SCENE_MODE_PARTY[];
614 static const char SCENE_MODE_CANDLELIGHT[];
615 // Applications are looking for a barcode. Camera driver will be optimized
616 // for barcode reading.
617 static const char SCENE_MODE_BARCODE[];
Eino-Ville Talvalac61b2aa2012-09-10 11:59:12 -0700618 // A high-dynamic range mode. In this mode, the HAL module will use a
619 // capture strategy that extends the dynamic range of the captured
620 // image in some fashion. Only the final image is returned.
621 static const char SCENE_MODE_HDR[];
Eino-Ville Talvalac2d64272012-05-15 15:38:27 -0700622
623 // Pixel color formats for KEY_PREVIEW_FORMAT, KEY_PICTURE_FORMAT,
624 // and KEY_VIDEO_FRAME_FORMAT
625 static const char PIXEL_FORMAT_YUV422SP[];
626 static const char PIXEL_FORMAT_YUV420SP[]; // NV21
627 static const char PIXEL_FORMAT_YUV422I[]; // YUY2
628 static const char PIXEL_FORMAT_YUV420P[]; // YV12
629 static const char PIXEL_FORMAT_RGB565[];
630 static const char PIXEL_FORMAT_RGBA8888[];
631 static const char PIXEL_FORMAT_JPEG[];
632 // Raw bayer format used for images, which is 10 bit precision samples
633 // stored in 16 bit words. The filter pattern is RGGB.
634 static const char PIXEL_FORMAT_BAYER_RGGB[];
Eino-Ville Talvalaf6d96962012-07-18 17:50:46 -0700635 // Pixel format is not known to the framework
636 static const char PIXEL_FORMAT_ANDROID_OPAQUE[];
Eino-Ville Talvalac2d64272012-05-15 15:38:27 -0700637
638 // Values for focus mode settings.
639 // Auto-focus mode. Applications should call
640 // CameraHardwareInterface.autoFocus to start the focus in this mode.
641 static const char FOCUS_MODE_AUTO[];
642 // Focus is set at infinity. Applications should not call
643 // CameraHardwareInterface.autoFocus in this mode.
644 static const char FOCUS_MODE_INFINITY[];
645 // Macro (close-up) focus mode. Applications should call
646 // CameraHardwareInterface.autoFocus to start the focus in this mode.
647 static const char FOCUS_MODE_MACRO[];
648 // Focus is fixed. The camera is always in this mode if the focus is not
649 // adjustable. If the camera has auto-focus, this mode can fix the
650 // focus, which is usually at hyperfocal distance. Applications should
651 // not call CameraHardwareInterface.autoFocus in this mode.
652 static const char FOCUS_MODE_FIXED[];
653 // Extended depth of field (EDOF). Focusing is done digitally and
654 // continuously. Applications should not call
655 // CameraHardwareInterface.autoFocus in this mode.
656 static const char FOCUS_MODE_EDOF[];
657 // Continuous auto focus mode intended for video recording. The camera
658 // continuously tries to focus. This is the best choice for video
659 // recording because the focus changes smoothly . Applications still can
660 // call CameraHardwareInterface.takePicture in this mode but the subject may
661 // not be in focus. Auto focus starts when the parameter is set.
662 //
663 // Applications can call CameraHardwareInterface.autoFocus in this mode. The
664 // focus callback will immediately return with a boolean that indicates
665 // whether the focus is sharp or not. The focus position is locked after
666 // autoFocus call. If applications want to resume the continuous focus,
667 // cancelAutoFocus must be called. Restarting the preview will not resume
668 // the continuous autofocus. To stop continuous focus, applications should
669 // change the focus mode to other modes.
670 static const char FOCUS_MODE_CONTINUOUS_VIDEO[];
671 // Continuous auto focus mode intended for taking pictures. The camera
672 // continuously tries to focus. The speed of focus change is more aggressive
673 // than FOCUS_MODE_CONTINUOUS_VIDEO. Auto focus starts when the parameter is
674 // set.
675 //
676 // Applications can call CameraHardwareInterface.autoFocus in this mode. If
677 // the autofocus is in the middle of scanning, the focus callback will
678 // return when it completes. If the autofocus is not scanning, focus
679 // callback will immediately return with a boolean that indicates whether
680 // the focus is sharp or not. The apps can then decide if they want to take
681 // a picture immediately or to change the focus mode to auto, and run a full
682 // autofocus cycle. The focus position is locked after autoFocus call. If
683 // applications want to resume the continuous focus, cancelAutoFocus must be
684 // called. Restarting the preview will not resume the continuous autofocus.
685 // To stop continuous focus, applications should change the focus mode to
686 // other modes.
687 static const char FOCUS_MODE_CONTINUOUS_PICTURE[];
688
James Paintere5382062012-09-05 18:02:32 -0700689 // Values for light special effects
690 // Low-light enhancement mode
691 static const char LIGHTFX_LOWLIGHT[];
692 // High-dynamic range mode
693 static const char LIGHTFX_HDR[];
694
Eino-Ville Talvalac2d64272012-05-15 15:38:27 -0700695private:
Igor Murashkin9078a1b2014-03-18 18:15:23 -0700696
697 // Quick and dirty map that maintains insertion order
698 template <typename KeyT, typename ValueT>
699 struct OrderedKeyedVector {
700
701 ssize_t add(const KeyT& key, const ValueT& value) {
702 return mList.add(Pair(key, value));
703 }
704
705 size_t size() const {
706 return mList.size();
707 }
708
709 const KeyT& keyAt(size_t idx) const {
710 return mList[idx].mKey;
711 }
712
713 const ValueT& valueAt(size_t idx) const {
714 return mList[idx].mValue;
715 }
716
717 const ValueT& valueFor(const KeyT& key) const {
718 ssize_t i = indexOfKey(key);
719 LOG_ALWAYS_FATAL_IF(i<0, "%s: key not found", __PRETTY_FUNCTION__);
720
721 return valueAt(i);
722 }
723
724 ssize_t indexOfKey(const KeyT& key) const {
725 size_t vectorIdx = 0;
726 for (; vectorIdx < mList.size(); ++vectorIdx) {
727 if (mList[vectorIdx].mKey == key) {
728 return (ssize_t) vectorIdx;
729 }
730 }
731
732 return NAME_NOT_FOUND;
733 }
734
735 ssize_t removeItem(const KeyT& key) {
736 size_t vectorIdx = (size_t) indexOfKey(key);
737
738 if (vectorIdx < 0) {
739 return vectorIdx;
740 }
741
742 return mList.removeAt(vectorIdx);
743 }
744
745 void clear() {
746 mList.clear();
747 }
748
749 // Same as removing and re-adding. The key's index changes to max.
750 ssize_t replaceValueFor(const KeyT& key, const ValueT& value) {
751 removeItem(key);
752 return add(key, value);
753 }
754
755 private:
756
757 struct Pair {
758 Pair() : mKey(), mValue() {}
759 Pair(const KeyT& key, const ValueT& value) :
760 mKey(key),
761 mValue(value) {}
762 KeyT mKey;
763 ValueT mValue;
764 };
765
766 Vector<Pair> mList;
767 };
768
769 /**
770 * Order matters: Keys that are set() later are stored later in the map.
771 *
772 * If two keys have meaning that conflict, then the later-set key
773 * wins.
774 *
775 * For example, preview FPS and preview FPS range conflict since only
776 * we only want to use the FPS range if that's the last thing that was set.
777 * So in that case, only use preview FPS range if it was set later than
778 * the preview FPS.
779 */
780 OrderedKeyedVector<String8,String8> mMap;
Eino-Ville Talvalac2d64272012-05-15 15:38:27 -0700781};
782
783}; // namespace android
784
785#endif