diff options
-rw-r--r-- | camera/CameraParameters.cpp | 59 | ||||
-rw-r--r-- | include/camera/CameraParameters.h | 15 |
2 files changed, 44 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 diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h index 4bc1799..a5c7874 100644 --- a/include/camera/CameraParameters.h +++ b/include/camera/CameraParameters.h @@ -61,6 +61,7 @@ public: void getSupportedPreviewSizes(Vector<Size> &sizes) const; void setPreviewFrameRate(int fps); int getPreviewFrameRate() const; + void getPreviewFpsRange(int *min_fps, int *max_fps) const; void setPreviewFormat(const char *format); const char *getPreviewFormat() const; void setPictureSize(int width, int height); @@ -82,6 +83,20 @@ public: // Supported preview frame sizes in pixels. // Example value: "800x600,480x320". Read only. static const char KEY_SUPPORTED_PREVIEW_SIZES[]; + // The current minimum and maximum preview fps. This controls the rate of + // preview frames received (CAMERA_MSG_PREVIEW_FRAME). The minimum and + // maximum fps must be one of the elements from + // KEY_SUPPORTED_PREVIEW_FPS_RANGE parameter. + // Example value: "10500,26623" + static const char KEY_PREVIEW_FPS_RANGE[]; + // The supported preview fps (frame-per-second) ranges. Each range contains + // a minimum fps and maximum fps. If minimum fps equals to maximum fps, the + // camera outputs frames in fixed frame rate. If not, the camera outputs + // frames in auto frame rate. The actual frame rate fluctuates between the + // minimum and the maximum. The list has at least one element. The list is + // sorted from small to large (first by maximum fps and then minimum fps). + // Example value: "(10500,26623),(15000,26623),(30000,30000)" + static const char KEY_SUPPORTED_PREVIEW_FPS_RANGE[]; // The image format for preview frames. See CAMERA_MSG_PREVIEW_FRAME in // frameworks/base/include/camera/Camera.h. // Example value: "yuv420sp" or PIXEL_FORMAT_XXX constants. Read/write. |