Changes from Widevine CDM repo
Squashed commit of these CLs from the widevine cdm repo: Update YT CP server URI to point to the UAT server https://widevine-internal-review.googlesource.com/#/c/9327/ OEMCrypto Version 9 API https://widevine-internal-review.googlesource.com/#/c/9142/ Correct Device ID length in OEMCrypto reference version https://widevine-internal-review.googlesource.com/#/c/8723/ Modify tests to prevent intermittent failures https://widevine-internal-review.googlesource.com/#/c/8982/ Generate a unique license request ID https://widevine-internal-review.googlesource.com/#/c/8721/ Re-enable android timer mechanisms https://widevine-internal-review.googlesource.com/#/c/8833/ Do not close CDM session on removeKeys https://widevine-internal-review.googlesource.com/#/c/8703/ And numerous changes required by Eureka, Steel, and CTE versions of Widevine CDM, as highlighted here: https://widevine-internal-review.googlesource.com/#/c/8596/ https://widevine-internal-review.googlesource.com/#/c/8955/ https://widevine-internal-review.googlesource.com/#/c/8922/ https://widevine-internal-review.googlesource.com/#/c/8890/ https://widevine-internal-review.googlesource.com/#/c/8871/ https://widevine-internal-review.googlesource.com/#/c/8706/ https://widevine-internal-review.googlesource.com/#/c/8425/ Change-Id: Iafd33905227e74eb2132c240b929d2282ab68042
This commit is contained in:
@@ -11,18 +11,27 @@
|
||||
#include "wv_cdm_constants.h"
|
||||
#include "wv_cdm_event_listener.h"
|
||||
|
||||
namespace {
|
||||
const int kCdmPolicyTimerDurationSeconds = 1;
|
||||
}
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
Lock WvContentDecryptionModule::session_sharing_id_generation_lock_;
|
||||
|
||||
WvContentDecryptionModule::WvContentDecryptionModule()
|
||||
: cdm_engine_(new CdmEngine()) {}
|
||||
|
||||
WvContentDecryptionModule::~WvContentDecryptionModule() {}
|
||||
WvContentDecryptionModule::~WvContentDecryptionModule() {
|
||||
DisablePolicyTimer(true);
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::OpenSession(
|
||||
const CdmKeySystem& key_system,
|
||||
CdmClientPropertySet* property_set,
|
||||
CdmSessionId* session_id) {
|
||||
if (property_set && property_set->is_session_sharing_enabled()) {
|
||||
AutoLock auto_lock(session_sharing_id_generation_lock_);
|
||||
if (property_set->session_sharing_id() == 0)
|
||||
property_set->set_session_sharing_id(GenerateSessionSharingId());
|
||||
}
|
||||
@@ -32,7 +41,9 @@ CdmResponseType WvContentDecryptionModule::OpenSession(
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::CloseSession(
|
||||
const CdmSessionId& session_id) {
|
||||
return cdm_engine_->CloseSession(session_id);
|
||||
CdmResponseType sts = cdm_engine_->CloseSession(session_id);
|
||||
DisablePolicyTimer(false);
|
||||
return sts;
|
||||
}
|
||||
|
||||
CdmResponseType WvContentDecryptionModule::GenerateKeyRequest(
|
||||
@@ -49,13 +60,19 @@ CdmResponseType WvContentDecryptionModule::GenerateKeyRequest(
|
||||
if (sts != NO_ERROR)
|
||||
return sts;
|
||||
}
|
||||
sts = cdm_engine_->GenerateKeyRequest(session_id, key_set_id,
|
||||
init_data, license_type,
|
||||
app_parameters, key_request,
|
||||
server_url);
|
||||
sts = cdm_engine_->GenerateKeyRequest(session_id, key_set_id, init_data,
|
||||
license_type, app_parameters,
|
||||
key_request, server_url);
|
||||
|
||||
if (license_type == kLicenseTypeRelease && sts != KEY_MESSAGE) {
|
||||
cdm_engine_->CloseKeySetSession(key_set_id);
|
||||
switch(license_type) {
|
||||
case kLicenseTypeRelease:
|
||||
if (sts != KEY_MESSAGE)
|
||||
cdm_engine_->CloseKeySetSession(key_set_id);
|
||||
break;
|
||||
default:
|
||||
if (sts == KEY_MESSAGE)
|
||||
EnablePolicyTimer();
|
||||
break;
|
||||
}
|
||||
return sts;
|
||||
}
|
||||
@@ -124,16 +141,17 @@ CdmResponseType WvContentDecryptionModule::Decrypt(
|
||||
const CdmSessionId& session_id,
|
||||
bool validate_key_id,
|
||||
const CdmDecryptionParameters& parameters) {
|
||||
CdmSessionId id = session_id;
|
||||
CdmSessionId local_session_id = session_id;
|
||||
if (validate_key_id &&
|
||||
Properties::GetSessionSharingId(session_id) != 0) {
|
||||
bool status = cdm_engine_->FindSessionForKey(*parameters.key_id, &id);
|
||||
bool status = cdm_engine_->FindSessionForKey(*parameters.key_id,
|
||||
&local_session_id);
|
||||
if (!status) {
|
||||
LOGE("WvContentDecryptionModule::Decrypt: unable to find session");
|
||||
return NEED_KEY;
|
||||
}
|
||||
}
|
||||
return cdm_engine_->Decrypt(id, parameters);
|
||||
return cdm_engine_->Decrypt(local_session_id, parameters);
|
||||
}
|
||||
|
||||
bool WvContentDecryptionModule::AttachEventListener(
|
||||
@@ -146,9 +164,25 @@ bool WvContentDecryptionModule::DetachEventListener(
|
||||
return cdm_engine_->DetachEventListener(session_id, listener);
|
||||
}
|
||||
|
||||
void WvContentDecryptionModule::EnablePolicyTimer() {
|
||||
if (!policy_timer_.IsRunning())
|
||||
policy_timer_.Start(this, kCdmPolicyTimerDurationSeconds);
|
||||
}
|
||||
|
||||
void WvContentDecryptionModule::DisablePolicyTimer(bool force) {
|
||||
if ((cdm_engine_->SessionSize() == 0 || force) && policy_timer_.IsRunning())
|
||||
policy_timer_.Stop();
|
||||
}
|
||||
|
||||
void WvContentDecryptionModule::OnTimerEvent() {
|
||||
cdm_engine_->OnTimerEvent();
|
||||
}
|
||||
|
||||
uint32_t WvContentDecryptionModule::GenerateSessionSharingId() {
|
||||
static int next_session_sharing_id = 0;
|
||||
return ++next_session_sharing_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
Reference in New Issue
Block a user