summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/CameraSourceTimeLapse.cpp
diff options
context:
space:
mode:
authorNipun Kwatra <nkwatra@google.com>2010-07-30 18:30:55 -0700
committerNipun Kwatra <nkwatra@google.com>2010-08-02 09:49:07 -0700
commit40e2f3f9b41f44bdb59f7708a421b87f169a6ede (patch)
treeda4d690100f6bc6c0319f551e5833ce7c08cd760 /media/libstagefright/CameraSourceTimeLapse.cpp
parent99b4de92430fe42f9d1493c8a4c3d27de89d3549 (diff)
downloadframeworks_av-40e2f3f9b41f44bdb59f7708a421b87f169a6ede.zip
frameworks_av-40e2f3f9b41f44bdb59f7708a421b87f169a6ede.tar.gz
frameworks_av-40e2f3f9b41f44bdb59f7708a421b87f169a6ede.tar.bz2
Implementing getSupportedPictureSizes
Go through all the supported picture sizes and choose the smallest one with both dimensions higher than the passed in video width and height. Change-Id: I4e9fe7a6384a0feeb9e069239ec68c70fb5f3033
Diffstat (limited to 'media/libstagefright/CameraSourceTimeLapse.cpp')
-rw-r--r--media/libstagefright/CameraSourceTimeLapse.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/media/libstagefright/CameraSourceTimeLapse.cpp b/media/libstagefright/CameraSourceTimeLapse.cpp
index a01450b..854afdd 100644
--- a/media/libstagefright/CameraSourceTimeLapse.cpp
+++ b/media/libstagefright/CameraSourceTimeLapse.cpp
@@ -30,6 +30,7 @@
#include <camera/CameraParameters.h>
#include <ui/Rect.h>
#include <utils/String8.h>
+#include <utils/Vector.h>
#include "OMX_Video.h"
namespace android {
@@ -79,7 +80,7 @@ CameraSourceTimeLapse::CameraSourceTimeLapse(const sp<Camera> &camera,
mVideoWidth = width;
mVideoHeight = height;
if (mUseStillCameraForTimeLapse) {
- setPictureSizeToClosestSupported(width, height);
+ CHECK(setPictureSizeToClosestSupported(width, height));
mNeedCropping = computeCropRectangleOffset();
mMeta->setInt32(kKeyWidth, width);
mMeta->setInt32(kKeyHeight, height);
@@ -89,11 +90,31 @@ CameraSourceTimeLapse::CameraSourceTimeLapse(const sp<Camera> &camera,
CameraSourceTimeLapse::~CameraSourceTimeLapse() {
}
-void CameraSourceTimeLapse::setPictureSizeToClosestSupported(int32_t width, int32_t height) {
- // TODO: Currently fixed to the highest resolution.
- // Need to poll the camera and set accordingly.
- mPictureWidth = 2048;
- mPictureHeight = 1536;
+bool CameraSourceTimeLapse::setPictureSizeToClosestSupported(int32_t width, int32_t height) {
+ int64_t token = IPCThreadState::self()->clearCallingIdentity();
+ String8 s = mCamera->getParameters();
+ IPCThreadState::self()->restoreCallingIdentity(token);
+
+ CameraParameters params(s);
+ Vector<Size> supportedSizes;
+ params.getSupportedPictureSizes(supportedSizes);
+
+ int32_t minPictureSize = INT_MAX;
+ for (uint32_t i = 0; i < supportedSizes.size(); ++i) {
+ int32_t pictureWidth = supportedSizes[i].width;
+ int32_t pictureHeight = supportedSizes[i].height;
+
+ if ((pictureWidth >= width) && (pictureHeight >= height)) {
+ int32_t pictureSize = pictureWidth*pictureHeight;
+ if (pictureSize < minPictureSize) {
+ minPictureSize = pictureSize;
+ mPictureWidth = pictureWidth;
+ mPictureHeight = pictureHeight;
+ }
+ }
+ }
+ LOGV("Picture size = (%d, %d)", mPictureWidth, mPictureHeight);
+ return (minPictureSize != INT_MAX);
}
bool CameraSourceTimeLapse::computeCropRectangleOffset() {