From ff793bcaf0c3cb47a3cf8ed58c44a39837262644 Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Wed, 16 May 2012 16:03:19 -0700 Subject: [PATCH] Fix HLS Live Playback with Widevine DRM. In WVMExtractorImpl.cpp, a structure of type WVCallbacks was not initialized. In version 4.5.0 of the Widevine library, this is just a struct (not a class) so it does not have a constructor method. This record was being set with garbage default values and was causing problems setting up playback. This may have caused other stability issues after we reverted to 4.5.0. In the future, when we push forward to version 6.0 of the Widevine library, this change should be removed. In WVMediaSource.cpp, a flag was set to strip off the ATDS headers. This was redundent, and causing seg faults, for live stream. related-to-bug: 6454710 Change-Id: I3edeb40c731021b2f31f639416188d4a1c002cc5 --- proprietary/wvm/WVMExtractorImpl.cpp | 17 +++++------------ proprietary/wvm/WVMMediaSource.cpp | 16 +++++++++------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/proprietary/wvm/WVMExtractorImpl.cpp b/proprietary/wvm/WVMExtractorImpl.cpp index d4498cab..e9f56584 100644 --- a/proprietary/wvm/WVMExtractorImpl.cpp +++ b/proprietary/wvm/WVMExtractorImpl.cpp @@ -132,23 +132,17 @@ void WVMExtractorImpl::Initialize() mIsLiveStream = (mDataSource->getUri().getPathExtension().find(".m3u8") == 0); } + WVCallbacks callbacks; + // The following memset is needed for 4.5.0 only, because WVCallbacks is a struct. + memset( &callbacks, 0, sizeof(callbacks)); + callbacks.socketInfo = SocketInfoCallback; #ifdef REQUIRE_SECURE_BUFFERS if (!mIsLiveStream) { //ALOGD("WVMExtractorImpl::Initialize setting DecryptCallback\n"); - WVCallbacks callbacks; callbacks.decrypt = WVMMediaSource::DecryptCallback; - callbacks.socketInfo = SocketInfoCallback; - result = WV_Initialize(&callbacks); - } else { - WVCallbacks callbacks; - callbacks.socketInfo = SocketInfoCallback; - result = WV_Initialize(&callbacks); } -#else - WVCallbacks callbacks; - callbacks.socketInfo = SocketInfoCallback; - result = WV_Initialize(&callbacks); #endif + result = WV_Initialize(&callbacks); if (result != WV_Status_OK) { ALOGE("WV_Initialize returned status %d\n", result); @@ -551,4 +545,3 @@ void WVMExtractorImpl::setUID(uid_t uid) } } // namespace android - diff --git a/proprietary/wvm/WVMMediaSource.cpp b/proprietary/wvm/WVMMediaSource.cpp index 893cdae7..8309209f 100644 --- a/proprietary/wvm/WVMMediaSource.cpp +++ b/proprietary/wvm/WVMMediaSource.cpp @@ -163,14 +163,16 @@ sp WVMMediaSource::getFormat() Mutex::Autolock autoLock(mLock); #ifdef REQUIRE_SECURE_BUFFERS - if (!mIsLiveStream && (mESSelector == WV_EsSelector_Video)) { - mTrackMetaData->setInt32(kKeyRequiresSecureBuffers, true); - } + if (!mIsLiveStream) { + if (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); + // 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