1 /*
2 **
3 ** Copyright 2008, The Android Open Source Project
4 **
5 ** 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
8 **
9 ** http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** 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
15 ** limitations under the License.
16 */
17
18 #define LOG_TAG "CameraParams"
19 #include <log/log.h>
20
21 #include <stdlib.h>
22 #include <string.h>
23 #include <system/graphics.h>
24 #include <unistd.h>
25 #include "CameraParameters.h"
26
27 namespace android {
28 namespace hardware {
29 namespace camera {
30 namespace common {
31 namespace helper {
32
33 // Parameter keys to communicate between camera application and driver.
34 const char CameraParameters::KEY_PREVIEW_SIZE[] = "preview-size";
35 const char CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES[] = "preview-size-values";
36 const char CameraParameters::KEY_PREVIEW_FORMAT[] = "preview-format";
37 const char CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS[] = "preview-format-values";
38 const char CameraParameters::KEY_PREVIEW_FRAME_RATE[] = "preview-frame-rate";
39 const char CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES[] = "preview-frame-rate-values";
40 const char CameraParameters::KEY_PREVIEW_FPS_RANGE[] = "preview-fps-range";
41 const char CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE[] = "preview-fps-range-values";
42 const char CameraParameters::KEY_PICTURE_SIZE[] = "picture-size";
43 const char CameraParameters::KEY_SUPPORTED_PICTURE_SIZES[] = "picture-size-values";
44 const char CameraParameters::KEY_PICTURE_FORMAT[] = "picture-format";
45 const char CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS[] = "picture-format-values";
46 const char CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH[] = "jpeg-thumbnail-width";
47 const char CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT[] = "jpeg-thumbnail-height";
48 const char CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES[] = "jpeg-thumbnail-size-values";
49 const char CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY[] = "jpeg-thumbnail-quality";
50 const char CameraParameters::KEY_JPEG_QUALITY[] = "jpeg-quality";
51 const char CameraParameters::KEY_ROTATION[] = "rotation";
52 const char CameraParameters::KEY_GPS_LATITUDE[] = "gps-latitude";
53 const char CameraParameters::KEY_GPS_LONGITUDE[] = "gps-longitude";
54 const char CameraParameters::KEY_GPS_ALTITUDE[] = "gps-altitude";
55 const char CameraParameters::KEY_GPS_TIMESTAMP[] = "gps-timestamp";
56 const char CameraParameters::KEY_GPS_PROCESSING_METHOD[] = "gps-processing-method";
57 const char CameraParameters::KEY_WHITE_BALANCE[] = "whitebalance";
58 const char CameraParameters::KEY_SUPPORTED_WHITE_BALANCE[] = "whitebalance-values";
59 const char CameraParameters::KEY_EFFECT[] = "effect";
60 const char CameraParameters::KEY_SUPPORTED_EFFECTS[] = "effect-values";
61 const char CameraParameters::KEY_ANTIBANDING[] = "antibanding";
62 const char CameraParameters::KEY_SUPPORTED_ANTIBANDING[] = "antibanding-values";
63 const char CameraParameters::KEY_SCENE_MODE[] = "scene-mode";
64 const char CameraParameters::KEY_SUPPORTED_SCENE_MODES[] = "scene-mode-values";
65 const char CameraParameters::KEY_FLASH_MODE[] = "flash-mode";
66 const char CameraParameters::KEY_SUPPORTED_FLASH_MODES[] = "flash-mode-values";
67 const char CameraParameters::KEY_FOCUS_MODE[] = "focus-mode";
68 const char CameraParameters::KEY_SUPPORTED_FOCUS_MODES[] = "focus-mode-values";
69 const char CameraParameters::KEY_MAX_NUM_FOCUS_AREAS[] = "max-num-focus-areas";
70 const char CameraParameters::KEY_FOCUS_AREAS[] = "focus-areas";
71 const char CameraParameters::KEY_FOCAL_LENGTH[] = "focal-length";
72 const char CameraParameters::KEY_HORIZONTAL_VIEW_ANGLE[] = "horizontal-view-angle";
73 const char CameraParameters::KEY_VERTICAL_VIEW_ANGLE[] = "vertical-view-angle";
74 const char CameraParameters::KEY_EXPOSURE_COMPENSATION[] = "exposure-compensation";
75 const char CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION[] = "max-exposure-compensation";
76 const char CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION[] = "min-exposure-compensation";
77 const char CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP[] = "exposure-compensation-step";
78 const char CameraParameters::KEY_AUTO_EXPOSURE_LOCK[] = "auto-exposure-lock";
79 const char CameraParameters::KEY_AUTO_EXPOSURE_LOCK_SUPPORTED[] = "auto-exposure-lock-supported";
80 const char CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK[] = "auto-whitebalance-lock";
81 const char CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED[] =
82 "auto-whitebalance-lock-supported";
83 const char CameraParameters::KEY_MAX_NUM_METERING_AREAS[] = "max-num-metering-areas";
84 const char CameraParameters::KEY_METERING_AREAS[] = "metering-areas";
85 const char CameraParameters::KEY_ZOOM[] = "zoom";
86 const char CameraParameters::KEY_MAX_ZOOM[] = "max-zoom";
87 const char CameraParameters::KEY_ZOOM_RATIOS[] = "zoom-ratios";
88 const char CameraParameters::KEY_ZOOM_SUPPORTED[] = "zoom-supported";
89 const char CameraParameters::KEY_SMOOTH_ZOOM_SUPPORTED[] = "smooth-zoom-supported";
90 const char CameraParameters::KEY_FOCUS_DISTANCES[] = "focus-distances";
91 const char CameraParameters::KEY_VIDEO_FRAME_FORMAT[] = "video-frame-format";
92 const char CameraParameters::KEY_VIDEO_SIZE[] = "video-size";
93 const char CameraParameters::KEY_SUPPORTED_VIDEO_SIZES[] = "video-size-values";
94 const char CameraParameters::KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO[] =
95 "preferred-preview-size-for-video";
96 const char CameraParameters::KEY_MAX_NUM_DETECTED_FACES_HW[] = "max-num-detected-faces-hw";
97 const char CameraParameters::KEY_MAX_NUM_DETECTED_FACES_SW[] = "max-num-detected-faces-sw";
98 const char CameraParameters::KEY_RECORDING_HINT[] = "recording-hint";
99 const char CameraParameters::KEY_VIDEO_SNAPSHOT_SUPPORTED[] = "video-snapshot-supported";
100 const char CameraParameters::KEY_VIDEO_STABILIZATION[] = "video-stabilization";
101 const char CameraParameters::KEY_VIDEO_STABILIZATION_SUPPORTED[] = "video-stabilization-supported";
102 const char CameraParameters::KEY_LIGHTFX[] = "light-fx";
103
104 const char CameraParameters::TRUE[] = "true";
105 const char CameraParameters::FALSE[] = "false";
106 const char CameraParameters::FOCUS_DISTANCE_INFINITY[] = "Infinity";
107
108 // Values for white balance settings.
109 const char CameraParameters::WHITE_BALANCE_AUTO[] = "auto";
110 const char CameraParameters::WHITE_BALANCE_INCANDESCENT[] = "incandescent";
111 const char CameraParameters::WHITE_BALANCE_FLUORESCENT[] = "fluorescent";
112 const char CameraParameters::WHITE_BALANCE_WARM_FLUORESCENT[] = "warm-fluorescent";
113 const char CameraParameters::WHITE_BALANCE_DAYLIGHT[] = "daylight";
114 const char CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT[] = "cloudy-daylight";
115 const char CameraParameters::WHITE_BALANCE_TWILIGHT[] = "twilight";
116 const char CameraParameters::WHITE_BALANCE_SHADE[] = "shade";
117
118 // Values for effect settings.
119 const char CameraParameters::EFFECT_NONE[] = "none";
120 const char CameraParameters::EFFECT_MONO[] = "mono";
121 const char CameraParameters::EFFECT_NEGATIVE[] = "negative";
122 const char CameraParameters::EFFECT_SOLARIZE[] = "solarize";
123 const char CameraParameters::EFFECT_SEPIA[] = "sepia";
124 const char CameraParameters::EFFECT_POSTERIZE[] = "posterize";
125 const char CameraParameters::EFFECT_WHITEBOARD[] = "whiteboard";
126 const char CameraParameters::EFFECT_BLACKBOARD[] = "blackboard";
127 const char CameraParameters::EFFECT_AQUA[] = "aqua";
128
129 // Values for antibanding settings.
130 const char CameraParameters::ANTIBANDING_AUTO[] = "auto";
131 const char CameraParameters::ANTIBANDING_50HZ[] = "50hz";
132 const char CameraParameters::ANTIBANDING_60HZ[] = "60hz";
133 const char CameraParameters::ANTIBANDING_OFF[] = "off";
134
135 // Values for flash mode settings.
136 const char CameraParameters::FLASH_MODE_OFF[] = "off";
137 const char CameraParameters::FLASH_MODE_AUTO[] = "auto";
138 const char CameraParameters::FLASH_MODE_ON[] = "on";
139 const char CameraParameters::FLASH_MODE_RED_EYE[] = "red-eye";
140 const char CameraParameters::FLASH_MODE_TORCH[] = "torch";
141
142 // Values for scene mode settings.
143 const char CameraParameters::SCENE_MODE_AUTO[] = "auto";
144 const char CameraParameters::SCENE_MODE_ACTION[] = "action";
145 const char CameraParameters::SCENE_MODE_PORTRAIT[] = "portrait";
146 const char CameraParameters::SCENE_MODE_LANDSCAPE[] = "landscape";
147 const char CameraParameters::SCENE_MODE_NIGHT[] = "night";
148 const char CameraParameters::SCENE_MODE_NIGHT_PORTRAIT[] = "night-portrait";
149 const char CameraParameters::SCENE_MODE_THEATRE[] = "theatre";
150 const char CameraParameters::SCENE_MODE_BEACH[] = "beach";
151 const char CameraParameters::SCENE_MODE_SNOW[] = "snow";
152 const char CameraParameters::SCENE_MODE_SUNSET[] = "sunset";
153 const char CameraParameters::SCENE_MODE_STEADYPHOTO[] = "steadyphoto";
154 const char CameraParameters::SCENE_MODE_FIREWORKS[] = "fireworks";
155 const char CameraParameters::SCENE_MODE_SPORTS[] = "sports";
156 const char CameraParameters::SCENE_MODE_PARTY[] = "party";
157 const char CameraParameters::SCENE_MODE_CANDLELIGHT[] = "candlelight";
158 const char CameraParameters::SCENE_MODE_BARCODE[] = "barcode";
159 const char CameraParameters::SCENE_MODE_HDR[] = "hdr";
160
161 const char CameraParameters::PIXEL_FORMAT_YUV422SP[] = "yuv422sp";
162 const char CameraParameters::PIXEL_FORMAT_YUV420SP[] = "yuv420sp";
163 const char CameraParameters::PIXEL_FORMAT_YUV422I[] = "yuv422i-yuyv";
164 const char CameraParameters::PIXEL_FORMAT_YUV420P[] = "yuv420p";
165 const char CameraParameters::PIXEL_FORMAT_RGB565[] = "rgb565";
166 const char CameraParameters::PIXEL_FORMAT_RGBA8888[] = "rgba8888";
167 const char CameraParameters::PIXEL_FORMAT_JPEG[] = "jpeg";
168 const char CameraParameters::PIXEL_FORMAT_BAYER_RGGB[] = "bayer-rggb";
169 const char CameraParameters::PIXEL_FORMAT_ANDROID_OPAQUE[] = "android-opaque";
170
171 // Values for focus mode settings.
172 const char CameraParameters::FOCUS_MODE_AUTO[] = "auto";
173 const char CameraParameters::FOCUS_MODE_INFINITY[] = "infinity";
174 const char CameraParameters::FOCUS_MODE_MACRO[] = "macro";
175 const char CameraParameters::FOCUS_MODE_FIXED[] = "fixed";
176 const char CameraParameters::FOCUS_MODE_EDOF[] = "edof";
177 const char CameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO[] = "continuous-video";
178 const char CameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE[] = "continuous-picture";
179
180 // Values for light fx settings
181 const char CameraParameters::LIGHTFX_LOWLIGHT[] = "low-light";
182 const char CameraParameters::LIGHTFX_HDR[] = "high-dynamic-range";
183
CameraParameters()184 CameraParameters::CameraParameters() : mMap() {}
185
~CameraParameters()186 CameraParameters::~CameraParameters() {}
187
flatten() const188 String8 CameraParameters::flatten() const {
189 String8 flattened("");
190 size_t size = mMap.size();
191
192 for (size_t i = 0; i < size; i++) {
193 String8 k, v;
194 k = mMap.keyAt(i);
195 v = mMap.valueAt(i);
196
197 flattened += k;
198 flattened += "=";
199 flattened += v;
200 if (i != size - 1) flattened += ";";
201 }
202
203 return flattened;
204 }
205
unflatten(const String8 & params)206 void CameraParameters::unflatten(const String8& params) {
207 const char* a = params.c_str();
208 const char* b;
209
210 mMap.clear();
211
212 for (;;) {
213 // Find the bounds of the key name.
214 b = strchr(a, '=');
215 if (b == 0) break;
216
217 // Create the key string.
218 String8 k(a, (size_t)(b - a));
219
220 // Find the value.
221 a = b + 1;
222 b = strchr(a, ';');
223 if (b == 0) {
224 // If there's no semicolon, this is the last item.
225 String8 v(a);
226 mMap.add(k, v);
227 break;
228 }
229
230 String8 v(a, (size_t)(b - a));
231 mMap.add(k, v);
232 a = b + 1;
233 }
234 }
235
set(const char * key,const char * value)236 void CameraParameters::set(const char* key, const char* value) {
237 // i think i can do this with strspn()
238 if (strchr(key, '=') || strchr(key, ';')) {
239 // ALOGE("Key \"%s\"contains invalid character (= or ;)", key);
240 return;
241 }
242
243 if (strchr(value, '=') || strchr(value, ';')) {
244 // ALOGE("Value \"%s\"contains invalid character (= or ;)", value);
245 return;
246 }
247
248 mMap.replaceValueFor(String8(key), String8(value));
249 }
250
set(const char * key,int value)251 void CameraParameters::set(const char* key, int value) {
252 char str[16];
253 sprintf(str, "%d", value);
254 set(key, str);
255 }
256
setFloat(const char * key,float value)257 void CameraParameters::setFloat(const char* key, float value) {
258 char str[16]; // 14 should be enough. We overestimate to be safe.
259 snprintf(str, sizeof(str), "%g", value);
260 set(key, str);
261 }
262
get(const char * key) const263 const char* CameraParameters::get(const char* key) const {
264 String8 v = mMap.valueFor(String8(key));
265 if (v.length() == 0) return 0;
266 return v.c_str();
267 }
268
getInt(const char * key) const269 int CameraParameters::getInt(const char* key) const {
270 const char* v = get(key);
271 if (v == 0) return -1;
272 return strtol(v, 0, 0);
273 }
274
getFloat(const char * key) const275 float CameraParameters::getFloat(const char* key) const {
276 const char* v = get(key);
277 if (v == 0) return -1;
278 return strtof(v, 0);
279 }
280
remove(const char * key)281 void CameraParameters::remove(const char* key) {
282 mMap.removeItem(String8(key));
283 }
284
285 // Parse string like "640x480" or "10000,20000"
parse_pair(const char * str,int * first,int * second,char delim,char ** endptr=NULL)286 static int parse_pair(const char* str, int* first, int* second, char delim, char** endptr = NULL) {
287 // Find the first integer.
288 char* end;
289 int w = (int)strtol(str, &end, 10);
290 // If a delimeter does not immediately follow, give up.
291 if (*end != delim) {
292 ALOGE("Cannot find delimeter (%c) in str=%s", delim, str);
293 return -1;
294 }
295
296 // Find the second integer, immediately after the delimeter.
297 int h = (int)strtol(end + 1, &end, 10);
298
299 *first = w;
300 *second = h;
301
302 if (endptr) {
303 *endptr = end;
304 }
305
306 return 0;
307 }
308
parseSizesList(const char * sizesStr,Vector<Size> & sizes)309 static void parseSizesList(const char* sizesStr, Vector<Size>& sizes) {
310 if (sizesStr == 0) {
311 return;
312 }
313
314 char* sizeStartPtr = (char*)sizesStr;
315
316 while (true) {
317 int width, height;
318 int success = parse_pair(sizeStartPtr, &width, &height, 'x', &sizeStartPtr);
319 if (success == -1 || (*sizeStartPtr != ',' && *sizeStartPtr != '\0')) {
320 ALOGE("Picture sizes string \"%s\" contains invalid character.", sizesStr);
321 return;
322 }
323 sizes.push(Size(width, height));
324
325 if (*sizeStartPtr == '\0') {
326 return;
327 }
328 sizeStartPtr++;
329 }
330 }
331
setPreviewSize(int width,int height)332 void CameraParameters::setPreviewSize(int width, int height) {
333 char str[32];
334 sprintf(str, "%dx%d", width, height);
335 set(KEY_PREVIEW_SIZE, str);
336 }
337
getPreviewSize(int * width,int * height) const338 void CameraParameters::getPreviewSize(int* width, int* height) const {
339 *width = *height = -1;
340 // Get the current string, if it doesn't exist, leave the -1x-1
341 const char* p = get(KEY_PREVIEW_SIZE);
342 if (p == 0) return;
343 parse_pair(p, width, height, 'x');
344 }
345
getPreferredPreviewSizeForVideo(int * width,int * height) const346 void CameraParameters::getPreferredPreviewSizeForVideo(int* width, int* height) const {
347 *width = *height = -1;
348 const char* p = get(KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO);
349 if (p == 0) return;
350 parse_pair(p, width, height, 'x');
351 }
352
getSupportedPreviewSizes(Vector<Size> & sizes) const353 void CameraParameters::getSupportedPreviewSizes(Vector<Size>& sizes) const {
354 const char* previewSizesStr = get(KEY_SUPPORTED_PREVIEW_SIZES);
355 parseSizesList(previewSizesStr, sizes);
356 }
357
setVideoSize(int width,int height)358 void CameraParameters::setVideoSize(int width, int height) {
359 char str[32];
360 sprintf(str, "%dx%d", width, height);
361 set(KEY_VIDEO_SIZE, str);
362 }
363
getVideoSize(int * width,int * height) const364 void CameraParameters::getVideoSize(int* width, int* height) const {
365 *width = *height = -1;
366 const char* p = get(KEY_VIDEO_SIZE);
367 if (p == 0) return;
368 parse_pair(p, width, height, 'x');
369 }
370
getSupportedVideoSizes(Vector<Size> & sizes) const371 void CameraParameters::getSupportedVideoSizes(Vector<Size>& sizes) const {
372 const char* videoSizesStr = get(KEY_SUPPORTED_VIDEO_SIZES);
373 parseSizesList(videoSizesStr, sizes);
374 }
375
setPreviewFrameRate(int fps)376 void CameraParameters::setPreviewFrameRate(int fps) {
377 set(KEY_PREVIEW_FRAME_RATE, fps);
378 }
379
getPreviewFrameRate() const380 int CameraParameters::getPreviewFrameRate() const {
381 return getInt(KEY_PREVIEW_FRAME_RATE);
382 }
383
getPreviewFpsRange(int * min_fps,int * max_fps) const384 void CameraParameters::getPreviewFpsRange(int* min_fps, int* max_fps) const {
385 *min_fps = *max_fps = -1;
386 const char* p = get(KEY_PREVIEW_FPS_RANGE);
387 if (p == 0) return;
388 parse_pair(p, min_fps, max_fps, ',');
389 }
390
setPreviewFormat(const char * format)391 void CameraParameters::setPreviewFormat(const char* format) {
392 set(KEY_PREVIEW_FORMAT, format);
393 }
394
getPreviewFormat() const395 const char* CameraParameters::getPreviewFormat() const {
396 return get(KEY_PREVIEW_FORMAT);
397 }
398
setPictureSize(int width,int height)399 void CameraParameters::setPictureSize(int width, int height) {
400 char str[32];
401 sprintf(str, "%dx%d", width, height);
402 set(KEY_PICTURE_SIZE, str);
403 }
404
getPictureSize(int * width,int * height) const405 void CameraParameters::getPictureSize(int* width, int* height) const {
406 *width = *height = -1;
407 // Get the current string, if it doesn't exist, leave the -1x-1
408 const char* p = get(KEY_PICTURE_SIZE);
409 if (p == 0) return;
410 parse_pair(p, width, height, 'x');
411 }
412
getSupportedPictureSizes(Vector<Size> & sizes) const413 void CameraParameters::getSupportedPictureSizes(Vector<Size>& sizes) const {
414 const char* pictureSizesStr = get(KEY_SUPPORTED_PICTURE_SIZES);
415 parseSizesList(pictureSizesStr, sizes);
416 }
417
setPictureFormat(const char * format)418 void CameraParameters::setPictureFormat(const char* format) {
419 set(KEY_PICTURE_FORMAT, format);
420 }
421
getPictureFormat() const422 const char* CameraParameters::getPictureFormat() const {
423 return get(KEY_PICTURE_FORMAT);
424 }
425
dump() const426 void CameraParameters::dump() const {
427 ALOGD("dump: mMap.size = %zu", mMap.size());
428 for (size_t i = 0; i < mMap.size(); i++) {
429 String8 k, v;
430 k = mMap.keyAt(i);
431 v = mMap.valueAt(i);
432 ALOGD("%s: %s\n", k.c_str(), v.c_str());
433 }
434 }
435
dump(int fd,const Vector<String16> &) const436 status_t CameraParameters::dump(int fd, const Vector<String16>& /*args*/) const {
437 const size_t SIZE = 256;
438 char buffer[SIZE];
439 String8 result;
440 snprintf(buffer, 255, "CameraParameters::dump: mMap.size = %zu\n", mMap.size());
441 result.append(buffer);
442 for (size_t i = 0; i < mMap.size(); i++) {
443 String8 k, v;
444 k = mMap.keyAt(i);
445 v = mMap.valueAt(i);
446 snprintf(buffer, 255, "\t%s: %s\n", k.c_str(), v.c_str());
447 result.append(buffer);
448 }
449 write(fd, result.c_str(), result.size());
450 return NO_ERROR;
451 }
452
getSupportedPreviewFormats(Vector<int> & formats) const453 void CameraParameters::getSupportedPreviewFormats(Vector<int>& formats) const {
454 const char* supportedPreviewFormats = get(CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS);
455
456 if (supportedPreviewFormats == NULL) {
457 ALOGW("%s: No supported preview formats.", __FUNCTION__);
458 return;
459 }
460
461 String8 fmtStr(supportedPreviewFormats);
462 char* prevFmts = fmtStr.lockBuffer(fmtStr.size());
463
464 char* savePtr;
465 char* fmt = strtok_r(prevFmts, ",", &savePtr);
466 while (fmt) {
467 int actual = previewFormatToEnum(fmt);
468 if (actual != -1) {
469 formats.add(actual);
470 }
471 fmt = strtok_r(NULL, ",", &savePtr);
472 }
473 fmtStr.unlockBuffer(fmtStr.size());
474 }
475
previewFormatToEnum(const char * format)476 int CameraParameters::previewFormatToEnum(const char* format) {
477 return !format ? HAL_PIXEL_FORMAT_YCrCb_420_SP
478 : !strcmp(format, PIXEL_FORMAT_YUV422SP) ? HAL_PIXEL_FORMAT_YCbCr_422_SP
479 : // NV16
480 !strcmp(format, PIXEL_FORMAT_YUV420SP) ? HAL_PIXEL_FORMAT_YCrCb_420_SP
481 : // NV21
482 !strcmp(format, PIXEL_FORMAT_YUV422I) ? HAL_PIXEL_FORMAT_YCbCr_422_I
483 : // YUY2
484 !strcmp(format, PIXEL_FORMAT_YUV420P) ? HAL_PIXEL_FORMAT_YV12
485 : // YV12
486 !strcmp(format, PIXEL_FORMAT_RGB565) ? HAL_PIXEL_FORMAT_RGB_565
487 : // RGB565
488 !strcmp(format, PIXEL_FORMAT_RGBA8888) ? HAL_PIXEL_FORMAT_RGBA_8888
489 : // RGB8888
490 !strcmp(format, PIXEL_FORMAT_BAYER_RGGB) ? HAL_PIXEL_FORMAT_RAW16
491 : // Raw sensor data
492 -1;
493 }
494
isEmpty() const495 bool CameraParameters::isEmpty() const {
496 return mMap.isEmpty();
497 }
498
499 }; // namespace helper
500 }; // namespace common
501 }; // namespace camera
502 }; // namespace hardware
503 }; // namespace android
504