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:
@@ -24,6 +24,7 @@ static void _cb(int code)
|
||||
}
|
||||
|
||||
status_t WVMMediaSource::sLastError = NO_ERROR;
|
||||
int64_t WVMMediaSource::sLastSeekTimeUs = -1;
|
||||
|
||||
WVMMediaSource::WVMMediaSource(WVSession *session, WVEsSelector esSelector,
|
||||
const sp<MetaData> &metaData, bool isLive,
|
||||
@@ -36,6 +37,7 @@ WVMMediaSource::WVMMediaSource(WVSession *session, WVEsSelector esSelector,
|
||||
mNewSegment(false),
|
||||
mCryptoInitialized(false),
|
||||
mStripADTS(false),
|
||||
mCryptoPluginMode(cryptoPluginMode),
|
||||
mGroup(NULL),
|
||||
mKeyTime(0),
|
||||
mDts(0),
|
||||
@@ -243,15 +245,25 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
|
||||
// prior to the specified time.
|
||||
seekNextSync = true;
|
||||
} else {
|
||||
// Let video stream control seek
|
||||
if (mESSelector == WV_EsSelector_Video) {
|
||||
// If we are not in Crypto Plugin Mode, let the video stream
|
||||
// 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;
|
||||
std::string when = usecToNPT(seekTimeUs) + std::string("-");
|
||||
|
||||
WVStatus result = WV_Play(mSession, 1.0, &scaleUsed, when );
|
||||
|
||||
if (result != WV_Status_OK) {
|
||||
ALOGE("WV_Play returned status %d in WVMMediaSource::read\n", result);
|
||||
return ERROR_IO;
|
||||
}
|
||||
|
||||
sLastSeekTimeUs = seekTimeUs;
|
||||
} else if (mCryptoPluginMode) {
|
||||
sLastSeekTimeUs = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ class WVMFileSource;
|
||||
class WVMMediaSource : public MediaSource {
|
||||
public:
|
||||
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 delegateDataSource(sp<DataSource> dataSource);
|
||||
@@ -76,6 +77,7 @@ protected:
|
||||
|
||||
private:
|
||||
Mutex mLock;
|
||||
static int64_t sLastSeekTimeUs;
|
||||
|
||||
WVSession *mSession;
|
||||
WVEsSelector mESSelector; // indicates audio vs. video
|
||||
@@ -88,6 +90,7 @@ private:
|
||||
bool mNewSegment;
|
||||
bool mCryptoInitialized;
|
||||
bool mStripADTS;
|
||||
bool mCryptoPluginMode;
|
||||
|
||||
MediaBufferGroup *mGroup;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user