blob: d0ed7df5925707e73c6f0265f71f9b470dcf8a3e [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";
Wu-cheng Lif7f63332010-06-03 16:34:18 +080076const char CameraParameters::KEY_METERING_MODE[] = "metering-mode";
Wu-cheng Li8aba2322010-06-04 14:18:32 +080077const char CameraParameters::KEY_SUPPORTED_METERING_MODES[] = "metering-mode-values";
Wu-cheng Li8de57d82009-09-23 14:37:52 -070078
Wu-cheng Lid9ef5d72010-03-08 15:28:48 -080079const char CameraParameters::TRUE[] = "true";
Wu-cheng Liae7ca4c2010-05-15 13:05:04 +080080const char CameraParameters::FOCUS_DISTANCE_INFINITY[] = "Infinity";
Wu-cheng Lid9ef5d72010-03-08 15:28:48 -080081
Wu-cheng Li8de57d82009-09-23 14:37:52 -070082// Values for white balance settings.
83const char CameraParameters::WHITE_BALANCE_AUTO[] = "auto";
84const char CameraParameters::WHITE_BALANCE_INCANDESCENT[] = "incandescent";
85const char CameraParameters::WHITE_BALANCE_FLUORESCENT[] = "fluorescent";
86const char CameraParameters::WHITE_BALANCE_WARM_FLUORESCENT[] = "warm-fluorescent";
87const char CameraParameters::WHITE_BALANCE_DAYLIGHT[] = "daylight";
88const char CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT[] = "cloudy-daylight";
89const char CameraParameters::WHITE_BALANCE_TWILIGHT[] = "twilight";
90const char CameraParameters::WHITE_BALANCE_SHADE[] = "shade";
91
92// Values for effect settings.
93const char CameraParameters::EFFECT_NONE[] = "none";
94const char CameraParameters::EFFECT_MONO[] = "mono";
95const char CameraParameters::EFFECT_NEGATIVE[] = "negative";
96const char CameraParameters::EFFECT_SOLARIZE[] = "solarize";
97const char CameraParameters::EFFECT_SEPIA[] = "sepia";
98const char CameraParameters::EFFECT_POSTERIZE[] = "posterize";
99const char CameraParameters::EFFECT_WHITEBOARD[] = "whiteboard";
100const char CameraParameters::EFFECT_BLACKBOARD[] = "blackboard";
101const char CameraParameters::EFFECT_AQUA[] = "aqua";
102
103// Values for antibanding settings.
104const char CameraParameters::ANTIBANDING_AUTO[] = "auto";
105const char CameraParameters::ANTIBANDING_50HZ[] = "50hz";
106const char CameraParameters::ANTIBANDING_60HZ[] = "60hz";
107const char CameraParameters::ANTIBANDING_OFF[] = "off";
108
109// Values for flash mode settings.
110const char CameraParameters::FLASH_MODE_OFF[] = "off";
111const char CameraParameters::FLASH_MODE_AUTO[] = "auto";
112const char CameraParameters::FLASH_MODE_ON[] = "on";
113const char CameraParameters::FLASH_MODE_RED_EYE[] = "red-eye";
Wu-cheng Life1a86d2009-09-28 13:51:12 -0700114const char CameraParameters::FLASH_MODE_TORCH[] = "torch";
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700115
116// Values for scene mode settings.
117const char CameraParameters::SCENE_MODE_AUTO[] = "auto";
118const char CameraParameters::SCENE_MODE_ACTION[] = "action";
119const char CameraParameters::SCENE_MODE_PORTRAIT[] = "portrait";
120const char CameraParameters::SCENE_MODE_LANDSCAPE[] = "landscape";
121const char CameraParameters::SCENE_MODE_NIGHT[] = "night";
122const char CameraParameters::SCENE_MODE_NIGHT_PORTRAIT[] = "night-portrait";
123const char CameraParameters::SCENE_MODE_THEATRE[] = "theatre";
124const char CameraParameters::SCENE_MODE_BEACH[] = "beach";
125const char CameraParameters::SCENE_MODE_SNOW[] = "snow";
126const char CameraParameters::SCENE_MODE_SUNSET[] = "sunset";
127const char CameraParameters::SCENE_MODE_STEADYPHOTO[] = "steadyphoto";
128const char CameraParameters::SCENE_MODE_FIREWORKS[] = "fireworks";
129const char CameraParameters::SCENE_MODE_SPORTS[] = "sports";
130const char CameraParameters::SCENE_MODE_PARTY[] = "party";
131const char CameraParameters::SCENE_MODE_CANDLELIGHT[] = "candlelight";
Wu-cheng Lic58b4232010-03-29 17:21:28 +0800132const char CameraParameters::SCENE_MODE_BARCODE[] = "barcode";
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700133
134// Formats for setPreviewFormat and setPictureFormat.
135const char CameraParameters::PIXEL_FORMAT_YUV422SP[] = "yuv422sp";
136const char CameraParameters::PIXEL_FORMAT_YUV420SP[] = "yuv420sp";
137const char CameraParameters::PIXEL_FORMAT_YUV422I[] = "yuv422i-yuyv";
138const char CameraParameters::PIXEL_FORMAT_RGB565[] = "rgb565";
139const char CameraParameters::PIXEL_FORMAT_JPEG[] = "jpeg";
140
141// Values for focus mode settings.
142const char CameraParameters::FOCUS_MODE_AUTO[] = "auto";
143const char CameraParameters::FOCUS_MODE_INFINITY[] = "infinity";
144const char CameraParameters::FOCUS_MODE_MACRO[] = "macro";
145const char CameraParameters::FOCUS_MODE_FIXED[] = "fixed";
Wu-cheng Lic58b4232010-03-29 17:21:28 +0800146const char CameraParameters::FOCUS_MODE_EDOF[] = "edof";
Wu-cheng Lica099612010-05-06 16:47:30 +0800147const char CameraParameters::FOCUS_MODE_CONTINUOUS[] = "continuous";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800148
Wu-cheng Lif7f63332010-06-03 16:34:18 +0800149// Values for metering mode settings.
Wu-cheng Li8aba2322010-06-04 14:18:32 +0800150const char CameraParameters::METERING_MODE_CENTER_WEIGHTED[] = "center-weighted";
151const char CameraParameters::METERING_MODE_FRAME_AVERAGE[] = "frame-average";
152const char CameraParameters::METERING_MODE_SPOT[] = "spot";
Wu-cheng Lif7f63332010-06-03 16:34:18 +0800153
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800154CameraParameters::CameraParameters()
155 : mMap()
156{
157}
158
159CameraParameters::~CameraParameters()
160{
161}
162
163String8 CameraParameters::flatten() const
164{
165 String8 flattened("");
166 size_t size = mMap.size();
167
168 for (size_t i = 0; i < size; i++) {
169 String8 k, v;
170 k = mMap.keyAt(i);
171 v = mMap.valueAt(i);
172
173 flattened += k;
174 flattened += "=";
175 flattened += v;
176 if (i != size-1)
177 flattened += ";";
178 }
179
180 return flattened;
181}
182
183void CameraParameters::unflatten(const String8 &params)
184{
185 const char *a = params.string();
186 const char *b;
187
188 mMap.clear();
189
190 for (;;) {
191 // Find the bounds of the key name.
192 b = strchr(a, '=');
193 if (b == 0)
194 break;
195
196 // Create the key string.
197 String8 k(a, (size_t)(b-a));
198
199 // Find the value.
200 a = b+1;
201 b = strchr(a, ';');
202 if (b == 0) {
203 // If there's no semicolon, this is the last item.
204 String8 v(a);
205 mMap.add(k, v);
206 break;
207 }
208
209 String8 v(a, (size_t)(b-a));
210 mMap.add(k, v);
211 a = b+1;
212 }
213}
214
215
216void CameraParameters::set(const char *key, const char *value)
217{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700218 // XXX i think i can do this with strspn()
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800219 if (strchr(key, '=') || strchr(key, ';')) {
220 //XXX LOGE("Key \"%s\"contains invalid character (= or ;)", key);
221 return;
222 }
223
224 if (strchr(value, '=') || strchr(key, ';')) {
225 //XXX LOGE("Value \"%s\"contains invalid character (= or ;)", value);
226 return;
227 }
228
229 mMap.replaceValueFor(String8(key), String8(value));
230}
231
232void CameraParameters::set(const char *key, int value)
233{
234 char str[16];
235 sprintf(str, "%d", value);
236 set(key, str);
237}
238
Wu-cheng Li7eae31c2010-01-31 14:19:38 +0800239void CameraParameters::setFloat(const char *key, float value)
240{
241 char str[16]; // 14 should be enough. We overestimate to be safe.
242 snprintf(str, sizeof(str), "%g", value);
243 set(key, str);
244}
245
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800246const char *CameraParameters::get(const char *key) const
247{
248 String8 v = mMap.valueFor(String8(key));
249 if (v.length() == 0)
250 return 0;
251 return v.string();
252}
253
254int CameraParameters::getInt(const char *key) const
255{
256 const char *v = get(key);
257 if (v == 0)
258 return -1;
259 return strtol(v, 0, 0);
260}
261
Wu-cheng Li7eae31c2010-01-31 14:19:38 +0800262float CameraParameters::getFloat(const char *key) const
263{
264 const char *v = get(key);
265 if (v == 0) return -1;
266 return strtof(v, 0);
267}
268
Wu-cheng Li78624e42010-05-11 12:11:56 +0800269void CameraParameters::remove(const char *key)
270{
271 mMap.removeItem(String8(key));
272}
273
Wu-cheng Li454630f2010-08-11 16:48:05 -0700274// Parse string like "640x480" or "10000,20000"
275static int parse_pair(const char *str, int *first, int *second, char delim,
276 char **endptr = NULL)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800277{
Wu-cheng Li454630f2010-08-11 16:48:05 -0700278 // Find the first integer.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800279 char *end;
280 int w = (int)strtol(str, &end, 10);
Wu-cheng Li454630f2010-08-11 16:48:05 -0700281 // If a delimeter does not immediately follow, give up.
282 if (*end != delim) {
283 LOGE("Cannot find delimeter (%c) in str=%s", delim, str);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800284 return -1;
Wu-cheng Li454630f2010-08-11 16:48:05 -0700285 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800286
Wu-cheng Li454630f2010-08-11 16:48:05 -0700287 // Find the second integer, immediately after the delimeter.
Nipun Kwatra0de0c492010-07-30 13:40:14 -0700288 int h = (int)strtol(end+1, &end, 10);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800289
Wu-cheng Li454630f2010-08-11 16:48:05 -0700290 *first = w;
291 *second = h;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800292
Nipun Kwatra0de0c492010-07-30 13:40:14 -0700293 if (endptr) {
294 *endptr = end;
295 }
296
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800297 return 0;
298}
299
Nipun Kwatra6c008b82010-08-04 14:04:07 -0700300static void parseSizesList(const char *sizesStr, Vector<Size> &sizes)
301{
302 if (sizesStr == 0) {
303 return;
304 }
305
306 char *sizeStartPtr = (char *)sizesStr;
307
308 while (true) {
309 int width, height;
Wu-cheng Li454630f2010-08-11 16:48:05 -0700310 int success = parse_pair(sizeStartPtr, &width, &height, 'x',
311 &sizeStartPtr);
Nipun Kwatra6c008b82010-08-04 14:04:07 -0700312 if (success == -1 || (*sizeStartPtr != ',' && *sizeStartPtr != '\0')) {
313 LOGE("Picture sizes string \"%s\" contains invalid character.", sizesStr);
314 return;
315 }
316 sizes.push(Size(width, height));
317
318 if (*sizeStartPtr == '\0') {
319 return;
320 }
321 sizeStartPtr++;
322 }
323}
324
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800325void CameraParameters::setPreviewSize(int width, int height)
326{
327 char str[32];
328 sprintf(str, "%dx%d", width, height);
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700329 set(KEY_PREVIEW_SIZE, str);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800330}
331
332void CameraParameters::getPreviewSize(int *width, int *height) const
333{
Wu-cheng Li454630f2010-08-11 16:48:05 -0700334 *width = *height = -1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800335 // Get the current string, if it doesn't exist, leave the -1x-1
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700336 const char *p = get(KEY_PREVIEW_SIZE);
Wu-cheng Li454630f2010-08-11 16:48:05 -0700337 if (p == 0) return;
338 parse_pair(p, width, height, 'x');
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800339}
340
Nipun Kwatra6c008b82010-08-04 14:04:07 -0700341void CameraParameters::getSupportedPreviewSizes(Vector<Size> &sizes) const
342{
343 const char *previewSizesStr = get(KEY_SUPPORTED_PREVIEW_SIZES);
344 parseSizesList(previewSizesStr, sizes);
345}
346
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800347void CameraParameters::setPreviewFrameRate(int fps)
348{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700349 set(KEY_PREVIEW_FRAME_RATE, fps);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800350}
351
352int CameraParameters::getPreviewFrameRate() const
353{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700354 return getInt(KEY_PREVIEW_FRAME_RATE);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800355}
356
Wu-cheng Li454630f2010-08-11 16:48:05 -0700357void CameraParameters::getPreviewFpsRange(int *min_fps, int *max_fps) const
358{
359 *min_fps = *max_fps = -1;
360 const char *p = get(KEY_PREVIEW_FPS_RANGE);
361 if (p == 0) return;
362 parse_pair(p, min_fps, max_fps, ',');
363}
364
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800365void CameraParameters::setPreviewFormat(const char *format)
366{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700367 set(KEY_PREVIEW_FORMAT, format);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800368}
369
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800370const char *CameraParameters::getPreviewFormat() const
371{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700372 return get(KEY_PREVIEW_FORMAT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800373}
374
375void CameraParameters::setPictureSize(int width, int height)
376{
377 char str[32];
378 sprintf(str, "%dx%d", width, height);
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700379 set(KEY_PICTURE_SIZE, str);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800380}
381
382void CameraParameters::getPictureSize(int *width, int *height) const
383{
Wu-cheng Li454630f2010-08-11 16:48:05 -0700384 *width = *height = -1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800385 // Get the current string, if it doesn't exist, leave the -1x-1
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700386 const char *p = get(KEY_PICTURE_SIZE);
Wu-cheng Li454630f2010-08-11 16:48:05 -0700387 if (p == 0) return;
388 parse_pair(p, width, height, 'x');
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800389}
390
Nipun Kwatra6c008b82010-08-04 14:04:07 -0700391void CameraParameters::getSupportedPictureSizes(Vector<Size> &sizes) const
392{
393 const char *pictureSizesStr = get(KEY_SUPPORTED_PICTURE_SIZES);
394 parseSizesList(pictureSizesStr, sizes);
395}
396
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800397void CameraParameters::setPictureFormat(const char *format)
398{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700399 set(KEY_PICTURE_FORMAT, format);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800400}
401
402const char *CameraParameters::getPictureFormat() const
403{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700404 return get(KEY_PICTURE_FORMAT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800405}
406
407void CameraParameters::dump() const
408{
409 LOGD("dump: mMap.size = %d", mMap.size());
410 for (size_t i = 0; i < mMap.size(); i++) {
411 String8 k, v;
412 k = mMap.keyAt(i);
413 v = mMap.valueAt(i);
414 LOGD("%s: %s\n", k.string(), v.string());
415 }
416}
417
418status_t CameraParameters::dump(int fd, const Vector<String16>& args) const
419{
420 const size_t SIZE = 256;
421 char buffer[SIZE];
422 String8 result;
423 snprintf(buffer, 255, "CameraParameters::dump: mMap.size = %d\n", mMap.size());
424 result.append(buffer);
425 for (size_t i = 0; i < mMap.size(); i++) {
426 String8 k, v;
427 k = mMap.keyAt(i);
428 v = mMap.valueAt(i);
429 snprintf(buffer, 255, "\t%s: %s\n", k.string(), v.string());
430 result.append(buffer);
431 }
432 write(fd, result.string(), result.size());
433 return NO_ERROR;
434}
435
436}; // namespace android