diff options
author | James Dong <jdong@google.com> | 2010-10-08 11:59:32 -0700 |
---|---|---|
committer | James Dong <jdong@google.com> | 2010-10-08 18:32:43 -0700 |
commit | 54ff19ac69ace7c05ea90d225e26dab3b133f487 (patch) | |
tree | abf0b910f9a40a2409d7e725c99c6144238d0625 /media/libstagefright/CameraSourceTimeLapse.cpp | |
parent | fa6a5d481474ba11517c8d0eb6431595d387b81e (diff) | |
download | frameworks_av-54ff19ac69ace7c05ea90d225e26dab3b133f487.zip frameworks_av-54ff19ac69ace7c05ea90d225e26dab3b133f487.tar.gz frameworks_av-54ff19ac69ace7c05ea90d225e26dab3b133f487.tar.bz2 |
Move Camera specific logic out from StagefrightRecorder to CameraSource
o updated comments and streamlined the logic in
checkVideoSize() and checkFrameRate() as suggested
Change-Id: I49d04ac7998d4a215997aa63555dfb6e814e38d3
Diffstat (limited to 'media/libstagefright/CameraSourceTimeLapse.cpp')
-rw-r--r-- | media/libstagefright/CameraSourceTimeLapse.cpp | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/media/libstagefright/CameraSourceTimeLapse.cpp b/media/libstagefright/CameraSourceTimeLapse.cpp index c1bc433..2f3f20b 100644 --- a/media/libstagefright/CameraSourceTimeLapse.cpp +++ b/media/libstagefright/CameraSourceTimeLapse.cpp @@ -37,57 +37,55 @@ namespace android { // static -CameraSourceTimeLapse *CameraSourceTimeLapse::Create( - int64_t timeBetweenTimeLapseFrameCaptureUs, - int32_t width, int32_t height, - int32_t videoFrameRate) { - sp<Camera> camera = Camera::connect(0); - - if (camera.get() == NULL) { - return NULL; - } - - return new CameraSourceTimeLapse(camera, timeBetweenTimeLapseFrameCaptureUs, - width, height, videoFrameRate); -} - -// static -CameraSourceTimeLapse *CameraSourceTimeLapse::CreateFromCamera(const sp<Camera> &camera, - int64_t timeBetweenTimeLapseFrameCaptureUs, - int32_t width, int32_t height, - int32_t videoFrameRate) { - if (camera.get() == NULL) { - return NULL; +CameraSourceTimeLapse *CameraSourceTimeLapse::CreateFromCamera( + const sp<ICamera> &camera, + int32_t cameraId, + Size videoSize, + int32_t videoFrameRate, + const sp<Surface>& surface, + int64_t timeBetweenTimeLapseFrameCaptureUs) { + + CameraSourceTimeLapse *source = new + CameraSourceTimeLapse(camera, cameraId, + videoSize, videoFrameRate, surface, + timeBetweenTimeLapseFrameCaptureUs); + + if (source != NULL) { + if (source->initCheck() != OK) { + delete source; + return NULL; + } } - - return new CameraSourceTimeLapse(camera, timeBetweenTimeLapseFrameCaptureUs, - width, height, videoFrameRate); + return source; } -CameraSourceTimeLapse::CameraSourceTimeLapse(const sp<Camera> &camera, - int64_t timeBetweenTimeLapseFrameCaptureUs, - int32_t width, int32_t height, - int32_t videoFrameRate) - : CameraSource(camera), +CameraSourceTimeLapse::CameraSourceTimeLapse( + const sp<ICamera>& camera, + int32_t cameraId, + Size videoSize, + int32_t videoFrameRate, + const sp<Surface>& surface, + int64_t timeBetweenTimeLapseFrameCaptureUs) + : CameraSource(camera, cameraId, videoSize, videoFrameRate, surface), mTimeBetweenTimeLapseFrameCaptureUs(timeBetweenTimeLapseFrameCaptureUs), mTimeBetweenTimeLapseVideoFramesUs(1E6/videoFrameRate), mLastTimeLapseFrameRealTimestampUs(0), mSkipCurrentFrame(false) { LOGV("starting time lapse mode"); - mVideoWidth = width; - mVideoHeight = height; + mVideoWidth = videoSize.width; + mVideoHeight = videoSize.height; - if (trySettingPreviewSize(width, height)) { + if (trySettingPreviewSize(videoSize.width, videoSize.height)) { mUseStillCameraForTimeLapse = false; } else { // TODO: Add a check to see that mTimeBetweenTimeLapseFrameCaptureUs is greater // than the fastest rate at which the still camera can take pictures. mUseStillCameraForTimeLapse = true; - CHECK(setPictureSizeToClosestSupported(width, height)); + CHECK(setPictureSizeToClosestSupported(videoSize.width, videoSize.height)); mNeedCropping = computeCropRectangleOffset(); - mMeta->setInt32(kKeyWidth, width); - mMeta->setInt32(kKeyHeight, height); + mMeta->setInt32(kKeyWidth, videoSize.width); + mMeta->setInt32(kKeyHeight, videoSize.height); } // Initialize quick stop variables. |