More policy engine/timers refactoring
[ Merge of http://go/wvgerrit/93838 ] Some more rework of policy engine/policy timers code to support timer and clock value handling introduced by OEMCrypto v16. Changes are * renamed methods to include rental duration since policies for v16 use rental and playback duration for all licenses. Previously rental and playback durations enforced timing for persistent licenses and license duration was used for streaming licenses. * Moved some common code to the base PolicyTimer class from PolicyTimerV15. * Corrected data member naming (policy_timers -> policy_timers_) * Updated comments Bug: 139372190 Test: Android WV unit/integration tests Change-Id: Id925ddcc14608a8500f30c2c68486d91608a9abe
This commit is contained in:
@@ -16,13 +16,26 @@ namespace wvcdm {
|
||||
|
||||
void PolicyTimers::SetLicense(const video_widevine::License& license) {
|
||||
policy_.Clear();
|
||||
license_start_time_ = license.license_start_time();
|
||||
if (license.has_license_start_time())
|
||||
license_start_time_ = license.license_start_time();
|
||||
}
|
||||
|
||||
void PolicyTimers::DecryptionEvent(int64_t current_time) {
|
||||
last_playback_time_ = current_time;
|
||||
}
|
||||
|
||||
int64_t PolicyTimers::GetPlaybackDurationRemaining(int64_t current_time) {
|
||||
const int64_t playback_duration = policy_.playback_duration_seconds();
|
||||
if (playback_duration == 0) return LLONG_MAX;
|
||||
if (playback_start_time_ == 0) return playback_duration;
|
||||
|
||||
const int64_t playback_expiry_time = playback_duration + playback_start_time_;
|
||||
if (playback_expiry_time < current_time) return 0;
|
||||
const int64_t policy_playback_duration = policy_.playback_duration_seconds();
|
||||
return std::min(playback_expiry_time - current_time,
|
||||
policy_playback_duration);
|
||||
}
|
||||
|
||||
bool PolicyTimers::GetSecondsSinceStarted(int64_t current_time,
|
||||
int64_t* seconds_since_started) {
|
||||
if (seconds_since_started == nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user