diff options
author | James Dong <jdong@google.com> | 2012-01-10 08:24:37 -0800 |
---|---|---|
committer | James Dong <jdong@google.com> | 2012-01-12 16:25:12 -0800 |
commit | 9d2f386dd2885eaffa11fd494ae258bb09fe6397 (patch) | |
tree | 382639f8cc7f1a3677589d7dfca37b667ea4261c /media/libstagefright/WVMExtractor.cpp | |
parent | 83bc7f3cf78b28a818417f40a4f0c00593993366 (diff) | |
download | frameworks_av-9d2f386dd2885eaffa11fd494ae258bb09fe6397.zip frameworks_av-9d2f386dd2885eaffa11fd494ae258bb09fe6397.tar.gz frameworks_av-9d2f386dd2885eaffa11fd494ae258bb09fe6397.tar.bz2 |
Separate sniffing from session initialization
This avoid lengthy/duplicate sniffing for drm plugins when a decrypt session is opened
o The change is backward compatibile in that no update is required
for existing drm plug-ins if they do not plan to provide separate
sniffer/extractor
related-to-bug: 5725548
Change-Id: I7fc4caf82d77472da4e2bc7b5d31060fb54fd84c
Diffstat (limited to 'media/libstagefright/WVMExtractor.cpp')
-rw-r--r-- | media/libstagefright/WVMExtractor.cpp | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/media/libstagefright/WVMExtractor.cpp b/media/libstagefright/WVMExtractor.cpp index 2092cb6..1e4e049 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) { - ALOGE("Failed to open libwvm.so"); - return; - } + if (!getVendorLibHandle()) { + return; } typedef WVMLoadableExtractor *(*GetInstanceFunc)(sp<DataSource>); @@ -64,13 +59,28 @@ WVMExtractor::WVMExtractor(const sp<DataSource> &source) "_ZN7android11GetInstanceENS_2spINS_10DataSourceEEE"); if (getInstanceFunc) { + CHECK(source->DrmInitialization(MEDIA_MIMETYPE_CONTAINER_WVM) != NULL); mImpl = (*getInstanceFunc)(source); CHECK(mImpl != NULL); + setDrmFlag(true); } else { ALOGE("Failed to locate GetInstance in libwvm.so"); } } +bool WVMExtractor::getVendorLibHandle() +{ + if (gVendorLibHandle == NULL) { + gVendorLibHandle = dlopen("libwvm.so", RTLD_NOW); + } + + if (gVendorLibHandle == NULL) { + ALOGE("Failed to open libwvm.so"); + } + + return gVendorLibHandle != NULL; +} + WVMExtractor::~WVMExtractor() { } @@ -113,5 +123,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)(const sp<DataSource>&); + SnifferFunc snifferFunc = + (SnifferFunc) dlsym(gVendorLibHandle, + "_ZN7android15IsWidevineMediaERKNS_2spINS_10DataSourceEEE"); + + if (snifferFunc) { + if ((*snifferFunc)(source)) { + *mimeType = MEDIA_MIMETYPE_CONTAINER_WVM; + *confidence = 10.0f; + return true; + } + } else { + ALOGE("IsWidevineMedia not found in libwvm.so"); + } + + return false; +} + } //namespace android |