From acb47e0f9a980b782742237d866224ef6f64e14f Mon Sep 17 00:00:00 2001 From: Jeff Tinker Date: Mon, 28 Oct 2013 15:19:15 -0700 Subject: [PATCH] Move OEMCrypto_Initialize earlier Some OEMCrypto calls are happening before OEMCrypto_Initialize. This change moves initialization earlier so it occurs before any other calls to OEMCrypto. bug: 10582250 Change-Id: Ic8992e8f0738dbfeb10074a4e1543bb9931a49d5 --- proprietary/wvm/WVMExtractorImpl.cpp | 14 ++++++++++++-- proprietary/wvm/WVMMediaSource.cpp | 14 ++------------ proprietary/wvm/include/WVMExtractorImpl.h | 2 +- proprietary/wvm/include/WVMMediaSource.h | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/proprietary/wvm/WVMExtractorImpl.cpp b/proprietary/wvm/WVMExtractorImpl.cpp index c1a00749..f7a1d387 100644 --- a/proprietary/wvm/WVMExtractorImpl.cpp +++ b/proprietary/wvm/WVMExtractorImpl.cpp @@ -104,6 +104,7 @@ WVMExtractorImpl::WVMExtractorImpl(sp dataSource) mHaveMetaData(false), mUseAdaptiveStreaming(false), mIsLiveStream(false), + mCryptoInitialized(false), mSession(NULL), mDuration(0), mError(OK), @@ -151,6 +152,15 @@ void WVMExtractorImpl::Initialize() memset( &callbacks, 0, sizeof(callbacks)); callbacks.socketInfo = SocketInfoCallback; #ifdef REQUIRE_SECURE_BUFFERS + if (!mClientContext->getCryptoPluginMode()) { + OEMCryptoResult res = OEMCrypto_Initialize(); + if (res == OEMCrypto_SUCCESS) { + mCryptoInitialized = true; + } else { + ALOGE("Crypto initialize failed (%d)", res); + } + } + if (!mIsLiveStream) { //ALOGD("WVMExtractorImpl::Initialize setting DecryptCallback\n"); callbacks.decrypt = WVMMediaSource::DecryptCallback; @@ -364,9 +374,9 @@ status_t WVMExtractorImpl::readMetaData() bool cryptoPluginMode = mClientContext->getCryptoPluginMode(); mAudioSource = new WVMMediaSource(mSession, WV_EsSelector_Audio, audioMetaData, - mIsLiveStream, cryptoPluginMode); + mIsLiveStream, cryptoPluginMode, false); mVideoSource = new WVMMediaSource(mSession, WV_EsSelector_Video, videoMetaData, - mIsLiveStream, cryptoPluginMode); + mIsLiveStream, cryptoPluginMode, mCryptoInitialized); // Since the WVExtractor goes away soon after this, we delegate ownership of some resources // to the constructed media source diff --git a/proprietary/wvm/WVMMediaSource.cpp b/proprietary/wvm/WVMMediaSource.cpp index d0a4d6c7..fe69691b 100644 --- a/proprietary/wvm/WVMMediaSource.cpp +++ b/proprietary/wvm/WVMMediaSource.cpp @@ -28,14 +28,14 @@ int64_t WVMMediaSource::sLastSeekTimeUs = -1; WVMMediaSource::WVMMediaSource(WVSession *session, WVEsSelector esSelector, const sp &metaData, bool isLive, - bool cryptoPluginMode) + bool cryptoPluginMode, bool cryptoInitialized) : mSession(session), mESSelector(esSelector), mTrackMetaData(metaData), mStarted(false), mIsLiveStream(isLive), mNewSegment(false), - mCryptoInitialized(false), + mCryptoInitialized(cryptoInitialized), mStripADTS(false), mCryptoPluginMode(cryptoPluginMode), mGroup(NULL), @@ -45,16 +45,6 @@ WVMMediaSource::WVMMediaSource(WVSession *session, WVEsSelector esSelector, { _ah010(_cb); #ifdef REQUIRE_SECURE_BUFFERS - if (esSelector == WV_EsSelector_Video) { - if (!cryptoPluginMode) { - OEMCryptoResult result = OEMCrypto_Initialize(); - if (result == OEMCrypto_SUCCESS) { - mCryptoInitialized = true; - } else { - ALOGE("Crypto initialize failed (%d)", result); - } - } - } mStripADTS = true; #else if (cryptoPluginMode) { diff --git a/proprietary/wvm/include/WVMExtractorImpl.h b/proprietary/wvm/include/WVMExtractorImpl.h index fb4397be..f1804dd7 100644 --- a/proprietary/wvm/include/WVMExtractorImpl.h +++ b/proprietary/wvm/include/WVMExtractorImpl.h @@ -76,7 +76,7 @@ private: bool mHaveMetaData; bool mUseAdaptiveStreaming; bool mIsLiveStream; - bool mAdaptivePrefetching; + bool mCryptoInitialized; WVSession *mSession; diff --git a/proprietary/wvm/include/WVMMediaSource.h b/proprietary/wvm/include/WVMMediaSource.h index 5f0e8a81..ab5ec1e5 100644 --- a/proprietary/wvm/include/WVMMediaSource.h +++ b/proprietary/wvm/include/WVMMediaSource.h @@ -27,7 +27,7 @@ class WVMMediaSource : public MediaSource { public: WVMMediaSource(WVSession *session, WVEsSelector esSelector, const sp &metaData, bool isLive, - bool cryptoPluginMode); + bool cryptoPluginMode, bool cryptoInitialized); void delegateFileSource(sp fileSource); void delegateDataSource(sp dataSource);