diff --git a/libwvdrmengine/cdm/core/include/policy_engine.h b/libwvdrmengine/cdm/core/include/policy_engine.h index 1d793fe6..fe8b4489 100644 --- a/libwvdrmengine/cdm/core/include/policy_engine.h +++ b/libwvdrmengine/cdm/core/include/policy_engine.h @@ -84,9 +84,9 @@ class PolicyEngine { int64_t last_playback_time); bool IsLicenseForFuture() { return license_state_ == kLicenseStatePending; } - bool IsPlaybackStarted() { return playback_start_time_ > 0; } + bool HasPlaybackStarted() { return playback_start_time_ > 0; } - bool IsLicenseOrPlaybackDurationExpired(int64_t current_time); + bool HasLicenseOrPlaybackDurationExpired(int64_t current_time); int64_t GetLicenseOrPlaybackDurationRemaining(); bool CanRenew() { return policy_.can_renew(); } @@ -124,9 +124,9 @@ class PolicyEngine { int64_t GetLicenseOrRentalDurationRemaining(int64_t current_time); int64_t GetPlaybackDurationRemaining(int64_t current_time); - bool IsRenewalDelayExpired(int64_t current_time); - bool IsRenewalRecoveryDurationExpired(int64_t current_time); - bool IsRenewalRetryIntervalExpired(int64_t current_time); + bool HasRenewalDelayExpired(int64_t current_time); + bool HasRenewalRecoveryDurationExpired(int64_t current_time); + bool HasRenewalRetryIntervalExpired(int64_t current_time); void UpdateRenewalRequest(int64_t current_time); diff --git a/libwvdrmengine/cdm/core/src/cdm_session.cpp b/libwvdrmengine/cdm/core/src/cdm_session.cpp index 6d3b8b80..744f8630 100644 --- a/libwvdrmengine/cdm/core/src/cdm_session.cpp +++ b/libwvdrmengine/cdm/core/src/cdm_session.cpp @@ -412,7 +412,7 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) { } else { Clock clock; int64_t current_time = clock.GetCurrentTime(); - if (policy_engine_->IsLicenseOrPlaybackDurationExpired(current_time)) { + if (policy_engine_->HasLicenseOrPlaybackDurationExpired(current_time)) { return NEED_KEY; } } diff --git a/libwvdrmengine/cdm/core/src/policy_engine.cpp b/libwvdrmengine/cdm/core/src/policy_engine.cpp index 8bb6289a..65b37750 100644 --- a/libwvdrmengine/cdm/core/src/policy_engine.cpp +++ b/libwvdrmengine/cdm/core/src/policy_engine.cpp @@ -78,7 +78,7 @@ void PolicyEngine::OnTimerEvent() { int64_t current_time = clock_->GetCurrentTime(); // License expiration trumps all. - if (IsLicenseOrPlaybackDurationExpired(current_time) && + if (HasLicenseOrPlaybackDurationExpired(current_time) && license_state_ != kLicenseStateExpired) { license_state_ = kLicenseStateExpired; NotifyKeysChange(kKeyStatusExpired); @@ -93,7 +93,7 @@ void PolicyEngine::OnTimerEvent() { // Test to determine if renewal should be attempted. switch (license_state_) { case kLicenseStateCanPlay: { - if (IsRenewalDelayExpired(current_time)) renewal_needed = true; + if (HasRenewalDelayExpired(current_time)) renewal_needed = true; // HDCP may change, so force a check. NotifyKeysChange(kKeyStatusUsable); break; @@ -105,7 +105,7 @@ void PolicyEngine::OnTimerEvent() { } case kLicenseStateWaitingLicenseUpdate: { - if (IsRenewalRetryIntervalExpired(current_time)) renewal_needed = true; + if (HasRenewalRetryIntervalExpired(current_time)) renewal_needed = true; break; } @@ -179,7 +179,8 @@ void PolicyEngine::UpdateLicense(const License& license) { next_renewal_time_ = license_start_time_ + policy_.renewal_delay_seconds(); int64_t current_time = clock_->GetCurrentTime(); - if (!policy_.can_play() || IsLicenseOrPlaybackDurationExpired(current_time)) { + if (!policy_.can_play() || + HasLicenseOrPlaybackDurationExpired(current_time)) { license_state_ = kLicenseStateExpired; NotifyKeysChange(kKeyStatusExpired); return; @@ -307,7 +308,7 @@ void PolicyEngine::UpdateRenewalRequest(int64_t current_time) { next_renewal_time_ = current_time + policy_.renewal_retry_interval_seconds(); } -bool PolicyEngine::IsLicenseOrPlaybackDurationExpired(int64_t current_time) { +bool PolicyEngine::HasLicenseOrPlaybackDurationExpired(int64_t current_time) { const int64_t expiry_time = GetExpiryTime(); return (expiry_time == NEVER_EXPIRES) ? false : (expiry_time <= current_time); } @@ -332,7 +333,7 @@ int64_t PolicyEngine::GetRentalExpiryTime() { } int64_t PolicyEngine::GetExpiryTime() { - if (!IsPlaybackStarted()) + if (!HasPlaybackStarted()) return GetRentalExpiryTime(); const int64_t hard_limit = GetHardLicenseExpiryTime(); @@ -350,7 +351,7 @@ int64_t PolicyEngine::GetLicenseOrRentalDurationRemaining( // This is only used in Query. This should return the time remaining on // license_duration_seconds for streaming licenses and rental_duration_seconds // for offline licenses. - if (IsLicenseOrPlaybackDurationExpired(current_time)) return 0; + if (HasLicenseOrPlaybackDurationExpired(current_time)) return 0; const int64_t license_expiry_time = GetRentalExpiryTime(); if (license_expiry_time == NEVER_EXPIRES) return LLONG_MAX; if (license_expiry_time < current_time) return 0; @@ -371,19 +372,19 @@ int64_t PolicyEngine::GetPlaybackDurationRemaining(int64_t current_time) { policy_.playback_duration_seconds()); } -bool PolicyEngine::IsRenewalDelayExpired(int64_t current_time) { +bool PolicyEngine::HasRenewalDelayExpired(int64_t current_time) { return policy_.can_renew() && (policy_.renewal_delay_seconds() > 0) && license_start_time_ + policy_.renewal_delay_seconds() <= current_time; } -bool PolicyEngine::IsRenewalRecoveryDurationExpired(int64_t current_time) { +bool PolicyEngine::HasRenewalRecoveryDurationExpired(int64_t current_time) { // NOTE: Renewal Recovery Duration is currently not used. return (policy_.renewal_recovery_duration_seconds() > 0) && license_start_time_ + policy_.renewal_recovery_duration_seconds() <= current_time; } -bool PolicyEngine::IsRenewalRetryIntervalExpired(int64_t current_time) { +bool PolicyEngine::HasRenewalRetryIntervalExpired(int64_t current_time) { return policy_.can_renew() && (policy_.renewal_retry_interval_seconds() > 0) && next_renewal_time_ <= current_time;