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