blob: 20eef7246ed56b60c67b50922bf0aff49fee8cbf [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
25class CameraParameters
26{
27public:
28 CameraParameters();
29 CameraParameters(const String8 &params) { unflatten(params); }
30 ~CameraParameters();
31
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032 String8 flatten() const;
33 void unflatten(const String8 &params);
34
35 void set(const char *key, const char *value);
36 void set(const char *key, int value);
Wu-cheng Li7eae31c2010-01-31 14:19:38 +080037 void setFloat(const char *key, float value);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038 const char *get(const char *key) const;
39 int getInt(const char *key) const;
Wu-cheng Li7eae31c2010-01-31 14:19:38 +080040 float getFloat(const char *key) const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041
Wu-cheng Li78624e42010-05-11 12:11:56 +080042 void remove(const char *key);
43
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044 void setPreviewSize(int width, int height);
45 void getPreviewSize(int *width, int *height) const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080046 void setPreviewFrameRate(int fps);
47 int getPreviewFrameRate() const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080048 void setPreviewFormat(const char *format);
49 const char *getPreviewFormat() const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080050 void setPictureSize(int width, int height);
51 void getPictureSize(int *width, int *height) const;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052 void setPictureFormat(const char *format);
53 const char *getPictureFormat() const;
54
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080055 void dump() const;
56 status_t dump(int fd, const Vector<String16>& args) const;
57
Wu-cheng Li8de57d82009-09-23 14:37:52 -070058 // Parameter keys to communicate between camera application and driver.
59 // The access (read/write, read only, or write only) is viewed from the
60 // perspective of applications, not driver.
61
62 // Preview frame size in pixels (width x height).
63 // Example value: "480x320". Read/Write.
64 static const char KEY_PREVIEW_SIZE[];
65 // Supported preview frame sizes in pixels.
66 // Example value: "800x600,480x320". Read only.
67 static const char KEY_SUPPORTED_PREVIEW_SIZES[];
68 // The image format for preview frames.
69 // Example value: "yuv420sp" or PIXEL_FORMAT_XXX constants. Read/write.
70 static const char KEY_PREVIEW_FORMAT[];
71 // Supported image formats for preview frames.
72 // Example value: "yuv420sp,yuv422i-yuyv". Read only.
73 static const char KEY_SUPPORTED_PREVIEW_FORMATS[];
74 // Number of preview frames per second.
75 // Example value: "15". Read/write.
76 static const char KEY_PREVIEW_FRAME_RATE[];
77 // Supported number of preview frames per second.
78 // Example value: "24,15,10". Read.
79 static const char KEY_SUPPORTED_PREVIEW_FRAME_RATES[];
80 // The dimensions for captured pictures in pixels (width x height).
81 // Example value: "1024x768". Read/write.
82 static const char KEY_PICTURE_SIZE[];
83 // Supported dimensions for captured pictures in pixels.
84 // Example value: "2048x1536,1024x768". Read only.
85 static const char KEY_SUPPORTED_PICTURE_SIZES[];
86 // The image format for captured pictures.
87 // Example value: "jpeg" or PIXEL_FORMAT_XXX constants. Read/write.
88 static const char KEY_PICTURE_FORMAT[];
89 // Supported image formats for captured pictures.
90 // Example value: "jpeg,rgb565". Read only.
91 static const char KEY_SUPPORTED_PICTURE_FORMATS[];
92 // The width (in pixels) of EXIF thumbnail in Jpeg picture.
93 // Example value: "512". Read/write.
94 static const char KEY_JPEG_THUMBNAIL_WIDTH[];
95 // The height (in pixels) of EXIF thumbnail in Jpeg picture.
96 // Example value: "384". Read/write.
97 static const char KEY_JPEG_THUMBNAIL_HEIGHT[];
Wu-cheng Liacf77032010-01-25 15:18:18 +080098 // Supported EXIF thumbnail sizes (width x height). 0x0 means not thumbnail
99 // in EXIF.
100 // Example value: "512x384,320x240,0x0". Read only.
101 static const char KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES[];
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700102 // The quality of the EXIF thumbnail in Jpeg picture. The range is 1 to 100,
103 // with 100 being the best.
104 // Example value: "90". Read/write.
105 static const char KEY_JPEG_THUMBNAIL_QUALITY[];
106 // Jpeg quality of captured picture. The range is 1 to 100, with 100 being
107 // the best.
108 // Example value: "90". Read/write.
109 static const char KEY_JPEG_QUALITY[];
110 // The orientation of the device in degrees. For example, suppose the
111 // natural position of the device is landscape. If the user takes a picture
112 // in landscape mode in 2048x1536 resolution, the rotation will be set to
113 // "0". If the user rotates the phone 90 degrees clockwise, the rotation
114 // should be set to "90".
115 // The camera driver can set orientation in the EXIF header without rotating
116 // the picture. Or the driver can rotate the picture and the EXIF thumbnail.
117 // If the Jpeg picture is rotated, the orientation in the EXIF header should
118 // be missing or 1 (row #0 is top and column #0 is left side). The driver
119 // should not set default value for this parameter.
120 // Example value: "0" or "90" or "180" or "270". Write only.
121 static const char KEY_ROTATION[];
122 // GPS latitude coordinate. This will be stored in JPEG EXIF header.
123 // Example value: "25.032146". Write only.
124 static const char KEY_GPS_LATITUDE[];
125 // GPS longitude coordinate. This will be stored in JPEG EXIF header.
126 // Example value: "121.564448". Write only.
127 static const char KEY_GPS_LONGITUDE[];
128 // GPS altitude. This will be stored in JPEG EXIF header.
129 // Example value: "21.0". Write only.
130 static const char KEY_GPS_ALTITUDE[];
131 // GPS timestamp (UTC in seconds since January 1, 1970). This should be
132 // stored in JPEG EXIF header.
133 // Example value: "1251192757". Write only.
134 static const char KEY_GPS_TIMESTAMP[];
Ray Chen055c9862010-02-23 10:45:42 +0800135 // GPS Processing Method
136 // Example value: "GPS" or "NETWORK". Write only.
137 static const char KEY_GPS_PROCESSING_METHOD[];
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700138 // Current white balance setting.
139 // Example value: "auto" or WHITE_BALANCE_XXX constants. Read/write.
140 static const char KEY_WHITE_BALANCE[];
141 // Supported white balance settings.
142 // Example value: "auto,incandescent,daylight". Read only.
143 static const char KEY_SUPPORTED_WHITE_BALANCE[];
144 // Current color effect setting.
145 // Example value: "none" or EFFECT_XXX constants. Read/write.
146 static const char KEY_EFFECT[];
147 // Supported color effect settings.
148 // Example value: "none,mono,sepia". Read only.
149 static const char KEY_SUPPORTED_EFFECTS[];
150 // Current antibanding setting.
151 // Example value: "auto" or ANTIBANDING_XXX constants. Read/write.
152 static const char KEY_ANTIBANDING[];
153 // Supported antibanding settings.
154 // Example value: "auto,50hz,60hz,off". Read only.
155 static const char KEY_SUPPORTED_ANTIBANDING[];
156 // Current scene mode.
157 // Example value: "auto" or SCENE_MODE_XXX constants. Read/write.
158 static const char KEY_SCENE_MODE[];
159 // Supported scene mode settings.
160 // Example value: "auto,night,fireworks". Read only.
161 static const char KEY_SUPPORTED_SCENE_MODES[];
162 // Current flash mode.
163 // Example value: "auto" or FLASH_MODE_XXX constants. Read/write.
164 static const char KEY_FLASH_MODE[];
165 // Supported flash modes.
166 // Example value: "auto,on,off". Read only.
167 static const char KEY_SUPPORTED_FLASH_MODES[];
168 // Current focus mode. If the camera does not support auto-focus, the value
169 // should be FOCUS_MODE_FIXED. If the focus mode is not FOCUS_MODE_FIXED or
170 // or FOCUS_MODE_INFINITY, applications should call
171 // CameraHardwareInterface.autoFocus to start the focus.
172 // Example value: "auto" or FOCUS_MODE_XXX constants. Read/write.
173 static const char KEY_FOCUS_MODE[];
174 // Supported focus modes.
175 // Example value: "auto,macro,fixed". Read only.
176 static const char KEY_SUPPORTED_FOCUS_MODES[];
Wu-cheng Li6c8d2762010-01-27 22:55:14 +0800177 // Focal length in millimeter.
178 // Example value: "4.31". Read only.
179 static const char KEY_FOCAL_LENGTH[];
180 // Horizontal angle of view in degrees.
181 // Example value: "54.8". Read only.
182 static const char KEY_HORIZONTAL_VIEW_ANGLE[];
183 // Vertical angle of view in degrees.
184 // Example value: "42.5". Read only.
185 static const char KEY_VERTICAL_VIEW_ANGLE[];
Wu-cheng Li24b326a2010-02-20 17:47:04 +0800186 // Exposure compensation index. 0 means exposure is not adjusted.
187 // Example value: "0" or "5". Read/write.
Wu-cheng Liff723b62010-02-09 13:38:19 +0800188 static const char KEY_EXPOSURE_COMPENSATION[];
Wu-cheng Li24b326a2010-02-20 17:47:04 +0800189 // The maximum exposure compensation index (>=0).
190 // Example value: "6". Read only.
191 static const char KEY_MAX_EXPOSURE_COMPENSATION[];
192 // The minimum exposure compensation index (<=0).
193 // Example value: "-6". Read only.
194 static const char KEY_MIN_EXPOSURE_COMPENSATION[];
195 // The exposure compensation step. Exposure compensation index multiply by
196 // step eqals to EV. Ex: if exposure compensation index is 6 and step is
197 // 0.3333, EV is -2.
198 // Example value: "0.333333333" or "0.5". Read only.
199 static const char KEY_EXPOSURE_COMPENSATION_STEP[];
Wu-cheng Li8cbb8f52010-02-28 23:19:55 -0800200 // Current zoom value.
201 // Example value: "0" or "6". Read/write.
202 static const char KEY_ZOOM[];
203 // Maximum zoom value.
204 // Example value: "6". Read only.
205 static const char KEY_MAX_ZOOM[];
206 // The zoom ratios of all zoom values. The zoom ratio is in 1/100
207 // increments. Ex: a zoom of 3.2x is returned as 320. The number of list
208 // elements is KEY_MAX_ZOOM + 1. The first element is always 100. The last
209 // element is the zoom ratio of zoom value KEY_MAX_ZOOM.
210 // Example value: "100,150,200,250,300,350,400". Read only.
211 static const char KEY_ZOOM_RATIOS[];
212 // Whether zoom is supported. Zoom is supported if the value is "true". Zoom
213 // is not supported if the value is not "true" or the key does not exist.
214 // Example value: "true". Read only.
215 static const char KEY_ZOOM_SUPPORTED[];
216 // Whether if smooth zoom is supported. Smooth zoom is supported if the
217 // value is "true". It is not supported if the value is not "true" or the
218 // key does not exist.
219 // See CAMERA_CMD_START_SMOOTH_ZOOM, CAMERA_CMD_STOP_SMOOTH_ZOOM, and
220 // CAMERA_MSG_ZOOM in frameworks/base/include/camera/Camera.h.
221 // Example value: "true". Read only.
222 static const char KEY_SMOOTH_ZOOM_SUPPORTED[];
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700223
Wu-cheng Lie339c5e2010-05-13 19:31:02 +0800224 // The distances (in meters) from the camera to where an object appears to
225 // be in focus. The object is sharpest at the optimal focus distance. The
226 // depth of field is the far focus distance minus near focus distance.
227 //
228 // Applications can read this parameter anytime to get the latest focus
229 // distances. If the focus mode is FOCUS_MODE_EDOF, the values may be all
230 // 0, which means focus distance is not applicable. If the focus mode is
231 // FOCUS_MODE_CONTINUOUS and autofocus has started, focus distances may
232 // change from time to time.
233 //
234 // Far focus distance > optimal focus distance > near focus distance. If
235 // the far focus distance is infinity, the value should be "Infinity" (case
236 // sensitive). The format is three float values separated by commas. The
237 // first is near focus distance. The second is optimal focus distance. The
238 // third is far focus distance.
239 // Example value: "0.95,1.9,Infinity" or "0.049,0.05,0.051". Read only.
240 static const char KEY_FOCUS_DISTANCES[];
241
Wu-cheng Lid9ef5d72010-03-08 15:28:48 -0800242 // Value for KEY_ZOOM_SUPPORTED or KEY_SMOOTH_ZOOM_SUPPORTED.
243 static const char TRUE[];
244
Wu-cheng Lie339c5e2010-05-13 19:31:02 +0800245 // Value for KEY_FOCUS_DISTANCES.
Wu-cheng Liae7ca4c2010-05-15 13:05:04 +0800246 static const char FOCUS_DISTANCE_INFINITY[];
Wu-cheng Lie339c5e2010-05-13 19:31:02 +0800247
Wu-cheng Li24b326a2010-02-20 17:47:04 +0800248 // Values for white balance settings.
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700249 static const char WHITE_BALANCE_AUTO[];
250 static const char WHITE_BALANCE_INCANDESCENT[];
251 static const char WHITE_BALANCE_FLUORESCENT[];
252 static const char WHITE_BALANCE_WARM_FLUORESCENT[];
253 static const char WHITE_BALANCE_DAYLIGHT[];
254 static const char WHITE_BALANCE_CLOUDY_DAYLIGHT[];
255 static const char WHITE_BALANCE_TWILIGHT[];
256 static const char WHITE_BALANCE_SHADE[];
257
258 // Values for effect settings.
259 static const char EFFECT_NONE[];
260 static const char EFFECT_MONO[];
261 static const char EFFECT_NEGATIVE[];
262 static const char EFFECT_SOLARIZE[];
263 static const char EFFECT_SEPIA[];
264 static const char EFFECT_POSTERIZE[];
265 static const char EFFECT_WHITEBOARD[];
266 static const char EFFECT_BLACKBOARD[];
267 static const char EFFECT_AQUA[];
268
269 // Values for antibanding settings.
270 static const char ANTIBANDING_AUTO[];
271 static const char ANTIBANDING_50HZ[];
272 static const char ANTIBANDING_60HZ[];
273 static const char ANTIBANDING_OFF[];
274
275 // Values for flash mode settings.
276 // Flash will not be fired.
277 static const char FLASH_MODE_OFF[];
Wu-cheng Life1a86d2009-09-28 13:51:12 -0700278 // Flash will be fired automatically when required. The flash may be fired
279 // during preview, auto-focus, or snapshot depending on the driver.
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700280 static const char FLASH_MODE_AUTO[];
Wu-cheng Life1a86d2009-09-28 13:51:12 -0700281 // Flash will always be fired during snapshot. The flash may also be
282 // fired during preview or auto-focus depending on the driver.
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700283 static const char FLASH_MODE_ON[];
284 // Flash will be fired in red-eye reduction mode.
285 static const char FLASH_MODE_RED_EYE[];
Wu-cheng Life1a86d2009-09-28 13:51:12 -0700286 // Constant emission of light during preview, auto-focus and snapshot.
287 // This can also be used for video recording.
288 static const char FLASH_MODE_TORCH[];
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700289
290 // Values for scene mode settings.
291 static const char SCENE_MODE_AUTO[];
292 static const char SCENE_MODE_ACTION[];
293 static const char SCENE_MODE_PORTRAIT[];
294 static const char SCENE_MODE_LANDSCAPE[];
295 static const char SCENE_MODE_NIGHT[];
296 static const char SCENE_MODE_NIGHT_PORTRAIT[];
297 static const char SCENE_MODE_THEATRE[];
298 static const char SCENE_MODE_BEACH[];
299 static const char SCENE_MODE_SNOW[];
300 static const char SCENE_MODE_SUNSET[];
301 static const char SCENE_MODE_STEADYPHOTO[];
302 static const char SCENE_MODE_FIREWORKS[];
303 static const char SCENE_MODE_SPORTS[];
304 static const char SCENE_MODE_PARTY[];
305 static const char SCENE_MODE_CANDLELIGHT[];
Wu-cheng Lic58b4232010-03-29 17:21:28 +0800306 // Applications are looking for a barcode. Camera driver will be optimized
307 // for barcode reading.
308 static const char SCENE_MODE_BARCODE[];
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700309
310 // Formats for setPreviewFormat and setPictureFormat.
311 static const char PIXEL_FORMAT_YUV422SP[];
312 static const char PIXEL_FORMAT_YUV420SP[]; // NV21
313 static const char PIXEL_FORMAT_YUV422I[]; // YUY2
314 static const char PIXEL_FORMAT_RGB565[];
315 static const char PIXEL_FORMAT_JPEG[];
316
317 // Values for focus mode settings.
318 // Auto-focus mode.
319 static const char FOCUS_MODE_AUTO[];
320 // Focus is set at infinity. Applications should not call
321 // CameraHardwareInterface.autoFocus in this mode.
322 static const char FOCUS_MODE_INFINITY[];
323 static const char FOCUS_MODE_MACRO[];
324 // Focus is fixed. The camera is always in this mode if the focus is not
325 // adjustable. If the camera has auto-focus, this mode can fix the
326 // focus, which is usually at hyperfocal distance. Applications should
327 // not call CameraHardwareInterface.autoFocus in this mode.
328 static const char FOCUS_MODE_FIXED[];
Wu-cheng Lic58b4232010-03-29 17:21:28 +0800329 // Extended depth of field (EDOF). Focusing is done digitally and
330 // continuously. Applications should not call
331 // CameraHardwareInterface.autoFocus in this mode.
332 static const char FOCUS_MODE_EDOF[];
Wu-cheng Lica099612010-05-06 16:47:30 +0800333 // Continuous focus mode. The camera continuously tries to focus. This is
334 // ideal for shooting video or shooting photo of moving object. Continuous
335 // focus starts when CameraHardwareInterface.autoFocus is called. Focus
336 // callback will be only called once as soon as the picture is in focus.
337 static const char FOCUS_MODE_CONTINUOUS[];
338
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700339
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800340private:
341 DefaultKeyedVector<String8,String8> mMap;
342};
343
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800344}; // namespace android
345
346#endif