From 54ff19ac69ace7c05ea90d225e26dab3b133f487 Mon Sep 17 00:00:00 2001 From: James Dong Date: Fri, 8 Oct 2010 11:59:32 -0700 Subject: 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 --- media/libstagefright/CameraSourceTimeLapse.cpp | 68 +++++++++++++------------- 1 file changed, 33 insertions(+), 35 deletions(-) (limited to 'media/libstagefright/CameraSourceTimeLapse.cpp') 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::connect(0); - - if (camera.get() == NULL) { - return NULL; - } - - return new CameraSourceTimeLapse(camera, timeBetweenTimeLapseFrameCaptureUs, - width, height, videoFrameRate); -} - -// static -CameraSourceTimeLapse *CameraSourceTimeLapse::CreateFromCamera(const sp &camera, - int64_t timeBetweenTimeLapseFrameCaptureUs, - int32_t width, int32_t height, - int32_t videoFrameRate) { - if (camera.get() == NULL) { - return NULL; +CameraSourceTimeLapse *CameraSourceTimeLapse::CreateFromCamera( + const sp &camera, + int32_t cameraId, + Size videoSize, + int32_t videoFrameRate, + const sp& 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, - int64_t timeBetweenTimeLapseFrameCaptureUs, - int32_t width, int32_t height, - int32_t videoFrameRate) - : CameraSource(camera), +CameraSourceTimeLapse::CameraSourceTimeLapse( + const sp& camera, + int32_t cameraId, + Size videoSize, + int32_t videoFrameRate, + const sp& 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. -- cgit v1.1