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:
@@ -105,8 +105,8 @@ class PolicyEngine {
|
||||
|
||||
bool IsLicenseForFuture() { return license_state_ == kLicenseStatePending; }
|
||||
|
||||
bool HasLicenseOrPlaybackDurationExpired(int64_t current_time);
|
||||
int64_t GetLicenseOrPlaybackDurationRemaining();
|
||||
bool HasLicenseOrRentalOrPlaybackDurationExpired(int64_t current_time);
|
||||
int64_t GetLicenseOrRentalOrPlaybackDurationRemaining();
|
||||
|
||||
bool CanRenew() const;
|
||||
|
||||
@@ -177,7 +177,7 @@ class PolicyEngine {
|
||||
uint32_t current_resolution_;
|
||||
CryptoSession* crypto_session_;
|
||||
|
||||
std::unique_ptr<PolicyTimers> policy_timers;
|
||||
std::unique_ptr<PolicyTimers> policy_timers_;
|
||||
std::unique_ptr<Clock> clock_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(PolicyEngine);
|
||||
|
||||
@@ -49,13 +49,17 @@ class PolicyTimers {
|
||||
int64_t grace_period_end_time) = 0;
|
||||
|
||||
virtual bool HasPlaybackStarted(int64_t current_time) = 0;
|
||||
virtual bool HasLicenseOrPlaybackDurationExpired(int64_t current_time) = 0;
|
||||
virtual bool HasLicenseOrRentalOrPlaybackDurationExpired(
|
||||
int64_t current_time) = 0;
|
||||
virtual bool HasPassedGracePeriod(int64_t current_time) = 0;
|
||||
|
||||
virtual int64_t GetLicenseOrPlaybackDurationRemaining(
|
||||
virtual int64_t GetLicenseOrRentalOrPlaybackDurationRemaining(
|
||||
int64_t current_time) = 0;
|
||||
virtual int64_t GetLicenseOrRentalDurationRemaining(int64_t current_time) = 0;
|
||||
virtual int64_t GetPlaybackDurationRemaining(int64_t current_time) = 0;
|
||||
// This is only used in Query. This should return |playback_duration_seconds|
|
||||
// before playback begins or the time remaining on
|
||||
// |playback_duration_seconds| after playback begins.
|
||||
virtual int64_t GetPlaybackDurationRemaining(int64_t current_time);
|
||||
|
||||
virtual bool GetSecondsSinceStarted(int64_t current_time,
|
||||
int64_t* seconds_since_started);
|
||||
@@ -89,6 +93,8 @@ class PolicyTimers {
|
||||
virtual int64_t GetExpiryTime(int64_t current_time,
|
||||
bool ignore_soft_enforce_playback_duration) = 0;
|
||||
|
||||
virtual int64_t GetRenewalStartTime() = 0;
|
||||
|
||||
// This is the current policy information for this license. This gets updated
|
||||
// as license renewals occur.
|
||||
video_widevine::License::Policy policy_;
|
||||
|
||||
@@ -29,7 +29,7 @@ class PolicyTimersV15 : public PolicyTimers {
|
||||
public:
|
||||
PolicyTimersV15() : grace_period_end_time_(0) {}
|
||||
|
||||
virtual ~PolicyTimersV15(){};
|
||||
virtual ~PolicyTimersV15() {}
|
||||
|
||||
// UpdateLicense is used in handling a license response for a renewal request.
|
||||
// The response may only contain any policy fields that have changed. In this
|
||||
@@ -49,17 +49,21 @@ class PolicyTimersV15 : public PolicyTimers {
|
||||
int64_t grace_period_end_time) override;
|
||||
|
||||
bool HasPlaybackStarted(int64_t current_time) override;
|
||||
bool HasLicenseOrPlaybackDurationExpired(int64_t current_time) override;
|
||||
bool HasLicenseOrRentalOrPlaybackDurationExpired(
|
||||
int64_t current_time) override;
|
||||
bool HasPassedGracePeriod(int64_t current_time) override;
|
||||
|
||||
int64_t GetLicenseOrPlaybackDurationRemaining(int64_t current_time) override;
|
||||
// This returns
|
||||
// * for streaming licenses: the time remaining on |license_duration_seconds|
|
||||
// * for persistent licenses: the time remaining on |rental_duration_seconds|
|
||||
// before playback begins or the time remaining on
|
||||
// |playback_duration_seconds| after.
|
||||
int64_t GetLicenseOrRentalOrPlaybackDurationRemaining(
|
||||
int64_t current_time) override;
|
||||
// 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.
|
||||
// |license_duration_seconds| for streaming licenses and
|
||||
// |rental_duration_seconds| for persistent licenses.
|
||||
int64_t GetLicenseOrRentalDurationRemaining(int64_t current_time) override;
|
||||
// This is only used in Query. This should return playback_duration_seconds,
|
||||
// or the time remaining on it if playing.
|
||||
int64_t GetPlaybackDurationRemaining(int64_t current_time) override;
|
||||
|
||||
protected:
|
||||
// Gets the clock time that the license expires based on whether we have
|
||||
@@ -67,6 +71,8 @@ class PolicyTimersV15 : public PolicyTimers {
|
||||
int64_t GetExpiryTime(int64_t current_time,
|
||||
bool ignore_soft_enforce_playback_duration) override;
|
||||
|
||||
int64_t GetRenewalStartTime() override { return license_start_time_; }
|
||||
|
||||
private:
|
||||
// Gets the clock time that the license expires. This is the hard limit that
|
||||
// all license types must obey at all times.
|
||||
|
||||
Reference in New Issue
Block a user