Merge "Support for MP4V-ES packetization format according to RFC3016." into gingerbread
diff --git a/camera/CameraParameters.cpp b/camera/CameraParameters.cpp
index 1415493..abd418a 100644
--- a/camera/CameraParameters.cpp
+++ b/camera/CameraParameters.cpp
@@ -269,7 +269,7 @@
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,14 +279,42 @@
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;
}
+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];
@@ -311,6 +339,12 @@
}
}
+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);
@@ -355,6 +389,12 @@
}
}
+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 99a3115..4bc1799 100644
--- a/include/camera/CameraParameters.h
+++ b/include/camera/CameraParameters.h
@@ -22,6 +22,21 @@
namespace android {
+struct Size {
+ int width;
+ int height;
+
+ Size() {
+ width = 0;
+ height = 0;
+ }
+
+ Size(int w, int h) {
+ width = w;
+ height = h;
+ }
+};
+
class CameraParameters
{
public:
@@ -43,12 +58,14 @@
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);
const char *getPreviewFormat() const;
void setPictureSize(int width, int height);
void getPictureSize(int *width, int *height) const;
+ void getSupportedPictureSizes(Vector<Size> &sizes) const;
void setPictureFormat(const char *format);
const char *getPictureFormat() const;