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

@@ -200,8 +200,11 @@ void WVMExtractorImpl::SocketInfoCallback(int fd, int closing, void *context)
WVMExtractorImpl *obj = (WVMExtractorImpl *)context;
if (!obj || !obj->mUIDIsSet) {
ALOGW("SocketInfoCallback - UID not set!");
if (!obj) {
ALOGW("SocketInfoCallback: missing context!");
return;
} else if (!obj->mUIDIsSet) {
ALOGW("SocketInfoCallback: UID not set!");
return;
}
@@ -331,8 +334,10 @@ status_t WVMExtractorImpl::readMetaData()
}
}
mAudioSource = new WVMMediaSource(mSession, WV_EsSelector_Audio, audioMetaData, mIsLiveStream);
mVideoSource = new WVMMediaSource(mSession, WV_EsSelector_Video, videoMetaData, mIsLiveStream);
mAudioSource = new WVMMediaSource(mSession, WV_EsSelector_Audio, audioMetaData,
mIsLiveStream, mCryptoPluginMode);
mVideoSource = new WVMMediaSource(mSession, WV_EsSelector_Video, videoMetaData,
mIsLiveStream, mCryptoPluginMode);
// Since the WVExtractor goes away soon after this, we delegate ownership of some resources
// to the constructed media source

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
if (mCryptoInitialized) {
OEMCrypto_Terminate();
}
#endif
}
WVMExtractorImpl::cleanup();

View File

@@ -25,7 +25,7 @@ class WVMFileSource;
class WVMMediaSource : public MediaSource {
public:
WVMMediaSource(WVSession *session, WVEsSelector esSelector,
const sp<MetaData> &metaData, bool isLive);
const sp<MetaData> &metaData, bool isLive, bool cryptoPluginMode);
void delegateFileSource(sp<WVMFileSource> fileSource);
void delegateDataSource(sp<DataSource> dataSource);
@@ -79,7 +79,7 @@ private:
bool mLogOnce;
bool mIsLiveStream;
bool mNewSegment;
bool mCryptoPluginMode;
bool mCryptoInitialized;
MediaBufferGroup *mGroup;