diff options
-rw-r--r-- | camera/CameraParameters.cpp | 61 | ||||
-rw-r--r-- | include/camera/CameraParameters.h | 1 |
2 files changed, 37 insertions, 25 deletions
diff --git a/camera/CameraParameters.cpp b/camera/CameraParameters.cpp index 1cf19a0..abd418a 100644 --- a/camera/CameraParameters.cpp +++ b/camera/CameraParameters.cpp @@ -291,6 +291,30 @@ static int parse_size(const char *str, int &width, int &height, char **endptr = return 0; } +static void parseSizesList(const char *sizesStr, Vector<Size> &sizes) +{ + if (sizesStr == 0) { + return; + } + + char *sizeStartPtr = (char *)sizesStr; + + while (true) { + int width, height; + int success = parse_size(sizeStartPtr, width, height, &sizeStartPtr); + if (success == -1 || (*sizeStartPtr != ',' && *sizeStartPtr != '\0')) { + LOGE("Picture sizes string \"%s\" contains invalid character.", sizesStr); + return; + } + sizes.push(Size(width, height)); + + if (*sizeStartPtr == '\0') { + return; + } + sizeStartPtr++; + } +} + void CameraParameters::setPreviewSize(int width, int height) { char str[32]; @@ -315,6 +339,12 @@ void CameraParameters::getPreviewSize(int *width, int *height) const } } +void CameraParameters::getSupportedPreviewSizes(Vector<Size> &sizes) const +{ + const char *previewSizesStr = get(KEY_SUPPORTED_PREVIEW_SIZES); + parseSizesList(previewSizesStr, sizes); +} + void CameraParameters::setPreviewFrameRate(int fps) { set(KEY_PREVIEW_FRAME_RATE, fps); @@ -342,31 +372,6 @@ void CameraParameters::setPictureSize(int width, int height) set(KEY_PICTURE_SIZE, str); } -void CameraParameters::getSupportedPictureSizes(Vector<Size> &sizes) const -{ - const char *pictureSizesStr = get(KEY_SUPPORTED_PICTURE_SIZES); - if (pictureSizesStr == 0) { - return; - } - - char *sizeStartPtr = (char *)pictureSizesStr; - - while (true) { - int width, height; - int success = parse_size(sizeStartPtr, width, height, &sizeStartPtr); - if (success == -1 || (*sizeStartPtr != ',' && *sizeStartPtr != '\0')) { - LOGE("Picture sizes string \"%s\" contains invalid character.", pictureSizesStr); - return; - } - sizes.push(Size(width, height)); - - if (*sizeStartPtr == '\0') { - return; - } - sizeStartPtr++; - } -} - void CameraParameters::getPictureSize(int *width, int *height) const { *width = -1; @@ -384,6 +389,12 @@ void CameraParameters::getPictureSize(int *width, int *height) const } } +void CameraParameters::getSupportedPictureSizes(Vector<Size> &sizes) const +{ + const char *pictureSizesStr = get(KEY_SUPPORTED_PICTURE_SIZES); + parseSizesList(pictureSizesStr, sizes); +} + void CameraParameters::setPictureFormat(const char *format) { set(KEY_PICTURE_FORMAT, format); diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h index 5211c95..b2808f5 100644 --- a/include/camera/CameraParameters.h +++ b/include/camera/CameraParameters.h @@ -58,6 +58,7 @@ public: void setPreviewSize(int width, int height); void getPreviewSize(int *width, int *height) const; + void getSupportedPreviewSizes(Vector<Size> &sizes) const; void setPreviewFrameRate(int fps); int getPreviewFrameRate() const; void setPreviewFormat(const char *format); |