Note that this version does not have Widevine Provisioning 4.0 support. It is only suitable for device upgrades. A new patch with provisioning 4.0 support will be made later.
96 lines
3.0 KiB
C++
96 lines
3.0 KiB
C++
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
|
// source code may only be used and distributed under the Widevine Master
|
|
// License Agreement.
|
|
|
|
#include "widevine_media_cas.h"
|
|
|
|
#include <memory>
|
|
|
|
#include "cas_util.h"
|
|
#include "crypto_session.h"
|
|
#include "utils/Errors.h"
|
|
#include "widevine_media_cas_plugin.h"
|
|
|
|
using android::BAD_VALUE;
|
|
using android::OK;
|
|
|
|
// Widevine Technologies CA system ID.
|
|
static constexpr int32_t kWidevineCAID = 0x4AD4;
|
|
// New Widevine CAS IDs 0x56C0 to 0x56C9 (all inclusive).
|
|
static constexpr int32_t kWidevineNewCasIdLowerBound = 0x56C0;
|
|
static constexpr int32_t kWidevineNewCasIdUpperBound = 0x56C9;
|
|
// Total number of supported Widevine CAS ids.
|
|
static constexpr size_t kWidevineCasIdCount = 11;
|
|
static constexpr char kName[] = "WidevineCas";
|
|
|
|
// Implements extern android::CasFactory *createCasFactory() entry point.
|
|
CasFactory* createCasFactory() {
|
|
return wvcas::WidevineCasFactory::createCasFactory();
|
|
}
|
|
|
|
namespace wvcas {
|
|
|
|
/************************ Cas factory implementation *********************/
|
|
|
|
// The widevine cas implementation of the cas plugin factory.
|
|
WidevineCasFactory* WidevineCasFactory::createCasFactory() {
|
|
return new WidevineCasFactory();
|
|
}
|
|
|
|
bool WidevineCasFactory::isSystemIdSupported(int32_t CA_system_id) const {
|
|
return (CA_system_id == kWidevineCAID) ||
|
|
(CA_system_id >= kWidevineNewCasIdLowerBound &&
|
|
CA_system_id <= kWidevineNewCasIdUpperBound);
|
|
}
|
|
|
|
status_t WidevineCasFactory::queryPlugins(
|
|
std::vector<CasPluginDescriptor>* descriptors) const {
|
|
if (nullptr == descriptors) {
|
|
return BAD_VALUE;
|
|
}
|
|
descriptors->clear();
|
|
descriptors->reserve(kWidevineCasIdCount);
|
|
descriptors->push_back({kWidevineCAID, String8(kName)});
|
|
for (int32_t new_id = kWidevineNewCasIdLowerBound;
|
|
new_id <= kWidevineNewCasIdUpperBound; ++new_id) {
|
|
descriptors->push_back({new_id, String8(kName)});
|
|
}
|
|
return OK;
|
|
}
|
|
|
|
status_t WidevineCasFactory::createPlugin(int32_t CA_system_id, void* appData,
|
|
CasPluginCallback callback,
|
|
CasPlugin** plugin) {
|
|
if (nullptr == plugin || !isSystemIdSupported(CA_system_id)) {
|
|
return BAD_VALUE;
|
|
}
|
|
|
|
std::unique_ptr<WidevineCasPlugin> new_plugin =
|
|
make_unique<WidevineCasPlugin>(appData, callback);
|
|
status_t status = new_plugin->initialize();
|
|
if (status != OK) {
|
|
return status;
|
|
}
|
|
*plugin = new_plugin.release();
|
|
return OK;
|
|
}
|
|
|
|
status_t WidevineCasFactory::createPlugin(int32_t CA_system_id, void* appData,
|
|
CasPluginCallbackExt callback,
|
|
CasPlugin** plugin) {
|
|
if (nullptr == plugin || !isSystemIdSupported(CA_system_id)) {
|
|
return BAD_VALUE;
|
|
}
|
|
|
|
std::unique_ptr<WidevineCasPlugin> new_plugin =
|
|
make_unique<WidevineCasPlugin>(appData, callback);
|
|
status_t status = new_plugin->initialize();
|
|
if (status != OK) {
|
|
return status;
|
|
}
|
|
*plugin = new_plugin.release();
|
|
return OK;
|
|
}
|
|
|
|
} // namespace wvcas
|