Merge "Fix log spamming during time lapse video recording" into ics-mr1
This commit is contained in:
@@ -153,6 +153,9 @@ protected:
|
||||
bool mStarted;
|
||||
int32_t mNumFramesEncoded;
|
||||
|
||||
// Time between capture of two frames.
|
||||
int64_t mTimeBetweenFrameCaptureUs;
|
||||
|
||||
CameraSource(const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy,
|
||||
int32_t cameraId,
|
||||
Size videoSize, int32_t frameRate,
|
||||
|
||||
@@ -57,10 +57,6 @@ private:
|
||||
int32_t mVideoWidth;
|
||||
int32_t mVideoHeight;
|
||||
|
||||
// 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;
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
|
||||
namespace android {
|
||||
|
||||
static const int64_t CAMERA_SOURCE_TIMEOUT_NS = 3000000000LL;
|
||||
|
||||
struct CameraSourceListener : public CameraListener {
|
||||
CameraSourceListener(const sp<CameraSource> &source);
|
||||
|
||||
@@ -156,6 +158,7 @@ CameraSource::CameraSource(
|
||||
mLastFrameTimestampUs(0),
|
||||
mStarted(false),
|
||||
mNumFramesEncoded(0),
|
||||
mTimeBetweenFrameCaptureUs(0),
|
||||
mFirstFrameTimeUs(0),
|
||||
mNumFramesDropped(0),
|
||||
mNumGlitches(0),
|
||||
@@ -644,7 +647,8 @@ status_t CameraSource::stop() {
|
||||
releaseQueuedFrames();
|
||||
while (!mFramesBeingEncoded.empty()) {
|
||||
if (NO_ERROR !=
|
||||
mFrameCompleteCondition.waitRelative(mLock, 3000000000LL)) {
|
||||
mFrameCompleteCondition.waitRelative(mLock,
|
||||
mTimeBetweenFrameCaptureUs * 1000LL + CAMERA_SOURCE_TIMEOUT_NS)) {
|
||||
LOGW("Timed out waiting for outstanding frames being encoded: %d",
|
||||
mFramesBeingEncoded.size());
|
||||
}
|
||||
@@ -736,7 +740,8 @@ status_t CameraSource::read(
|
||||
Mutex::Autolock autoLock(mLock);
|
||||
while (mStarted && mFramesReceived.empty()) {
|
||||
if (NO_ERROR !=
|
||||
mFrameAvailableCondition.waitRelative(mLock, 1000000000LL)) {
|
||||
mFrameAvailableCondition.waitRelative(mLock,
|
||||
mTimeBetweenFrameCaptureUs * 1000LL + CAMERA_SOURCE_TIMEOUT_NS)) {
|
||||
if (mCameraRecordingProxy != 0 &&
|
||||
!mCameraRecordingProxy->asBinder()->isBinderAlive()) {
|
||||
LOGW("camera recording proxy is gone");
|
||||
|
||||
@@ -39,12 +39,12 @@ CameraSourceTimeLapse *CameraSourceTimeLapse::CreateFromCamera(
|
||||
Size videoSize,
|
||||
int32_t videoFrameRate,
|
||||
const sp<Surface>& surface,
|
||||
int64_t timeBetweenTimeLapseFrameCaptureUs) {
|
||||
int64_t timeBetweenFrameCaptureUs) {
|
||||
|
||||
CameraSourceTimeLapse *source = new
|
||||
CameraSourceTimeLapse(camera, proxy, cameraId,
|
||||
videoSize, videoFrameRate, surface,
|
||||
timeBetweenTimeLapseFrameCaptureUs);
|
||||
timeBetweenFrameCaptureUs);
|
||||
|
||||
if (source != NULL) {
|
||||
if (source->initCheck() != OK) {
|
||||
@@ -62,15 +62,15 @@ CameraSourceTimeLapse::CameraSourceTimeLapse(
|
||||
Size videoSize,
|
||||
int32_t videoFrameRate,
|
||||
const sp<Surface>& surface,
|
||||
int64_t timeBetweenTimeLapseFrameCaptureUs)
|
||||
int64_t timeBetweenFrameCaptureUs)
|
||||
: CameraSource(camera, proxy, cameraId, videoSize, videoFrameRate, surface, true),
|
||||
mTimeBetweenTimeLapseFrameCaptureUs(timeBetweenTimeLapseFrameCaptureUs),
|
||||
mTimeBetweenTimeLapseVideoFramesUs(1E6/videoFrameRate),
|
||||
mLastTimeLapseFrameRealTimestampUs(0),
|
||||
mSkipCurrentFrame(false) {
|
||||
|
||||
mTimeBetweenFrameCaptureUs = timeBetweenFrameCaptureUs;
|
||||
LOGD("starting time lapse mode: %lld us",
|
||||
mTimeBetweenTimeLapseFrameCaptureUs);
|
||||
mTimeBetweenFrameCaptureUs);
|
||||
|
||||
mVideoWidth = videoSize.width;
|
||||
mVideoHeight = videoSize.height;
|
||||
@@ -271,14 +271,14 @@ bool CameraSourceTimeLapse::skipFrameAndModifyTimeStamp(int64_t *timestampUs) {
|
||||
// The first 2 output frames from the encoder are: decoder specific info and
|
||||
// the compressed video frame data for the first input video frame.
|
||||
if (mNumFramesEncoded >= 1 && *timestampUs <
|
||||
(mLastTimeLapseFrameRealTimestampUs + mTimeBetweenTimeLapseFrameCaptureUs)) {
|
||||
(mLastTimeLapseFrameRealTimestampUs + mTimeBetweenFrameCaptureUs)) {
|
||||
// Skip all frames from last encoded frame until
|
||||
// sufficient time (mTimeBetweenTimeLapseFrameCaptureUs) has passed.
|
||||
// sufficient time (mTimeBetweenFrameCaptureUs) has passed.
|
||||
// Tell the camera to release its recording frame and return.
|
||||
LOGV("dataCallbackTimestamp timelapse: skipping intermediate frame");
|
||||
return true;
|
||||
} else {
|
||||
// Desired frame has arrived after mTimeBetweenTimeLapseFrameCaptureUs time:
|
||||
// Desired frame has arrived after mTimeBetweenFrameCaptureUs time:
|
||||
// - Reset mLastTimeLapseFrameRealTimestampUs to current time.
|
||||
// - Artificially modify timestampUs to be one frame time (1/framerate) ahead
|
||||
// of the last encoded frame's time stamp.
|
||||
|
||||
Reference in New Issue
Block a user