Initial import of Widevine Common Encryption DRM engine

Builds libwvmdrmengine.so, which is loaded by the new
MediaDrm APIs to support playback of Widevine/CENC
protected content.

Change-Id: I6f57dd37083dfd96c402cb9dd137c7d74edc8f1c
This commit is contained in:
Jeff Tinker
2013-03-21 17:39:02 -07:00
parent 38334efbe7
commit 1a8aa0dd05
211 changed files with 51913 additions and 144 deletions

View File

@@ -1,2 +0,0 @@
Add make file to create libwvdrmengine.so
Juce and Jerry to fill in and add tests.

View File

@@ -0,0 +1,32 @@
//
// Copyright 2013 Google Inc. All Rights Reserved.
//
//#define LOG_NDEBUG 0
#define LOG_TAG "WVCdm"
#include <utils/Log.h>
#include "WVCDMSingleton.h"
#include "utils/Mutex.h"
namespace wvdrm {
using wvcdm::WvContentDecryptionModule;
using android::Mutex;
Mutex cdmLock;
WvContentDecryptionModule* cdm = NULL;
WvContentDecryptionModule* getCDM() {
Mutex::Autolock lock(cdmLock);
if (cdm == NULL) {
ALOGD("Instantiating CDM.");
cdm = new WvContentDecryptionModule();
}
return cdm;
}
} // namespace wvdrm

View File

@@ -0,0 +1,20 @@
//
// Copyright 2013 Google Inc. All Rights Reserved.
//
#include "WVCreatePluginFactories.h"
#include "WVCryptoFactory.h"
#include "WVDrmFactory.h"
extern "C" {
android::DrmFactory* createDrmFactory() {
return new wvdrm::WVDrmFactory();
}
android::CryptoFactory* createCryptoFactory() {
return new wvdrm::WVCryptoFactory();
}
} // extern "C"

View File

@@ -0,0 +1,89 @@
//
// Copyright 2013 Google Inc. All Rights Reserved.
//
//#define LOG_NDEBUG 0
#define LOG_TAG "WVCdm"
#include <utils/Log.h>
#include "WVCryptoFactory.h"
#include <dlfcn.h>
#include "utils/Errors.h"
#include "WVCDMSingleton.h"
#include "WVCryptoPlugin.h"
#include "WVUUID.h"
namespace wvdrm {
using namespace android;
WVCryptoFactory::WVCryptoFactory()
: mLegacyLibraryHandle(NULL),
mLegacyFactory(NULL) {
mLegacyLibraryHandle = dlopen("libdrmdecrypt.so", RTLD_NOW);
if (mLegacyLibraryHandle == NULL) {
ALOGE("Unable to locate libdrmdecrypt.so");
} else {
typedef CryptoFactory* (*CreateCryptoFactoryFunc)();
CreateCryptoFactoryFunc legacyCreateCryptoFactory =
(CreateCryptoFactoryFunc)dlsym(mLegacyLibraryHandle,
"createCryptoFactory");
if (legacyCreateCryptoFactory == NULL) {
ALOGE("Unable to find legacy symbol 'createCryptoFactory'.");
dlclose(mLegacyLibraryHandle);
mLegacyLibraryHandle = NULL;
} else {
mLegacyFactory = legacyCreateCryptoFactory();
if (mLegacyFactory == NULL) {
ALOGE("Legacy createCryptoFactory() failed.");
dlclose(mLegacyLibraryHandle);
mLegacyLibraryHandle = NULL;
}
}
}
}
WVCryptoFactory::~WVCryptoFactory() {
if (mLegacyFactory != NULL) {
delete mLegacyFactory;
mLegacyFactory = NULL;
}
if (mLegacyLibraryHandle != NULL) {
dlclose(mLegacyLibraryHandle);
mLegacyLibraryHandle = NULL;
}
}
bool WVCryptoFactory::isCryptoSchemeSupported(const uint8_t uuid[16]) const {
return isWidevineUUID(uuid);
}
status_t WVCryptoFactory::createPlugin(const uint8_t uuid[16], const void* data,
size_t size, CryptoPlugin** plugin) {
if (!isCryptoSchemeSupported(uuid)) {
*plugin = NULL;
return BAD_VALUE;
}
// 0 size means they want an old-style Widevine plugin
if (size == 0) {
if (mLegacyFactory == NULL) {
return -EINVAL;
}
return mLegacyFactory->createPlugin(uuid, data, size, plugin);
}
// We received a session ID, so create a CENC plugin.
*plugin = new WVCryptoPlugin(data, size, getCDM());
return OK;
}
} // namespace wvdrm

View File

@@ -0,0 +1,36 @@
//
// Copyright 2013 Google Inc. All Rights Reserved.
//
//#define LOG_NDEBUG 0
#define LOG_TAG "WVCdm"
#include <utils/Log.h>
#include "WVDrmFactory.h"
#include "utils/Errors.h"
#include "WVCDMSingleton.h"
#include "WVDrmPlugin.h"
#include "WVUUID.h"
namespace wvdrm {
using namespace android;
bool WVDrmFactory::isCryptoSchemeSupported(const uint8_t uuid[16]) {
return isWidevineUUID(uuid);
}
status_t WVDrmFactory::createDrmPlugin(const uint8_t uuid[16],
DrmPlugin** plugin) {
if (!isCryptoSchemeSupported(uuid)) {
*plugin = NULL;
return BAD_VALUE;
}
*plugin = new WVDrmPlugin(getCDM());
return OK;
}
} // namespace wvdrm

View File

@@ -0,0 +1,26 @@
//
// Copyright 2013 Google Inc. All Rights Reserved.
//
#include "WVUUID.h"
#include <string.h>
namespace wvdrm {
bool isWidevineUUID(const uint8_t uuid[16]) {
static const uint8_t kWidevineUUID[16] = {
0xED,0xEF,0x8B,0xA9,0x79,0xD6,0x4A,0xCE,
0xA3,0xC8,0x27,0xDC,0xD5,0x1D,0x21,0xED
};
static const uint8_t kOldNetflixWidevineUUID[16] = {
0x29,0x70,0x1F,0xE4,0x3C,0xC7,0x4A,0x34,
0x8C,0x5B,0xAE,0x90,0xC7,0x43,0x9A,0x47
};
return !memcmp(uuid, kWidevineUUID, 16) ||
!memcmp(uuid, kOldNetflixWidevineUUID, 16);
}
} // namespace wvdrm