Playback duration should override license duration

[ Merge of go/wvgerrit/14360 ]

If within playback window, do not expire license on expiry of rental or
license duration. In this case playback duration will extend the license.

b/17791094

Change-Id: I26d255aa8f0287bd583ebdeec991c613d49d8f22
This commit is contained in:
Rahul Frias
2015-05-14 15:51:01 -07:00
parent 1c6b675f0c
commit d4900bc9a2
3 changed files with 190 additions and 100 deletions

View File

@@ -49,8 +49,8 @@ void PolicyEngine::OnTimerEvent() {
int64_t current_time = clock_->GetCurrentTime();
// License expiration trumps all.
if ((IsLicenseDurationExpired(current_time) ||
IsPlaybackDurationExpired(current_time)) &&
if ((IsPlaybackDurationExpired(current_time) ||
(IsLicenseDurationExpired(current_time) && !IsPlaybackStarted())) &&
license_state_ != kLicenseStateExpired) {
license_state_ = kLicenseStateExpired;
NotifyKeysChange(kKeyStatusExpired);
@@ -164,8 +164,8 @@ void PolicyEngine::UpdateLicense(const License& license) {
}
int64_t current_time = clock_->GetCurrentTime();
if (!policy_.can_play() || IsLicenseDurationExpired(current_time) ||
IsPlaybackDurationExpired(current_time)) {
if (!policy_.can_play() || IsPlaybackDurationExpired(current_time) ||
(IsLicenseDurationExpired(current_time) && !IsPlaybackStarted())) {
license_state_ = kLicenseStateExpired;
NotifyKeysChange(kKeyStatusExpired);
return;
@@ -348,8 +348,9 @@ void PolicyEngine::NotifyKeysChange(CdmKeyStatus new_status) {
}
void PolicyEngine::NotifyExpirationUpdate() {
int64_t expiry_time =
std::min(GetLicenseExpiryTime(), GetPlaybackExpiryTime());
int64_t expiry_time = IsPlaybackStarted() ? GetPlaybackExpiryTime()
: std::min(GetLicenseExpiryTime(),
GetPlaybackExpiryTime());
if (expiry_time != last_expiry_time_) {
last_expiry_time_ = expiry_time;
if (event_listener_)