Merge "Report key status change"

This commit is contained in:
Kongqun Yang
2015-04-02 17:18:19 +00:00
committed by Android (Google) Code Review
10 changed files with 315 additions and 26 deletions

View File

@@ -128,7 +128,6 @@ class CdmSession {
// instance variables
bool initialized_;
CdmSessionId session_id_;
WvCdmEventListener* event_listener_;
scoped_ptr<CdmLicense> license_parser_;
scoped_ptr<CryptoSession> crypto_session_;
scoped_ptr<PolicyEngine> policy_engine_;

View File

@@ -3,6 +3,7 @@
#ifndef WVCDM_CORE_POLICY_ENGINE_H_
#define WVCDM_CORE_POLICY_ENGINE_H_
#include <map>
#include <string>
#include "license_protocol.pb.h"
@@ -59,6 +60,8 @@ class PolicyEngine {
// Used for notifying the Policy Engine of resolution changes
virtual void NotifyResolution(uint32_t width, uint32_t height);
virtual void NotifySessionExpiration();
virtual CdmResponseType Query(CdmQueryMap* key_info);
virtual const LicenseIdentification& license_id() { return license_id_; }
@@ -105,15 +108,19 @@ class PolicyEngine {
void UpdateRenewalRequest(int64_t current_time);
// Notifies updates in keys information and fire OnKeysChange event if
// key changes.
void NotifyKeysChange(CdmKeyStatus new_status);
// Notifies updates in expiry time and fire OnExpirationUpdate event if
// expiry time changes.
void NotifyExpirationUpdate();
// These setters are for testing only. Takes ownership of the pointers.
void set_clock(Clock* clock);
void set_max_res_engine(MaxResEngine* max_res_engine);
LicenseState license_state_;
bool can_decrypt_;
// This is the current policy information for this license. This gets updated
// as license renewals occur.
@@ -142,7 +149,10 @@ class PolicyEngine {
CdmSessionId session_id_;
WvCdmEventListener* event_listener_;
MaxResEngine max_res_engine_;
scoped_ptr<MaxResEngine> max_res_engine_;
std::map<KeyId, CdmKeyStatus> keys_status_;
scoped_ptr<Clock> clock_;
CORE_DISALLOW_COPY_AND_ASSIGN(PolicyEngine);

View File

@@ -15,6 +15,10 @@ class WvCdmEventListener {
virtual void OnSessionRenewalNeeded(const CdmSessionId& session_id) = 0;
virtual void OnSessionExpiration(const CdmSessionId& session_id) = 0;
virtual void OnSessionKeysChange(
const CdmSessionId& session_id,
const std::vector<CdmKeyInformation>& cdm_keys_info,
bool has_new_usable_key) = 0;
virtual void OnExpirationUpdate(const CdmSessionId& session_id,
int64_t new_expiry_time) = 0;

View File

@@ -49,6 +49,15 @@ enum CdmResponseType {
INSUFFICIENT_CRYPTO_RESOURCES,
};
enum CdmKeyStatus {
kKeyStatusUsable,
kKeyStatusInternalError,
kKeyStatusExpired,
kKeyStatusOutputNotAllowed,
kKeyStatusOutputDownscaled,
kKeyStatusPending,
};
#define CORE_DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)
@@ -116,6 +125,14 @@ struct CdmDecryptionParameters {
is_video(true) {}
};
struct CdmKeyInformation {
CdmKeyInformation(const KeyId& id, CdmKeyStatus status)
: key_id(id), key_status(status) {}
KeyId key_id;
CdmKeyStatus key_status;
};
// forward class references
class KeyMessage;
class Request;