blob: 214cd4df8280d64d795878b91dfaf2d51a377b3e [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 Li30771b72011-04-02 06:19:46 +080062const char CameraParameters::KEY_MAX_NUM_FOCUS_AREAS[] = "max-num-focus-areas";
63const char CameraParameters::KEY_FOCUS_AREAS[] = "focus-areas";
Wu-cheng Li6c8d2762010-01-27 22:55:14 +080064const char CameraParameters::KEY_FOCAL_LENGTH[] = "focal-length";
65const char CameraParameters::KEY_HORIZONTAL_VIEW_ANGLE[] = "horizontal-view-angle";
66const char CameraParameters::KEY_VERTICAL_VIEW_ANGLE[] = "vertical-view-angle";
Wu-cheng Liff723b62010-02-09 13:38:19 +080067const char CameraParameters::KEY_EXPOSURE_COMPENSATION[] = "exposure-compensation";
Wu-cheng Li24b326a2010-02-20 17:47:04 +080068const char CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION[] = "max-exposure-compensation";
69const char CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION[] = "min-exposure-compensation";
70const char CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP[] = "exposure-compensation-step";
Wu-cheng Lie98e4c82011-04-12 19:34:29 +080071const char CameraParameters::KEY_MAX_NUM_METERING_AREAS[] = "max-num-metering-areas";
72const char CameraParameters::KEY_METERING_AREAS[] = "metering-areas";
Wu-cheng Li8cbb8f52010-02-28 23:19:55 -080073const char CameraParameters::KEY_ZOOM[] = "zoom";
74const char CameraParameters::KEY_MAX_ZOOM[] = "max-zoom";
75const char CameraParameters::KEY_ZOOM_RATIOS[] = "zoom-ratios";
76const char CameraParameters::KEY_ZOOM_SUPPORTED[] = "zoom-supported";
77const char CameraParameters::KEY_SMOOTH_ZOOM_SUPPORTED[] = "smooth-zoom-supported";
Wu-cheng Lie339c5e2010-05-13 19:31:02 +080078const char CameraParameters::KEY_FOCUS_DISTANCES[] = "focus-distances";
Wu-cheng Lid2c29292010-05-28 17:32:41 +080079const char CameraParameters::KEY_VIDEO_FRAME_FORMAT[] = "video-frame-format";
James Dong4fd446f2010-09-30 10:50:51 -070080const char CameraParameters::KEY_VIDEO_SIZE[] = "video-size";
81const char CameraParameters::KEY_SUPPORTED_VIDEO_SIZES[] = "video-size-values";
James Dong4ddca9b2010-11-29 16:51:55 -080082const char CameraParameters::KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO[] = "preferred-preview-size-for-video";
Wu-cheng Li8de57d82009-09-23 14:37:52 -070083
Wu-cheng Lid9ef5d72010-03-08 15:28:48 -080084const char CameraParameters::TRUE[] = "true";
Wu-cheng Liae7ca4c2010-05-15 13:05:04 +080085const char CameraParameters::FOCUS_DISTANCE_INFINITY[] = "Infinity";
Wu-cheng Lid9ef5d72010-03-08 15:28:48 -080086
Wu-cheng Li8de57d82009-09-23 14:37:52 -070087// Values for white balance settings.
88const char CameraParameters::WHITE_BALANCE_AUTO[] = "auto";
89const char CameraParameters::WHITE_BALANCE_INCANDESCENT[] = "incandescent";
90const char CameraParameters::WHITE_BALANCE_FLUORESCENT[] = "fluorescent";
91const char CameraParameters::WHITE_BALANCE_WARM_FLUORESCENT[] = "warm-fluorescent";
92const char CameraParameters::WHITE_BALANCE_DAYLIGHT[] = "daylight";
93const char CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT[] = "cloudy-daylight";
94const char CameraParameters::WHITE_BALANCE_TWILIGHT[] = "twilight";
95const char CameraParameters::WHITE_BALANCE_SHADE[] = "shade";
96
97// Values for effect settings.
98const char CameraParameters::EFFECT_NONE[] = "none";
99const char CameraParameters::EFFECT_MONO[] = "mono";
100const char CameraParameters::EFFECT_NEGATIVE[] = "negative";
101const char CameraParameters::EFFECT_SOLARIZE[] = "solarize";
102const char CameraParameters::EFFECT_SEPIA[] = "sepia";
103const char CameraParameters::EFFECT_POSTERIZE[] = "posterize";
104const char CameraParameters::EFFECT_WHITEBOARD[] = "whiteboard";
105const char CameraParameters::EFFECT_BLACKBOARD[] = "blackboard";
106const char CameraParameters::EFFECT_AQUA[] = "aqua";
107
108// Values for antibanding settings.
109const char CameraParameters::ANTIBANDING_AUTO[] = "auto";
110const char CameraParameters::ANTIBANDING_50HZ[] = "50hz";
111const char CameraParameters::ANTIBANDING_60HZ[] = "60hz";
112const char CameraParameters::ANTIBANDING_OFF[] = "off";
113
114// Values for flash mode settings.
115const char CameraParameters::FLASH_MODE_OFF[] = "off";
116const char CameraParameters::FLASH_MODE_AUTO[] = "auto";
117const char CameraParameters::FLASH_MODE_ON[] = "on";
118const char CameraParameters::FLASH_MODE_RED_EYE[] = "red-eye";
Wu-cheng Life1a86d2009-09-28 13:51:12 -0700119const char CameraParameters::FLASH_MODE_TORCH[] = "torch";
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700120
121// Values for scene mode settings.
122const char CameraParameters::SCENE_MODE_AUTO[] = "auto";
123const char CameraParameters::SCENE_MODE_ACTION[] = "action";
124const char CameraParameters::SCENE_MODE_PORTRAIT[] = "portrait";
125const char CameraParameters::SCENE_MODE_LANDSCAPE[] = "landscape";
126const char CameraParameters::SCENE_MODE_NIGHT[] = "night";
127const char CameraParameters::SCENE_MODE_NIGHT_PORTRAIT[] = "night-portrait";
128const char CameraParameters::SCENE_MODE_THEATRE[] = "theatre";
129const char CameraParameters::SCENE_MODE_BEACH[] = "beach";
130const char CameraParameters::SCENE_MODE_SNOW[] = "snow";
131const char CameraParameters::SCENE_MODE_SUNSET[] = "sunset";
132const char CameraParameters::SCENE_MODE_STEADYPHOTO[] = "steadyphoto";
133const char CameraParameters::SCENE_MODE_FIREWORKS[] = "fireworks";
134const char CameraParameters::SCENE_MODE_SPORTS[] = "sports";
135const char CameraParameters::SCENE_MODE_PARTY[] = "party";
136const char CameraParameters::SCENE_MODE_CANDLELIGHT[] = "candlelight";
Wu-cheng Lic58b4232010-03-29 17:21:28 +0800137const char CameraParameters::SCENE_MODE_BARCODE[] = "barcode";
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700138
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700139const char CameraParameters::PIXEL_FORMAT_YUV422SP[] = "yuv422sp";
140const char CameraParameters::PIXEL_FORMAT_YUV420SP[] = "yuv420sp";
141const char CameraParameters::PIXEL_FORMAT_YUV422I[] = "yuv422i-yuyv";
Wu-cheng Li10a1b302011-02-22 15:49:25 +0800142const char CameraParameters::PIXEL_FORMAT_YUV420P[] = "yuv420p";
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700143const char CameraParameters::PIXEL_FORMAT_RGB565[] = "rgb565";
144const char CameraParameters::PIXEL_FORMAT_JPEG[] = "jpeg";
145
146// Values for focus mode settings.
147const char CameraParameters::FOCUS_MODE_AUTO[] = "auto";
148const char CameraParameters::FOCUS_MODE_INFINITY[] = "infinity";
149const char CameraParameters::FOCUS_MODE_MACRO[] = "macro";
150const char CameraParameters::FOCUS_MODE_FIXED[] = "fixed";
Wu-cheng Lic58b4232010-03-29 17:21:28 +0800151const char CameraParameters::FOCUS_MODE_EDOF[] = "edof";
Wu-cheng Lid45cb722010-09-20 16:15:32 -0700152const char CameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO[] = "continuous-video";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -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
James Dong4ddca9b2010-11-29 16:51:55 -0800341void CameraParameters::getPreferredPreviewSizeForVideo(int *width, int *height) const
342{
343 *width = *height = -1;
344 const char *p = get(KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO);
345 if (p == 0) return;
346 parse_pair(p, width, height, 'x');
347}
348
Nipun Kwatra6c008b82010-08-04 14:04:07 -0700349void CameraParameters::getSupportedPreviewSizes(Vector<Size> &sizes) const
350{
351 const char *previewSizesStr = get(KEY_SUPPORTED_PREVIEW_SIZES);
352 parseSizesList(previewSizesStr, sizes);
353}
354
James Dong4fd446f2010-09-30 10:50:51 -0700355void CameraParameters::setVideoSize(int width, int height)
356{
357 char str[32];
358 sprintf(str, "%dx%d", width, height);
359 set(KEY_VIDEO_SIZE, str);
360}
361
362void CameraParameters::getVideoSize(int *width, int *height) const
363{
364 *width = *height = -1;
365 const char *p = get(KEY_VIDEO_SIZE);
366 if (p == 0) return;
367 parse_pair(p, width, height, 'x');
368}
369
370void CameraParameters::getSupportedVideoSizes(Vector<Size> &sizes) const
371{
372 const char *videoSizesStr = get(KEY_SUPPORTED_VIDEO_SIZES);
373 parseSizesList(videoSizesStr, sizes);
374}
375
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800376void CameraParameters::setPreviewFrameRate(int fps)
377{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700378 set(KEY_PREVIEW_FRAME_RATE, fps);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800379}
380
381int CameraParameters::getPreviewFrameRate() const
382{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700383 return getInt(KEY_PREVIEW_FRAME_RATE);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800384}
385
Wu-cheng Li454630f2010-08-11 16:48:05 -0700386void CameraParameters::getPreviewFpsRange(int *min_fps, int *max_fps) const
387{
388 *min_fps = *max_fps = -1;
389 const char *p = get(KEY_PREVIEW_FPS_RANGE);
390 if (p == 0) return;
391 parse_pair(p, min_fps, max_fps, ',');
392}
393
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800394void CameraParameters::setPreviewFormat(const char *format)
395{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700396 set(KEY_PREVIEW_FORMAT, format);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800397}
398
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800399const char *CameraParameters::getPreviewFormat() const
400{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700401 return get(KEY_PREVIEW_FORMAT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800402}
403
404void CameraParameters::setPictureSize(int width, int height)
405{
406 char str[32];
407 sprintf(str, "%dx%d", width, height);
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700408 set(KEY_PICTURE_SIZE, str);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800409}
410
411void CameraParameters::getPictureSize(int *width, int *height) const
412{
Wu-cheng Li454630f2010-08-11 16:48:05 -0700413 *width = *height = -1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800414 // Get the current string, if it doesn't exist, leave the -1x-1
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700415 const char *p = get(KEY_PICTURE_SIZE);
Wu-cheng Li454630f2010-08-11 16:48:05 -0700416 if (p == 0) return;
417 parse_pair(p, width, height, 'x');
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800418}
419
Nipun Kwatra6c008b82010-08-04 14:04:07 -0700420void CameraParameters::getSupportedPictureSizes(Vector<Size> &sizes) const
421{
422 const char *pictureSizesStr = get(KEY_SUPPORTED_PICTURE_SIZES);
423 parseSizesList(pictureSizesStr, sizes);
424}
425
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800426void CameraParameters::setPictureFormat(const char *format)
427{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700428 set(KEY_PICTURE_FORMAT, format);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800429}
430
431const char *CameraParameters::getPictureFormat() const
432{
Wu-cheng Li8de57d82009-09-23 14:37:52 -0700433 return get(KEY_PICTURE_FORMAT);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800434}
435
436void CameraParameters::dump() const
437{
438 LOGD("dump: mMap.size = %d", mMap.size());
439 for (size_t i = 0; i < mMap.size(); i++) {
440 String8 k, v;
441 k = mMap.keyAt(i);
442 v = mMap.valueAt(i);
443 LOGD("%s: %s\n", k.string(), v.string());
444 }
445}
446
447status_t CameraParameters::dump(int fd, const Vector<String16>& args) const
448{
449 const size_t SIZE = 256;
450 char buffer[SIZE];
451 String8 result;
452 snprintf(buffer, 255, "CameraParameters::dump: mMap.size = %d\n", mMap.size());
453 result.append(buffer);
454 for (size_t i = 0; i < mMap.size(); i++) {
455 String8 k, v;
456 k = mMap.keyAt(i);
457 v = mMap.valueAt(i);
458 snprintf(buffer, 255, "\t%s: %s\n", k.string(), v.string());
459 result.append(buffer);
460 }
461 write(fd, result.string(), result.size());
462 return NO_ERROR;
463}
464
465}; // namespace android