Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8e5f86e authored by James Dong's avatar James Dong
Browse files

Fix log spamming during time lapse video recording

Change-Id: I4fc0809203684ebb02eaf217d7abad00aefc898f

related-to-bug: 5626569
parent 6f5cc45c
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -153,6 +153,9 @@ protected:
    bool mStarted;
    bool mStarted;
    int32_t mNumFramesEncoded;
    int32_t mNumFramesEncoded;


    // Time between capture of two frames.
    int64_t mTimeBetweenFrameCaptureUs;

    CameraSource(const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy,
    CameraSource(const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy,
                 int32_t cameraId,
                 int32_t cameraId,
                 Size videoSize, int32_t frameRate,
                 Size videoSize, int32_t frameRate,
+0 −4
Original line number Original line Diff line number Diff line
@@ -57,10 +57,6 @@ private:
    int32_t mVideoWidth;
    int32_t mVideoWidth;
    int32_t mVideoHeight;
    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)
    // Time between two frames in final video (1/frameRate)
    int64_t mTimeBetweenTimeLapseVideoFramesUs;
    int64_t mTimeBetweenTimeLapseVideoFramesUs;


+7 −2
Original line number Original line Diff line number Diff line
@@ -33,6 +33,8 @@


namespace android {
namespace android {


static const int64_t CAMERA_SOURCE_TIMEOUT_NS = 3000000000LL;

struct CameraSourceListener : public CameraListener {
struct CameraSourceListener : public CameraListener {
    CameraSourceListener(const sp<CameraSource> &source);
    CameraSourceListener(const sp<CameraSource> &source);


@@ -156,6 +158,7 @@ CameraSource::CameraSource(
      mLastFrameTimestampUs(0),
      mLastFrameTimestampUs(0),
      mStarted(false),
      mStarted(false),
      mNumFramesEncoded(0),
      mNumFramesEncoded(0),
      mTimeBetweenFrameCaptureUs(0),
      mFirstFrameTimeUs(0),
      mFirstFrameTimeUs(0),
      mNumFramesDropped(0),
      mNumFramesDropped(0),
      mNumGlitches(0),
      mNumGlitches(0),
@@ -644,7 +647,8 @@ status_t CameraSource::stop() {
    releaseQueuedFrames();
    releaseQueuedFrames();
    while (!mFramesBeingEncoded.empty()) {
    while (!mFramesBeingEncoded.empty()) {
        if (NO_ERROR !=
        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",
            LOGW("Timed out waiting for outstanding frames being encoded: %d",
                mFramesBeingEncoded.size());
                mFramesBeingEncoded.size());
        }
        }
@@ -736,7 +740,8 @@ status_t CameraSource::read(
        Mutex::Autolock autoLock(mLock);
        Mutex::Autolock autoLock(mLock);
        while (mStarted && mFramesReceived.empty()) {
        while (mStarted && mFramesReceived.empty()) {
            if (NO_ERROR !=
            if (NO_ERROR !=
                mFrameAvailableCondition.waitRelative(mLock, 1000000000LL)) {
                mFrameAvailableCondition.waitRelative(mLock,
                    mTimeBetweenFrameCaptureUs * 1000LL + CAMERA_SOURCE_TIMEOUT_NS)) {
                if (mCameraRecordingProxy != 0 &&
                if (mCameraRecordingProxy != 0 &&
                    !mCameraRecordingProxy->asBinder()->isBinderAlive()) {
                    !mCameraRecordingProxy->asBinder()->isBinderAlive()) {
                    LOGW("camera recording proxy is gone");
                    LOGW("camera recording proxy is gone");
+8 −8
Original line number Original line Diff line number Diff line
@@ -39,12 +39,12 @@ CameraSourceTimeLapse *CameraSourceTimeLapse::CreateFromCamera(
        Size videoSize,
        Size videoSize,
        int32_t videoFrameRate,
        int32_t videoFrameRate,
        const sp<Surface>& surface,
        const sp<Surface>& surface,
        int64_t timeBetweenTimeLapseFrameCaptureUs) {
        int64_t timeBetweenFrameCaptureUs) {


    CameraSourceTimeLapse *source = new
    CameraSourceTimeLapse *source = new
            CameraSourceTimeLapse(camera, proxy, cameraId,
            CameraSourceTimeLapse(camera, proxy, cameraId,
                videoSize, videoFrameRate, surface,
                videoSize, videoFrameRate, surface,
                timeBetweenTimeLapseFrameCaptureUs);
                timeBetweenFrameCaptureUs);


    if (source != NULL) {
    if (source != NULL) {
        if (source->initCheck() != OK) {
        if (source->initCheck() != OK) {
@@ -62,15 +62,15 @@ CameraSourceTimeLapse::CameraSourceTimeLapse(
        Size videoSize,
        Size videoSize,
        int32_t videoFrameRate,
        int32_t videoFrameRate,
        const sp<Surface>& surface,
        const sp<Surface>& surface,
        int64_t timeBetweenTimeLapseFrameCaptureUs)
        int64_t timeBetweenFrameCaptureUs)
    : CameraSource(camera, proxy, cameraId, videoSize, videoFrameRate, surface, true),
    : CameraSource(camera, proxy, cameraId, videoSize, videoFrameRate, surface, true),
      mTimeBetweenTimeLapseFrameCaptureUs(timeBetweenTimeLapseFrameCaptureUs),
      mTimeBetweenTimeLapseVideoFramesUs(1E6/videoFrameRate),
      mTimeBetweenTimeLapseVideoFramesUs(1E6/videoFrameRate),
      mLastTimeLapseFrameRealTimestampUs(0),
      mLastTimeLapseFrameRealTimestampUs(0),
      mSkipCurrentFrame(false) {
      mSkipCurrentFrame(false) {


    mTimeBetweenFrameCaptureUs = timeBetweenFrameCaptureUs;
    LOGD("starting time lapse mode: %lld us",
    LOGD("starting time lapse mode: %lld us",
        mTimeBetweenTimeLapseFrameCaptureUs);
        mTimeBetweenFrameCaptureUs);


    mVideoWidth = videoSize.width;
    mVideoWidth = videoSize.width;
    mVideoHeight = videoSize.height;
    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 first 2 output frames from the encoder are: decoder specific info and
    // the compressed video frame data for the first input video frame.
    // the compressed video frame data for the first input video frame.
    if (mNumFramesEncoded >= 1 && *timestampUs <
    if (mNumFramesEncoded >= 1 && *timestampUs <
        (mLastTimeLapseFrameRealTimestampUs + mTimeBetweenTimeLapseFrameCaptureUs)) {
        (mLastTimeLapseFrameRealTimestampUs + mTimeBetweenFrameCaptureUs)) {
        // Skip all frames from last encoded frame until
        // 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.
        // Tell the camera to release its recording frame and return.
        LOGV("dataCallbackTimestamp timelapse: skipping intermediate frame");
        LOGV("dataCallbackTimestamp timelapse: skipping intermediate frame");
        return true;
        return true;
    } else {
    } else {
        // Desired frame has arrived after mTimeBetweenTimeLapseFrameCaptureUs time:
        // Desired frame has arrived after mTimeBetweenFrameCaptureUs time:
        // - Reset mLastTimeLapseFrameRealTimestampUs to current time.
        // - Reset mLastTimeLapseFrameRealTimestampUs to current time.
        // - Artificially modify timestampUs to be one frame time (1/framerate) ahead
        // - Artificially modify timestampUs to be one frame time (1/framerate) ahead
        // of the last encoded frame's time stamp.
        // of the last encoded frame's time stamp.