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

Commit 2b1222f8 authored by Andreas Huber's avatar Andreas Huber
Browse files

Display a single (still-)frame of video after seeking while paused.

Change-Id: Ia78bf29ba6d649043e70c49913725cecdf918c03
related-to-bug: 3392259
parent 802da7bc
Loading
Loading
Loading
Loading
+37 −29
Original line number Diff line number Diff line
@@ -766,6 +766,8 @@ status_t AwesomePlayer::play() {
}

status_t AwesomePlayer::play_l() {
    mFlags &= ~SEEK_PREVIEW;

    if (mFlags & PLAYING) {
        return OK;
    }
@@ -1079,6 +1081,11 @@ status_t AwesomePlayer::seekTo_l(int64_t timeUs) {

        notifyListener_l(MEDIA_SEEK_COMPLETE);
        mSeekNotificationSent = true;

        if ((mFlags & PREPARED) && mVideoSource != NULL) {
            mFlags |= SEEK_PREVIEW;
            postVideoEvent_l();
        }
    }

    return OK;
@@ -1181,7 +1188,7 @@ status_t AwesomePlayer::initVideoDecoder(uint32_t flags) {
}

void AwesomePlayer::finishSeekIfNecessary(int64_t videoTimeUs) {
    if (!mSeeking) {
    if (!mSeeking || (mFlags & SEEK_PREVIEW)) {
        return;
    }

@@ -1228,7 +1235,8 @@ void AwesomePlayer::onVideoEvent() {
            mVideoBuffer = NULL;
        }

        if (mCachedSource != NULL && mAudioSource != NULL) {
        if (mCachedSource != NULL && mAudioSource != NULL
                && !(mFlags & SEEK_PREVIEW)) {
            // We're going to seek the video source first, followed by
            // the audio source.
            // In order to avoid jumps in the DataSource offset caused by
@@ -1322,20 +1330,14 @@ void AwesomePlayer::onVideoEvent() {
        mTimeSourceDeltaUs = realTimeUs - mediaTimeUs;
    }

    int64_t nowUs = ts->getRealTimeUs() - mTimeSourceDeltaUs;

    int64_t latenessUs = nowUs - timeUs;

    if (wasSeeking) {
    if (!wasSeeking && mRTPSession == NULL) {
        // Let's display the first frame after seeking right away.
        latenessUs = 0;
    }

    if (mRTPSession != NULL) {
        // We'll completely ignore timestamps for gtalk videochat
        // and we'll play incoming video as fast as we get it.
        latenessUs = 0;
    }

        int64_t nowUs = ts->getRealTimeUs() - mTimeSourceDeltaUs;

        int64_t latenessUs = nowUs - timeUs;

        if (latenessUs > 40000) {
            // We're more than 40ms late.
@@ -1358,6 +1360,7 @@ void AwesomePlayer::onVideoEvent() {
            postVideoEvent_l(10000);
            return;
        }
    }

    if (mVideoRendererIsPreview || mVideoRenderer == NULL) {
        mVideoRendererIsPreview = false;
@@ -1373,6 +1376,11 @@ void AwesomePlayer::onVideoEvent() {
    mVideoBuffer->release();
    mVideoBuffer = NULL;

    if (wasSeeking && (mFlags & SEEK_PREVIEW)) {
        mFlags &= ~SEEK_PREVIEW;
        return;
    }

    postVideoEvent_l();
}

+4 −0
Original line number Diff line number Diff line
@@ -119,6 +119,10 @@ private:
        // sufficient data to begin playback and finish the preparation phase
        // for good.
        PREPARING_CONNECTED = 2048,

        // We're triggering a single video event to display the first frame
        // after the seekpoint.
        SEEK_PREVIEW        = 4096,
    };

    mutable Mutex mLock;