summaryrefslogtreecommitdiffstats
path: root/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'media/libmediaplayerservice/nuplayer/NuPlayer.cpp')
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.cpp48
1 files changed, 20 insertions, 28 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 1c73995..eb5821b 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -151,7 +151,6 @@ private:
NuPlayer::NuPlayer()
: mUIDValid(false),
mSourceFlags(0),
- mCurrentPositionUs(0),
mVideoIsAVC(false),
mOffloadAudio(false),
mCurrentOffloadInfo(AUDIO_INFO_INITIALIZER),
@@ -169,7 +168,6 @@ NuPlayer::NuPlayer()
mFlushingVideo(NONE),
mSkipRenderingAudioUntilMediaTimeUs(-1ll),
mSkipRenderingVideoUntilMediaTimeUs(-1ll),
- mVideoLateByUs(0ll),
mNumFramesTotal(0ll),
mNumFramesDropped(0ll),
mVideoScalingMode(NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW),
@@ -546,8 +544,11 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
// the extractor may not yet be started and will assert.
// If the video decoder is not set (perhaps audio only in this case)
// do not perform a seek as it is not needed.
- mDeferredActions.push_back(
- new SeekAction(mCurrentPositionUs, false /* needNotify */));
+ int64_t currentPositionUs = 0;
+ if (getCurrentPosition(&currentPositionUs) == OK) {
+ mDeferredActions.push_back(
+ new SeekAction(currentPositionUs, false /* needNotify */));
+ }
}
// If there is a new surface texture, instantiate decoders
@@ -581,7 +582,6 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
mVideoEOS = false;
mSkipRenderingAudioUntilMediaTimeUs = -1;
mSkipRenderingVideoUntilMediaTimeUs = -1;
- mVideoLateByUs = 0;
mNumFramesTotal = 0;
mNumFramesDropped = 0;
mStarted = true;
@@ -889,22 +889,6 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
&& (mVideoEOS || mVideoDecoder == NULL)) {
notifyListener(MEDIA_PLAYBACK_COMPLETE, 0, 0);
}
- } else if (what == Renderer::kWhatPosition) {
- int64_t positionUs;
- CHECK(msg->findInt64("positionUs", &positionUs));
- mCurrentPositionUs = positionUs;
-
- CHECK(msg->findInt64("videoLateByUs", &mVideoLateByUs));
-
- if (mDriver != NULL) {
- sp<NuPlayerDriver> driver = mDriver.promote();
- if (driver != NULL) {
- driver->notifyPosition(positionUs);
-
- driver->notifyFrameStats(
- mNumFramesTotal, mNumFramesDropped);
- }
- }
} else if (what == Renderer::kWhatFlushComplete) {
int32_t audio;
CHECK(msg->findInt32("audio", &audio));
@@ -1053,10 +1037,6 @@ void NuPlayer::handleFlushComplete(bool audio, bool isDecoder) {
case FLUSHING_DECODER:
{
*state = FLUSHED;
-
- if (!audio) {
- mVideoLateByUs = 0;
- }
break;
}
@@ -1066,7 +1046,6 @@ void NuPlayer::handleFlushComplete(bool audio, bool isDecoder) {
ALOGV("initiating %s decoder shutdown", audio ? "audio" : "video");
if (!audio) {
- mVideoLateByUs = 0;
// Widevine source reads must stop before releasing the video decoder.
if (mSource != NULL && mSourceFlags & Source::FLAG_SECURE) {
mSource->stop();
@@ -1487,7 +1466,7 @@ status_t NuPlayer::feedDecoderInputData(bool audio, const sp<AMessage> &msg) {
dropAccessUnit = false;
if (!audio
&& !(mSourceFlags & Source::FLAG_SECURE)
- && mVideoLateByUs > 100000ll
+ && mRenderer->getVideoLateByUs() > 100000ll
&& mVideoIsAVC
&& !IsAVCReferenceFrame(accessUnit)) {
dropAccessUnit = true;
@@ -1822,6 +1801,20 @@ status_t NuPlayer::selectTrack(size_t trackIndex, bool select) {
return err;
}
+status_t NuPlayer::getCurrentPosition(int64_t *mediaUs) {
+ sp<Renderer> renderer = mRenderer;
+ if (renderer == NULL) {
+ return NO_INIT;
+ }
+
+ return renderer->getCurrentPosition(mediaUs);
+}
+
+void NuPlayer::getStats(int64_t *numFramesTotal, int64_t *numFramesDropped) {
+ *numFramesTotal = mNumFramesTotal;
+ *numFramesDropped = mNumFramesDropped;
+}
+
sp<MetaData> NuPlayer::getFileMeta() {
return mSource->getFileFormatMeta();
}
@@ -1879,7 +1872,6 @@ void NuPlayer::performSeek(int64_t seekTimeUs, bool needNotify) {
if (mDriver != NULL) {
sp<NuPlayerDriver> driver = mDriver.promote();
if (driver != NULL) {
- driver->notifyPosition(seekTimeUs);
if (needNotify) {
driver->notifySeekComplete();
}