Fix ERROR_IO due to timeout on video stream and corrupt samples

This change applies to the wv extractor when used in conjunction
with new MediaCodec model.

Change-Id: I999990ff41d35641110a58472f1cdb8c4c7db02e
related-to-bug: 5986621
This commit is contained in:
Jeff Tinker
2012-04-27 18:52:09 -07:00
parent d4241dddd3
commit ec2d703970
6 changed files with 33 additions and 11 deletions

View File

@@ -25,13 +25,15 @@ static void _cb(int code)
status_t WVMMediaSource::sLastError = NO_ERROR;
WVMMediaSource::WVMMediaSource(WVSession *session, WVEsSelector esSelector,
const sp<MetaData> &metaData, bool isLive)
const sp<MetaData> &metaData, bool isLive,
bool cryptoPluginMode)
: mSession(session),
mESSelector(esSelector),
mTrackMetaData(metaData),
mStarted(false),
mIsLiveStream(isLive),
mNewSegment(false),
mCryptoInitialized(false),
mGroup(NULL),
mDts(0),
mPts(0)
@@ -39,7 +41,14 @@ WVMMediaSource::WVMMediaSource(WVSession *session, WVEsSelector esSelector,
_ah010(_cb);
#ifdef REQUIRE_SECURE_BUFFERS
if (esSelector == WV_EsSelector_Video) {
OEMCrypto_Initialize();
if (!cryptoPluginMode) {
OEMCryptoResult result = OEMCrypto_Initialize();
if (result == OEMCrypto_SUCCESS) {
mCryptoInitialized = true;
} else {
ALOGE("Crypto initialize failed (%d)", result);
}
}
}
#endif
}
@@ -157,6 +166,12 @@ sp<MetaData> WVMMediaSource::getFormat()
if (!mIsLiveStream && (mESSelector == WV_EsSelector_Video)) {
mTrackMetaData->setInt32(kKeyRequiresSecureBuffers, true);
}
// Only support AAC on android for now, so assume the audio
// track is AAC and notify the audio codec it has ADTS framing
if (mESSelector == WV_EsSelector_Audio) {
mTrackMetaData->setInt32(kKeyIsADTS, 1);
}
#endif
return mTrackMetaData;
@@ -425,6 +440,7 @@ WVStatus WVMMediaSource::DecryptCallback(WVEsSelector esType, void* input, void*
if (key) {
source->addEncryptedSize(length);
}
memcpy((uint8_t *)context.mMediaBuf->data() + context.mOffset, input, length);
} else {
// do decrypt
if (key)
@@ -446,9 +462,8 @@ WVStatus WVMMediaSource::DecryptCallback(WVEsSelector esType, void* input, void*
status = WV_Status_Unknown;
ALOGD("OEMCrypto decrypt failure: %d", result);
}
context.mOffset += copied;
}
context.mOffset += copied;
return status;
}
@@ -467,7 +482,9 @@ WVMMediaSource::~WVMMediaSource()
if (mSession != NULL) {
WV_Teardown(mSession);
#ifdef REQUIRE_SECURE_BUFFERS
OEMCrypto_Terminate();
if (mCryptoInitialized) {
OEMCrypto_Terminate();
}
#endif
}
WVMExtractorImpl::cleanup();