Loading media/libstagefright/AwesomePlayer.cpp +37 −29 Original line number Diff line number Diff line Loading @@ -766,6 +766,8 @@ status_t AwesomePlayer::play() { } status_t AwesomePlayer::play_l() { mFlags &= ~SEEK_PREVIEW; if (mFlags & PLAYING) { return OK; } Loading Loading @@ -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; Loading Loading @@ -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; } Loading Loading @@ -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 Loading Loading @@ -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. Loading @@ -1358,6 +1360,7 @@ void AwesomePlayer::onVideoEvent() { postVideoEvent_l(10000); return; } } if (mVideoRendererIsPreview || mVideoRenderer == NULL) { mVideoRendererIsPreview = false; Loading @@ -1373,6 +1376,11 @@ void AwesomePlayer::onVideoEvent() { mVideoBuffer->release(); mVideoBuffer = NULL; if (wasSeeking && (mFlags & SEEK_PREVIEW)) { mFlags &= ~SEEK_PREVIEW; return; } postVideoEvent_l(); } Loading media/libstagefright/include/AwesomePlayer.h +4 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading
media/libstagefright/AwesomePlayer.cpp +37 −29 Original line number Diff line number Diff line Loading @@ -766,6 +766,8 @@ status_t AwesomePlayer::play() { } status_t AwesomePlayer::play_l() { mFlags &= ~SEEK_PREVIEW; if (mFlags & PLAYING) { return OK; } Loading Loading @@ -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; Loading Loading @@ -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; } Loading Loading @@ -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 Loading Loading @@ -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. Loading @@ -1358,6 +1360,7 @@ void AwesomePlayer::onVideoEvent() { postVideoEvent_l(10000); return; } } if (mVideoRendererIsPreview || mVideoRenderer == NULL) { mVideoRendererIsPreview = false; Loading @@ -1373,6 +1376,11 @@ void AwesomePlayer::onVideoEvent() { mVideoBuffer->release(); mVideoBuffer = NULL; if (wasSeeking && (mFlags & SEEK_PREVIEW)) { mFlags &= ~SEEK_PREVIEW; return; } postVideoEvent_l(); } Loading
media/libstagefright/include/AwesomePlayer.h +4 −0 Original line number Diff line number Diff line Loading @@ -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; Loading