blob: 013452fbbc6d043e3d86d33e167269af78a2e224 [file] [log] [blame]
Mathias Agopian3cf61352010-02-09 17:46:37 -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 Kwatra34c91a32010-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
Mathias Agopian3cf61352010-02-09 17:46:37 -080040class CameraParameters
41{
42public:
43 CameraParameters();
44 CameraParameters(const String8 &params) { unflatten(params); }
45 ~CameraParameters();
46
47 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);
52 void setFloat(const char *key, float value);
53 const char *get(const char *key) const;
54 int getInt(const char *key) const;
55 float getFloat(const char *key) const;
56
Wu-cheng Liadbda962010-05-11 12:11:56 +080057 void remove(const char *key);
58
Mathias Agopian3cf61352010-02-09 17:46:37 -080059 void setPreviewSize(int width, int height);
60 void getPreviewSize(int *width, int *height) const;
Mathias Agopian3cf61352010-02-09 17:46:37 -080061 void setPreviewFrameRate(int fps);
62 int getPreviewFrameRate() const;
Mathias Agopian3cf61352010-02-09 17:46:37 -080063 void setPreviewFormat(const char *format);
64 const char *getPreviewFormat() const;
Mathias Agopian3cf61352010-02-09 17:46:37 -080065 void setPictureSize(int width, int height);
66 void getPictureSize(int *width, int *height) const;
Nipun Kwatra34c91a32010-07-30 13:40:14 -070067 void getSupportedPictureSizes(Vector<Size> &sizes) const;
Mathias Agopian3cf61352010-02-09 17:46:37 -080068 void setPictureFormat(const char *format);
69 const char *getPictureFormat() const;
70
71 void dump() const;
72 status_t dump(int fd, const Vector<String16>& args) const;
73
74 // Parameter keys to communicate between camera application and driver.
75 // The access (read/write, read only, or write only) is viewed from the
76 // perspective of applications, not driver.
77
78 // Preview frame size in pixels (width x height).
79 // Example value: "480x320". Read/Write.
80 static const char KEY_PREVIEW_SIZE[];
81 // Supported preview frame sizes in pixels.
82 // Example value: "800x600,480x320". Read only.
83 static const char KEY_SUPPORTED_PREVIEW_SIZES[];
Wu-cheng Li0b0279e2010-05-28 17:32:41 +080084 // The image format for preview frames. See CAMERA_MSG_PREVIEW_FRAME in
85 // frameworks/base/include/camera/Camera.h.
Mathias Agopian3cf61352010-02-09 17:46:37 -080086 // Example value: "yuv420sp" or PIXEL_FORMAT_XXX constants. Read/write.
87 static const char KEY_PREVIEW_FORMAT[];
88 // Supported image formats for preview frames.
89 // Example value: "yuv420sp,yuv422i-yuyv". Read only.
90 static const char KEY_SUPPORTED_PREVIEW_FORMATS[];
Wu-cheng Li0b0279e2010-05-28 17:32:41 +080091 // Number of preview frames per second. This is the target frame rate. The
92 // actual frame rate depends on the driver.
Mathias Agopian3cf61352010-02-09 17:46:37 -080093 // Example value: "15". Read/write.
94 static const char KEY_PREVIEW_FRAME_RATE[];
95 // Supported number of preview frames per second.
96 // Example value: "24,15,10". Read.
97 static const char KEY_SUPPORTED_PREVIEW_FRAME_RATES[];
98 // The dimensions for captured pictures in pixels (width x height).
99 // Example value: "1024x768". Read/write.
100 static const char KEY_PICTURE_SIZE[];
101 // Supported dimensions for captured pictures in pixels.
102 // Example value: "2048x1536,1024x768". Read only.
103 static const char KEY_SUPPORTED_PICTURE_SIZES[];
Wu-cheng Li0b0279e2010-05-28 17:32:41 +0800104 // The image format for captured pictures. See CAMERA_MSG_COMPRESSED_IMAGE
105 // in frameworks/base/include/camera/Camera.h.
Mathias Agopian3cf61352010-02-09 17:46:37 -0800106 // Example value: "jpeg" or PIXEL_FORMAT_XXX constants. Read/write.
107 static const char KEY_PICTURE_FORMAT[];
108 // Supported image formats for captured pictures.
109 // Example value: "jpeg,rgb565". Read only.
110 static const char KEY_SUPPORTED_PICTURE_FORMATS[];
111 // The width (in pixels) of EXIF thumbnail in Jpeg picture.
112 // Example value: "512". Read/write.
113 static const char KEY_JPEG_THUMBNAIL_WIDTH[];
114 // The height (in pixels) of EXIF thumbnail in Jpeg picture.
115 // Example value: "384". Read/write.
116 static const char KEY_JPEG_THUMBNAIL_HEIGHT[];
117 // Supported EXIF thumbnail sizes (width x height). 0x0 means not thumbnail
118 // in EXIF.
119 // Example value: "512x384,320x240,0x0". Read only.
120 static const char KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES[];
121 // The quality of the EXIF thumbnail in Jpeg picture. The range is 1 to 100,
122 // with 100 being the best.
123 // Example value: "90". Read/write.
124 static const char KEY_JPEG_THUMBNAIL_QUALITY[];
125 // Jpeg quality of captured picture. The range is 1 to 100, with 100 being
126 // the best.
127 // Example value: "90". Read/write.
128 static const char KEY_JPEG_QUALITY[];
129 // The orientation of the device in degrees. For example, suppose the
130 // natural position of the device is landscape. If the user takes a picture
131 // in landscape mode in 2048x1536 resolution, the rotation will be set to
132 // "0". If the user rotates the phone 90 degrees clockwise, the rotation
133 // should be set to "90".
134 // The camera driver can set orientation in the EXIF header without rotating
135 // the picture. Or the driver can rotate the picture and the EXIF thumbnail.
136 // If the Jpeg picture is rotated, the orientation in the EXIF header should
137 // be missing or 1 (row #0 is top and column #0 is left side). The driver
138 // should not set default value for this parameter.
139 // Example value: "0" or "90" or "180" or "270". Write only.
140 static const char KEY_ROTATION[];
Wu-cheng Li6b19fac2010-05-21 17:52:42 +0800141 // GPS latitude coordinate. GPSLatitude and GPSLatitudeRef will be stored in
142 // JPEG EXIF header.
143 // Example value: "25.032146" or "-33.462809". Write only.
Mathias Agopian3cf61352010-02-09 17:46:37 -0800144 static const char KEY_GPS_LATITUDE[];
Wu-cheng Li6b19fac2010-05-21 17:52:42 +0800145 // GPS longitude coordinate. GPSLongitude and GPSLongitudeRef will be stored
146 // in JPEG EXIF header.
147 // Example value: "121.564448" or "-70.660286". Write only.
Mathias Agopian3cf61352010-02-09 17:46:37 -0800148 static const char KEY_GPS_LONGITUDE[];
Wu-cheng Li6b19fac2010-05-21 17:52:42 +0800149 // GPS altitude. GPSAltitude and GPSAltitudeRef will be stored in JPEG EXIF
150 // header.
151 // Example value: "21.0" or "-5". Write only.
Mathias Agopian3cf61352010-02-09 17:46:37 -0800152 static const char KEY_GPS_ALTITUDE[];
153 // GPS timestamp (UTC in seconds since January 1, 1970). This should be
154 // stored in JPEG EXIF header.
155 // Example value: "1251192757". Write only.
156 static const char KEY_GPS_TIMESTAMP[];
Ray Chenc0170bc2010-02-23 10:45:42 +0800157 // GPS Processing Method
158 // Example value: "GPS" or "NETWORK". Write only.
159 static const char KEY_GPS_PROCESSING_METHOD[];
Mathias Agopian3cf61352010-02-09 17:46:37 -0800160 // Current white balance setting.
161 // Example value: "auto" or WHITE_BALANCE_XXX constants. Read/write.
162 static const char KEY_WHITE_BALANCE[];
163 // Supported white balance settings.
164 // Example value: "auto,incandescent,daylight". Read only.
165 static const char KEY_SUPPORTED_WHITE_BALANCE[];
166 // Current color effect setting.
167 // Example value: "none" or EFFECT_XXX constants. Read/write.
168 static const char KEY_EFFECT[];
169 // Supported color effect settings.
170 // Example value: "none,mono,sepia". Read only.
171 static const char KEY_SUPPORTED_EFFECTS[];
172 // Current antibanding setting.
173 // Example value: "auto" or ANTIBANDING_XXX constants. Read/write.
174 static const char KEY_ANTIBANDING[];
175 // Supported antibanding settings.
176 // Example value: "auto,50hz,60hz,off". Read only.
177 static const char KEY_SUPPORTED_ANTIBANDING[];
178 // Current scene mode.
179 // Example value: "auto" or SCENE_MODE_XXX constants. Read/write.
180 static const char KEY_SCENE_MODE[];
181 // Supported scene mode settings.
182 // Example value: "auto,night,fireworks". Read only.
183 static const char KEY_SUPPORTED_SCENE_MODES[];
184 // Current flash mode.
185 // Example value: "auto" or FLASH_MODE_XXX constants. Read/write.
186 static const char KEY_FLASH_MODE[];
187 // Supported flash modes.
188 // Example value: "auto,on,off". Read only.
189 static const char KEY_SUPPORTED_FLASH_MODES[];
Wu-cheng Lic6e88fd2010-08-05 11:50:25 -0700190 // Current focus mode. This will not be empty. Applications should call
191 // CameraHardwareInterface.autoFocus to start the focus if focus mode is
192 // FOCUS_MODE_AUTO or FOCUS_MODE_MACRO.
Mathias Agopian3cf61352010-02-09 17:46:37 -0800193 // Example value: "auto" or FOCUS_MODE_XXX constants. Read/write.
194 static const char KEY_FOCUS_MODE[];
195 // Supported focus modes.
196 // Example value: "auto,macro,fixed". Read only.
197 static const char KEY_SUPPORTED_FOCUS_MODES[];
198 // Focal length in millimeter.
199 // Example value: "4.31". Read only.
200 static const char KEY_FOCAL_LENGTH[];
201 // Horizontal angle of view in degrees.
202 // Example value: "54.8". Read only.
203 static const char KEY_HORIZONTAL_VIEW_ANGLE[];
204 // Vertical angle of view in degrees.
205 // Example value: "42.5". Read only.
206 static const char KEY_VERTICAL_VIEW_ANGLE[];
Wu-cheng Li4f1bff92010-02-20 17:47:04 +0800207 // Exposure compensation index. 0 means exposure is not adjusted.
208 // Example value: "0" or "5". Read/write.
Mathias Agopian3cf61352010-02-09 17:46:37 -0800209 static const char KEY_EXPOSURE_COMPENSATION[];
Wu-cheng Li4f1bff92010-02-20 17:47:04 +0800210 // The maximum exposure compensation index (>=0).
211 // Example value: "6". Read only.
212 static const char KEY_MAX_EXPOSURE_COMPENSATION[];
213 // The minimum exposure compensation index (<=0).
214 // Example value: "-6". Read only.
215 static const char KEY_MIN_EXPOSURE_COMPENSATION[];
216 // The exposure compensation step. Exposure compensation index multiply by
217 // step eqals to EV. Ex: if exposure compensation index is 6 and step is
218 // 0.3333, EV is -2.
219 // Example value: "0.333333333" or "0.5". Read only.
220 static const char KEY_EXPOSURE_COMPENSATION_STEP[];
Wu-cheng Li949c5032010-02-28 23:19:55 -0800221 // Current zoom value.
222 // Example value: "0" or "6". Read/write.
223 static const char KEY_ZOOM[];
224 // Maximum zoom value.
225 // Example value: "6". Read only.
226 static const char KEY_MAX_ZOOM[];
227 // The zoom ratios of all zoom values. The zoom ratio is in 1/100
228 // increments. Ex: a zoom of 3.2x is returned as 320. The number of list
229 // elements is KEY_MAX_ZOOM + 1. The first element is always 100. The last
230 // element is the zoom ratio of zoom value KEY_MAX_ZOOM.
231 // Example value: "100,150,200,250,300,350,400". Read only.
232 static const char KEY_ZOOM_RATIOS[];
233 // Whether zoom is supported. Zoom is supported if the value is "true". Zoom
234 // is not supported if the value is not "true" or the key does not exist.
235 // Example value: "true". Read only.
236 static const char KEY_ZOOM_SUPPORTED[];
237 // Whether if smooth zoom is supported. Smooth zoom is supported if the
238 // value is "true". It is not supported if the value is not "true" or the
239 // key does not exist.
240 // See CAMERA_CMD_START_SMOOTH_ZOOM, CAMERA_CMD_STOP_SMOOTH_ZOOM, and
241 // CAMERA_MSG_ZOOM in frameworks/base/include/camera/Camera.h.
242 // Example value: "true". Read only.
243 static const char KEY_SMOOTH_ZOOM_SUPPORTED[];
Mathias Agopian3cf61352010-02-09 17:46:37 -0800244
Wu-cheng Li09a2ab92010-05-13 19:31:02 +0800245 // The distances (in meters) from the camera to where an object appears to
246 // be in focus. The object is sharpest at the optimal focus distance. The
247 // depth of field is the far focus distance minus near focus distance.
248 //
Wu-cheng Lic6e88fd2010-08-05 11:50:25 -0700249 // Focus distances may change after starting auto focus, canceling auto
250 // focus, or starting the preview. Applications can read this anytime to get
251 // the latest focus distances. If the focus mode is FOCUS_MODE_CONTINUOUS,
252 // focus distances may change from time to time.
253 //
254 // This is intended to estimate the distance between the camera and the
255 // subject. After autofocus, the subject distance may be within near and far
256 // focus distance. However, the precision depends on the camera hardware,
257 // autofocus algorithm, the focus area, and the scene. The error can be
258 // large and it should be only used as a reference.
Wu-cheng Li09a2ab92010-05-13 19:31:02 +0800259 //
260 // Far focus distance > optimal focus distance > near focus distance. If
261 // the far focus distance is infinity, the value should be "Infinity" (case
262 // sensitive). The format is three float values separated by commas. The
263 // first is near focus distance. The second is optimal focus distance. The
264 // third is far focus distance.
265 // Example value: "0.95,1.9,Infinity" or "0.049,0.05,0.051". Read only.
266 static const char KEY_FOCUS_DISTANCES[];
267
Wu-cheng Li0b0279e2010-05-28 17:32:41 +0800268 // The image format for video frames. See CAMERA_MSG_VIDEO_FRAME in
269 // frameworks/base/include/camera/Camera.h.
270 // Example value: "yuv420sp" or PIXEL_FORMAT_XXX constants. Read only.
271 static const char KEY_VIDEO_FRAME_FORMAT[];
272
Wu-cheng Li2b8aba22010-06-03 16:34:18 +0800273 // Metering mode. This affects how camera determines exposure.
274 // Example value: "spot" or METERING_MODE_XXX constants. Read/write.
275 static const char KEY_METERING_MODE[];
Wu-cheng Lid38bee52010-06-04 14:18:32 +0800276 // Supported metering modes.
277 // Example value: "center-weighted,frame-average,spot". Read only.
278 static const char KEY_SUPPORTED_METERING_MODES[];
Wu-cheng Li2b8aba22010-06-03 16:34:18 +0800279
Wu-cheng Lid8d888e2010-03-08 15:28:48 -0800280 // Value for KEY_ZOOM_SUPPORTED or KEY_SMOOTH_ZOOM_SUPPORTED.
281 static const char TRUE[];
282
Wu-cheng Li09a2ab92010-05-13 19:31:02 +0800283 // Value for KEY_FOCUS_DISTANCES.
Wu-cheng Liae77ffa2010-05-15 13:05:04 +0800284 static const char FOCUS_DISTANCE_INFINITY[];
Wu-cheng Li09a2ab92010-05-13 19:31:02 +0800285
Wu-cheng Li4f1bff92010-02-20 17:47:04 +0800286 // Values for white balance settings.
Mathias Agopian3cf61352010-02-09 17:46:37 -0800287 static const char WHITE_BALANCE_AUTO[];
288 static const char WHITE_BALANCE_INCANDESCENT[];
289 static const char WHITE_BALANCE_FLUORESCENT[];
290 static const char WHITE_BALANCE_WARM_FLUORESCENT[];
291 static const char WHITE_BALANCE_DAYLIGHT[];
292 static const char WHITE_BALANCE_CLOUDY_DAYLIGHT[];
293 static const char WHITE_BALANCE_TWILIGHT[];
294 static const char WHITE_BALANCE_SHADE[];
295
296 // Values for effect settings.
297 static const char EFFECT_NONE[];
298 static const char EFFECT_MONO[];
299 static const char EFFECT_NEGATIVE[];
300 static const char EFFECT_SOLARIZE[];
301 static const char EFFECT_SEPIA[];
302 static const char EFFECT_POSTERIZE[];
303 static const char EFFECT_WHITEBOARD[];
304 static const char EFFECT_BLACKBOARD[];
305 static const char EFFECT_AQUA[];
306
307 // Values for antibanding settings.
308 static const char ANTIBANDING_AUTO[];
309 static const char ANTIBANDING_50HZ[];
310 static const char ANTIBANDING_60HZ[];
311 static const char ANTIBANDING_OFF[];
312
313 // Values for flash mode settings.
314 // Flash will not be fired.
315 static const char FLASH_MODE_OFF[];
316 // Flash will be fired automatically when required. The flash may be fired
317 // during preview, auto-focus, or snapshot depending on the driver.
318 static const char FLASH_MODE_AUTO[];
319 // Flash will always be fired during snapshot. The flash may also be
320 // fired during preview or auto-focus depending on the driver.
321 static const char FLASH_MODE_ON[];
322 // Flash will be fired in red-eye reduction mode.
323 static const char FLASH_MODE_RED_EYE[];
324 // Constant emission of light during preview, auto-focus and snapshot.
325 // This can also be used for video recording.
326 static const char FLASH_MODE_TORCH[];
327
328 // Values for scene mode settings.
329 static const char SCENE_MODE_AUTO[];
330 static const char SCENE_MODE_ACTION[];
331 static const char SCENE_MODE_PORTRAIT[];
332 static const char SCENE_MODE_LANDSCAPE[];
333 static const char SCENE_MODE_NIGHT[];
334 static const char SCENE_MODE_NIGHT_PORTRAIT[];
335 static const char SCENE_MODE_THEATRE[];
336 static const char SCENE_MODE_BEACH[];
337 static const char SCENE_MODE_SNOW[];
338 static const char SCENE_MODE_SUNSET[];
339 static const char SCENE_MODE_STEADYPHOTO[];
340 static const char SCENE_MODE_FIREWORKS[];
341 static const char SCENE_MODE_SPORTS[];
342 static const char SCENE_MODE_PARTY[];
343 static const char SCENE_MODE_CANDLELIGHT[];
Wu-cheng Li465d5a72010-03-29 17:21:28 +0800344 // Applications are looking for a barcode. Camera driver will be optimized
345 // for barcode reading.
346 static const char SCENE_MODE_BARCODE[];
Mathias Agopian3cf61352010-02-09 17:46:37 -0800347
348 // Formats for setPreviewFormat and setPictureFormat.
349 static const char PIXEL_FORMAT_YUV422SP[];
350 static const char PIXEL_FORMAT_YUV420SP[]; // NV21
351 static const char PIXEL_FORMAT_YUV422I[]; // YUY2
352 static const char PIXEL_FORMAT_RGB565[];
353 static const char PIXEL_FORMAT_JPEG[];
354
355 // Values for focus mode settings.
Wu-cheng Li85b6e162010-08-17 13:44:35 -0700356 // Auto-focus mode. Applications should call
357 // CameraHardwareInterface.autoFocus to start the focus in this mode.
Mathias Agopian3cf61352010-02-09 17:46:37 -0800358 static const char FOCUS_MODE_AUTO[];
359 // Focus is set at infinity. Applications should not call
360 // CameraHardwareInterface.autoFocus in this mode.
361 static const char FOCUS_MODE_INFINITY[];
Wu-cheng Li85b6e162010-08-17 13:44:35 -0700362 // Macro (close-up) focus mode. Applications should call
363 // CameraHardwareInterface.autoFocus to start the focus in this mode.
Mathias Agopian3cf61352010-02-09 17:46:37 -0800364 static const char FOCUS_MODE_MACRO[];
365 // Focus is fixed. The camera is always in this mode if the focus is not
366 // adjustable. If the camera has auto-focus, this mode can fix the
367 // focus, which is usually at hyperfocal distance. Applications should
368 // not call CameraHardwareInterface.autoFocus in this mode.
369 static const char FOCUS_MODE_FIXED[];
Wu-cheng Li465d5a72010-03-29 17:21:28 +0800370 // Extended depth of field (EDOF). Focusing is done digitally and
371 // continuously. Applications should not call
372 // CameraHardwareInterface.autoFocus in this mode.
373 static const char FOCUS_MODE_EDOF[];
Wu-cheng Lic6e88fd2010-08-05 11:50:25 -0700374 // Continuous auto focus mode. The camera continuously tries to focus. This
375 // is ideal for shooting video or shooting photo of moving object. Auto
376 // focus starts when the parameter is set. Applications should not call
Wu-cheng Li85b6e162010-08-17 13:44:35 -0700377 // CameraHardwareInterface.autoFocus in this mode. To stop continuous
378 // focus, applications should change the focus mode to other modes.
Wu-cheng Li4bf7ace2010-05-06 16:47:30 +0800379 static const char FOCUS_MODE_CONTINUOUS[];
380
Wu-cheng Li2b8aba22010-06-03 16:34:18 +0800381 // The camera determines the exposure by giving more weight to the
382 // central part of the scene.
383 static const char METERING_MODE_CENTER_WEIGHTED[];
384 // The camera determines the exposure by averaging the entire scene,
385 // giving no weighting to any particular area.
386 static const char METERING_MODE_FRAME_AVERAGE[];
387 // The camera determines the exposure by a very small area of the scene,
388 // typically the center.
389 static const char METERING_MODE_SPOT[];
Mathias Agopian3cf61352010-02-09 17:46:37 -0800390
391private:
392 DefaultKeyedVector<String8,String8> mMap;
393};
394
395}; // namespace android
396
397#endif