Remove references to policy_timers_v15

[ Merge of http://go/wvgerrit/164257 ]

Support for OEMCrypto v15 is being removed from the CDM. The
policy_timers_v15 will no longer be invoked and can be removed.

Bug: 256038127
Test: WV unit/integration tests
Change-Id: Ic3a503ef2a17223dd0bc13696960dcd6822cc343
This commit is contained in:
Rahul Frias
2022-12-21 00:48:14 -08:00
parent ead412cc55
commit 539843da00
3 changed files with 0 additions and 252 deletions

View File

@@ -1,154 +0,0 @@
// Copyright 2020 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
#include "policy_timers_v15.h"
#include <algorithm>
#include <string>
#include "log.h"
#include "wv_cdm_constants.h"
using video_widevine::License;
namespace {
const int64_t kTimeZero = 0;
} // namespace
namespace wvcdm {
bool PolicyTimersV15::UpdateLicense(int64_t current_time,
const License& license) {
if (!license.has_policy()) return false;
policy_.MergeFrom(license.policy());
// some basic license validation
// license start time needs to be specified in the initial response
if (!license.has_license_start_time()) return false;
// Update time information
license_start_time_ = license.license_start_time();
next_renewal_time_ = license_start_time_ + policy_.renewal_delay_seconds();
if (!policy_.can_play() ||
HasLicenseOrRentalOrPlaybackDurationExpired(current_time))
return false;
return true;
}
void PolicyTimersV15::BeginDecryption(int64_t current_time) {
if (playback_start_time_ == 0) {
playback_start_time_ = current_time;
last_playback_time_ = current_time;
if (policy_.play_start_grace_period_seconds() == 0)
grace_period_end_time_ = current_time;
}
}
void PolicyTimersV15::RestorePlaybackTimes(int64_t current_time,
int64_t playback_start_time,
int64_t last_playback_time,
int64_t grace_period_end_time) {
playback_start_time_ = std::max(playback_start_time, kTimeZero);
last_playback_time_ = std::max(last_playback_time, kTimeZero);
grace_period_end_time_ = grace_period_end_time;
if (policy_.play_start_grace_period_seconds() != 0) {
// If we are using grace period, we may need to override some of the values
// given to us by OEMCrypto. |grace_period_end_time| will be 0 if the grace
// period has not expired (effectively playback has not begun). Otherwise,
// |grace_period_end_time| contains the playback start time we should use.
playback_start_time_ = grace_period_end_time;
}
const int64_t expiry_time = GetExpiryTime(
current_time, /* ignore_soft_enforce_playback_duration */ true);
was_expired_on_load_ =
expiry_time != NEVER_EXPIRES && expiry_time < current_time;
}
bool PolicyTimersV15::HasPlaybackStarted(int64_t current_time) {
if (playback_start_time_ == 0) return false;
const int64_t playback_time = current_time - playback_start_time_;
return playback_time >= policy_.play_start_grace_period_seconds();
}
bool PolicyTimersV15::HasLicenseOrRentalOrPlaybackDurationExpired(
int64_t current_time) {
const int64_t expiry_time = GetExpiryTime(
current_time, /* ignore_soft_enforce_playback_duration */ false);
return expiry_time != NEVER_EXPIRES && expiry_time <= current_time;
}
bool PolicyTimersV15::HasPassedGracePeriod(int64_t current_time) {
if (grace_period_end_time_ == 0 && HasPlaybackStarted(current_time)) {
grace_period_end_time_ = playback_start_time_;
return true;
}
return false;
}
int64_t PolicyTimersV15::GetLicenseOrRentalOrPlaybackDurationRemaining(
int64_t current_time) {
const int64_t expiry_time = GetExpiryTime(
current_time, /* ignore_soft_enforce_playback_duration */ false);
if (expiry_time == NEVER_EXPIRES) return LLONG_MAX;
if (expiry_time < current_time) return 0;
return expiry_time - current_time;
}
int64_t PolicyTimersV15::GetLicenseOrRentalDurationRemaining(
int64_t current_time) {
if (HasLicenseOrRentalOrPlaybackDurationExpired(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;
const int64_t policy_license_duration = policy_.license_duration_seconds();
if (policy_license_duration == UNLIMITED_DURATION)
return license_expiry_time - current_time;
return std::min(license_expiry_time - current_time, policy_license_duration);
}
// For the policy time fields checked in the following methods, a value of 0
// (UNLIMITED_DURATION) indicates that there is no limit to the duration.
// If the fields are UNLIMITED_DURATION (including the hard limit) then these
// methods will return NEVER_EXPIRES.
int64_t PolicyTimersV15::GetHardLicenseExpiryTime() {
return policy_.license_duration_seconds() > 0
? license_start_time_ + policy_.license_duration_seconds()
: NEVER_EXPIRES;
}
int64_t PolicyTimersV15::GetRentalExpiryTime() {
const int64_t hard_limit = GetHardLicenseExpiryTime();
if (policy_.rental_duration_seconds() == 0) return hard_limit;
const int64_t expiry_time =
license_start_time_ + policy_.rental_duration_seconds();
if (hard_limit == NEVER_EXPIRES) return expiry_time;
return std::min(hard_limit, expiry_time);
}
int64_t PolicyTimersV15::GetExpiryTime(
int64_t current_time, bool ignore_soft_enforce_playback_duration) {
if (!HasPlaybackStarted(current_time)) return GetRentalExpiryTime();
const int64_t hard_limit = GetHardLicenseExpiryTime();
if (policy_.playback_duration_seconds() == 0) return hard_limit;
if (!ignore_soft_enforce_playback_duration && !was_expired_on_load_ &&
policy_.soft_enforce_playback_duration()) {
return hard_limit;
}
const int64_t expiry_time =
playback_start_time_ + policy_.playback_duration_seconds();
if (hard_limit == NEVER_EXPIRES) return expiry_time;
return std::min(hard_limit, expiry_time);
}
} // namespace wvcdm