Cannot Rewind WVM in MediaCodec Mode

The solution previously checked in as 2e0e3 is re-introduced here. However,
the MediaCodec-compatible heuristic is not used unless WVM is in Crypto Plugin
(i.e. Media Codec) mode.

To repeat from last time: The problem here is that WVM cannot independently
seek the audio and video read heads, but the API assumes it can. WVM does the
right thing for AwesomePlayer-based playback (essentially ignoring audio
seeks) but the wrong thing for MediaCodec-based playback. For MediaCodec
mode, we should respect the first seek we get for a given destination and
ignore the second.

In this part, the new heuristic is reintroduced, but the old heuristic is
maintained for use in non-Crypto Plugin mode.

Bug: 6793514
Change-Id: I7ced2bf20af117a57eec27490b0920d906a8a684
This commit is contained in:
John "Juce" Bruce
2012-10-09 15:17:49 -07:00
parent 2316ae8825
commit e8cad9485c
2 changed files with 18 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ static void _cb(int code)
} }
status_t WVMMediaSource::sLastError = NO_ERROR; status_t WVMMediaSource::sLastError = NO_ERROR;
int64_t WVMMediaSource::sLastSeekTimeUs = -1;
WVMMediaSource::WVMMediaSource(WVSession *session, WVEsSelector esSelector, WVMMediaSource::WVMMediaSource(WVSession *session, WVEsSelector esSelector,
const sp<MetaData> &metaData, bool isLive, const sp<MetaData> &metaData, bool isLive,
@@ -36,6 +37,7 @@ WVMMediaSource::WVMMediaSource(WVSession *session, WVEsSelector esSelector,
mNewSegment(false), mNewSegment(false),
mCryptoInitialized(false), mCryptoInitialized(false),
mStripADTS(false), mStripADTS(false),
mCryptoPluginMode(cryptoPluginMode),
mGroup(NULL), mGroup(NULL),
mKeyTime(0), mKeyTime(0),
mDts(0), mDts(0),
@@ -243,15 +245,25 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
// prior to the specified time. // prior to the specified time.
seekNextSync = true; seekNextSync = true;
} else { } else {
// Let video stream control seek // If we are not in Crypto Plugin Mode, let the video stream
if (mESSelector == WV_EsSelector_Video) { // control the seek.
// If we are in Crypto Plugin Mode, obey the first seek we get to a
// given point, then ignore the subsequent one.
if ((!mCryptoPluginMode && mESSelector == WV_EsSelector_Video) ||
(mCryptoPluginMode && seekTimeUs != sLastSeekTimeUs)) {
float scaleUsed; float scaleUsed;
std::string when = usecToNPT(seekTimeUs) + std::string("-"); std::string when = usecToNPT(seekTimeUs) + std::string("-");
WVStatus result = WV_Play(mSession, 1.0, &scaleUsed, when ); WVStatus result = WV_Play(mSession, 1.0, &scaleUsed, when );
if (result != WV_Status_OK) { if (result != WV_Status_OK) {
ALOGE("WV_Play returned status %d in WVMMediaSource::read\n", result); ALOGE("WV_Play returned status %d in WVMMediaSource::read\n", result);
return ERROR_IO; return ERROR_IO;
} }
sLastSeekTimeUs = seekTimeUs;
} else if (mCryptoPluginMode) {
sLastSeekTimeUs = -1;
} }
} }
} }

View File

@@ -26,7 +26,8 @@ class WVMFileSource;
class WVMMediaSource : public MediaSource { class WVMMediaSource : public MediaSource {
public: public:
WVMMediaSource(WVSession *session, WVEsSelector esSelector, WVMMediaSource(WVSession *session, WVEsSelector esSelector,
const sp<MetaData> &metaData, bool isLive, bool cryptoPluginMode); const sp<MetaData> &metaData, bool isLive,
bool cryptoPluginMode);
void delegateFileSource(sp<WVMFileSource> fileSource); void delegateFileSource(sp<WVMFileSource> fileSource);
void delegateDataSource(sp<DataSource> dataSource); void delegateDataSource(sp<DataSource> dataSource);
@@ -76,6 +77,7 @@ protected:
private: private:
Mutex mLock; Mutex mLock;
static int64_t sLastSeekTimeUs;
WVSession *mSession; WVSession *mSession;
WVEsSelector mESSelector; // indicates audio vs. video WVEsSelector mESSelector; // indicates audio vs. video
@@ -88,6 +90,7 @@ private:
bool mNewSegment; bool mNewSegment;
bool mCryptoInitialized; bool mCryptoInitialized;
bool mStripADTS; bool mStripADTS;
bool mCryptoPluginMode;
MediaBufferGroup *mGroup; MediaBufferGroup *mGroup;