diff options
author | Wu-cheng Li <wuchengli@google.com> | 2010-08-24 09:01:27 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-08-24 09:01:27 -0700 |
commit | 10d3d28bdd0004dec5cc7963ec4a73f096fe93d2 (patch) | |
tree | 14073185f90d0c39e4c36beac8ecb7713a4a5340 /camera | |
parent | 8f3e6aa2951358c0dea593a2448171a3f97cc0eb (diff) | |
parent | 846f79b30e249ebca7d95442907723a0d14601fa (diff) | |
download | frameworks_av-10d3d28bdd0004dec5cc7963ec4a73f096fe93d2.zip frameworks_av-10d3d28bdd0004dec5cc7963ec4a73f096fe93d2.tar.gz frameworks_av-10d3d28bdd0004dec5cc7963ec4a73f096fe93d2.tar.bz2 |
am 346b6126: am 97a56269: Merge "Add camera fps range API." into gingerbread
Merge commit '346b6126d54bda4ddc705b27f49004b5cf3a2b3e'
* commit '346b6126d54bda4ddc705b27f49004b5cf3a2b3e':
Add camera fps range API.
Diffstat (limited to 'camera')
-rw-r--r-- | camera/CameraParameters.cpp | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/camera/CameraParameters.cpp b/camera/CameraParameters.cpp index abd418a..d0ed7df 100644 --- a/camera/CameraParameters.cpp +++ b/camera/CameraParameters.cpp @@ -30,6 +30,8 @@ const char CameraParameters::KEY_PREVIEW_FORMAT[] = "preview-format"; const char CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS[] = "preview-format-values"; const char CameraParameters::KEY_PREVIEW_FRAME_RATE[] = "preview-frame-rate"; const char CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES[] = "preview-frame-rate-values"; +const char CameraParameters::KEY_PREVIEW_FPS_RANGE[] = "preview-fps-range"; +const char CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE[] = "preview-fps-range-values"; const char CameraParameters::KEY_PICTURE_SIZE[] = "picture-size"; const char CameraParameters::KEY_SUPPORTED_PICTURE_SIZES[] = "picture-size-values"; const char CameraParameters::KEY_PICTURE_FORMAT[] = "picture-format"; @@ -269,20 +271,24 @@ void CameraParameters::remove(const char *key) mMap.removeItem(String8(key)); } -static int parse_size(const char *str, int &width, int &height, char **endptr = NULL) +// Parse string like "640x480" or "10000,20000" +static int parse_pair(const char *str, int *first, int *second, char delim, + char **endptr = NULL) { - // Find the width. + // Find the first integer. char *end; int w = (int)strtol(str, &end, 10); - // If an 'x' does not immediately follow, give up. - if (*end != 'x') + // If a delimeter does not immediately follow, give up. + if (*end != delim) { + LOGE("Cannot find delimeter (%c) in str=%s", delim, str); return -1; + } - // Find the height, immediately after the 'x'. + // Find the second integer, immediately after the delimeter. int h = (int)strtol(end+1, &end, 10); - width = w; - height = h; + *first = w; + *second = h; if (endptr) { *endptr = end; @@ -301,7 +307,8 @@ static void parseSizesList(const char *sizesStr, Vector<Size> &sizes) while (true) { int width, height; - int success = parse_size(sizeStartPtr, width, height, &sizeStartPtr); + int success = parse_pair(sizeStartPtr, &width, &height, 'x', + &sizeStartPtr); if (success == -1 || (*sizeStartPtr != ',' && *sizeStartPtr != '\0')) { LOGE("Picture sizes string \"%s\" contains invalid character.", sizesStr); return; @@ -324,19 +331,11 @@ void CameraParameters::setPreviewSize(int width, int height) void CameraParameters::getPreviewSize(int *width, int *height) const { - *width = -1; - *height = -1; - + *width = *height = -1; // Get the current string, if it doesn't exist, leave the -1x-1 const char *p = get(KEY_PREVIEW_SIZE); - if (p == 0) - return; - - int w, h; - if (parse_size(p, w, h) == 0) { - *width = w; - *height = h; - } + if (p == 0) return; + parse_pair(p, width, height, 'x'); } void CameraParameters::getSupportedPreviewSizes(Vector<Size> &sizes) const @@ -355,6 +354,14 @@ int CameraParameters::getPreviewFrameRate() const return getInt(KEY_PREVIEW_FRAME_RATE); } +void CameraParameters::getPreviewFpsRange(int *min_fps, int *max_fps) const +{ + *min_fps = *max_fps = -1; + const char *p = get(KEY_PREVIEW_FPS_RANGE); + if (p == 0) return; + parse_pair(p, min_fps, max_fps, ','); +} + void CameraParameters::setPreviewFormat(const char *format) { set(KEY_PREVIEW_FORMAT, format); @@ -374,19 +381,11 @@ void CameraParameters::setPictureSize(int width, int height) void CameraParameters::getPictureSize(int *width, int *height) const { - *width = -1; - *height = -1; - + *width = *height = -1; // Get the current string, if it doesn't exist, leave the -1x-1 const char *p = get(KEY_PICTURE_SIZE); - if (p == 0) - return; - - int w, h; - if (parse_size(p, w, h) == 0) { - *width = w; - *height = h; - } + if (p == 0) return; + parse_pair(p, width, height, 'x'); } void CameraParameters::getSupportedPictureSizes(Vector<Size> &sizes) const |