Skip to content

Commit 96af14d

Browse files
author
James Dong
committed
Fix log spamming during time lapse video recording
Change-Id: I4fc0809203684ebb02eaf217d7abad00aefc898f related-to-bug: 5626569
1 parent 7859c18 commit 96af14d

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

include/media/stagefright/CameraSource.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ class CameraSource : public MediaSource, public MediaBufferObserver {
153153
bool mStarted;
154154
int32_t mNumFramesEncoded;
155155

156+
// Time between capture of two frames.
157+
int64_t mTimeBetweenFrameCaptureUs;
158+
156159
CameraSource(const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy,
157160
int32_t cameraId,
158161
Size videoSize, int32_t frameRate,

include/media/stagefright/CameraSourceTimeLapse.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ class CameraSourceTimeLapse : public CameraSource {
5757
int32_t mVideoWidth;
5858
int32_t mVideoHeight;
5959

60-
// Time between capture of two frames during time lapse recording
61-
// Negative value indicates that timelapse is disabled.
62-
int64_t mTimeBetweenTimeLapseFrameCaptureUs;
63-
6460
// Time between two frames in final video (1/frameRate)
6561
int64_t mTimeBetweenTimeLapseVideoFramesUs;
6662

media/libstagefright/CameraSource.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333

3434
namespace android {
3535

36+
static const int64_t CAMERA_SOURCE_TIMEOUT_NS = 3000000000LL;
37+
3638
struct CameraSourceListener : public CameraListener {
3739
CameraSourceListener(const sp<CameraSource> &source);
3840

@@ -156,6 +158,7 @@ CameraSource::CameraSource(
156158
mLastFrameTimestampUs(0),
157159
mStarted(false),
158160
mNumFramesEncoded(0),
161+
mTimeBetweenFrameCaptureUs(0),
159162
mFirstFrameTimeUs(0),
160163
mNumFramesDropped(0),
161164
mNumGlitches(0),
@@ -644,7 +647,8 @@ status_t CameraSource::stop() {
644647
releaseQueuedFrames();
645648
while (!mFramesBeingEncoded.empty()) {
646649
if (NO_ERROR !=
647-
mFrameCompleteCondition.waitRelative(mLock, 3000000000LL)) {
650+
mFrameCompleteCondition.waitRelative(mLock,
651+
mTimeBetweenFrameCaptureUs * 1000LL + CAMERA_SOURCE_TIMEOUT_NS)) {
648652
LOGW("Timed out waiting for outstanding frames being encoded: %d",
649653
mFramesBeingEncoded.size());
650654
}
@@ -736,7 +740,8 @@ status_t CameraSource::read(
736740
Mutex::Autolock autoLock(mLock);
737741
while (mStarted && mFramesReceived.empty()) {
738742
if (NO_ERROR !=
739-
mFrameAvailableCondition.waitRelative(mLock, 1000000000LL)) {
743+
mFrameAvailableCondition.waitRelative(mLock,
744+
mTimeBetweenFrameCaptureUs * 1000LL + CAMERA_SOURCE_TIMEOUT_NS)) {
740745
if (mCameraRecordingProxy != 0 &&
741746
!mCameraRecordingProxy->asBinder()->isBinderAlive()) {
742747
LOGW("camera recording proxy is gone");

media/libstagefright/CameraSourceTimeLapse.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ CameraSourceTimeLapse *CameraSourceTimeLapse::CreateFromCamera(
3939
Size videoSize,
4040
int32_t videoFrameRate,
4141
const sp<Surface>& surface,
42-
int64_t timeBetweenTimeLapseFrameCaptureUs) {
42+
int64_t timeBetweenFrameCaptureUs) {
4343

4444
CameraSourceTimeLapse *source = new
4545
CameraSourceTimeLapse(camera, proxy, cameraId,
4646
videoSize, videoFrameRate, surface,
47-
timeBetweenTimeLapseFrameCaptureUs);
47+
timeBetweenFrameCaptureUs);
4848

4949
if (source != NULL) {
5050
if (source->initCheck() != OK) {
@@ -62,15 +62,15 @@ CameraSourceTimeLapse::CameraSourceTimeLapse(
6262
Size videoSize,
6363
int32_t videoFrameRate,
6464
const sp<Surface>& surface,
65-
int64_t timeBetweenTimeLapseFrameCaptureUs)
65+
int64_t timeBetweenFrameCaptureUs)
6666
: CameraSource(camera, proxy, cameraId, videoSize, videoFrameRate, surface, true),
67-
mTimeBetweenTimeLapseFrameCaptureUs(timeBetweenTimeLapseFrameCaptureUs),
6867
mTimeBetweenTimeLapseVideoFramesUs(1E6/videoFrameRate),
6968
mLastTimeLapseFrameRealTimestampUs(0),
7069
mSkipCurrentFrame(false) {
7170

71+
mTimeBetweenFrameCaptureUs = timeBetweenFrameCaptureUs;
7272
LOGD("starting time lapse mode: %lld us",
73-
mTimeBetweenTimeLapseFrameCaptureUs);
73+
mTimeBetweenFrameCaptureUs);
7474

7575
mVideoWidth = videoSize.width;
7676
mVideoHeight = videoSize.height;
@@ -271,14 +271,14 @@ bool CameraSourceTimeLapse::skipFrameAndModifyTimeStamp(int64_t *timestampUs) {
271271
// The first 2 output frames from the encoder are: decoder specific info and
272272
// the compressed video frame data for the first input video frame.
273273
if (mNumFramesEncoded >= 1 && *timestampUs <
274-
(mLastTimeLapseFrameRealTimestampUs + mTimeBetweenTimeLapseFrameCaptureUs)) {
274+
(mLastTimeLapseFrameRealTimestampUs + mTimeBetweenFrameCaptureUs)) {
275275
// Skip all frames from last encoded frame until
276-
// sufficient time (mTimeBetweenTimeLapseFrameCaptureUs) has passed.
276+
// sufficient time (mTimeBetweenFrameCaptureUs) has passed.
277277
// Tell the camera to release its recording frame and return.
278278
LOGV("dataCallbackTimestamp timelapse: skipping intermediate frame");
279279
return true;
280280
} else {
281-
// Desired frame has arrived after mTimeBetweenTimeLapseFrameCaptureUs time:
281+
// Desired frame has arrived after mTimeBetweenFrameCaptureUs time:
282282
// - Reset mLastTimeLapseFrameRealTimestampUs to current time.
283283
// - Artificially modify timestampUs to be one frame time (1/framerate) ahead
284284
// of the last encoded frame's time stamp.

0 commit comments

Comments
 (0)