blob: b2808f5bceeb9af03fc98b4a8720cc6df0a05bd6 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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>
21#include <utils/String8.h>
22
23namespace android {
24
Nipun Kwatra51c2ec22010-07-30 13:40:14 -070025struct Size {
26 int width;
27 int height;
28
29 Size() {
30 width = 0;
31 height = 0;
32 }
33
34 Size(int w, int h) {
35 width = w;
36 height = h;
37 }
38};
39
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040class CameraParameters
41{
42public:
43 CameraParameters();
44 CameraParameters(const String8 &params) { unflatten(params); }
45 ~CameraParameters();
46
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080047 String8 flatten() const;
48 void unflatten(const String8 &params);
49
50 void set(const char *key, const char *value);
51 void set(const char *key, int value);
Wu-cheng Li7eae31c2010-01-31 14:19:38 +080052 void setFloat(const char *key, float value);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080053 const char *get(const char *key) const;
54 int getInt(const char *key) const;
Wu-cheng Li7eae31c2010-01-31 14:19:38 +080055 float getFloat(const char *key) const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080056
Wu-cheng Li78624e412010-05-11 12:11:56 +080057 void remove(const char *key);
58
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080059 void setPreviewSize(int width, int height);
60 void getPreviewSize(int *width, int *height) const;
Nipun Kwatrab70c1db2010-08-04 14:04:07 -070061 void getSupportedPreviewSizes(Vector<Size> &sizes) const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080062 void setPreviewFrameRate(int fps);
63 int getPreviewFrameRate() const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080064 void setPreviewFormat(const char *format);
65 const char *getPreviewFormat() const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080066 void setPictureSize(int width, int height);
67 void getPictureSize(int *width, int *height) const;
Nipun Kwatra51c2ec22010-07-30 13:40:14 -070068 void getSupportedPictureSizes(Vector<Size> &sizes) const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080069 void setPictureFormat(const char *format);
70 const char *getPictureFormat() const;
71
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080072 void dump() const;
73 status_t dump(int fd, const Vector<String16>& args) const;
74
Wu-cheng Li8de57d82009-09-23 14:37:52 -070075 // Parameter keys to communicate between camera application and driver.
76 // The access (read/write, read only, or write only) is viewed from the
77 // perspective of applications, not driver.
78
79 // Preview frame size in pixels (width x height).
80 // Example value: "480x320". Read/Write.
81 static const char KEY_PREVIEW_SIZE[];
82 // Supported preview frame sizes in pixels.
83 // Example value: "800x600,480x320". Read only.
84 static const char KEY_SUPPORTED_PREVIEW_SIZES[];
Wu-cheng Lid2c29292010-05-28 17:32:41 +080085 // The image format for preview frames. See CAMERA_MSG_PREVIEW_FRAME in
86 // frameworks/base/include/camera/Camera.h.
Wu-cheng Li8de57d82009-09-23 14:37:52 -070087 // Example value: "yuv420sp" or PIXEL_FORMAT_XXX constants. Read/write.
88 static const char KEY_PREVIEW_FORMAT[];
89 // Supported image formats for preview frames.
90 // Example value: "yuv420sp,yuv422i-yuyv". Read only.
91 static const char KEY_SUPPORTED_PREVIEW_FORMATS[];
Wu-cheng Lid2c29292010-05-28 17:32:41 +080092 // Number of preview frames per second. This is the target frame rate. The
93 // actual frame rate depends on the driver.
Wu-cheng Li8de57d82009-09-23 14:37:52 -070094 // Example value: "15". Read/write.
95 static const char KEY_PREVIEW_FRAME_RATE[];
96 // Supported number of preview frames per second.
97 // Example value: "24,15,10". Read.
98 static const char KEY_SUPPORTED_PREVIEW_FRAME_RATES[];
99 // The dimensions for captured pictures in pixels (width x height).
100 // Example value: "1024x768". Read/write.
101 static const char KEY_PICTURE_SIZE[];
102 // Supported dimensions for captured pictures in pixels.
103 // Example value: "2048x1536,1024x768". Read only.
104 static const char KEY_SUPPORTED_PICTURE_SIZES[];
Wu-cheng Lid2c29292010-05-28 17:32:41 +0800105 // The image format for captured pictures. See CAMERA_MSG_COMPRESSED_IMAGE
106 // in frameworks/base/include/camera/Camera.h.
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700107 // Example value: "jpeg" or PIXEL_FORMAT_XXX constants. Read/write.
108 static const char KEY_PICTURE_FORMAT[];
109 // Supported image formats for captured pictures.
110 // Example value: "jpeg,rgb565". Read only.
111 static const char KEY_SUPPORTED_PICTURE_FORMATS[];
112 // The width (in pixels) of EXIF thumbnail in Jpeg picture.
113 // Example value: "512". Read/write.
114 static const char KEY_JPEG_THUMBNAIL_WIDTH[];
115 // The height (in pixels) of EXIF thumbnail in Jpeg picture.
116 // Example value: "384". Read/write.
117 static const char KEY_JPEG_THUMBNAIL_HEIGHT[];
Wu-cheng Liacf77032010-01-25 15:18:18 +0800118 // Supported EXIF thumbnail sizes (width x height). 0x0 means not thumbnail
119 // in EXIF.
120 // Example value: "512x384,320x240,0x0". Read only.
121 static const char KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES[];
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700122 // The quality of the EXIF thumbnail in Jpeg picture. The range is 1 to 100,
123 // with 100 being the best.
124 // Example value: "90". Read/write.
125 static const char KEY_JPEG_THUMBNAIL_QUALITY[];
126 // Jpeg quality of captured picture. The range is 1 to 100, with 100 being
127 // the best.
128 // Example value: "90". Read/write.
129 static const char KEY_JPEG_QUALITY[];
130 // The orientation of the device in degrees. For example, suppose the
131 // natural position of the device is landscape. If the user takes a picture
132 // in landscape mode in 2048x1536 resolution, the rotation will be set to
133 // "0". If the user rotates the phone 90 degrees clockwise, the rotation
134 // should be set to "90".
135 // The camera driver can set orientation in the EXIF header without rotating
136 // the picture. Or the driver can rotate the picture and the EXIF thumbnail.
137 // If the Jpeg picture is rotated, the orientation in the EXIF header should
138 // be missing or 1 (row #0 is top and column #0 is left side). The driver
139 // should not set default value for this parameter.
140 // Example value: "0" or "90" or "180" or "270". Write only.
141 static const char KEY_ROTATION[];
Wu-cheng Libd329dd2010-05-21 17:52:42 +0800142 // GPS latitude coordinate. GPSLatitude and GPSLatitudeRef will be stored in
143 // JPEG EXIF header.
144 // Example value: "25.032146" or "-33.462809". Write only.
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700145 static const char KEY_GPS_LATITUDE[];
Wu-cheng Libd329dd2010-05-21 17:52:42 +0800146 // GPS longitude coordinate. GPSLongitude and GPSLongitudeRef will be stored
147 // in JPEG EXIF header.
148 // Example value: "121.564448" or "-70.660286". Write only.
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700149 static const char KEY_GPS_LONGITUDE[];
Wu-cheng Libd329dd2010-05-21 17:52:42 +0800150 // GPS altitude. GPSAltitude and GPSAltitudeRef will be stored in JPEG EXIF
151 // header.
152 // Example value: "21.0" or "-5". Write only.
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700153 static const char KEY_GPS_ALTITUDE[];
154 // GPS timestamp (UTC in seconds since January 1, 1970). This should be
155 // stored in JPEG EXIF header.
156 // Example value: "1251192757". Write only.
157 static const char KEY_GPS_TIMESTAMP[];
Ray Chen055c9862010-02-23 10:45:42 +0800158 // GPS Processing Method
159 // Example value: "GPS" or "NETWORK". Write only.
160 static const char KEY_GPS_PROCESSING_METHOD[];
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700161 // Current white balance setting.
162 // Example value: "auto" or WHITE_BALANCE_XXX constants. Read/write.
163 static const char KEY_WHITE_BALANCE[];
164 // Supported white balance settings.
165 // Example value: "auto,incandescent,daylight". Read only.
166 static const char KEY_SUPPORTED_WHITE_BALANCE[];
167 // Current color effect setting.
168 // Example value: "none" or EFFECT_XXX constants. Read/write.
169 static const char KEY_EFFECT[];
170 // Supported color effect settings.
171 // Example value: "none,mono,sepia". Read only.
172 static const char KEY_SUPPORTED_EFFECTS[];
173 // Current antibanding setting.
174 // Example value: "auto" or ANTIBANDING_XXX constants. Read/write.
175 static const char KEY_ANTIBANDING[];
176 // Supported antibanding settings.
177 // Example value: "auto,50hz,60hz,off". Read only.
178 static const char KEY_SUPPORTED_ANTIBANDING[];
179 // Current scene mode.
180 // Example value: "auto" or SCENE_MODE_XXX constants. Read/write.
181 static const char KEY_SCENE_MODE[];
182 // Supported scene mode settings.
183 // Example value: "auto,night,fireworks". Read only.
184 static const char KEY_SUPPORTED_SCENE_MODES[];
185 // Current flash mode.
186 // Example value: "auto" or FLASH_MODE_XXX constants. Read/write.
187 static const char KEY_FLASH_MODE[];
188 // Supported flash modes.
189 // Example value: "auto,on,off". Read only.
190 static const char KEY_SUPPORTED_FLASH_MODES[];
191 // Current focus mode. If the camera does not support auto-focus, the value
192 // should be FOCUS_MODE_FIXED. If the focus mode is not FOCUS_MODE_FIXED or
193 // or FOCUS_MODE_INFINITY, applications should call
194 // CameraHardwareInterface.autoFocus to start the focus.
195 // Example value: "auto" or FOCUS_MODE_XXX constants. Read/write.
196 static const char KEY_FOCUS_MODE[];
197 // Supported focus modes.
198 // Example value: "auto,macro,fixed". Read only.
199 static const char KEY_SUPPORTED_FOCUS_MODES[];
Wu-cheng Li6c8d2762010-01-27 22:55:14 +0800200 // Focal length in millimeter.
201 // Example value: "4.31". Read only.
202 static const char KEY_FOCAL_LENGTH[];
203 // Horizontal angle of view in degrees.
204 // Example value: "54.8". Read only.
205 static const char KEY_HORIZONTAL_VIEW_ANGLE[];
206 // Vertical angle of view in degrees.
207 // Example value: "42.5". Read only.
208 static const char KEY_VERTICAL_VIEW_ANGLE[];
Wu-cheng Li24b326a2010-02-20 17:47:04 +0800209 // Exposure compensation index. 0 means exposure is not adjusted.
210 // Example value: "0" or "5". Read/write.
Wu-cheng Liff723b6c2010-02-09 13:38:19 +0800211 static const char KEY_EXPOSURE_COMPENSATION[];
Wu-cheng Li24b326a2010-02-20 17:47:04 +0800212 // The maximum exposure compensation index (>=0).
213 // Example value: "6". Read only.
214 static const char KEY_MAX_EXPOSURE_COMPENSATION[];
215 // The minimum exposure compensation index (<=0).
216 // Example value: "-6". Read only.
217 static const char KEY_MIN_EXPOSURE_COMPENSATION[];
218 // The exposure compensation step. Exposure compensation index multiply by
219 // step eqals to EV. Ex: if exposure compensation index is 6 and step is
220 // 0.3333, EV is -2.
221 // Example value: "0.333333333" or "0.5". Read only.
222 static const char KEY_EXPOSURE_COMPENSATION_STEP[];
Wu-cheng Li8cbb8f52010-02-28 23:19:55 -0800223 // Current zoom value.
224 // Example value: "0" or "6". Read/write.
225 static const char KEY_ZOOM[];
226 // Maximum zoom value.
227 // Example value: "6". Read only.
228 static const char KEY_MAX_ZOOM[];
229 // The zoom ratios of all zoom values. The zoom ratio is in 1/100
230 // increments. Ex: a zoom of 3.2x is returned as 320. The number of list
231 // elements is KEY_MAX_ZOOM + 1. The first element is always 100. The last
232 // element is the zoom ratio of zoom value KEY_MAX_ZOOM.
233 // Example value: "100,150,200,250,300,350,400". Read only.
234 static const char KEY_ZOOM_RATIOS[];
235 // Whether zoom is supported. Zoom is supported if the value is "true". Zoom
236 // is not supported if the value is not "true" or the key does not exist.
237 // Example value: "true". Read only.
238 static const char KEY_ZOOM_SUPPORTED[];
239 // Whether if smooth zoom is supported. Smooth zoom is supported if the
240 // value is "true". It is not supported if the value is not "true" or the
241 // key does not exist.
242 // See CAMERA_CMD_START_SMOOTH_ZOOM, CAMERA_CMD_STOP_SMOOTH_ZOOM, and
243 // CAMERA_MSG_ZOOM in frameworks/base/include/camera/Camera.h.
244 // Example value: "true". Read only.
245 static const char KEY_SMOOTH_ZOOM_SUPPORTED[];
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700246
Wu-cheng Lie339c5e2010-05-13 19:31:02 +0800247 // The distances (in meters) from the camera to where an object appears to
248 // be in focus. The object is sharpest at the optimal focus distance. The
249 // depth of field is the far focus distance minus near focus distance.
250 //
251 // Applications can read this parameter anytime to get the latest focus
252 // distances. If the focus mode is FOCUS_MODE_EDOF, the values may be all
253 // 0, which means focus distance is not applicable. If the focus mode is
254 // FOCUS_MODE_CONTINUOUS and autofocus has started, focus distances may
255 // change from time to time.
256 //
257 // Far focus distance > optimal focus distance > near focus distance. If
258 // the far focus distance is infinity, the value should be "Infinity" (case
259 // sensitive). The format is three float values separated by commas. The
260 // first is near focus distance. The second is optimal focus distance. The
261 // third is far focus distance.
262 // Example value: "0.95,1.9,Infinity" or "0.049,0.05,0.051". Read only.
263 static const char KEY_FOCUS_DISTANCES[];
264
Wu-cheng Lid2c29292010-05-28 17:32:41 +0800265 // The image format for video frames. See CAMERA_MSG_VIDEO_FRAME in
266 // frameworks/base/include/camera/Camera.h.
267 // Example value: "yuv420sp" or PIXEL_FORMAT_XXX constants. Read only.
268 static const char KEY_VIDEO_FRAME_FORMAT[];
269
Wu-cheng Lif7f63332010-06-03 16:34:18 +0800270 // Metering mode. This affects how camera determines exposure.
271 // Example value: "spot" or METERING_MODE_XXX constants. Read/write.
272 static const char KEY_METERING_MODE[];
Wu-cheng Li8aba2322010-06-04 14:18:32 +0800273 // Supported metering modes.
274 // Example value: "center-weighted,frame-average,spot". Read only.
275 static const char KEY_SUPPORTED_METERING_MODES[];
Wu-cheng Lif7f63332010-06-03 16:34:18 +0800276
Wu-cheng Lid9ef5d72010-03-08 15:28:48 -0800277 // Value for KEY_ZOOM_SUPPORTED or KEY_SMOOTH_ZOOM_SUPPORTED.
278 static const char TRUE[];
279
Wu-cheng Lie339c5e2010-05-13 19:31:02 +0800280 // Value for KEY_FOCUS_DISTANCES.
Wu-cheng Liae7ca4c2010-05-15 13:05:04 +0800281 static const char FOCUS_DISTANCE_INFINITY[];
Wu-cheng Lie339c5e2010-05-13 19:31:02 +0800282
Wu-cheng Li24b326a2010-02-20 17:47:04 +0800283 // Values for white balance settings.
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700284 static const char WHITE_BALANCE_AUTO[];
285 static const char WHITE_BALANCE_INCANDESCENT[];
286 static const char WHITE_BALANCE_FLUORESCENT[];
287 static const char WHITE_BALANCE_WARM_FLUORESCENT[];
288 static const char WHITE_BALANCE_DAYLIGHT[];
289 static const char WHITE_BALANCE_CLOUDY_DAYLIGHT[];
290 static const char WHITE_BALANCE_TWILIGHT[];
291 static const char WHITE_BALANCE_SHADE[];
292
293 // Values for effect settings.
294 static const char EFFECT_NONE[];
295 static const char EFFECT_MONO[];
296 static const char EFFECT_NEGATIVE[];
297 static const char EFFECT_SOLARIZE[];
298 static const char EFFECT_SEPIA[];
299 static const char EFFECT_POSTERIZE[];
300 static const char EFFECT_WHITEBOARD[];
301 static const char EFFECT_BLACKBOARD[];
302 static const char EFFECT_AQUA[];
303
304 // Values for antibanding settings.
305 static const char ANTIBANDING_AUTO[];
306 static const char ANTIBANDING_50HZ[];
307 static const char ANTIBANDING_60HZ[];
308 static const char ANTIBANDING_OFF[];
309
310 // Values for flash mode settings.
311 // Flash will not be fired.
312 static const char FLASH_MODE_OFF[];
Wu-cheng Life1a86d2009-09-28 13:51:12 -0700313 // Flash will be fired automatically when required. The flash may be fired
314 // during preview, auto-focus, or snapshot depending on the driver.
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700315 static const char FLASH_MODE_AUTO[];
Wu-cheng Life1a86d2009-09-28 13:51:12 -0700316 // Flash will always be fired during snapshot. The flash may also be
317 // fired during preview or auto-focus depending on the driver.
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700318 static const char FLASH_MODE_ON[];
319 // Flash will be fired in red-eye reduction mode.
320 static const char FLASH_MODE_RED_EYE[];
Wu-cheng Life1a86d2009-09-28 13:51:12 -0700321 // Constant emission of light during preview, auto-focus and snapshot.
322 // This can also be used for video recording.
323 static const char FLASH_MODE_TORCH[];
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700324
325 // Values for scene mode settings.
326 static const char SCENE_MODE_AUTO[];
327 static const char SCENE_MODE_ACTION[];
328 static const char SCENE_MODE_PORTRAIT[];
329 static const char SCENE_MODE_LANDSCAPE[];
330 static const char SCENE_MODE_NIGHT[];
331 static const char SCENE_MODE_NIGHT_PORTRAIT[];
332 static const char SCENE_MODE_THEATRE[];
333 static const char SCENE_MODE_BEACH[];
334 static const char SCENE_MODE_SNOW[];
335 static const char SCENE_MODE_SUNSET[];
336 static const char SCENE_MODE_STEADYPHOTO[];
337 static const char SCENE_MODE_FIREWORKS[];
338 static const char SCENE_MODE_SPORTS[];
339 static const char SCENE_MODE_PARTY[];
340 static const char SCENE_MODE_CANDLELIGHT[];
Wu-cheng Lic58b4232010-03-29 17:21:28 +0800341 // Applications are looking for a barcode. Camera driver will be optimized
342 // for barcode reading.
343 static const char SCENE_MODE_BARCODE[];
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700344
345 // Formats for setPreviewFormat and setPictureFormat.
346 static const char PIXEL_FORMAT_YUV422SP[];
347 static const char PIXEL_FORMAT_YUV420SP[]; // NV21
348 static const char PIXEL_FORMAT_YUV422I[]; // YUY2
349 static const char PIXEL_FORMAT_RGB565[];
350 static const char PIXEL_FORMAT_JPEG[];
351
352 // Values for focus mode settings.
353 // Auto-focus mode.
354 static const char FOCUS_MODE_AUTO[];
355 // Focus is set at infinity. Applications should not call
356 // CameraHardwareInterface.autoFocus in this mode.
357 static const char FOCUS_MODE_INFINITY[];
358 static const char FOCUS_MODE_MACRO[];
359 // Focus is fixed. The camera is always in this mode if the focus is not
360 // adjustable. If the camera has auto-focus, this mode can fix the
361 // focus, which is usually at hyperfocal distance. Applications should
362 // not call CameraHardwareInterface.autoFocus in this mode.
363 static const char FOCUS_MODE_FIXED[];
Wu-cheng Lic58b4232010-03-29 17:21:28 +0800364 // Extended depth of field (EDOF). Focusing is done digitally and
365 // continuously. Applications should not call
366 // CameraHardwareInterface.autoFocus in this mode.
367 static const char FOCUS_MODE_EDOF[];
Wu-cheng Lica099612010-05-06 16:47:30 +0800368 // Continuous focus mode. The camera continuously tries to focus. This is
369 // ideal for shooting video or shooting photo of moving object. Continuous
370 // focus starts when CameraHardwareInterface.autoFocus is called. Focus
371 // callback will be only called once as soon as the picture is in focus.
372 static const char FOCUS_MODE_CONTINUOUS[];
373
Wu-cheng Lif7f63332010-06-03 16:34:18 +0800374 // The camera determines the exposure by giving more weight to the
375 // central part of the scene.
376 static const char METERING_MODE_CENTER_WEIGHTED[];
377 // The camera determines the exposure by averaging the entire scene,
378 // giving no weighting to any particular area.
379 static const char METERING_MODE_FRAME_AVERAGE[];
380 // The camera determines the exposure by a very small area of the scene,
381 // typically the center.
382 static const char METERING_MODE_SPOT[];
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700383
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800384private:
385 DefaultKeyedVector<String8,String8> mMap;
386};
387
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800388}; // namespace android
389
390#endif