Add support for crypto HAL on L3 devices DO NOT MERGE

Includes widevine library release version 4.5.0.7571

Change-Id: I9e574d5606576aab376d0524a4bf1a81e5a61678
related-to-bug: 6427322
related-to-bug: 6427274
This commit is contained in:
Jeff Tinker
2012-06-09 14:59:20 -07:00
parent e6513d5c7c
commit b07508ef01
13 changed files with 183 additions and 53 deletions

View File

@@ -36,6 +36,7 @@ WVMMediaSource::WVMMediaSource(WVSession *session, WVEsSelector esSelector,
mNewSegment(false),
mCryptoInitialized(false),
mIsStalled(false),
mStripADTS(false),
mGroup(NULL),
mKeyTime(0),
mDts(0),
@@ -53,6 +54,11 @@ WVMMediaSource::WVMMediaSource(WVSession *session, WVEsSelector esSelector,
}
}
}
mStripADTS = true;
#else
if (cryptoPluginMode) {
mStripADTS = true;
}
#endif
}
@@ -171,19 +177,21 @@ sp<MetaData> WVMMediaSource::getFormat()
{
Mutex::Autolock autoLock(mLock);
#ifdef REQUIRE_SECURE_BUFFERS
if (!mIsLiveStream) {
#ifdef REQUIRE_SECURE_BUFFERS
if (mESSelector == WV_EsSelector_Video) {
mTrackMetaData->setInt32(kKeyRequiresSecureBuffers, true);
}
#endif
// 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);
if (mStripADTS) {
// 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;
}
@@ -260,10 +268,8 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
return err;
}
#ifdef REQUIRE_SECURE_BUFFERS
mDecryptContext.Initialize(mediaBuf);
mEncryptedSizes.clear();
#endif
size_t bytesRead;
bool auStart;
@@ -351,10 +357,8 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
// drop frames up to next sync if requested
mIsStalled = true;
usleep(10000);
#ifdef REQUIRE_SECURE_BUFFERS
mDecryptContext.Initialize(mediaBuf);
mEncryptedSizes.clear();
#endif
continue;
}
@@ -394,13 +398,15 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
mediaBuf->set_range(0, bytesRead + offset);
#ifdef REQUIRE_SECURE_BUFFERS
if (!mIsLiveStream && mEncryptedSizes.size()) {
mediaBuf->meta_data()->setData(kKeyEncryptedSizes, 0, &mEncryptedSizes[0],
mEncryptedSizes.size() * sizeof(size_t));
mediaBuf->meta_data()->setInt32(kKeyCryptoMode, CryptoPlugin::kMode_AES_WV);
}
#ifndef REQUIRE_SECURE_BUFFERS
mediaBuf->meta_data()->setData(kKeyCryptoKey, 0, mCryptoPluginKey, sizeof(mCryptoPluginKey));
#endif
}
#if 0
// debug code - log packets to files
@@ -432,7 +438,6 @@ status_t WVMMediaSource::read(MediaBuffer **buffer, const ReadOptions *options)
return OK;
}
#ifdef REQUIRE_SECURE_BUFFERS
void WVMMediaSource::DecryptCallback(WVEsSelector esType, void* input, void* output,
size_t length, int key, void *obj)
@@ -453,10 +458,7 @@ void WVMMediaSource::DecryptCallback(WVEsSelector esType, void* input, void* out
source = clientContext->getAudioSource();
DecryptContext &context = source->getDecryptContext();
OEMCrypto_UINT32 copied = length;
OEMCryptoResult result;
unsigned char *iv = NULL;
uint32_t copied = length;
if (clientContext->getCryptoPluginMode()) {
// just determine crypto unit boundaries
@@ -465,7 +467,12 @@ void WVMMediaSource::DecryptCallback(WVEsSelector esType, void* input, void* out
}
memcpy((uint8_t *)context.mMediaBuf->data() + context.mOffset, input, length);
} else {
#ifdef REQUIRE_SECURE_BUFFERS
// do decrypt
OEMCryptoResult result;
unsigned char *iv = NULL;
if (key)
iv = context.mIV;
@@ -482,10 +489,10 @@ void WVMMediaSource::DecryptCallback(WVEsSelector esType, void* input, void* out
if (result != OEMCrypto_SUCCESS) {
ALOGD("OEMCrypto decrypt failure: %d", result);
}
#endif
}
context.mOffset += copied;
}
#endif
WVMMediaSource::~WVMMediaSource()