From 14f0deafac556fcfa255598e658d7b3f26c93320 Mon Sep 17 00:00:00 2001 From: Jeffrey Tinker Date: Wed, 22 Aug 2012 09:17:58 -0700 Subject: [PATCH] Configure the Widevine cache buffer size via a property The property ro.com.widevine.cachesize may be set on a device to override the default stream buffer cache size. related-to-bug: 6819880 Change-Id: I27da154e38289c5d1f5f2f5f424202253d0721cc --- proprietary/wvm/WVMExtractorImpl.cpp | 14 ++++++++++++-- proprietary/wvm/include/WVMExtractorImpl.h | 4 +++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/proprietary/wvm/WVMExtractorImpl.cpp b/proprietary/wvm/WVMExtractorImpl.cpp index 978d98ae..1942d224 100644 --- a/proprietary/wvm/WVMExtractorImpl.cpp +++ b/proprietary/wvm/WVMExtractorImpl.cpp @@ -5,6 +5,7 @@ #define LOG_TAG "WVMExtractorImpl" #include #include +#include #include "WVMExtractorImpl.h" #include "WVMMediaSource.h" @@ -159,13 +160,13 @@ void WVMExtractorImpl::Initialize() // Use the URI - streaming case, only for widevine:// protocol result = WV_Setup(mSession, mDataSource->getUri().string(), "RAW/RAW/RAW;destination=getdata", credentials, - WV_OutputFormat_ES, kStreamCacheSize, mClientContext.get()); + WV_OutputFormat_ES, getStreamCacheSize(), mClientContext.get()); } else { // No URI supplied or not adaptive, pull data from the stagefright data source. mFileSource = new WVMFileSource(mDataSource); result = WV_Setup(mSession, mFileSource.get(), "RAW/RAW/RAW;destination=getdata", credentials, - WV_OutputFormat_ES, kStreamCacheSize, mClientContext.get()); + WV_OutputFormat_ES, getStreamCacheSize(), mClientContext.get()); } if (result != WV_Status_OK) { @@ -580,4 +581,13 @@ void WVMExtractorImpl::setUID(uid_t uid) mClientContext->setUID(uid); } +size_t WVMExtractorImpl::getStreamCacheSize() const +{ + char value[PROPERTY_VALUE_MAX]; + snprintf(value, sizeof(value), "%d", kDefaultStreamCacheSize); + + property_get("ro.com.widevine.cachesize", value, NULL); + return atol(value); +} + } // namespace android diff --git a/proprietary/wvm/include/WVMExtractorImpl.h b/proprietary/wvm/include/WVMExtractorImpl.h index 7a48e1e0..346ae3b6 100644 --- a/proprietary/wvm/include/WVMExtractorImpl.h +++ b/proprietary/wvm/include/WVMExtractorImpl.h @@ -80,7 +80,9 @@ private: status_t readMetaData(); - const static size_t kStreamCacheSize = 10 * 1024 * 1024; + size_t getStreamCacheSize() const; + + const static size_t kDefaultStreamCacheSize = 10 * 1024 * 1024; WVMExtractorImpl(const WVMExtractorImpl &); WVMExtractorImpl &operator=(const WVMExtractorImpl &);