Merge Tweaks Originating in Merge Review Comments

This merges several small changes that were made in response to
comments that arose when LMP changes were merged into the Widevine
repository's master branch.

Change-Id: Ifec968af54dbc3288f24654ec0c6ca9b5962e1aa
This commit is contained in:
John "Juce" Bruce
2015-03-10 15:22:11 -07:00
parent fb6d83398c
commit 1bd405fc40
11 changed files with 32 additions and 52 deletions

View File

@@ -40,9 +40,7 @@ class UsagePropertySet : public CdmClientPropertySet {
virtual const std::string& service_certificate() const { return empty_; }
virtual bool is_session_sharing_enabled() const { return false; }
virtual uint32_t session_sharing_id() const { return 0; }
virtual void set_session_sharing_id(uint32_t id) {
id; // noop to suppress warning
}
virtual void set_session_sharing_id(uint32_t /* id */) {}
virtual const std::string& app_id() const { return app_id_; }
void set_app_id(const std::string& appId) { app_id_ = appId; }

View File

@@ -72,7 +72,7 @@ void CdmSession::Create(CdmLicense* license_parser,
is_initial_usage_update_ = true;
is_usage_update_needed_ = false;
is_initial_decryption_ = true;
has_decrypted_recently_ = false;
has_decrypted_since_last_report_ = false;
if (cdm_client_property_set) {
Properties::AddSessionPropertySet(session_id_, cdm_client_property_set);
}
@@ -340,6 +340,8 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) {
if (crypto_session_.get() == NULL || !crypto_session_->IsOpen())
return UNKNOWN_ERROR;
// Playback may not begin until either the start time passes or the license
// is updated, so we treat this Decrypt call as invalid and return KEY_ERROR.
if (params.is_encrypted && !policy_engine_->CanDecrypt(*params.key_id)) {
return policy_engine_->IsLicenseForFuture() ? KEY_ERROR : NEED_KEY;
}
@@ -352,7 +354,7 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) {
policy_engine_->BeginDecryption();
is_initial_decryption_ = false;
}
has_decrypted_recently_ = true;
has_decrypted_since_last_report_ = true;
if (!is_usage_update_needed_) {
is_usage_update_needed_ =
!license_parser_->provider_session_token().empty();
@@ -368,9 +370,6 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) {
}
break;
}
default: { //Ignore
break;
}
}
return status;
@@ -557,9 +556,9 @@ void CdmSession::OnTimerEvent(bool update_usage) {
bool event_occurred = false;
CdmEventType event;
if (update_usage && has_decrypted_recently_) {
if (update_usage && has_decrypted_since_last_report_) {
policy_engine_->DecryptionEvent();
has_decrypted_recently_ = false;
has_decrypted_since_last_report_ = false;
if (is_offline_ && !is_release_) {
StoreLicense(DeviceFiles::kLicenseStateActive);
}

View File

@@ -14,12 +14,11 @@ const uint32_t kNoResolution = 0;
namespace wvcdm {
MaxResEngine::MaxResEngine(CryptoSession* crypto_session) : status_lock_() {
MaxResEngine::MaxResEngine(CryptoSession* crypto_session) {
Init(crypto_session, new Clock());
}
MaxResEngine::MaxResEngine(CryptoSession* crypto_session, Clock* clock)
: status_lock_() {
MaxResEngine::MaxResEngine(CryptoSession* crypto_session, Clock* clock) {
Init(crypto_session, clock);
}
@@ -51,8 +50,8 @@ void MaxResEngine::SetLicense(
const video_widevine_server::sdk::License& license) {
AutoLock lock(status_lock_);
DeleteAllKeys();
for (int32_t key_iter = 0; key_iter < license.key_size(); ++key_iter) {
const KeyContainer& key = license.key(key_iter);
for (int32_t key_index = 0; key_index < license.key_size(); ++key_index) {
const KeyContainer& key = license.key(key_index);
if (key.type() == KeyContainer::CONTENT && key.has_id() &&
key.video_resolution_constraints_size() > 0) {
const ConstraintList& constraints = key.video_resolution_constraints();
@@ -96,15 +95,14 @@ void MaxResEngine::DeleteAllKeys() {
}
MaxResEngine::KeyStatus::KeyStatus(const ConstraintList& constraints)
: default_hdcp_level_(NULL) {
: default_hdcp_level_(CryptoSession::kOemCryptoHdcpNotSupported) {
Init(constraints);
}
MaxResEngine::KeyStatus::KeyStatus(
const ConstraintList& constraints,
const OutputProtection::HDCP& default_hdcp_level) {
default_hdcp_level_.reset(new CryptoSession::OemCryptoHdcpVersion(
ProtobufHdcpToOemCryptoHdcp(default_hdcp_level)));
const OutputProtection::HDCP& default_hdcp_level)
: default_hdcp_level_(ProtobufHdcpToOemCryptoHdcp(default_hdcp_level)) {
Init(constraints);
}
@@ -127,14 +125,9 @@ void MaxResEngine::KeyStatus::Update(
if (current_constraint->has_required_protection()) {
desired_hdcp_level = ProtobufHdcpToOemCryptoHdcp(
current_constraint->required_protection().hdcp());
} else if (default_hdcp_level_.get() != NULL) {
desired_hdcp_level = *default_hdcp_level_;
} else {
// No constraint value and no default means there's nothing to enforce.
can_decrypt_ = true;
return;
desired_hdcp_level = default_hdcp_level_;
}
can_decrypt_ = (current_hdcp_level >= desired_hdcp_level);
}

View File

@@ -185,21 +185,4 @@ int64_t htonll64(int64_t x) { // Convert to big endian (network-byte-order)
}
}
int64_t ntohll64(int64_t x) { // Convert from big endian (network-byte-order)
union {
uint32_t array[2];
int64_t number;
} mixed;
mixed.number = 1;
if (mixed.array[0] == 1) { // Little Endian.
mixed.number = x;
uint32_t temp = mixed.array[0];
mixed.array[0] = ntohl(mixed.array[1]);
mixed.array[1] = ntohl(temp);
return mixed.number;
} else { // Big Endian.
return x;
}
}
} // namespace wvcdm