summaryrefslogtreecommitdiffstats
path: root/camera
diff options
context:
space:
mode:
authorNipun Kwatra <nkwatra@google.com>2010-07-30 13:40:14 -0700
committerWu-cheng Li <wuchengli@google.com>2010-08-19 09:59:11 -0700
commit34c91a321c297c1a7518ec4f10ae5993904034dd (patch)
tree4ab2943804b3d534da5539037c8c8957648684b1 /camera
parent186c38766c030b15135e7e8484d2d6b83464513a (diff)
downloadframeworks_av-34c91a321c297c1a7518ec4f10ae5993904034dd.zip
frameworks_av-34c91a321c297c1a7518ec4f10ae5993904034dd.tar.gz
frameworks_av-34c91a321c297c1a7518ec4f10ae5993904034dd.tar.bz2
Adding getSupportedPictureSizes to CameraParameters.DO NOT MERGE
Also added a struct 'Size' containing a width and a height field. Modified parse_size to optionally set an end pointer pointing to the character after the found size. Change-Id: I0c95ebf1ad4684721b32165f363db7d4d15a1b19
Diffstat (limited to 'camera')
-rw-r--r--camera/CameraParameters.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/camera/CameraParameters.cpp b/camera/CameraParameters.cpp
index 1415493..1cf19a0 100644
--- a/camera/CameraParameters.cpp
+++ b/camera/CameraParameters.cpp
@@ -269,7 +269,7 @@ void CameraParameters::remove(const char *key)
mMap.removeItem(String8(key));
}
-static int parse_size(const char *str, int &width, int &height)
+static int parse_size(const char *str, int &width, int &height, char **endptr = NULL)
{
// Find the width.
char *end;
@@ -279,11 +279,15 @@ static int parse_size(const char *str, int &width, int &height)
return -1;
// Find the height, immediately after the 'x'.
- int h = (int)strtol(end+1, 0, 10);
+ int h = (int)strtol(end+1, &end, 10);
width = w;
height = h;
+ if (endptr) {
+ *endptr = end;
+ }
+
return 0;
}
@@ -338,6 +342,31 @@ 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;