diff options
-rw-r--r-- | drm/drmserver/DrmManagerService.cpp | 16 | ||||
-rw-r--r-- | media/libmediaplayerservice/Crypto.cpp | 9 | ||||
-rw-r--r-- | media/libstagefright/DataSource.cpp | 40 | ||||
-rw-r--r-- | media/libstagefright/NuMediaExtractor.cpp | 24 | ||||
-rw-r--r-- | media/libstagefright/WVMExtractor.cpp | 12 |
5 files changed, 69 insertions, 32 deletions
diff --git a/drm/drmserver/DrmManagerService.cpp b/drm/drmserver/DrmManagerService.cpp index 8ba0203..746f506 100644 --- a/drm/drmserver/DrmManagerService.cpp +++ b/drm/drmserver/DrmManagerService.cpp @@ -34,21 +34,7 @@ using namespace android; static Vector<uid_t> trustedUids; static bool isProtectedCallAllowed() { - // TODO - // Following implementation is just for reference. - // Each OEM manufacturer should implement/replace with their own solutions. - bool result = false; - - IPCThreadState* ipcState = IPCThreadState::self(); - uid_t uid = ipcState->getCallingUid(); - - for (unsigned int i = 0; i < trustedUids.size(); ++i) { - if (trustedUids[i] == uid) { - result = true; - break; - } - } - return result; + return true; } void DrmManagerService::instantiate() { diff --git a/media/libmediaplayerservice/Crypto.cpp b/media/libmediaplayerservice/Crypto.cpp index 4491f2b..574ae71 100644 --- a/media/libmediaplayerservice/Crypto.cpp +++ b/media/libmediaplayerservice/Crypto.cpp @@ -32,6 +32,7 @@ namespace android { Crypto::Crypto() : mInitCheck(NO_INIT), mLibHandle(NULL), + mFactory(NULL), mPlugin(NULL) { mInitCheck = init(); } @@ -57,6 +58,8 @@ status_t Crypto::init() { mLibHandle = dlopen("libdrmdecrypt.so", RTLD_NOW); if (mLibHandle == NULL) { + ALOGE("Unable to locate libdrmdecrypt.so"); + return ERROR_UNSUPPORTED; } @@ -66,6 +69,12 @@ status_t Crypto::init() { if (createCryptoFactory == NULL || ((mFactory = createCryptoFactory()) == NULL)) { + if (createCryptoFactory == NULL) { + ALOGE("Unable to find symbol 'createCryptoFactory'."); + } else { + ALOGE("createCryptoFactory() failed."); + } + dlclose(mLibHandle); mLibHandle = NULL; diff --git a/media/libstagefright/DataSource.cpp b/media/libstagefright/DataSource.cpp index aba95bc..3400724 100644 --- a/media/libstagefright/DataSource.cpp +++ b/media/libstagefright/DataSource.cpp @@ -133,27 +133,45 @@ void DataSource::RegisterDefaultSniffers() { // static sp<DataSource> DataSource::CreateFromURI( const char *uri, const KeyedVector<String8, String8> *headers) { + bool isWidevine = !strncasecmp("widevine://", uri, 11); + sp<DataSource> source; if (!strncasecmp("file://", uri, 7)) { source = new FileSource(uri + 7); } else if (!strncasecmp("http://", uri, 7) - || !strncasecmp("https://", uri, 8)) { + || !strncasecmp("https://", uri, 8) + || isWidevine) { sp<HTTPBase> httpSource = HTTPBase::Create(); + + String8 tmp; + if (isWidevine) { + tmp = String8("http://"); + tmp.append(uri + 11); + + uri = tmp.string(); + } + if (httpSource->connect(uri, headers) != OK) { return NULL; } - String8 cacheConfig; - bool disconnectAtHighwatermark; - if (headers != NULL) { - KeyedVector<String8, String8> copy = *headers; - NuCachedSource2::RemoveCacheSpecificHeaders( - ©, &cacheConfig, &disconnectAtHighwatermark); - } + if (!isWidevine) { + String8 cacheConfig; + bool disconnectAtHighwatermark; + if (headers != NULL) { + KeyedVector<String8, String8> copy = *headers; + NuCachedSource2::RemoveCacheSpecificHeaders( + ©, &cacheConfig, &disconnectAtHighwatermark); + } - source = new NuCachedSource2( - httpSource, - cacheConfig.isEmpty() ? NULL : cacheConfig.string()); + source = new NuCachedSource2( + httpSource, + cacheConfig.isEmpty() ? NULL : cacheConfig.string()); + } else { + // We do not want that prefetching, caching, datasource wrapper + // in the widevine:// case. + source = httpSource; + } # if CHROMIUM_AVAILABLE } else if (!strncasecmp("data:", uri, 5)) { diff --git a/media/libstagefright/NuMediaExtractor.cpp b/media/libstagefright/NuMediaExtractor.cpp index 8758c93..a1d95e6 100644 --- a/media/libstagefright/NuMediaExtractor.cpp +++ b/media/libstagefright/NuMediaExtractor.cpp @@ -21,6 +21,7 @@ #include <media/stagefright/NuMediaExtractor.h> #include "include/ESDS.h" +#include "include/WVMExtractor.h" #include <media/stagefright/foundation/ABuffer.h> #include <media/stagefright/foundation/ADebug.h> @@ -58,13 +59,32 @@ status_t NuMediaExtractor::setDataSource( return -EINVAL; } - sp<DataSource> dataSource = DataSource::CreateFromURI(path, headers); + sp<DataSource> dataSource = + DataSource::CreateFromURI(path, headers); if (dataSource == NULL) { return -ENOENT; } - mImpl = MediaExtractor::Create(dataSource); + if (!strncasecmp("widevine://", path, 11)) { + String8 mimeType; + float confidence; + sp<AMessage> dummy; + bool success = SniffWVM(dataSource, &mimeType, &confidence, &dummy); + + if (!success + || strcasecmp( + mimeType.string(), MEDIA_MIMETYPE_CONTAINER_WVM)) { + return ERROR_UNSUPPORTED; + } + + sp<WVMExtractor> extractor = new WVMExtractor(dataSource); + extractor->setAdaptiveStreamingMode(true); + + mImpl = extractor; + } else { + mImpl = MediaExtractor::Create(dataSource); + } if (mImpl == NULL) { return ERROR_UNSUPPORTED; diff --git a/media/libstagefright/WVMExtractor.cpp b/media/libstagefright/WVMExtractor.cpp index dac8106..effe336 100644 --- a/media/libstagefright/WVMExtractor.cpp +++ b/media/libstagefright/WVMExtractor.cpp @@ -59,10 +59,14 @@ 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); + if (source->DrmInitialization( + MEDIA_MIMETYPE_CONTAINER_WVM) != NULL) { + mImpl = (*getInstanceFunc)(source); + CHECK(mImpl != NULL); + setDrmFlag(true); + } else { + ALOGE("Drm manager failed to initialize."); + } } else { ALOGE("Failed to locate GetInstance in libwvm.so"); } |