blob: 0fd79a4eb961975f19db253459ef8034ae9e3096 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2**
3** Copyright 2008, The Android Open Source Project
4**
Wu-cheng Li8de57d82009-09-23 14:37:52 -07005** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008**
Wu-cheng Li8de57d82009-09-23 14:37:52 -07009** http://www.apache.org/licenses/LICENSE-2.0
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080010**
Wu-cheng Li8de57d82009-09-23 14:37:52 -070011** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080015** limitations under the License.
16*/
17
18#define LOG_TAG "CameraParams"
19#include <utils/Log.h>
20
21#include <string.h>
22#include <stdlib.h>
Mathias Agopian000479f2010-02-09 17:46:37 -080023#include <camera/CameraParameters.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024
25namespace android {
Wu-cheng Li8de57d82009-09-23 14:37:52 -070026// Parameter keys to communicate between camera application and driver.
27const char CameraParameters::KEY_PREVIEW_SIZE[] = "preview-size";
28const char CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES[] = "preview-size-values";
29const char CameraParameters::KEY_PREVIEW_FORMAT[] = "preview-format";
30const char CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS[] = "preview-format-values";
31const char CameraParameters::KEY_PREVIEW_FRAME_RATE[] = "preview-frame-rate";
32const char CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES[] = "preview-frame-rate-values";
Wu-cheng Li454630f2010-08-11 16:48:05 -070033const char CameraParameters::KEY_PREVIEW_FPS_RANGE[] = "preview-fps-range";
34const char CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE[] = "preview-fps-range-values";
Wu-cheng Li8de57d82009-09-23 14:37:52 -070035const char CameraParameters::KEY_PICTURE_SIZE[] = "picture-size";
36const char CameraParameters::KEY_SUPPORTED_PICTURE_SIZES[] = "picture-size-values";
37const char CameraParameters::KEY_PICTURE_FORMAT[] = "picture-format";
38const char CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS[] = "picture-format-values";
39const char CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH[] = "jpeg-thumbnail-width";
40const char CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT[] = "jpeg-thumbnail-height";
Wu-cheng Liacf77032010-01-25 15:18:18 +080041const char CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES[] = "jpeg-thumbnail-size-values";
Wu-cheng Li8de57d82009-09-23 14:37:52 -070042const char CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY[] = "jpeg-thumbnail-quality";
43const char CameraParameters::KEY_JPEG_QUALITY[] = "jpeg-quality";
44const char CameraParameters::KEY_ROTATION[] = "rotation";
45const char CameraParameters::KEY_GPS_LATITUDE[] = "gps-latitude";
46const char CameraParameters::KEY_GPS_LONGITUDE[] = "gps-longitude";
47const char CameraParameters::KEY_GPS_ALTITUDE[] = "gps-altitude";
48const char CameraParameters::KEY_GPS_TIMESTAMP[] = "gps-timestamp";
Ray Chen055c9862010-02-23 10:45:42 +080049const char CameraParameters::KEY_GPS_PROCESSING_METHOD[] = "gps-processing-method";
Wu-cheng Li8de57d82009-09-23 14:37:52 -070050const char CameraParameters::KEY_WHITE_BALANCE[] = "whitebalance";
51const char CameraParameters::KEY_SUPPORTED_WHITE_BALANCE[] = "whitebalance-values";
52const char CameraParameters::KEY_EFFECT[] = "effect";
53const char CameraParameters::KEY_SUPPORTED_EFFECTS[] = "effect-values";
54const char CameraParameters::KEY_ANTIBANDING[] = "antibanding";
55const char CameraParameters::KEY_SUPPORTED_ANTIBANDING[] = "antibanding-values";
56const char CameraParameters::KEY_SCENE_MODE[] = "scene-mode";
57const char CameraParameters::KEY_SUPPORTED_SCENE_MODES[] = "scene-mode-values";
58const char CameraParameters::KEY_FLASH_MODE[] = "flash-mode";
59const char CameraParameters::KEY_SUPPORTED_FLASH_MODES[] = "flash-mode-values";
60const char CameraParameters::KEY_FOCUS_MODE[] = "focus-mode";
61const char CameraParameters::KEY_SUPPORTED_FOCUS_MODES[] = "focus-mode-values";
Wu-cheng Li6c8d2762010-01-27 22:55:14 +080062const char CameraParameters::KEY_FOCAL_LENGTH[] = "focal-length";
63const char CameraParameters::KEY_HORIZONTAL_VIEW_ANGLE[] = "horizontal-view-angle";
64const char CameraParameters::KEY_VERTICAL_VIEW_ANGLE[] = "vertical-view-angle";
Wu-cheng Liff723b62010-02-09 13:38:19 +080065const char CameraParameters::KEY_EXPOSURE_COMPENSATION[] = "exposure-compensation";
Wu-cheng Li24b326a2010-02-20 17:47:04 +080066const char CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION[] = "max-exposure-compensation";
67const char CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION[] = "min-exposure-compensation";
68const char CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP[] = "exposure-compensation-step";
Wu-cheng Li8cbb8f52010-02-28 23:19:55 -080069const char CameraParameters::KEY_ZOOM[] = "zoom";
70const char CameraParameters::KEY_MAX_ZOOM[] = "max-zoom";
71const char CameraParameters::KEY_ZOOM_RATIOS[] = "zoom-ratios";
72const char CameraParameters::KEY_ZOOM_SUPPORTED[] = "zoom-supported";
73const char CameraParameters::KEY_SMOOTH_ZOOM_SUPPORTED[] = "smooth-zoom-supported";
Wu-cheng Lie339c5e2010-05-13 19:31:02 +080074const char CameraParameters::KEY_FOCUS_DISTANCES[] = "focus-distances";
Wu-cheng Lid2c29292010-05-28 17:32:41 +080075const char CameraParameters::KEY_VIDEO_FRAME_FORMAT[] = "video-frame-format";
James Dong4fd446f2010-09-30 10:50:51 -070076const char CameraParameters::KEY_VIDEO_SIZE[] = "video-size";
77const char CameraParameters::KEY_SUPPORTED_VIDEO_SIZES[] = "video-size-values";
James Dong4ddca9b2010-11-29 16:51:55 -080078const char CameraParameters::KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO[] = "preferred-preview-size-for-video";
Wu-cheng Li8de57d82009-09-23 14:37:52 -070079
Wu-cheng Lid9ef5d72010-03-08 15:28:48 -080080const char CameraParameters::TRUE[] = "true";
Wu-cheng Liae7ca4c2010-05-15 13:05:04 +080081const char CameraParameters::FOCUS_DISTANCE_INFINITY[] = "Infinity";
Wu-cheng Lid9ef5d72010-03-08 15:28:48 -080082
Wu-cheng Li8de57d82009-09-23 14:37:52 -070083// Values for white balance settings.
84const char CameraParameters::WHITE_BALANCE_AUTO[] = "auto";
85const char CameraParameters::WHITE_BALANCE_INCANDESCENT[] = "incandescent";
86const char CameraParameters::WHITE_BALANCE_FLUORESCENT[] = "fluorescent";
87const char CameraParameters::WHITE_BALANCE_WARM_FLUORESCENT[] = "warm-fluorescent";
88const char CameraParameters::WHITE_BALANCE_DAYLIGHT[] = "daylight";
89const char CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT[] = "cloudy-daylight";
90const char CameraParameters::WHITE_BALANCE_TWILIGHT[] = "twilight";
91const char CameraParameters::WHITE_BALANCE_SHADE[] = "shade";
92
93// Values for effect settings.
94const char CameraParameters::EFFECT_NONE[] = "none";
95const char CameraParameters::EFFECT_MONO[] = "mono";
96const char CameraParameters::EFFECT_NEGATIVE[] = "negative";
97const char CameraParameters::EFFECT_SOLARIZE[] = "solarize";
98const char CameraParameters::EFFECT_SEPIA[] = "sepia";
99const char CameraParameters::EFFECT_POSTERIZE[] = "posterize";
100const char CameraParameters::EFFECT_WHITEBOARD[] = "whiteboard";
101const char CameraParameters::EFFECT_BLACKBOARD[] = "blackboard";
102const char CameraParameters::EFFECT_AQUA[] = "aqua";
103
104// Values for antibanding settings.
105const char CameraParameters::ANTIBANDING_AUTO[] = "auto";
106const char CameraParameters::ANTIBANDING_50HZ[] = "50hz";
107const char CameraParameters::ANTIBANDING_60HZ[] = "60hz";
108const char CameraParameters::ANTIBANDING_OFF[] = "off";
109
110// Values for flash mode settings.
111const char CameraParameters::FLASH_MODE_OFF[] = "off";
112const char CameraParameters::FLASH_MODE_AUTO[] = "auto";
113const char CameraParameters::FLASH_MODE_ON[] = "on";
114const char CameraParameters::FLASH_MODE_RED_EYE[] = "red-eye";
Wu-cheng Life1a86d2009-09-28 13:51:12 -0700115const char CameraParameters::FLASH_MODE_TORCH[] = "torch";
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700116
117// Values for scene mode settings.
118const char CameraParameters::SCENE_MODE_AUTO[] = "auto";
119const char CameraParameters::SCENE_MODE_ACTION[] = "action";
120const char CameraParameters::SCENE_MODE_PORTRAIT[] = "portrait";
121const char CameraParameters::SCENE_MODE_LANDSCAPE[] = "landscape";
122const char CameraParameters::SCENE_MODE_NIGHT[] = "night";
123const char CameraParameters::SCENE_MODE_NIGHT_PORTRAIT[] = "night-portrait";
124const char CameraParameters::SCENE_MODE_THEATRE[] = "theatre";
125const char CameraParameters::SCENE_MODE_BEACH[] = "beach";
126const char CameraParameters::SCENE_MODE_SNOW[] = "snow";
127const char CameraParameters::SCENE_MODE_SUNSET[] = "sunset";
128const char CameraParameters::SCENE_MODE_STEADYPHOTO[] = "steadyphoto";
129const char CameraParameters::SCENE_MODE_FIREWORKS[] = "fireworks";
130const char CameraParameters::SCENE_MODE_SPORTS[] = "sports";
131const char CameraParameters::SCENE_MODE_PARTY[] = "party";
132const char CameraParameters::SCENE_MODE_CANDLELIGHT[] = "candlelight";
Wu-cheng Lic58b4232010-03-29 17:21:28 +0800133const char CameraParameters::SCENE_MODE_BARCODE[] = "barcode";
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700134
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700135const char CameraParameters::PIXEL_FORMAT_YUV422SP[] = "yuv422sp";
136const char CameraParameters::PIXEL_FORMAT_YUV420SP[] = "yuv420sp";
137const char CameraParameters::PIXEL_FORMAT_YUV422I[] = "yuv422i-yuyv";
Wu-cheng Li10a1b302011-02-22 15:49:25 +0800138const char CameraParameters::PIXEL_FORMAT_YUV420P[] = "yuv420p";
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700139const char CameraParameters::PIXEL_FORMAT_RGB565[] = "rgb565";
140const char CameraParameters::PIXEL_FORMAT_JPEG[] = "jpeg";
141
142// Values for focus mode settings.
143const char CameraParameters::FOCUS_MODE_AUTO[] = "auto";
144const char CameraParameters::FOCUS_MODE_INFINITY[] = "infinity";
145const char CameraParameters::FOCUS_MODE_MACRO[] = "macro";
146const char CameraParameters::FOCUS_MODE_FIXED[] = "fixed";
Wu-cheng Lic58b4232010-03-29 17:21:28 +0800147const char CameraParameters::FOCUS_MODE_EDOF[] = "edof";
Wu-cheng Lid45cb722010-09-20 16:15:32 -0700148const char CameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO[] = "continuous-video";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800149
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800150CameraParameters::CameraParameters()
151 : mMap()
152{
153}
154
155CameraParameters::~CameraParameters()
156{
157}
158
159String8 CameraParameters::flatten() const
160{
161 String8 flattened("");
162 size_t size = mMap.size();
163
164 for (size_t i = 0; i < size; i++) {
165 String8 k, v;
166 k = mMap.keyAt(i);
167 v = mMap.valueAt(i);
168
169 flattened += k;
170 flattened += "=";
171 flattened += v;
172 if (i != size-1)
173 flattened += ";";
174 }
175
176 return flattened;
177}
178
179void CameraParameters::unflatten(const String8 &params)
180{
181 const char *a = params.string();
182 const char *b;
183
184 mMap.clear();
185
186 for (;;) {
187 // Find the bounds of the key name.
188 b = strchr(a, '=');
189 if (b == 0)
190 break;
191
192 // Create the key string.
193 String8 k(a, (size_t)(b-a));
194
195 // Find the value.
196 a = b+1;
197 b = strchr(a, ';');
198 if (b == 0) {
199 // If there's no semicolon, this is the last item.
200 String8 v(a);
201 mMap.add(k, v);
202 break;
203 }
204
205 String8 v(a, (size_t)(b-a));
206 mMap.add(k, v);
207 a = b+1;
208 }
209}
210
211
212void CameraParameters::set(const char *key, const char *value)
213{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700214 // XXX i think i can do this with strspn()
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800215 if (strchr(key, '=') || strchr(key, ';')) {
216 //XXX LOGE("Key \"%s\"contains invalid character (= or ;)", key);
217 return;
218 }
219
220 if (strchr(value, '=') || strchr(key, ';')) {
221 //XXX LOGE("Value \"%s\"contains invalid character (= or ;)", value);
222 return;
223 }
224
225 mMap.replaceValueFor(String8(key), String8(value));
226}
227
228void CameraParameters::set(const char *key, int value)
229{
230 char str[16];
231 sprintf(str, "%d", value);
232 set(key, str);
233}
234
Wu-cheng Li7eae31c2010-01-31 14:19:38 +0800235void CameraParameters::setFloat(const char *key, float value)
236{
237 char str[16]; // 14 should be enough. We overestimate to be safe.
238 snprintf(str, sizeof(str), "%g", value);
239 set(key, str);
240}
241
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800242const char *CameraParameters::get(const char *key) const
243{
244 String8 v = mMap.valueFor(String8(key));
245 if (v.length() == 0)
246 return 0;
247 return v.string();
248}
249
250int CameraParameters::getInt(const char *key) const
251{
252 const char *v = get(key);
253 if (v == 0)
254 return -1;
255 return strtol(v, 0, 0);
256}
257
Wu-cheng Li7eae31c2010-01-31 14:19:38 +0800258float CameraParameters::getFloat(const char *key) const
259{
260 const char *v = get(key);
261 if (v == 0) return -1;
262 return strtof(v, 0);
263}
264
Wu-cheng Li78624e42010-05-11 12:11:56 +0800265void CameraParameters::remove(const char *key)
266{
267 mMap.removeItem(String8(key));
268}
269
Wu-cheng Li454630f2010-08-11 16:48:05 -0700270// Parse string like "640x480" or "10000,20000"
271static int parse_pair(const char *str, int *first, int *second, char delim,
272 char **endptr = NULL)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800273{
Wu-cheng Li454630f2010-08-11 16:48:05 -0700274 // Find the first integer.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800275 char *end;
276 int w = (int)strtol(str, &end, 10);
Wu-cheng Li454630f2010-08-11 16:48:05 -0700277 // If a delimeter does not immediately follow, give up.
278 if (*end != delim) {
279 LOGE("Cannot find delimeter (%c) in str=%s", delim, str);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280 return -1;
Wu-cheng Li454630f2010-08-11 16:48:05 -0700281 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800282
Wu-cheng Li454630f2010-08-11 16:48:05 -0700283 // Find the second integer, immediately after the delimeter.
Nipun Kwatra0de0c492010-07-30 13:40:14 -0700284 int h = (int)strtol(end+1, &end, 10);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800285
Wu-cheng Li454630f2010-08-11 16:48:05 -0700286 *first = w;
287 *second = h;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800288
Nipun Kwatra0de0c492010-07-30 13:40:14 -0700289 if (endptr) {
290 *endptr = end;
291 }
292
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800293 return 0;
294}
295
Nipun Kwatra6c008b82010-08-04 14:04:07 -0700296static void parseSizesList(const char *sizesStr, Vector<Size> &sizes)
297{
298 if (sizesStr == 0) {
299 return;
300 }
301
302 char *sizeStartPtr = (char *)sizesStr;
303
304 while (true) {
305 int width, height;
Wu-cheng Li454630f2010-08-11 16:48:05 -0700306 int success = parse_pair(sizeStartPtr, &width, &height, 'x',
307 &sizeStartPtr);
Nipun Kwatra6c008b82010-08-04 14:04:07 -0700308 if (success == -1 || (*sizeStartPtr != ',' && *sizeStartPtr != '\0')) {
309 LOGE("Picture sizes string \"%s\" contains invalid character.", sizesStr);
310 return;
311 }
312 sizes.push(Size(width, height));
313
314 if (*sizeStartPtr == '\0') {
315 return;
316 }
317 sizeStartPtr++;
318 }
319}
320
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800321void CameraParameters::setPreviewSize(int width, int height)
322{
323 char str[32];
324 sprintf(str, "%dx%d", width, height);
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700325 set(KEY_PREVIEW_SIZE, str);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800326}
327
328void CameraParameters::getPreviewSize(int *width, int *height) const
329{
Wu-cheng Li454630f2010-08-11 16:48:05 -0700330 *width = *height = -1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800331 // Get the current string, if it doesn't exist, leave the -1x-1
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700332 const char *p = get(KEY_PREVIEW_SIZE);
Wu-cheng Li454630f2010-08-11 16:48:05 -0700333 if (p == 0) return;
334 parse_pair(p, width, height, 'x');
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800335}
336
James Dong4ddca9b2010-11-29 16:51:55 -0800337void CameraParameters::getPreferredPreviewSizeForVideo(int *width, int *height) const
338{
339 *width = *height = -1;
340 const char *p = get(KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO);
341 if (p == 0) return;
342 parse_pair(p, width, height, 'x');
343}
344
Nipun Kwatra6c008b82010-08-04 14:04:07 -0700345void CameraParameters::getSupportedPreviewSizes(Vector<Size> &sizes) const
346{
347 const char *previewSizesStr = get(KEY_SUPPORTED_PREVIEW_SIZES);
348 parseSizesList(previewSizesStr, sizes);
349}
350
James Dong4fd446f2010-09-30 10:50:51 -0700351void CameraParameters::setVideoSize(int width, int height)
352{
353 char str[32];
354 sprintf(str, "%dx%d", width, height);
355 set(KEY_VIDEO_SIZE, str);
356}
357
358void CameraParameters::getVideoSize(int *width, int *height) const
359{
360 *width = *height = -1;
361 const char *p = get(KEY_VIDEO_SIZE);
362 if (p == 0) return;
363 parse_pair(p, width, height, 'x');
364}
365
366void CameraParameters::getSupportedVideoSizes(Vector<Size> &sizes) const
367{
368 const char *videoSizesStr = get(KEY_SUPPORTED_VIDEO_SIZES);
369 parseSizesList(videoSizesStr, sizes);
370}
371
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800372void CameraParameters::setPreviewFrameRate(int fps)
373{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700374 set(KEY_PREVIEW_FRAME_RATE, fps);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800375}
376
377int CameraParameters::getPreviewFrameRate() const
378{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700379 return getInt(KEY_PREVIEW_FRAME_RATE);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800380}
381
Wu-cheng Li454630f2010-08-11 16:48:05 -0700382void CameraParameters::getPreviewFpsRange(int *min_fps, int *max_fps) const
383{
384 *min_fps = *max_fps = -1;
385 const char *p = get(KEY_PREVIEW_FPS_RANGE);
386 if (p == 0) return;
387 parse_pair(p, min_fps, max_fps, ',');
388}
389
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800390void CameraParameters::setPreviewFormat(const char *format)
391{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700392 set(KEY_PREVIEW_FORMAT, format);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800393}
394
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800395const char *CameraParameters::getPreviewFormat() const
396{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700397 return get(KEY_PREVIEW_FORMAT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800398}
399
400void CameraParameters::setPictureSize(int width, int height)
401{
402 char str[32];
403 sprintf(str, "%dx%d", width, height);
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700404 set(KEY_PICTURE_SIZE, str);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800405}
406
407void CameraParameters::getPictureSize(int *width, int *height) const
408{
Wu-cheng Li454630f2010-08-11 16:48:05 -0700409 *width = *height = -1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800410 // Get the current string, if it doesn't exist, leave the -1x-1
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700411 const char *p = get(KEY_PICTURE_SIZE);
Wu-cheng Li454630f2010-08-11 16:48:05 -0700412 if (p == 0) return;
413 parse_pair(p, width, height, 'x');
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800414}
415
Nipun Kwatra6c008b82010-08-04 14:04:07 -0700416void CameraParameters::getSupportedPictureSizes(Vector<Size> &sizes) const
417{
418 const char *pictureSizesStr = get(KEY_SUPPORTED_PICTURE_SIZES);
419 parseSizesList(pictureSizesStr, sizes);
420}
421
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800422void CameraParameters::setPictureFormat(const char *format)
423{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700424 set(KEY_PICTURE_FORMAT, format);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800425}
426
427const char *CameraParameters::getPictureFormat() const
428{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700429 return get(KEY_PICTURE_FORMAT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800430}
431
432void CameraParameters::dump() const
433{
434 LOGD("dump: mMap.size = %d", mMap.size());
435 for (size_t i = 0; i < mMap.size(); i++) {
436 String8 k, v;
437 k = mMap.keyAt(i);
438 v = mMap.valueAt(i);
439 LOGD("%s: %s\n", k.string(), v.string());
440 }
441}
442
443status_t CameraParameters::dump(int fd, const Vector<String16>& args) const
444{
445 const size_t SIZE = 256;
446 char buffer[SIZE];
447 String8 result;
448 snprintf(buffer, 255, "CameraParameters::dump: mMap.size = %d\n", mMap.size());
449 result.append(buffer);
450 for (size_t i = 0; i < mMap.size(); i++) {
451 String8 k, v;
452 k = mMap.keyAt(i);
453 v = mMap.valueAt(i);
454 snprintf(buffer, 255, "\t%s: %s\n", k.string(), v.string());
455 result.append(buffer);
456 }
457 write(fd, result.string(), result.size());
458 return NO_ERROR;
459}
460
461}; // namespace android