diff options
author | Jeff Tinker <jtinker@google.com> | 2011-12-07 20:23:20 -0800 |
---|---|---|
committer | Jeff Tinker <jtinker@google.com> | 2011-12-07 20:23:20 -0800 |
commit | 8e49b604c806eabe3eea2bd24813cdfc4b87c64c (patch) | |
tree | 8bf163231b5a4d481b9f17375ab0967727474d11 /media/libstagefright/WVMExtractor.cpp | |
parent | 4fe1c6c3988f79fd67c14a1f91e4b1df8a7e806f (diff) | |
download | frameworks_av-8e49b604c806eabe3eea2bd24813cdfc4b87c64c.zip frameworks_av-8e49b604c806eabe3eea2bd24813cdfc4b87c64c.tar.gz frameworks_av-8e49b604c806eabe3eea2bd24813cdfc4b87c64c.tar.bz2 |
Fix ANRs due to Widevine DRM plugin sniff taking too long.
Add a Widevine-specific format sniffer to avoid having to
refetch data from the remote server.
Change-Id: I5fdb21fe7a0d6e74f2a6f06e6fbf8070b068ac60
related-to-bug: 5725548
Diffstat (limited to 'media/libstagefright/WVMExtractor.cpp')
-rw-r--r-- | media/libstagefright/WVMExtractor.cpp | 56 |
1 files changed, 46 insertions, 10 deletions
diff --git a/media/libstagefright/WVMExtractor.cpp b/media/libstagefright/WVMExtractor.cpp index 26eda0c..79dedca 100644 --- a/media/libstagefright/WVMExtractor.cpp +++ b/media/libstagefright/WVMExtractor.cpp @@ -45,17 +45,12 @@ namespace android { static Mutex gWVMutex; WVMExtractor::WVMExtractor(const sp<DataSource> &source) - : mDataSource(source) { - { - Mutex::Autolock autoLock(gWVMutex); - if (gVendorLibHandle == NULL) { - gVendorLibHandle = dlopen("libwvm.so", RTLD_NOW); - } + : mDataSource(source) +{ + Mutex::Autolock autoLock(gWVMutex); - if (gVendorLibHandle == NULL) { - LOGE("Failed to open libwvm.so"); - return; - } + if (!getVendorLibHandle()) { + return; } typedef WVMLoadableExtractor *(*GetInstanceFunc)(sp<DataSource>); @@ -71,6 +66,19 @@ WVMExtractor::WVMExtractor(const sp<DataSource> &source) } } +bool WVMExtractor::getVendorLibHandle() +{ + if (gVendorLibHandle == NULL) { + gVendorLibHandle = dlopen("libwvm.so", RTLD_NOW); + } + + if (gVendorLibHandle == NULL) { + LOGE("Failed to open libwvm.so"); + } + + return gVendorLibHandle != NULL; +} + WVMExtractor::~WVMExtractor() { } @@ -113,5 +121,33 @@ void WVMExtractor::setAdaptiveStreamingMode(bool adaptive) { } } +bool SniffWVM( + const sp<DataSource> &source, String8 *mimeType, float *confidence, + sp<AMessage> *) { + + Mutex::Autolock autoLock(gWVMutex); + + if (!WVMExtractor::getVendorLibHandle()) { + return false; + } + + typedef WVMLoadableExtractor *(*SnifferFunc)(sp<DataSource>); + SnifferFunc snifferFunc = + (SnifferFunc) dlsym(gVendorLibHandle, + "_ZN7android15IsWidevineMediaENS_2spINS_10DataSourceEEE"); + + if (snifferFunc) { + if ((*snifferFunc)(source)) { + *mimeType = MEDIA_MIMETYPE_CONTAINER_WVM; + *confidence = 10.0f; + return true; + } + } else { + LOGE("IsWidevineMedia not found in libwvm.so"); + } + + return false; +} + } //namespace android |