summaryrefslogtreecommitdiffstats
path: root/include/media/stagefright/CameraSource.h
diff options
context:
space:
mode:
authorNipun Kwatra <nkwatra@google.com>2010-07-12 09:17:14 -0700
committerNipun Kwatra <nkwatra@google.com>2010-07-19 18:22:56 -0700
commit65e7e6facda89927cb26594b3b65ae81b3235ebc (patch)
tree89129cc7a87973b4218e3c899ec439a8ac48938b /include/media/stagefright/CameraSource.h
parent6113efbd1e5f7495b80bf64f7ee90a571e3cf6a6 (diff)
downloadframeworks_av-65e7e6facda89927cb26594b3b65ae81b3235ebc.zip
frameworks_av-65e7e6facda89927cb26594b3b65ae81b3235ebc.tar.gz
frameworks_av-65e7e6facda89927cb26594b3b65ae81b3235ebc.tar.bz2
Adding support for timelapse capture using still camera's takepicture.
Also moving entire implementation into a new class CameraSourceTimeLapse which inherits from CameraSource. For timelapse capture using still camera, we start a thread which runs a loop in which it calls Camera::takePicture() and then sleeps until the next frame should be captured. The function dataCallback() handles the callback from the camera with the raw image data. This function copies the data and creates an artificial timestamp corresponding to one frame time ahead of the last encoded frame's time stamp. It then calls dataCallbackTimestamp() of the base class which will think that it recieved the frame from a video camera and proceed as usual. For moving the implementation to the subclass CameraSourceTimeLapse, added a few virtual functions to CameraSource, which do the current thing for the base class, but specialized things for CameraSourceTimeLapse. E.g. startCameraRecording() in the base class just calls mCamera->startRecording(), while in CameraSourceTimeLapse it may start a thread for the still camera case. Change-Id: Ib787f24bd2e1f41681513f0257e1c4ca10a2b4de
Diffstat (limited to 'include/media/stagefright/CameraSource.h')
-rw-r--r--include/media/stagefright/CameraSource.h50
1 files changed, 25 insertions, 25 deletions
diff --git a/include/media/stagefright/CameraSource.h b/include/media/stagefright/CameraSource.h
index fd30ba5..ed5f09f 100644
--- a/include/media/stagefright/CameraSource.h
+++ b/include/media/stagefright/CameraSource.h
@@ -22,7 +22,6 @@
#include <media/stagefright/MediaSource.h>
#include <utils/List.h>
#include <utils/RefBase.h>
-#include <utils/threads.h>
namespace android {
@@ -35,10 +34,6 @@ public:
static CameraSource *Create();
static CameraSource *CreateFromCamera(const sp<Camera> &camera);
- void enableTimeLapseMode(
- int64_t timeBetweenTimeLapseFrameCaptureUs, int32_t videoFrameRate);
- void disableTimeLapseMode();
-
virtual ~CameraSource();
virtual status_t start(MetaData *params = NULL);
@@ -51,12 +46,34 @@ public:
virtual void signalBufferReturned(MediaBuffer* buffer);
-private:
- friend class CameraSourceListener;
-
+protected:
sp<Camera> mCamera;
sp<MetaData> mMeta;
+ int64_t mStartTimeUs;
+ int32_t mNumFramesReceived;
+ int64_t mLastFrameTimestampUs;
+ bool mStarted;
+
+ CameraSource(const sp<Camera> &camera);
+
+ virtual void startCameraRecording();
+ virtual void stopCameraRecording();
+ virtual void releaseRecordingFrame(const sp<IMemory>& frame);
+
+ // Returns true if need to skip the current frame.
+ // Called from dataCallbackTimestamp.
+ virtual bool skipCurrentFrame(int64_t timestampUs) {return false;}
+
+ // Callback called when still camera raw data is available.
+ virtual void dataCallback(int32_t msgType, const sp<IMemory> &data) {}
+
+ virtual void dataCallbackTimestamp(int64_t timestampUs, int32_t msgType,
+ const sp<IMemory> &data);
+
+private:
+ friend class CameraSourceListener;
+
Mutex mLock;
Condition mFrameAvailableCondition;
Condition mFrameCompleteCondition;
@@ -64,29 +81,12 @@ private:
List<sp<IMemory> > mFramesBeingEncoded;
List<int64_t> mFrameTimes;
- int64_t mStartTimeUs;
int64_t mFirstFrameTimeUs;
- int64_t mLastFrameTimestampUs;
- int32_t mNumFramesReceived;
int32_t mNumFramesEncoded;
int32_t mNumFramesDropped;
int32_t mNumGlitches;
int64_t mGlitchDurationThresholdUs;
bool mCollectStats;
- bool mStarted;
-
- // Time between capture of two frames during time lapse recording
- // Negative value indicates that timelapse is disabled.
- int64_t mTimeBetweenTimeLapseFrameCaptureUs;
- // Time between two frames in final video (1/frameRate)
- int64_t mTimeBetweenTimeLapseVideoFramesUs;
- // Real timestamp of the last encoded time lapse frame
- int64_t mLastTimeLapseFrameRealTimestampUs;
-
- CameraSource(const sp<Camera> &camera);
-
- void dataCallbackTimestamp(
- int64_t timestampUs, int32_t msgType, const sp<IMemory> &data);
void releaseQueuedFrames();
void releaseOneRecordingFrame(const sp<IMemory>& frame);