diff options
author | Andreas Huber <andih@google.com> | 2011-02-07 11:43:12 -0800 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2011-02-07 11:43:12 -0800 |
commit | 2b1222f8938356669672f35e0e53e176c78c40ef (patch) | |
tree | 788d25f249cc28caedaa0047b6bf6301dabc07fd /media | |
parent | 802da7bc462f6f9df6e681cc75c51dc0a056a4a1 (diff) | |
download | frameworks_av-2b1222f8938356669672f35e0e53e176c78c40ef.zip frameworks_av-2b1222f8938356669672f35e0e53e176c78c40ef.tar.gz frameworks_av-2b1222f8938356669672f35e0e53e176c78c40ef.tar.bz2 |
Display a single (still-)frame of video after seeking while paused.
Change-Id: Ia78bf29ba6d649043e70c49913725cecdf918c03
related-to-bug: 3392259
Diffstat (limited to 'media')
-rw-r--r-- | media/libstagefright/AwesomePlayer.cpp | 66 | ||||
-rw-r--r-- | media/libstagefright/include/AwesomePlayer.h | 4 |
2 files changed, 41 insertions, 29 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index 11ac56c..99a047a 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -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,41 +1330,36 @@ 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; - } - if (latenessUs > 40000) { - // We're more than 40ms late. - LOGV("we're late by %lld us (%.2f secs)", latenessUs, latenessUs / 1E6); - if ( mSinceLastDropped > FRAME_DROP_FREQ) - { - LOGV("we're late by %lld us (%.2f secs) dropping one after %d frames", latenessUs, latenessUs / 1E6, mSinceLastDropped); - mSinceLastDropped = 0; - mVideoBuffer->release(); - mVideoBuffer = NULL; + int64_t nowUs = ts->getRealTimeUs() - mTimeSourceDeltaUs; - postVideoEvent_l(); - return; + int64_t latenessUs = nowUs - timeUs; + + if (latenessUs > 40000) { + // We're more than 40ms late. + LOGV("we're late by %lld us (%.2f secs)", latenessUs, latenessUs / 1E6); + if ( mSinceLastDropped > FRAME_DROP_FREQ) + { + LOGV("we're late by %lld us (%.2f secs) dropping one after %d frames", latenessUs, latenessUs / 1E6, mSinceLastDropped); + mSinceLastDropped = 0; + mVideoBuffer->release(); + mVideoBuffer = NULL; + + postVideoEvent_l(); + return; + } } - } - if (latenessUs < -10000) { - // We're more than 10ms early. + if (latenessUs < -10000) { + // We're more than 10ms early. - postVideoEvent_l(10000); - return; + postVideoEvent_l(10000); + return; + } } if (mVideoRendererIsPreview || mVideoRenderer == NULL) { @@ -1373,6 +1376,11 @@ void AwesomePlayer::onVideoEvent() { mVideoBuffer->release(); mVideoBuffer = NULL; + if (wasSeeking && (mFlags & SEEK_PREVIEW)) { + mFlags &= ~SEEK_PREVIEW; + return; + } + postVideoEvent_l(); } diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h index 41ef181..3021359 100644 --- a/media/libstagefright/include/AwesomePlayer.h +++ b/media/libstagefright/include/AwesomePlayer.h @@ -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; |