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