diff options
author | Marco Nelissen <marcone@google.com> | 2014-09-16 15:43:44 -0700 |
---|---|---|
committer | Marco Nelissen <marcone@google.com> | 2014-09-17 08:17:46 -0700 |
commit | f0b72b509ab1147a2a0925aced970dd68fd7fa4f (patch) | |
tree | 0eae72c913500fc5c4be4e0a32bb32b39f44aebc /media/libmediaplayerservice | |
parent | 086c1e3f41a92aa0025a1da1db5dabbfdffaf129 (diff) | |
download | frameworks_av-f0b72b509ab1147a2a0925aced970dd68fd7fa4f.zip frameworks_av-f0b72b509ab1147a2a0925aced970dd68fd7fa4f.tar.gz frameworks_av-f0b72b509ab1147a2a0925aced970dd68fd7fa4f.tar.bz2 |
Add support for ANDROID_LOOP to NuPlayer
Bug: 17518139
Change-Id: I9355ddd4c998d967013dd8bd32d670a9a83dea31
Diffstat (limited to 'media/libmediaplayerservice')
7 files changed, 30 insertions, 4 deletions
diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.cpp b/media/libmediaplayerservice/nuplayer/GenericSource.cpp index 511871d..d194e73 100644 --- a/media/libmediaplayerservice/nuplayer/GenericSource.cpp +++ b/media/libmediaplayerservice/nuplayer/GenericSource.cpp @@ -106,6 +106,10 @@ status_t NuPlayer::GenericSource::setDataSource( return OK; } +sp<MetaData> NuPlayer::GenericSource::getFileFormatMeta() const { + return mFileMeta; +} + status_t NuPlayer::GenericSource::initFromDataSource() { sp<MediaExtractor> extractor; @@ -144,10 +148,10 @@ status_t NuPlayer::GenericSource::initFromDataSource() { checkDrmStatus(mDataSource); } - sp<MetaData> fileMeta = extractor->getMetaData(); - if (fileMeta != NULL) { + mFileMeta = extractor->getMetaData(); + if (mFileMeta != NULL) { int64_t duration; - if (fileMeta->findInt64(kKeyDuration, &duration)) { + if (mFileMeta->findInt64(kKeyDuration, &duration)) { mDurationUs = duration; } } diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.h b/media/libmediaplayerservice/nuplayer/GenericSource.h index c70c48e..dcdfb0a 100644 --- a/media/libmediaplayerservice/nuplayer/GenericSource.h +++ b/media/libmediaplayerservice/nuplayer/GenericSource.h @@ -57,6 +57,8 @@ struct NuPlayer::GenericSource : public NuPlayer::Source { virtual status_t feedMoreTSData(); + virtual sp<MetaData> getFileFormatMeta() const; + virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit); virtual status_t getDuration(int64_t *durationUs); @@ -123,6 +125,7 @@ private: sp<DataSource> mDataSource; sp<NuCachedSource2> mCachedSource; sp<WVMExtractor> mWVMExtractor; + sp<MetaData> mFileMeta; DrmManagerClient *mDrmManagerClient; sp<DecryptHandle> mDecryptHandle; bool mStarted; diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index 9020a8d..4bb7c96 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -1720,6 +1720,10 @@ status_t NuPlayer::selectTrack(size_t trackIndex, bool select) { return err; } +sp<MetaData> NuPlayer::getFileMeta() { + return mSource->getFileFormatMeta(); +} + void NuPlayer::schedulePollDuration() { sp<AMessage> msg = new AMessage(kWhatPollDuration, id()); msg->setInt32("generation", mPollDurationGeneration); diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h index 2e951bd..7197e5f 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h @@ -67,6 +67,8 @@ struct NuPlayer : public AHandler { status_t getSelectedTrack(int32_t type, Parcel* reply) const; status_t selectTrack(size_t trackIndex, bool select); + sp<MetaData> getFileMeta(); + static const size_t kAggregateBufferSizeBytes; protected: diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp index 7dd54c1..69aa7b3 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp @@ -45,6 +45,7 @@ NuPlayerDriver::NuPlayerDriver() mPlayerFlags(0), mAtEOS(false), mLooping(false), + mAutoLoop(false), mStartupSeekTimeUs(-1) { mLooper->setName("NuPlayerDriver Looper"); @@ -498,6 +499,7 @@ status_t NuPlayerDriver::invoke(const Parcel &request, Parcel *reply) { void NuPlayerDriver::setAudioSink(const sp<AudioSink> &audioSink) { mPlayer->setAudioSink(audioSink); + mAudioSink = audioSink; } status_t NuPlayerDriver::setParameter( @@ -627,7 +629,8 @@ void NuPlayerDriver::notifyListener_l( case MEDIA_PLAYBACK_COMPLETE: { if (mState != STATE_RESET_IN_PROGRESS) { - if (mLooping) { + if (mLooping || (mAutoLoop + && (mAudioSink == NULL || mAudioSink->realtime()))) { mPlayer->seekToAsync(0); break; } @@ -693,6 +696,13 @@ void NuPlayerDriver::notifyPrepareCompleted(status_t err) { } } + sp<MetaData> meta = mPlayer->getFileMeta(); + int32_t loop; + if (meta != NULL + && meta->findInt32(kKeyAutoLoop, &loop) && loop != 0) { + mAutoLoop = true; + } + mCondition.broadcast(); } diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h index e81d605..f2bd431 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h @@ -114,10 +114,12 @@ private: sp<ALooper> mLooper; sp<NuPlayer> mPlayer; + sp<AudioSink> mAudioSink; uint32_t mPlayerFlags; bool mAtEOS; bool mLooping; + bool mAutoLoop; int64_t mStartupSeekTimeUs; diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerSource.h b/media/libmediaplayerservice/nuplayer/NuPlayerSource.h index 7ccf3b1..a2d9b2f 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerSource.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayerSource.h @@ -73,6 +73,7 @@ struct NuPlayer::Source : public AHandler { virtual sp<AMessage> getFormat(bool audio); virtual sp<MetaData> getFormatMeta(bool /* audio */) { return NULL; } + virtual sp<MetaData> getFileFormatMeta() const { return NULL; } virtual status_t dequeueAccessUnit( bool audio, sp<ABuffer> *accessUnit) = 0; |