Generate key set ID on initialization and interface clean up
This is a merge of squashed CLs. * Cdm Session and Engine interface clean up [ Merge of http://go/wvgerrit/16387 ] Key Set Ids have been removed from the CdmSession interface (GenerateKeyRequest, Addkey) as they can be queried by an accessor. The CdmEngine interface now allows one to specify or retrieve a session ID, since both were not being used in a single call. Key set IDs are no longer returned though GenerateKeyRequest as they was not being used. * Generate key set ID when session is initialized [ Merge of http://go/wvgerrit/16370 ] Key set IDs are currently generated at different times in the CdmSession lifecycle. Android generates key set IDs when the license is received, while the CE CDM generates (or overrides them) when the session is constructed. The key set IDs are now generated when the session is initialized. Key set generation cannot occur earlier as it has a dependency on security level and in turn on crypto session initialization which occurs when the session is initialized. Depenencies on Session ID has caused other activities, construction of PolicyEngine, CdmLicense, setting property CDM client sets to be deferred from CdmSession constructor to Init(). Android will still retrieve the key set IDs after the offline license is processed. For streaming requests, the key set will be unreserved and discarded when the session is terminated. Change-Id: Ib802d1c043742d62efa9a2c901fcd113e836c33d
This commit is contained in:
@@ -30,11 +30,15 @@ class CdmEngine {
|
|||||||
virtual ~CdmEngine();
|
virtual ~CdmEngine();
|
||||||
|
|
||||||
// Session related methods
|
// Session related methods
|
||||||
|
virtual CdmResponseType OpenSession(const CdmKeySystem& key_system,
|
||||||
|
CdmClientPropertySet* property_set,
|
||||||
|
const std::string& origin,
|
||||||
|
const CdmSessionId& forced_session_id,
|
||||||
|
WvCdmEventListener* event_listener);
|
||||||
virtual CdmResponseType OpenSession(const CdmKeySystem& key_system,
|
virtual CdmResponseType OpenSession(const CdmKeySystem& key_system,
|
||||||
CdmClientPropertySet* property_set,
|
CdmClientPropertySet* property_set,
|
||||||
const std::string& origin,
|
const std::string& origin,
|
||||||
WvCdmEventListener* event_listener,
|
WvCdmEventListener* event_listener,
|
||||||
const CdmSessionId* forced_session_id,
|
|
||||||
CdmSessionId* session_id);
|
CdmSessionId* session_id);
|
||||||
virtual CdmResponseType CloseSession(const CdmSessionId& session_id);
|
virtual CdmResponseType CloseSession(const CdmSessionId& session_id);
|
||||||
virtual bool IsOpenSession(const CdmSessionId& session_id);
|
virtual bool IsOpenSession(const CdmSessionId& session_id);
|
||||||
@@ -66,18 +70,13 @@ class CdmEngine {
|
|||||||
// server_url: This must be non-null and point to a string. The string will
|
// server_url: This must be non-null and point to a string. The string will
|
||||||
// have its contents replaced with the default URL (if one is
|
// have its contents replaced with the default URL (if one is
|
||||||
// known) to send this key request to.
|
// known) to send this key request to.
|
||||||
// key_set_id_out: May be null. If it is non-null, the CdmKeySetId pointed to
|
|
||||||
// will have its contents replaced with the key set ID of the
|
|
||||||
// session. Note that for non-offline license requests, the
|
|
||||||
// key set ID is empty, so the CdmKeySetId will be cleared.
|
|
||||||
// TODO(kqyang): Consider refactor GenerateKeyRequest to reduce the number of
|
// TODO(kqyang): Consider refactor GenerateKeyRequest to reduce the number of
|
||||||
// parameters.
|
// parameters.
|
||||||
virtual CdmResponseType GenerateKeyRequest(
|
virtual CdmResponseType GenerateKeyRequest(
|
||||||
const CdmSessionId& session_id, const CdmKeySetId& key_set_id,
|
const CdmSessionId& session_id, const CdmKeySetId& key_set_id,
|
||||||
const InitializationData& init_data, const CdmLicenseType license_type,
|
const InitializationData& init_data, const CdmLicenseType license_type,
|
||||||
CdmAppParameterMap& app_parameters, CdmKeyMessage* key_request,
|
CdmAppParameterMap& app_parameters, CdmKeyMessage* key_request,
|
||||||
CdmKeyRequestType* key_request_type, std::string* server_url,
|
CdmKeyRequestType* key_request_type, std::string* server_url);
|
||||||
CdmKeySetId* key_set_id_out);
|
|
||||||
|
|
||||||
// Accept license response and extract key info.
|
// Accept license response and extract key info.
|
||||||
virtual CdmResponseType AddKey(const CdmSessionId& session_id,
|
virtual CdmResponseType AddKey(const CdmSessionId& session_id,
|
||||||
@@ -175,6 +174,13 @@ class CdmEngine {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// private methods
|
// private methods
|
||||||
|
CdmResponseType OpenSession(const CdmKeySystem& key_system,
|
||||||
|
CdmClientPropertySet* property_set,
|
||||||
|
const std::string& origin,
|
||||||
|
WvCdmEventListener* event_listener,
|
||||||
|
const CdmSessionId* forced_session_id,
|
||||||
|
CdmSessionId* session_id);
|
||||||
|
|
||||||
void DeleteAllUsageReportsUponFactoryReset();
|
void DeleteAllUsageReportsUponFactoryReset();
|
||||||
bool ValidateKeySystem(const CdmKeySystem& key_system);
|
bool ValidateKeySystem(const CdmKeySystem& key_system);
|
||||||
CdmResponseType GetUsageInfo(const std::string& app_id,
|
CdmResponseType GetUsageInfo(const std::string& app_id,
|
||||||
|
|||||||
@@ -22,12 +22,30 @@ class WvCdmEventListener;
|
|||||||
|
|
||||||
class CdmSession {
|
class CdmSession {
|
||||||
public:
|
public:
|
||||||
CdmSession(CdmClientPropertySet* cdm_client_property_set,
|
CdmSession(const std::string& origin)
|
||||||
const std::string& origin, WvCdmEventListener* event_listener,
|
: initialized_(false),
|
||||||
const CdmSessionId* forced_session_id);
|
origin_(origin),
|
||||||
|
crypto_session_(new CryptoSession),
|
||||||
|
file_handle_(new DeviceFiles),
|
||||||
|
license_received_(false),
|
||||||
|
is_offline_(false),
|
||||||
|
is_release_(false),
|
||||||
|
is_temporary_(false),
|
||||||
|
security_level_(kSecurityLevelUninitialized),
|
||||||
|
requested_security_level_(kLevelDefault),
|
||||||
|
is_initial_decryption_(true),
|
||||||
|
has_decrypted_since_last_report_(false),
|
||||||
|
is_initial_usage_update_(true),
|
||||||
|
is_usage_update_needed_(false),
|
||||||
|
mock_license_parser_in_use_(false),
|
||||||
|
mock_policy_engine_in_use_(false) {}
|
||||||
|
|
||||||
virtual ~CdmSession();
|
virtual ~CdmSession();
|
||||||
|
|
||||||
virtual CdmResponseType Init();
|
virtual CdmResponseType Init(CdmClientPropertySet* cdm_client_property_set);
|
||||||
|
virtual CdmResponseType Init(CdmClientPropertySet* cdm_client_property_set,
|
||||||
|
const CdmSessionId* forced_session_id,
|
||||||
|
WvCdmEventListener* event_listener);
|
||||||
|
|
||||||
virtual CdmResponseType RestoreOfflineSession(
|
virtual CdmResponseType RestoreOfflineSession(
|
||||||
const CdmKeySetId& key_set_id, const CdmLicenseType license_type);
|
const CdmKeySetId& key_set_id, const CdmLicenseType license_type);
|
||||||
@@ -35,16 +53,15 @@ class CdmSession {
|
|||||||
const CdmKeyMessage& key_request, const CdmKeyResponse& key_response);
|
const CdmKeyMessage& key_request, const CdmKeyResponse& key_response);
|
||||||
|
|
||||||
virtual const CdmSessionId& session_id() { return session_id_; }
|
virtual const CdmSessionId& session_id() { return session_id_; }
|
||||||
|
virtual const CdmKeySetId& key_set_id() { return key_set_id_; }
|
||||||
|
|
||||||
virtual CdmResponseType GenerateKeyRequest(
|
virtual CdmResponseType GenerateKeyRequest(
|
||||||
const InitializationData& init_data, CdmLicenseType license_type,
|
const InitializationData& init_data, CdmLicenseType license_type,
|
||||||
const CdmAppParameterMap& app_parameters, CdmKeyMessage* key_request,
|
const CdmAppParameterMap& app_parameters, CdmKeyMessage* key_request,
|
||||||
CdmKeyRequestType* key_request_type, std::string* server_url,
|
CdmKeyRequestType* key_request_type, std::string* server_url);
|
||||||
CdmKeySetId* key_set_id);
|
|
||||||
|
|
||||||
// AddKey() - Accept license response and extract key info.
|
// AddKey() - Accept license response and extract key info.
|
||||||
virtual CdmResponseType AddKey(const CdmKeyResponse& key_response,
|
virtual CdmResponseType AddKey(const CdmKeyResponse& key_response);
|
||||||
CdmKeySetId* key_set_id);
|
|
||||||
|
|
||||||
// Query session status
|
// Query session status
|
||||||
virtual CdmResponseType QueryStatus(CdmQueryMap* key_info);
|
virtual CdmResponseType QueryStatus(CdmQueryMap* key_info);
|
||||||
@@ -167,6 +184,9 @@ class CdmSession {
|
|||||||
// license type release and offline related information
|
// license type release and offline related information
|
||||||
CdmKeySetId key_set_id_;
|
CdmKeySetId key_set_id_;
|
||||||
|
|
||||||
|
bool mock_license_parser_in_use_;
|
||||||
|
bool mock_policy_engine_in_use_;
|
||||||
|
|
||||||
CORE_DISALLOW_COPY_AND_ASSIGN(CdmSession);
|
CORE_DISALLOW_COPY_AND_ASSIGN(CdmSession);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -149,9 +149,9 @@ enum CdmResponseType {
|
|||||||
RENEW_KEY_ERROR_1,
|
RENEW_KEY_ERROR_1,
|
||||||
RENEW_KEY_ERROR_2,
|
RENEW_KEY_ERROR_2,
|
||||||
LICENSE_RENEWAL_SIGNING_ERROR,
|
LICENSE_RENEWAL_SIGNING_ERROR,
|
||||||
RESTORE_OFFLINE_LICENSE_ERROR_1,
|
UNUSED_4, /* previously RESTORE_OFFLINE_LICENSE_ERROR_1 */
|
||||||
RESTORE_OFFLINE_LICENSE_ERROR_2,
|
RESTORE_OFFLINE_LICENSE_ERROR_2,
|
||||||
SESSION_INIT_ERROR_1,
|
UNUSED_5, /* SESSION_INIT_ERROR_1 */
|
||||||
SESSION_INIT_ERROR_2,
|
SESSION_INIT_ERROR_2,
|
||||||
SESSION_INIT_GET_KEYBOX_ERROR,
|
SESSION_INIT_GET_KEYBOX_ERROR,
|
||||||
SESSION_NOT_FOUND_1,
|
SESSION_NOT_FOUND_1,
|
||||||
@@ -169,7 +169,7 @@ enum CdmResponseType {
|
|||||||
SIGNATURE_NOT_FOUND,
|
SIGNATURE_NOT_FOUND,
|
||||||
STORE_LICENSE_ERROR_1,
|
STORE_LICENSE_ERROR_1,
|
||||||
STORE_LICENSE_ERROR_2,
|
STORE_LICENSE_ERROR_2,
|
||||||
STORE_LICENSE_ERROR_3,
|
UNUSED_6, /* previously STORE_LICENSE_ERROR_3 */
|
||||||
STORE_USAGE_INFO_ERROR,
|
STORE_USAGE_INFO_ERROR,
|
||||||
UNPROVISION_ERROR_1,
|
UNPROVISION_ERROR_1,
|
||||||
UNPROVISION_ERROR_2,
|
UNPROVISION_ERROR_2,
|
||||||
@@ -213,6 +213,7 @@ enum CdmResponseType {
|
|||||||
SESSION_NOT_FOUND_11,
|
SESSION_NOT_FOUND_11,
|
||||||
LOAD_USAGE_INFO_FILE_ERROR,
|
LOAD_USAGE_INFO_FILE_ERROR,
|
||||||
LOAD_USAGE_INFO_MISSING,
|
LOAD_USAGE_INFO_MISSING,
|
||||||
|
SESSION_FILE_HANDLE_INIT_ERROR,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CdmKeyStatus {
|
enum CdmKeyStatus {
|
||||||
|
|||||||
@@ -77,6 +77,24 @@ CdmEngine::~CdmEngine() {
|
|||||||
sessions_.clear();
|
sessions_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system,
|
||||||
|
CdmClientPropertySet* property_set,
|
||||||
|
const std::string& origin,
|
||||||
|
const CdmSessionId& forced_session_id,
|
||||||
|
WvCdmEventListener* event_listener) {
|
||||||
|
return OpenSession(key_system, property_set, origin, event_listener,
|
||||||
|
&forced_session_id, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system,
|
||||||
|
CdmClientPropertySet* property_set,
|
||||||
|
const std::string& origin,
|
||||||
|
WvCdmEventListener* event_listener,
|
||||||
|
CdmSessionId* session_id) {
|
||||||
|
return OpenSession(key_system, property_set, origin, event_listener,
|
||||||
|
NULL, session_id);
|
||||||
|
}
|
||||||
|
|
||||||
CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system,
|
CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system,
|
||||||
CdmClientPropertySet* property_set,
|
CdmClientPropertySet* property_set,
|
||||||
const std::string& origin,
|
const std::string& origin,
|
||||||
@@ -90,8 +108,8 @@ CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system,
|
|||||||
return INVALID_KEY_SYSTEM;
|
return INVALID_KEY_SYSTEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!session_id) {
|
if (!session_id && !forced_session_id) {
|
||||||
LOGE("CdmEngine::OpenSession: no session ID destination provided");
|
LOGE("CdmEngine::OpenSession: no (forced/)session ID destination provided");
|
||||||
return INVALID_PARAMETERS_ENG_1;
|
return INVALID_PARAMETERS_ENG_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,14 +119,9 @@ CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_ptr<CdmSession> new_session(
|
scoped_ptr<CdmSession> new_session(new CdmSession(origin));
|
||||||
new CdmSession(property_set, origin, event_listener, forced_session_id));
|
CdmResponseType sts = new_session->Init(property_set, forced_session_id,
|
||||||
if (new_session->session_id().empty()) {
|
event_listener);
|
||||||
LOGE("CdmEngine::OpenSession: failure to generate session ID");
|
|
||||||
return EMPTY_SESSION_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
CdmResponseType sts = new_session->Init();
|
|
||||||
if (sts != NO_ERROR) {
|
if (sts != NO_ERROR) {
|
||||||
if (sts == NEED_PROVISIONING) {
|
if (sts == NEED_PROVISIONING) {
|
||||||
cert_provisioning_requested_security_level_ =
|
cert_provisioning_requested_security_level_ =
|
||||||
@@ -118,9 +131,11 @@ CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system,
|
|||||||
}
|
}
|
||||||
return sts;
|
return sts;
|
||||||
}
|
}
|
||||||
*session_id = new_session->session_id();
|
CdmSessionId id = new_session->session_id();
|
||||||
|
|
||||||
AutoLock lock(session_list_lock_);
|
AutoLock lock(session_list_lock_);
|
||||||
sessions_[*session_id] = new_session.release();
|
sessions_[id] = new_session.release();
|
||||||
|
if (session_id) *session_id = id;
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,8 +198,7 @@ CdmResponseType CdmEngine::GenerateKeyRequest(
|
|||||||
const CdmSessionId& session_id, const CdmKeySetId& key_set_id,
|
const CdmSessionId& session_id, const CdmKeySetId& key_set_id,
|
||||||
const InitializationData& init_data, const CdmLicenseType license_type,
|
const InitializationData& init_data, const CdmLicenseType license_type,
|
||||||
CdmAppParameterMap& app_parameters, CdmKeyMessage* key_request,
|
CdmAppParameterMap& app_parameters, CdmKeyMessage* key_request,
|
||||||
CdmKeyRequestType* key_request_type, std::string* server_url,
|
CdmKeyRequestType* key_request_type, std::string* server_url) {
|
||||||
CdmKeySetId* key_set_id_out) {
|
|
||||||
LOGI("CdmEngine::GenerateKeyRequest");
|
LOGI("CdmEngine::GenerateKeyRequest");
|
||||||
|
|
||||||
CdmSessionId id = session_id;
|
CdmSessionId id = session_id;
|
||||||
@@ -241,7 +255,7 @@ CdmResponseType CdmEngine::GenerateKeyRequest(
|
|||||||
|
|
||||||
sts = iter->second->GenerateKeyRequest(
|
sts = iter->second->GenerateKeyRequest(
|
||||||
init_data, license_type, app_parameters, key_request, key_request_type,
|
init_data, license_type, app_parameters, key_request, key_request_type,
|
||||||
server_url, key_set_id_out);
|
server_url);
|
||||||
|
|
||||||
if (KEY_MESSAGE != sts) {
|
if (KEY_MESSAGE != sts) {
|
||||||
if (sts == NEED_PROVISIONING) {
|
if (sts == NEED_PROVISIONING) {
|
||||||
@@ -300,7 +314,8 @@ CdmResponseType CdmEngine::AddKey(const CdmSessionId& session_id,
|
|||||||
return EMPTY_KEY_DATA_1;
|
return EMPTY_KEY_DATA_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CdmResponseType sts = iter->second->AddKey(key_data, key_set_id);
|
CdmResponseType sts = iter->second->AddKey(key_data);
|
||||||
|
*key_set_id = iter->second->key_set_id();
|
||||||
|
|
||||||
switch (sts) {
|
switch (sts) {
|
||||||
case KEY_ADDED:
|
case KEY_ADDED:
|
||||||
@@ -734,9 +749,8 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
|||||||
}
|
}
|
||||||
usage_property_set_->set_security_level(kLevelDefault);
|
usage_property_set_->set_security_level(kLevelDefault);
|
||||||
usage_property_set_->set_app_id(app_id);
|
usage_property_set_->set_app_id(app_id);
|
||||||
usage_session_.reset(
|
usage_session_.reset(new CdmSession(EMPTY_ORIGIN));
|
||||||
new CdmSession(usage_property_set_.get(), EMPTY_ORIGIN, NULL, NULL));
|
CdmResponseType status = usage_session_->Init(usage_property_set_.get());
|
||||||
CdmResponseType status = usage_session_->Init();
|
|
||||||
if (NO_ERROR != status) {
|
if (NO_ERROR != status) {
|
||||||
LOGE("CdmEngine::GetUsageInfo: session init error");
|
LOGE("CdmEngine::GetUsageInfo: session init error");
|
||||||
return status;
|
return status;
|
||||||
@@ -753,9 +767,8 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
|||||||
&license_response)) {
|
&license_response)) {
|
||||||
usage_property_set_->set_security_level(kLevel3);
|
usage_property_set_->set_security_level(kLevel3);
|
||||||
usage_property_set_->set_app_id(app_id);
|
usage_property_set_->set_app_id(app_id);
|
||||||
usage_session_.reset(
|
usage_session_.reset(new CdmSession(EMPTY_ORIGIN));
|
||||||
new CdmSession(usage_property_set_.get(), EMPTY_ORIGIN, NULL, NULL));
|
status = usage_session_->Init(usage_property_set_.get());
|
||||||
status = usage_session_->Init();
|
|
||||||
if (NO_ERROR != status) {
|
if (NO_ERROR != status) {
|
||||||
LOGE("CdmEngine::GetUsageInfo: session init error");
|
LOGE("CdmEngine::GetUsageInfo: session init error");
|
||||||
return status;
|
return status;
|
||||||
@@ -822,10 +835,9 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
|||||||
usage_property_set_->set_security_level(requested_security_level);
|
usage_property_set_->set_security_level(requested_security_level);
|
||||||
usage_property_set_->set_app_id(app_id);
|
usage_property_set_->set_app_id(app_id);
|
||||||
|
|
||||||
usage_session_.reset(
|
usage_session_.reset(new CdmSession(EMPTY_ORIGIN));
|
||||||
new CdmSession(usage_property_set_.get(), EMPTY_ORIGIN, NULL, NULL));
|
|
||||||
|
|
||||||
CdmResponseType status = usage_session_->Init();
|
CdmResponseType status = usage_session_->Init(usage_property_set_.get());
|
||||||
if (NO_ERROR != status) {
|
if (NO_ERROR != status) {
|
||||||
LOGE("CdmEngine::GetUsageInfo: session init error");
|
LOGE("CdmEngine::GetUsageInfo: session init error");
|
||||||
return status;
|
return status;
|
||||||
@@ -901,9 +913,8 @@ CdmResponseType CdmEngine::ReleaseAllUsageInfo(const std::string& app_id) {
|
|||||||
? kLevel3
|
? kLevel3
|
||||||
: kLevelDefault;
|
: kLevelDefault;
|
||||||
usage_property_set_->set_security_level(security_level);
|
usage_property_set_->set_security_level(security_level);
|
||||||
usage_session_.reset(
|
usage_session_.reset(new CdmSession(EMPTY_ORIGIN));
|
||||||
new CdmSession(usage_property_set_.get(),
|
usage_session_->Init(usage_property_set_.get());
|
||||||
EMPTY_ORIGIN, NULL, NULL));
|
|
||||||
CdmResponseType status2 = usage_session_->
|
CdmResponseType status2 = usage_session_->
|
||||||
DeleteMultipleUsageInformation(provider_session_tokens);
|
DeleteMultipleUsageInformation(provider_session_tokens);
|
||||||
if (status2 != NO_ERROR) {
|
if (status2 != NO_ERROR) {
|
||||||
|
|||||||
@@ -25,48 +25,6 @@ const size_t kKeySetIdLength = 14;
|
|||||||
|
|
||||||
namespace wvcdm {
|
namespace wvcdm {
|
||||||
|
|
||||||
CdmSession::CdmSession(CdmClientPropertySet* cdm_client_property_set,
|
|
||||||
const std::string& origin,
|
|
||||||
WvCdmEventListener* event_listener,
|
|
||||||
const CdmSessionId* forced_session_id)
|
|
||||||
: initialized_(false),
|
|
||||||
session_id_(GenerateSessionId()),
|
|
||||||
origin_(origin),
|
|
||||||
crypto_session_(new CryptoSession),
|
|
||||||
file_handle_(new DeviceFiles),
|
|
||||||
license_received_(false),
|
|
||||||
is_offline_(false),
|
|
||||||
is_release_(false),
|
|
||||||
is_temporary_(false),
|
|
||||||
security_level_(kSecurityLevelUninitialized),
|
|
||||||
requested_security_level_(kLevelDefault),
|
|
||||||
is_initial_decryption_(true),
|
|
||||||
has_decrypted_since_last_report_(false),
|
|
||||||
is_initial_usage_update_(true),
|
|
||||||
is_usage_update_needed_(false) {
|
|
||||||
if (Properties::AlwaysUseKeySetIds()) {
|
|
||||||
if (forced_session_id) {
|
|
||||||
key_set_id_ = *forced_session_id;
|
|
||||||
} else {
|
|
||||||
bool ok = GenerateKeySetId(&key_set_id_);
|
|
||||||
(void)ok; // ok is now used when assertions are turned off.
|
|
||||||
assert(ok);
|
|
||||||
}
|
|
||||||
session_id_ = key_set_id_;
|
|
||||||
}
|
|
||||||
license_parser_.reset(new CdmLicense(session_id_));
|
|
||||||
policy_engine_.reset(new PolicyEngine(
|
|
||||||
session_id_, event_listener, crypto_session_.get()));
|
|
||||||
if (cdm_client_property_set) {
|
|
||||||
if (cdm_client_property_set->security_level() ==
|
|
||||||
QUERY_VALUE_SECURITY_LEVEL_L3) {
|
|
||||||
requested_security_level_ = kLevel3;
|
|
||||||
security_level_ = kSecurityLevelL3;
|
|
||||||
}
|
|
||||||
Properties::AddSessionPropertySet(session_id_, cdm_client_property_set);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CdmSession::~CdmSession() {
|
CdmSession::~CdmSession() {
|
||||||
if (!key_set_id_.empty()) {
|
if (!key_set_id_.empty()) {
|
||||||
// Unreserve the license ID.
|
// Unreserve the license ID.
|
||||||
@@ -75,24 +33,37 @@ CdmSession::~CdmSession() {
|
|||||||
Properties::RemoveSessionPropertySet(session_id_);
|
Properties::RemoveSessionPropertySet(session_id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
CdmResponseType CdmSession::Init() {
|
CdmResponseType CdmSession::Init(
|
||||||
if (session_id_.empty()) {
|
CdmClientPropertySet* cdm_client_property_set) {
|
||||||
LOGE("CdmSession::Init: Failed, session not properly constructed");
|
return Init(cdm_client_property_set, NULL, NULL);
|
||||||
return SESSION_INIT_ERROR_1;
|
}
|
||||||
}
|
|
||||||
|
CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
|
||||||
|
const CdmSessionId* forced_session_id,
|
||||||
|
WvCdmEventListener* event_listener) {
|
||||||
if (initialized_) {
|
if (initialized_) {
|
||||||
LOGE("CdmSession::Init: Failed due to previous initialization");
|
LOGE("CdmSession::Init: Failed due to previous initialization");
|
||||||
return SESSION_INIT_ERROR_2;
|
return SESSION_INIT_ERROR_2;
|
||||||
}
|
}
|
||||||
|
if (cdm_client_property_set &&
|
||||||
|
cdm_client_property_set->security_level() ==
|
||||||
|
QUERY_VALUE_SECURITY_LEVEL_L3) {
|
||||||
|
requested_security_level_ = kLevel3;
|
||||||
|
security_level_ = kSecurityLevelL3;
|
||||||
|
}
|
||||||
CdmResponseType sts = crypto_session_->Open(requested_security_level_);
|
CdmResponseType sts = crypto_session_->Open(requested_security_level_);
|
||||||
if (NO_ERROR != sts) return sts;
|
if (NO_ERROR != sts) return sts;
|
||||||
security_level_ = crypto_session_->GetSecurityLevel();
|
security_level_ = crypto_session_->GetSecurityLevel();
|
||||||
|
|
||||||
|
if (!file_handle_->Init(security_level_)) {
|
||||||
|
LOGE("CdmSession::Init: Unable to initialize file handle");
|
||||||
|
return SESSION_FILE_HANDLE_INIT_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
std::string token;
|
std::string token;
|
||||||
if (Properties::use_certificates_as_identification()) {
|
if (Properties::use_certificates_as_identification()) {
|
||||||
std::string wrapped_key;
|
std::string wrapped_key;
|
||||||
if (!file_handle_->Init(security_level_) ||
|
if (!file_handle_->RetrieveCertificate(origin_, &token, &wrapped_key) ||
|
||||||
!file_handle_->RetrieveCertificate(origin_, &token, &wrapped_key) ||
|
|
||||||
!crypto_session_->LoadCertificatePrivateKey(wrapped_key)) {
|
!crypto_session_->LoadCertificatePrivateKey(wrapped_key)) {
|
||||||
return NEED_PROVISIONING;
|
return NEED_PROVISIONING;
|
||||||
}
|
}
|
||||||
@@ -101,6 +72,30 @@ CdmResponseType CdmSession::Init() {
|
|||||||
return SESSION_INIT_GET_KEYBOX_ERROR;
|
return SESSION_INIT_GET_KEYBOX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (forced_session_id) {
|
||||||
|
key_set_id_ = *forced_session_id;
|
||||||
|
} else {
|
||||||
|
bool ok = GenerateKeySetId(&key_set_id_);
|
||||||
|
(void)ok; // ok is now used when assertions are turned off.
|
||||||
|
assert(ok);
|
||||||
|
}
|
||||||
|
|
||||||
|
session_id_ =
|
||||||
|
Properties::AlwaysUseKeySetIds() ? key_set_id_ : GenerateSessionId();
|
||||||
|
|
||||||
|
if (session_id_.empty()) {
|
||||||
|
LOGE("CdmSession::Init: empty session ID");
|
||||||
|
return EMPTY_SESSION_ID;
|
||||||
|
}
|
||||||
|
if (cdm_client_property_set)
|
||||||
|
Properties::AddSessionPropertySet(session_id_, cdm_client_property_set);
|
||||||
|
|
||||||
|
if (!mock_license_parser_in_use_)
|
||||||
|
license_parser_.reset(new CdmLicense(session_id_));
|
||||||
|
if (!mock_policy_engine_in_use_)
|
||||||
|
policy_engine_.reset(new PolicyEngine(
|
||||||
|
session_id_, event_listener, crypto_session_.get()));
|
||||||
|
|
||||||
if (!license_parser_->Init(token, crypto_session_.get(),
|
if (!license_parser_->Init(token, crypto_session_.get(),
|
||||||
policy_engine_.get()))
|
policy_engine_.get()))
|
||||||
return LICENSE_PARSER_INIT_ERROR;
|
return LICENSE_PARSER_INIT_ERROR;
|
||||||
@@ -115,10 +110,6 @@ CdmResponseType CdmSession::RestoreOfflineSession(
|
|||||||
const CdmKeySetId& key_set_id, const CdmLicenseType license_type) {
|
const CdmKeySetId& key_set_id, const CdmLicenseType license_type) {
|
||||||
key_set_id_ = key_set_id;
|
key_set_id_ = key_set_id;
|
||||||
|
|
||||||
// Retrieve license information from persistent store
|
|
||||||
if (!file_handle_->Reset(security_level_))
|
|
||||||
return RESTORE_OFFLINE_LICENSE_ERROR_1;
|
|
||||||
|
|
||||||
DeviceFiles::LicenseState license_state;
|
DeviceFiles::LicenseState license_state;
|
||||||
int64_t playback_start_time;
|
int64_t playback_start_time;
|
||||||
int64_t last_playback_time;
|
int64_t last_playback_time;
|
||||||
@@ -178,8 +169,7 @@ CdmResponseType CdmSession::RestoreUsageSession(
|
|||||||
CdmResponseType CdmSession::GenerateKeyRequest(
|
CdmResponseType CdmSession::GenerateKeyRequest(
|
||||||
const InitializationData& init_data, CdmLicenseType license_type,
|
const InitializationData& init_data, CdmLicenseType license_type,
|
||||||
const CdmAppParameterMap& app_parameters, CdmKeyMessage* key_request,
|
const CdmAppParameterMap& app_parameters, CdmKeyMessage* key_request,
|
||||||
CdmKeyRequestType* key_request_type, std::string* server_url,
|
CdmKeyRequestType* key_request_type, std::string* server_url) {
|
||||||
CdmKeySetId* key_set_id) {
|
|
||||||
if (crypto_session_.get() == NULL) {
|
if (crypto_session_.get() == NULL) {
|
||||||
LOGW("CdmSession::GenerateKeyRequest: Invalid crypto session");
|
LOGW("CdmSession::GenerateKeyRequest: Invalid crypto session");
|
||||||
return INVALID_CRYPTO_SESSION_1;
|
return INVALID_CRYPTO_SESSION_1;
|
||||||
@@ -248,8 +238,7 @@ CdmResponseType CdmSession::GenerateKeyRequest(
|
|||||||
return INIT_DATA_NOT_FOUND;
|
return INIT_DATA_NOT_FOUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_offline_ && key_set_id_.empty() &&
|
if (is_offline_ && key_set_id_.empty()) {
|
||||||
!GenerateKeySetId(&key_set_id_)) {
|
|
||||||
LOGE("CdmSession::GenerateKeyRequest: Unable to generate key set ID");
|
LOGE("CdmSession::GenerateKeyRequest: Unable to generate key set ID");
|
||||||
return KEY_REQUEST_ERROR_1;
|
return KEY_REQUEST_ERROR_1;
|
||||||
}
|
}
|
||||||
@@ -267,14 +256,12 @@ CdmResponseType CdmSession::GenerateKeyRequest(
|
|||||||
offline_release_server_url_ = *server_url;
|
offline_release_server_url_ = *server_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key_set_id) *key_set_id = key_set_id_;
|
|
||||||
return KEY_MESSAGE;
|
return KEY_MESSAGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddKey() - Accept license response and extract key info.
|
// AddKey() - Accept license response and extract key info.
|
||||||
CdmResponseType CdmSession::AddKey(const CdmKeyResponse& key_response,
|
CdmResponseType CdmSession::AddKey(const CdmKeyResponse& key_response) {
|
||||||
CdmKeySetId* key_set_id) {
|
|
||||||
if (crypto_session_.get() == NULL) {
|
if (crypto_session_.get() == NULL) {
|
||||||
LOGW("CdmSession::AddKey: Invalid crypto session");
|
LOGW("CdmSession::AddKey: Invalid crypto session");
|
||||||
return INVALID_CRYPTO_SESSION_2;
|
return INVALID_CRYPTO_SESSION_2;
|
||||||
@@ -303,7 +290,6 @@ CdmResponseType CdmSession::AddKey(const CdmKeyResponse& key_response,
|
|||||||
if (sts != NO_ERROR) return sts;
|
if (sts != NO_ERROR) return sts;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key_set_id) *key_set_id = key_set_id_;
|
|
||||||
return KEY_ADDED;
|
return KEY_ADDED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -477,8 +463,6 @@ bool CdmSession::GenerateKeySetId(CdmKeySetId* key_set_id) {
|
|||||||
std::vector<uint8_t> random_data(
|
std::vector<uint8_t> random_data(
|
||||||
(kKeySetIdLength - sizeof(KEY_SET_ID_PREFIX)) / 2, 0);
|
(kKeySetIdLength - sizeof(KEY_SET_ID_PREFIX)) / 2, 0);
|
||||||
|
|
||||||
if (!file_handle_->Reset(security_level_)) return false;
|
|
||||||
|
|
||||||
while (key_set_id->empty()) {
|
while (key_set_id->empty()) {
|
||||||
if (!crypto_session_->GetRandom(random_data.size(), &random_data[0]))
|
if (!crypto_session_->GetRandom(random_data.size(), &random_data[0]))
|
||||||
return false;
|
return false;
|
||||||
@@ -514,13 +498,6 @@ CdmResponseType CdmSession::StoreLicense() {
|
|||||||
|
|
||||||
if (!StoreLicense(DeviceFiles::kLicenseStateActive)) {
|
if (!StoreLicense(DeviceFiles::kLicenseStateActive)) {
|
||||||
LOGE("CdmSession::StoreLicense: Unable to store license");
|
LOGE("CdmSession::StoreLicense: Unable to store license");
|
||||||
CdmResponseType sts = Init();
|
|
||||||
if (sts != NO_ERROR) {
|
|
||||||
LOGW("CdmSession::StoreLicense: Reinitialization failed");
|
|
||||||
return sts;
|
|
||||||
}
|
|
||||||
|
|
||||||
key_set_id_.clear();
|
|
||||||
return STORE_LICENSE_ERROR_1;
|
return STORE_LICENSE_ERROR_1;
|
||||||
}
|
}
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
@@ -533,11 +510,6 @@ CdmResponseType CdmSession::StoreLicense() {
|
|||||||
return STORE_LICENSE_ERROR_2;
|
return STORE_LICENSE_ERROR_2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_handle_->Reset(security_level_)) {
|
|
||||||
LOGE("CdmSession::StoreLicense: Unable to initialize device files");
|
|
||||||
return STORE_LICENSE_ERROR_3;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string app_id;
|
std::string app_id;
|
||||||
GetApplicationId(&app_id);
|
GetApplicationId(&app_id);
|
||||||
if (!file_handle_->StoreUsageInfo(provider_session_token, key_request_,
|
if (!file_handle_->StoreUsageInfo(provider_session_token, key_request_,
|
||||||
@@ -549,8 +521,6 @@ CdmResponseType CdmSession::StoreLicense() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CdmSession::StoreLicense(DeviceFiles::LicenseState state) {
|
bool CdmSession::StoreLicense(DeviceFiles::LicenseState state) {
|
||||||
if (!file_handle_->Reset(security_level_)) return false;
|
|
||||||
|
|
||||||
return file_handle_->StoreLicense(
|
return file_handle_->StoreLicense(
|
||||||
key_set_id_, state, offline_init_data_, key_request_, key_response_,
|
key_set_id_, state, offline_init_data_, key_request_, key_response_,
|
||||||
offline_key_renewal_request_, offline_key_renewal_response_,
|
offline_key_renewal_request_, offline_key_renewal_response_,
|
||||||
@@ -562,10 +532,6 @@ bool CdmSession::DeleteLicense() {
|
|||||||
if (!is_offline_ && license_parser_->provider_session_token().empty())
|
if (!is_offline_ && license_parser_->provider_session_token().empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!file_handle_->Reset(security_level_)) {
|
|
||||||
LOGE("CdmSession::DeleteLicense: Unable to initialize device files");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (is_offline_) {
|
if (is_offline_) {
|
||||||
return file_handle_->DeleteLicense(key_set_id_);
|
return file_handle_->DeleteLicense(key_set_id_);
|
||||||
} else {
|
} else {
|
||||||
@@ -620,6 +586,7 @@ CdmResponseType CdmSession::ReleaseCrypto() {
|
|||||||
|
|
||||||
void CdmSession::set_license_parser(CdmLicense* license_parser) {
|
void CdmSession::set_license_parser(CdmLicense* license_parser) {
|
||||||
license_parser_.reset(license_parser);
|
license_parser_.reset(license_parser);
|
||||||
|
mock_license_parser_in_use_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdmSession::set_crypto_session(CryptoSession* crypto_session) {
|
void CdmSession::set_crypto_session(CryptoSession* crypto_session) {
|
||||||
@@ -628,6 +595,7 @@ void CdmSession::set_crypto_session(CryptoSession* crypto_session) {
|
|||||||
|
|
||||||
void CdmSession::set_policy_engine(PolicyEngine* policy_engine) {
|
void CdmSession::set_policy_engine(PolicyEngine* policy_engine) {
|
||||||
policy_engine_.reset(policy_engine);
|
policy_engine_.reset(policy_engine);
|
||||||
|
mock_policy_engine_in_use_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdmSession::set_file_handle(DeviceFiles* file_handle) {
|
void CdmSession::set_file_handle(DeviceFiles* file_handle) {
|
||||||
|
|||||||
@@ -60,11 +60,10 @@ class WvCdmEngineTest : public testing::Test {
|
|||||||
virtual void SetUp() {
|
virtual void SetUp() {
|
||||||
CdmResponseType status =
|
CdmResponseType status =
|
||||||
cdm_engine_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL,
|
cdm_engine_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL,
|
||||||
NULL /* forced_session_id */, &session_id_);
|
&session_id_);
|
||||||
if (status == NEED_PROVISIONING) {
|
if (status == NEED_PROVISIONING) {
|
||||||
Provision();
|
Provision();
|
||||||
status = cdm_engine_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL,
|
status = cdm_engine_.OpenSession(g_key_system, NULL, EMPTY_ORIGIN, NULL,
|
||||||
NULL /* forced_session_id */,
|
|
||||||
&session_id_);
|
&session_id_);
|
||||||
}
|
}
|
||||||
ASSERT_EQ(NO_ERROR, status);
|
ASSERT_EQ(NO_ERROR, status);
|
||||||
@@ -106,7 +105,7 @@ class WvCdmEngineTest : public testing::Test {
|
|||||||
EXPECT_EQ(KEY_MESSAGE, cdm_engine_.GenerateKeyRequest(
|
EXPECT_EQ(KEY_MESSAGE, cdm_engine_.GenerateKeyRequest(
|
||||||
session_id_, key_set_id, init_data,
|
session_id_, key_set_id, init_data,
|
||||||
kLicenseTypeStreaming, app_parameters, &key_msg_,
|
kLicenseTypeStreaming, app_parameters, &key_msg_,
|
||||||
&key_request_type, &server_url, NULL));
|
&key_request_type, &server_url));
|
||||||
EXPECT_EQ(kKeyRequestTypeInitial, key_request_type);
|
EXPECT_EQ(kKeyRequestTypeInitial, key_request_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ using ::testing::StrEq;
|
|||||||
class CdmSessionTest : public ::testing::Test {
|
class CdmSessionTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
virtual void SetUp() {
|
virtual void SetUp() {
|
||||||
cdm_session_.reset(new CdmSession(NULL, kTestOrigin, NULL, NULL));
|
cdm_session_.reset(new CdmSession(kTestOrigin));
|
||||||
// Inject testing mocks.
|
// Inject testing mocks.
|
||||||
license_parser_ = new MockCdmLicense(cdm_session_->session_id());
|
license_parser_ = new MockCdmLicense(cdm_session_->session_id());
|
||||||
cdm_session_->set_license_parser(license_parser_);
|
cdm_session_->set_license_parser(license_parser_);
|
||||||
@@ -178,7 +178,7 @@ TEST_F(CdmSessionTest, InitWithCertificate) {
|
|||||||
|
|
||||||
Properties::set_use_certificates_as_identification(true);
|
Properties::set_use_certificates_as_identification(true);
|
||||||
|
|
||||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init());
|
ASSERT_EQ(NO_ERROR, cdm_session_->Init(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CdmSessionTest, InitWithKeybox) {
|
TEST_F(CdmSessionTest, InitWithKeybox) {
|
||||||
@@ -193,13 +193,14 @@ TEST_F(CdmSessionTest, InitWithKeybox) {
|
|||||||
EXPECT_CALL(*crypto_session_, GetToken(NotNull()))
|
EXPECT_CALL(*crypto_session_, GetToken(NotNull()))
|
||||||
.InSequence(crypto_session_seq)
|
.InSequence(crypto_session_seq)
|
||||||
.WillOnce(DoAll(SetArgPointee<0>(kToken), Return(true)));
|
.WillOnce(DoAll(SetArgPointee<0>(kToken), Return(true)));
|
||||||
|
EXPECT_CALL(*file_handle_, Init(Eq(level))).WillOnce(Return(true));
|
||||||
EXPECT_CALL(*license_parser_,
|
EXPECT_CALL(*license_parser_,
|
||||||
Init(Eq(kToken), Eq(crypto_session_), Eq(policy_engine_)))
|
Init(Eq(kToken), Eq(crypto_session_), Eq(policy_engine_)))
|
||||||
.WillOnce(Return(true));
|
.WillOnce(Return(true));
|
||||||
|
|
||||||
Properties::set_use_certificates_as_identification(false);
|
Properties::set_use_certificates_as_identification(false);
|
||||||
|
|
||||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init());
|
ASSERT_EQ(NO_ERROR, cdm_session_->Init(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CdmSessionTest, ReInitFail) {
|
TEST_F(CdmSessionTest, ReInitFail) {
|
||||||
@@ -225,8 +226,8 @@ TEST_F(CdmSessionTest, ReInitFail) {
|
|||||||
|
|
||||||
Properties::set_use_certificates_as_identification(true);
|
Properties::set_use_certificates_as_identification(true);
|
||||||
|
|
||||||
ASSERT_EQ(NO_ERROR, cdm_session_->Init());
|
ASSERT_EQ(NO_ERROR, cdm_session_->Init(NULL));
|
||||||
ASSERT_NE(NO_ERROR, cdm_session_->Init());
|
ASSERT_NE(NO_ERROR, cdm_session_->Init(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CdmSessionTest, InitFailCryptoError) {
|
TEST_F(CdmSessionTest, InitFailCryptoError) {
|
||||||
@@ -235,7 +236,7 @@ TEST_F(CdmSessionTest, InitFailCryptoError) {
|
|||||||
|
|
||||||
Properties::set_use_certificates_as_identification(true);
|
Properties::set_use_certificates_as_identification(true);
|
||||||
|
|
||||||
ASSERT_EQ(UNKNOWN_ERROR, cdm_session_->Init());
|
ASSERT_EQ(UNKNOWN_ERROR, cdm_session_->Init(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CdmSessionTest, InitNeedsProvisioning) {
|
TEST_F(CdmSessionTest, InitNeedsProvisioning) {
|
||||||
@@ -254,7 +255,7 @@ TEST_F(CdmSessionTest, InitNeedsProvisioning) {
|
|||||||
|
|
||||||
Properties::set_use_certificates_as_identification(true);
|
Properties::set_use_certificates_as_identification(true);
|
||||||
|
|
||||||
ASSERT_EQ(NEED_PROVISIONING, cdm_session_->Init());
|
ASSERT_EQ(NEED_PROVISIONING, cdm_session_->Init(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace wvcdm
|
} // namespace wvcdm
|
||||||
|
|||||||
@@ -231,12 +231,8 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
|
|||||||
break;
|
break;
|
||||||
case LICENSE_RENEWAL_SIGNING_ERROR: *os << "LICENSE_RENEWAL_SIGNING_ERROR";
|
case LICENSE_RENEWAL_SIGNING_ERROR: *os << "LICENSE_RENEWAL_SIGNING_ERROR";
|
||||||
break;
|
break;
|
||||||
case RESTORE_OFFLINE_LICENSE_ERROR_1: *os << "RESTORE_OFFLINE_LICENSE_ERROR_1";
|
|
||||||
break;
|
|
||||||
case RESTORE_OFFLINE_LICENSE_ERROR_2: *os << "RESTORE_OFFLINE_LICENSE_ERROR_2";
|
case RESTORE_OFFLINE_LICENSE_ERROR_2: *os << "RESTORE_OFFLINE_LICENSE_ERROR_2";
|
||||||
break;
|
break;
|
||||||
case SESSION_INIT_ERROR_1: *os << "SESSION_INIT_ERROR_1";
|
|
||||||
break;
|
|
||||||
case SESSION_INIT_ERROR_2: *os << "SESSION_INIT_ERROR_2";
|
case SESSION_INIT_ERROR_2: *os << "SESSION_INIT_ERROR_2";
|
||||||
break;
|
break;
|
||||||
case SESSION_INIT_GET_KEYBOX_ERROR: *os << "SESSION_INIT_GET_KEYBOX_ERROR";
|
case SESSION_INIT_GET_KEYBOX_ERROR: *os << "SESSION_INIT_GET_KEYBOX_ERROR";
|
||||||
@@ -271,8 +267,6 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
|
|||||||
break;
|
break;
|
||||||
case STORE_LICENSE_ERROR_2: *os << "STORE_LICENSE_ERROR_2";
|
case STORE_LICENSE_ERROR_2: *os << "STORE_LICENSE_ERROR_2";
|
||||||
break;
|
break;
|
||||||
case STORE_LICENSE_ERROR_3: *os << "STORE_LICENSE_ERROR_3";
|
|
||||||
break;
|
|
||||||
case STORE_USAGE_INFO_ERROR: *os << "STORE_USAGE_INFO_ERROR";
|
case STORE_USAGE_INFO_ERROR: *os << "STORE_USAGE_INFO_ERROR";
|
||||||
break;
|
break;
|
||||||
case UNPROVISION_ERROR_1: *os << "UNPROVISION_ERROR_1";
|
case UNPROVISION_ERROR_1: *os << "UNPROVISION_ERROR_1";
|
||||||
@@ -339,6 +333,7 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
|
|||||||
break;
|
break;
|
||||||
case DUPLICATE_SESSION_ID_SPECIFIED: *os << "DUPLICATE_SESSION_ID_SPECIFIED";
|
case DUPLICATE_SESSION_ID_SPECIFIED: *os << "DUPLICATE_SESSION_ID_SPECIFIED";
|
||||||
case LICENSE_RENEWAL_PROHIBITED: *os << "LICENSE_RENEWAL_PROHIBITED";
|
case LICENSE_RENEWAL_PROHIBITED: *os << "LICENSE_RENEWAL_PROHIBITED";
|
||||||
|
case SESSION_FILE_HANDLE_INIT_ERROR: *os << "SESSION_FILE_HANDLE_INIT_ERROR";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
*os << "Unknown CdmResponseType";
|
*os << "Unknown CdmResponseType";
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ CdmResponseType WvContentDecryptionModule::OpenSession(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return cdm_engine_->OpenSession(key_system, property_set, origin,
|
return cdm_engine_->OpenSession(key_system, property_set, origin,
|
||||||
event_listener, NULL /* forced_session_id */,
|
event_listener, session_id);
|
||||||
session_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CdmResponseType WvContentDecryptionModule::CloseSession(
|
CdmResponseType WvContentDecryptionModule::CloseSession(
|
||||||
@@ -84,7 +83,7 @@ CdmResponseType WvContentDecryptionModule::GenerateKeyRequest(
|
|||||||
InitializationData initialization_data(init_data_type, init_data);
|
InitializationData initialization_data(init_data_type, init_data);
|
||||||
sts = cdm_engine_->GenerateKeyRequest(
|
sts = cdm_engine_->GenerateKeyRequest(
|
||||||
session_id, key_set_id, initialization_data, license_type, app_parameters,
|
session_id, key_set_id, initialization_data, license_type, app_parameters,
|
||||||
key_request, key_request_type, server_url, NULL);
|
key_request, key_request_type, server_url);
|
||||||
|
|
||||||
switch(license_type) {
|
switch(license_type) {
|
||||||
case kLicenseTypeRelease:
|
case kLicenseTypeRelease:
|
||||||
|
|||||||
@@ -183,7 +183,8 @@ enum {
|
|||||||
kSessionNotFound11 = ERROR_DRM_VENDOR_MIN + 169,
|
kSessionNotFound11 = ERROR_DRM_VENDOR_MIN + 169,
|
||||||
kLoadUsageInfoFileError = ERROR_DRM_VENDOR_MIN + 170,
|
kLoadUsageInfoFileError = ERROR_DRM_VENDOR_MIN + 170,
|
||||||
kLoadUsageInfoMissing = ERROR_DRM_VENDOR_MIN + 171,
|
kLoadUsageInfoMissing = ERROR_DRM_VENDOR_MIN + 171,
|
||||||
kErrorWVDrmMaxErrorUsed = ERROR_DRM_VENDOR_MIN + 171,
|
kSessionFileHandleInitError = ERROR_DRM_VENDOR_MIN + 172,
|
||||||
|
kErrorWVDrmMaxErrorUsed = ERROR_DRM_VENDOR_MIN + 172,
|
||||||
|
|
||||||
// Used by crypto test mode
|
// Used by crypto test mode
|
||||||
kErrorTestMode = ERROR_DRM_VENDOR_MAX,
|
kErrorTestMode = ERROR_DRM_VENDOR_MAX,
|
||||||
|
|||||||
@@ -233,12 +233,8 @@ static android::status_t mapCdmResponseType(wvcdm::CdmResponseType res) {
|
|||||||
return kRenewKeyError2;
|
return kRenewKeyError2;
|
||||||
case wvcdm::LICENSE_RENEWAL_SIGNING_ERROR:
|
case wvcdm::LICENSE_RENEWAL_SIGNING_ERROR:
|
||||||
return kLicenseRenewalSigningError;
|
return kLicenseRenewalSigningError;
|
||||||
case wvcdm::RESTORE_OFFLINE_LICENSE_ERROR_1:
|
|
||||||
return kRestoreOfflineLicenseError1;
|
|
||||||
case wvcdm::RESTORE_OFFLINE_LICENSE_ERROR_2:
|
case wvcdm::RESTORE_OFFLINE_LICENSE_ERROR_2:
|
||||||
return kRestoreOfflineLicenseError2;
|
return kRestoreOfflineLicenseError2;
|
||||||
case wvcdm::SESSION_INIT_ERROR_1:
|
|
||||||
return kSessionInitError1;
|
|
||||||
case wvcdm::SESSION_INIT_ERROR_2:
|
case wvcdm::SESSION_INIT_ERROR_2:
|
||||||
return kSessionInitError2;
|
return kSessionInitError2;
|
||||||
case wvcdm::SESSION_INIT_GET_KEYBOX_ERROR:
|
case wvcdm::SESSION_INIT_GET_KEYBOX_ERROR:
|
||||||
@@ -271,8 +267,6 @@ static android::status_t mapCdmResponseType(wvcdm::CdmResponseType res) {
|
|||||||
return kStoreLicenseError1;
|
return kStoreLicenseError1;
|
||||||
case wvcdm::STORE_LICENSE_ERROR_2:
|
case wvcdm::STORE_LICENSE_ERROR_2:
|
||||||
return kStoreLicenseError2;
|
return kStoreLicenseError2;
|
||||||
case wvcdm::STORE_LICENSE_ERROR_3:
|
|
||||||
return kStoreLicenseError3;
|
|
||||||
case wvcdm::STORE_USAGE_INFO_ERROR:
|
case wvcdm::STORE_USAGE_INFO_ERROR:
|
||||||
return kStoreUsageInfoError;
|
return kStoreUsageInfoError;
|
||||||
case wvcdm::UNPROVISION_ERROR_1:
|
case wvcdm::UNPROVISION_ERROR_1:
|
||||||
@@ -355,6 +349,8 @@ static android::status_t mapCdmResponseType(wvcdm::CdmResponseType res) {
|
|||||||
return kLoadUsageInfoFileError;
|
return kLoadUsageInfoFileError;
|
||||||
case wvcdm::LOAD_USAGE_INFO_MISSING:
|
case wvcdm::LOAD_USAGE_INFO_MISSING:
|
||||||
return kLoadUsageInfoMissing;
|
return kLoadUsageInfoMissing;
|
||||||
|
case wvcdm::SESSION_FILE_HANDLE_INIT_ERROR:
|
||||||
|
return kSessionFileHandleInitError;
|
||||||
case wvcdm::UNKNOWN_ERROR:
|
case wvcdm::UNKNOWN_ERROR:
|
||||||
return android::ERROR_DRM_UNKNOWN;
|
return android::ERROR_DRM_UNKNOWN;
|
||||||
case wvcdm::SECURE_BUFFER_REQUIRED:
|
case wvcdm::SECURE_BUFFER_REQUIRED:
|
||||||
@@ -362,6 +358,9 @@ static android::status_t mapCdmResponseType(wvcdm::CdmResponseType res) {
|
|||||||
case wvcdm::UNUSED_1:
|
case wvcdm::UNUSED_1:
|
||||||
case wvcdm::UNUSED_2:
|
case wvcdm::UNUSED_2:
|
||||||
case wvcdm::UNUSED_3:
|
case wvcdm::UNUSED_3:
|
||||||
|
case wvcdm::UNUSED_4:
|
||||||
|
case wvcdm::UNUSED_5:
|
||||||
|
case wvcdm::UNUSED_6:
|
||||||
return android::UNKNOWN_ERROR;
|
return android::UNKNOWN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user