blob: 9df26958303183b0b4333234d6ce68158a1f6a8a [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
25class CameraParameters
26{
27public:
28 CameraParameters();
29 CameraParameters(const String8 &params) { unflatten(params); }
30 ~CameraParameters();
31
32 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);
37 void setFloat(const char *key, float value);
38 const char *get(const char *key) const;
39 int getInt(const char *key) const;
40 float getFloat(const char *key) const;
41
42 /* preview-size=176x144 */
43 void setPreviewSize(int width, int height);
44 void getPreviewSize(int *width, int *height) const;
45
46 /* preview-fps=15 */
47 void setPreviewFrameRate(int fps);
48 int getPreviewFrameRate() const;
49
50 /* preview-format=rgb565|yuv422 */
51 void setPreviewFormat(const char *format);
52 const char *getPreviewFormat() const;
53
54 /* picture-size=1024x768 */
55 void setPictureSize(int width, int height);
56 void getPictureSize(int *width, int *height) const;
57
58 /* picture-format=yuv422|jpeg */
59 void setPictureFormat(const char *format);
60 const char *getPictureFormat() const;
61
62 void dump() const;
63 status_t dump(int fd, const Vector<String16>& args) const;
64
65 // Parameter keys to communicate between camera application and driver.
66 // The access (read/write, read only, or write only) is viewed from the
67 // perspective of applications, not driver.
68
69 // Preview frame size in pixels (width x height).
70 // Example value: "480x320". Read/Write.
71 static const char KEY_PREVIEW_SIZE[];
72 // Supported preview frame sizes in pixels.
73 // Example value: "800x600,480x320". Read only.
74 static const char KEY_SUPPORTED_PREVIEW_SIZES[];
75 // The image format for preview frames.
76 // Example value: "yuv420sp" or PIXEL_FORMAT_XXX constants. Read/write.
77 static const char KEY_PREVIEW_FORMAT[];
78 // Supported image formats for preview frames.
79 // Example value: "yuv420sp,yuv422i-yuyv". Read only.
80 static const char KEY_SUPPORTED_PREVIEW_FORMATS[];
81 // Number of preview frames per second.
82 // Example value: "15". Read/write.
83 static const char KEY_PREVIEW_FRAME_RATE[];
84 // Supported number of preview frames per second.
85 // Example value: "24,15,10". Read.
86 static const char KEY_SUPPORTED_PREVIEW_FRAME_RATES[];
87 // The dimensions for captured pictures in pixels (width x height).
88 // Example value: "1024x768". Read/write.
89 static const char KEY_PICTURE_SIZE[];
90 // Supported dimensions for captured pictures in pixels.
91 // Example value: "2048x1536,1024x768". Read only.
92 static const char KEY_SUPPORTED_PICTURE_SIZES[];
93 // The image format for captured pictures.
94 // Example value: "jpeg" or PIXEL_FORMAT_XXX constants. Read/write.
95 static const char KEY_PICTURE_FORMAT[];
96 // Supported image formats for captured pictures.
97 // Example value: "jpeg,rgb565". Read only.
98 static const char KEY_SUPPORTED_PICTURE_FORMATS[];
99 // The width (in pixels) of EXIF thumbnail in Jpeg picture.
100 // Example value: "512". Read/write.
101 static const char KEY_JPEG_THUMBNAIL_WIDTH[];
102 // The height (in pixels) of EXIF thumbnail in Jpeg picture.
103 // Example value: "384". Read/write.
104 static const char KEY_JPEG_THUMBNAIL_HEIGHT[];
105 // Supported EXIF thumbnail sizes (width x height). 0x0 means not thumbnail
106 // in EXIF.
107 // Example value: "512x384,320x240,0x0". Read only.
108 static const char KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES[];
109 // The quality of the EXIF thumbnail in Jpeg picture. The range is 1 to 100,
110 // with 100 being the best.
111 // Example value: "90". Read/write.
112 static const char KEY_JPEG_THUMBNAIL_QUALITY[];
113 // Jpeg quality of captured picture. The range is 1 to 100, with 100 being
114 // the best.
115 // Example value: "90". Read/write.
116 static const char KEY_JPEG_QUALITY[];
117 // The orientation of the device in degrees. For example, suppose the
118 // natural position of the device is landscape. If the user takes a picture
119 // in landscape mode in 2048x1536 resolution, the rotation will be set to
120 // "0". If the user rotates the phone 90 degrees clockwise, the rotation
121 // should be set to "90".
122 // The camera driver can set orientation in the EXIF header without rotating
123 // the picture. Or the driver can rotate the picture and the EXIF thumbnail.
124 // If the Jpeg picture is rotated, the orientation in the EXIF header should
125 // be missing or 1 (row #0 is top and column #0 is left side). The driver
126 // should not set default value for this parameter.
127 // Example value: "0" or "90" or "180" or "270". Write only.
128 static const char KEY_ROTATION[];
129 // GPS latitude coordinate. This will be stored in JPEG EXIF header.
130 // Example value: "25.032146". Write only.
131 static const char KEY_GPS_LATITUDE[];
132 // GPS longitude coordinate. This will be stored in JPEG EXIF header.
133 // Example value: "121.564448". Write only.
134 static const char KEY_GPS_LONGITUDE[];
135 // GPS altitude. This will be stored in JPEG EXIF header.
136 // Example value: "21.0". Write only.
137 static const char KEY_GPS_ALTITUDE[];
138 // GPS timestamp (UTC in seconds since January 1, 1970). This should be
139 // stored in JPEG EXIF header.
140 // Example value: "1251192757". Write only.
141 static const char KEY_GPS_TIMESTAMP[];
142 // Current white balance setting.
143 // Example value: "auto" or WHITE_BALANCE_XXX constants. Read/write.
144 static const char KEY_WHITE_BALANCE[];
145 // Supported white balance settings.
146 // Example value: "auto,incandescent,daylight". Read only.
147 static const char KEY_SUPPORTED_WHITE_BALANCE[];
148 // Current color effect setting.
149 // Example value: "none" or EFFECT_XXX constants. Read/write.
150 static const char KEY_EFFECT[];
151 // Supported color effect settings.
152 // Example value: "none,mono,sepia". Read only.
153 static const char KEY_SUPPORTED_EFFECTS[];
154 // Current antibanding setting.
155 // Example value: "auto" or ANTIBANDING_XXX constants. Read/write.
156 static const char KEY_ANTIBANDING[];
157 // Supported antibanding settings.
158 // Example value: "auto,50hz,60hz,off". Read only.
159 static const char KEY_SUPPORTED_ANTIBANDING[];
160 // Current scene mode.
161 // Example value: "auto" or SCENE_MODE_XXX constants. Read/write.
162 static const char KEY_SCENE_MODE[];
163 // Supported scene mode settings.
164 // Example value: "auto,night,fireworks". Read only.
165 static const char KEY_SUPPORTED_SCENE_MODES[];
166 // Current flash mode.
167 // Example value: "auto" or FLASH_MODE_XXX constants. Read/write.
168 static const char KEY_FLASH_MODE[];
169 // Supported flash modes.
170 // Example value: "auto,on,off". Read only.
171 static const char KEY_SUPPORTED_FLASH_MODES[];
172 // Current focus mode. If the camera does not support auto-focus, the value
173 // should be FOCUS_MODE_FIXED. If the focus mode is not FOCUS_MODE_FIXED or
174 // or FOCUS_MODE_INFINITY, applications should call
175 // CameraHardwareInterface.autoFocus to start the focus.
176 // Example value: "auto" or FOCUS_MODE_XXX constants. Read/write.
177 static const char KEY_FOCUS_MODE[];
178 // Supported focus modes.
179 // Example value: "auto,macro,fixed". Read only.
180 static const char KEY_SUPPORTED_FOCUS_MODES[];
181 // Focal length in millimeter.
182 // Example value: "4.31". Read only.
183 static const char KEY_FOCAL_LENGTH[];
184 // Horizontal angle of view in degrees.
185 // Example value: "54.8". Read only.
186 static const char KEY_HORIZONTAL_VIEW_ANGLE[];
187 // Vertical angle of view in degrees.
188 // Example value: "42.5". Read only.
189 static const char KEY_VERTICAL_VIEW_ANGLE[];
Wu-cheng Li4f1bff92010-02-20 17:47:04 +0800190 // Exposure compensation index. 0 means exposure is not adjusted.
191 // Example value: "0" or "5". Read/write.
Mathias Agopian3cf61352010-02-09 17:46:37 -0800192 static const char KEY_EXPOSURE_COMPENSATION[];
Wu-cheng Li4f1bff92010-02-20 17:47:04 +0800193 // The maximum exposure compensation index (>=0).
194 // Example value: "6". Read only.
195 static const char KEY_MAX_EXPOSURE_COMPENSATION[];
196 // The minimum exposure compensation index (<=0).
197 // Example value: "-6". Read only.
198 static const char KEY_MIN_EXPOSURE_COMPENSATION[];
199 // The exposure compensation step. Exposure compensation index multiply by
200 // step eqals to EV. Ex: if exposure compensation index is 6 and step is
201 // 0.3333, EV is -2.
202 // Example value: "0.333333333" or "0.5". Read only.
203 static const char KEY_EXPOSURE_COMPENSATION_STEP[];
Mathias Agopian3cf61352010-02-09 17:46:37 -0800204
205
Wu-cheng Li4f1bff92010-02-20 17:47:04 +0800206 // Values for white balance settings.
Mathias Agopian3cf61352010-02-09 17:46:37 -0800207 static const char WHITE_BALANCE_AUTO[];
208 static const char WHITE_BALANCE_INCANDESCENT[];
209 static const char WHITE_BALANCE_FLUORESCENT[];
210 static const char WHITE_BALANCE_WARM_FLUORESCENT[];
211 static const char WHITE_BALANCE_DAYLIGHT[];
212 static const char WHITE_BALANCE_CLOUDY_DAYLIGHT[];
213 static const char WHITE_BALANCE_TWILIGHT[];
214 static const char WHITE_BALANCE_SHADE[];
215
216 // Values for effect settings.
217 static const char EFFECT_NONE[];
218 static const char EFFECT_MONO[];
219 static const char EFFECT_NEGATIVE[];
220 static const char EFFECT_SOLARIZE[];
221 static const char EFFECT_SEPIA[];
222 static const char EFFECT_POSTERIZE[];
223 static const char EFFECT_WHITEBOARD[];
224 static const char EFFECT_BLACKBOARD[];
225 static const char EFFECT_AQUA[];
226
227 // Values for antibanding settings.
228 static const char ANTIBANDING_AUTO[];
229 static const char ANTIBANDING_50HZ[];
230 static const char ANTIBANDING_60HZ[];
231 static const char ANTIBANDING_OFF[];
232
233 // Values for flash mode settings.
234 // Flash will not be fired.
235 static const char FLASH_MODE_OFF[];
236 // Flash will be fired automatically when required. The flash may be fired
237 // during preview, auto-focus, or snapshot depending on the driver.
238 static const char FLASH_MODE_AUTO[];
239 // Flash will always be fired during snapshot. The flash may also be
240 // fired during preview or auto-focus depending on the driver.
241 static const char FLASH_MODE_ON[];
242 // Flash will be fired in red-eye reduction mode.
243 static const char FLASH_MODE_RED_EYE[];
244 // Constant emission of light during preview, auto-focus and snapshot.
245 // This can also be used for video recording.
246 static const char FLASH_MODE_TORCH[];
247
248 // Values for scene mode settings.
249 static const char SCENE_MODE_AUTO[];
250 static const char SCENE_MODE_ACTION[];
251 static const char SCENE_MODE_PORTRAIT[];
252 static const char SCENE_MODE_LANDSCAPE[];
253 static const char SCENE_MODE_NIGHT[];
254 static const char SCENE_MODE_NIGHT_PORTRAIT[];
255 static const char SCENE_MODE_THEATRE[];
256 static const char SCENE_MODE_BEACH[];
257 static const char SCENE_MODE_SNOW[];
258 static const char SCENE_MODE_SUNSET[];
259 static const char SCENE_MODE_STEADYPHOTO[];
260 static const char SCENE_MODE_FIREWORKS[];
261 static const char SCENE_MODE_SPORTS[];
262 static const char SCENE_MODE_PARTY[];
263 static const char SCENE_MODE_CANDLELIGHT[];
264
265 // Formats for setPreviewFormat and setPictureFormat.
266 static const char PIXEL_FORMAT_YUV422SP[];
267 static const char PIXEL_FORMAT_YUV420SP[]; // NV21
268 static const char PIXEL_FORMAT_YUV422I[]; // YUY2
269 static const char PIXEL_FORMAT_RGB565[];
270 static const char PIXEL_FORMAT_JPEG[];
271
272 // Values for focus mode settings.
273 // Auto-focus mode.
274 static const char FOCUS_MODE_AUTO[];
275 // Focus is set at infinity. Applications should not call
276 // CameraHardwareInterface.autoFocus in this mode.
277 static const char FOCUS_MODE_INFINITY[];
278 static const char FOCUS_MODE_MACRO[];
279 // Focus is fixed. The camera is always in this mode if the focus is not
280 // adjustable. If the camera has auto-focus, this mode can fix the
281 // focus, which is usually at hyperfocal distance. Applications should
282 // not call CameraHardwareInterface.autoFocus in this mode.
283 static const char FOCUS_MODE_FIXED[];
284
285private:
286 DefaultKeyedVector<String8,String8> mMap;
287};
288
289}; // namespace android
290
291#endif