Merge "Refactor WvCdmEventListener and some cleanups"

This commit is contained in:
KongQun Yang
2015-03-23 16:43:53 +00:00
committed by Android (Google) Code Review
16 changed files with 237 additions and 494 deletions

View File

@@ -32,11 +32,13 @@ class CdmEngine {
// Session related methods // Session related methods
virtual CdmResponseType OpenSession(const CdmKeySystem& key_system, virtual CdmResponseType OpenSession(const CdmKeySystem& key_system,
const CdmClientPropertySet* property_set, const CdmClientPropertySet* property_set,
WvCdmEventListener* event_listener,
CdmSessionId* session_id); CdmSessionId* session_id);
virtual CdmResponseType CloseSession(const CdmSessionId& session_id); virtual CdmResponseType CloseSession(const CdmSessionId& session_id);
virtual CdmResponseType OpenKeySetSession( virtual CdmResponseType OpenKeySetSession(
const CdmKeySetId& key_set_id, const CdmClientPropertySet* property_set); const CdmKeySetId& key_set_id, const CdmClientPropertySet* property_set,
WvCdmEventListener* event_listener);
virtual CdmResponseType CloseKeySetSession(const CdmKeySetId& key_set_id); virtual CdmResponseType CloseKeySetSession(const CdmKeySetId& key_set_id);
// License related methods // License related methods
@@ -138,25 +140,17 @@ class CdmEngine {
virtual bool IsKeyLoaded(const KeyId& key_id); virtual bool IsKeyLoaded(const KeyId& key_id);
virtual bool FindSessionForKey(const KeyId& key_id, CdmSessionId* sessionId); virtual bool FindSessionForKey(const KeyId& key_id, CdmSessionId* sessionId);
// Event listener related methods.
// We assume that the WvCdmEventListener is asynchronous -- i.e. an event
// should be dispatched to another thread which actually does the work. In
// particular, if a synchronous listener calls OpenSession or CloseSession,
// the thread will dead lock.
// Returns false if listener already attached.
virtual bool AttachEventListener(const CdmSessionId& session_id,
WvCdmEventListener* listener);
// Returns true if listener was detached.
virtual bool DetachEventListener(const CdmSessionId& session_id,
WvCdmEventListener* listener);
// Used for notifying the Max-Res Engine of resolution changes // Used for notifying the Max-Res Engine of resolution changes
virtual void NotifyResolution(const CdmSessionId& session_id, uint32_t width, virtual void NotifyResolution(const CdmSessionId& session_id, uint32_t width,
uint32_t height); uint32_t height);
// Timer expiration method. This method is not re-entrant -- there can be // Timer expiration method. This method is not re-entrant -- there can be
// only one timer. // only one timer.
// This method triggers appropriate event callbacks from |event_listener_|,
// which is assumed to be asynchronous -- i.e. an event should be dispatched
// to another thread which does the actual work. In particular, if a
// synchronous listener calls OpenSession or CloseSession, the thread will
// dead lock.
virtual void OnTimerEvent(); virtual void OnTimerEvent();
private: private:

View File

@@ -21,7 +21,8 @@ class WvCdmEventListener;
class CdmSession { class CdmSession {
public: public:
explicit CdmSession(const CdmClientPropertySet* cdm_client_property_set); CdmSession(const CdmClientPropertySet* cdm_client_property_set,
WvCdmEventListener* event_listener);
virtual ~CdmSession(); virtual ~CdmSession();
virtual CdmResponseType Init(); virtual CdmResponseType Init();
@@ -74,10 +75,6 @@ class CdmSession {
virtual bool IsKeyLoaded(const KeyId& key_id); virtual bool IsKeyLoaded(const KeyId& key_id);
// See comments for CdmEngine::AttachEventListener/DetachEventListener.
virtual bool AttachEventListener(WvCdmEventListener* listener);
virtual bool DetachEventListener(WvCdmEventListener* listener);
// Used for notifying the Policy Engine of resolution changes // Used for notifying the Policy Engine of resolution changes
virtual void NotifyResolution(uint32_t width, uint32_t height); virtual void NotifyResolution(uint32_t width, uint32_t height);
@@ -112,10 +109,7 @@ class CdmSession {
bool DeleteLicense(); bool DeleteLicense();
private: private:
// Internal constructor friend class CdmSessionTest;
void Create(CdmLicense* license_parser, CryptoSession* crypto_session,
PolicyEngine* policy_engine, DeviceFiles* file_handle,
const CdmClientPropertySet* cdm_client_property_set);
// Generate unique ID for each new session. // Generate unique ID for each new session.
CdmSessionId GenerateSessionId(); CdmSessionId GenerateSessionId();
@@ -123,9 +117,17 @@ class CdmSession {
CdmResponseType StoreLicense(); CdmResponseType StoreLicense();
bool StoreLicense(DeviceFiles::LicenseState state); bool StoreLicense(DeviceFiles::LicenseState state);
// These setters are for testing only. Takes ownership of the pointers.
void set_license_parser(CdmLicense* license_parser);
void set_crypto_session(CryptoSession* crypto_session);
void set_policy_engine(PolicyEngine* policy_engine);
void set_file_handle(DeviceFiles* file_handle);
// instance variables // instance variables
bool initialized_; bool initialized_;
CdmSessionId session_id_; CdmSessionId session_id_;
WvCdmEventListener* event_listener_;
scoped_ptr<CdmLicense> license_parser_; scoped_ptr<CdmLicense> license_parser_;
scoped_ptr<CryptoSession> crypto_session_; scoped_ptr<CryptoSession> crypto_session_;
scoped_ptr<PolicyEngine> policy_engine_; scoped_ptr<PolicyEngine> policy_engine_;
@@ -156,18 +158,6 @@ class CdmSession {
// license type release and offline related information // license type release and offline related information
CdmKeySetId key_set_id_; CdmKeySetId key_set_id_;
std::set<WvCdmEventListener*> listeners_;
// For testing only
// Takes ownership of license_parser, crypto_session, policy_engine
// and device_files
CdmSession(CdmLicense* license_parser, CryptoSession* crypto_session,
PolicyEngine* policy_engine, DeviceFiles* file_handle,
const CdmClientPropertySet* cdm_client_property_set);
#if defined(UNIT_TEST)
friend class CdmSessionTest;
#endif
CORE_DISALLOW_COPY_AND_ASSIGN(CdmSession); CORE_DISALLOW_COPY_AND_ASSIGN(CdmSession);
}; };

View File

@@ -7,6 +7,7 @@
#include "license_protocol.pb.h" #include "license_protocol.pb.h"
#include "max_res_engine.h" #include "max_res_engine.h"
#include "scoped_ptr.h"
#include "wv_cdm_types.h" #include "wv_cdm_types.h"
namespace wvcdm { namespace wvcdm {
@@ -15,7 +16,6 @@ using video_widevine_server::sdk::LicenseIdentification;
class Clock; class Clock;
class CryptoSession; class CryptoSession;
class PolicyEngineTest;
// This acts as an oracle that basically says "Yes(true) you may still decrypt // This acts as an oracle that basically says "Yes(true) you may still decrypt
// or no(false) you may not decrypt this data anymore." // or no(false) you may not decrypt this data anymore."
@@ -78,6 +78,8 @@ class PolicyEngine {
bool IsLicenseForFuture() { return license_state_ == kLicenseStatePending; } bool IsLicenseForFuture() { return license_state_ == kLicenseStatePending; }
private: private:
friend class PolicyEngineTest;
typedef enum { typedef enum {
kLicenseStateInitial, kLicenseStateInitial,
kLicenseStatePending, // if license is issued for sometime in the future kLicenseStatePending, // if license is issued for sometime in the future
@@ -87,8 +89,6 @@ class PolicyEngine {
kLicenseStateExpired kLicenseStateExpired
} LicenseState; } LicenseState;
void Init(Clock* clock);
int64_t GetLicenseDurationRemaining(int64_t current_time); int64_t GetLicenseDurationRemaining(int64_t current_time);
int64_t GetPlaybackDurationRemaining(int64_t current_time); int64_t GetPlaybackDurationRemaining(int64_t current_time);
@@ -98,6 +98,9 @@ class PolicyEngine {
void UpdateRenewalRequest(int64_t current_time); void UpdateRenewalRequest(int64_t current_time);
// These setters are for testing only. Takes ownership of the pointers.
void set_clock(Clock* clock);
LicenseState license_state_; LicenseState license_state_;
bool can_decrypt_; bool can_decrypt_;
@@ -124,11 +127,7 @@ class PolicyEngine {
int64_t policy_max_duration_seconds_; int64_t policy_max_duration_seconds_;
MaxResEngine max_res_engine_; MaxResEngine max_res_engine_;
Clock* clock_; scoped_ptr<Clock> clock_;
// For testing
friend class PolicyEngineTest;
PolicyEngine(CryptoSession* crypto_session, Clock* clock);
CORE_DISALLOW_COPY_AND_ASSIGN(PolicyEngine); CORE_DISALLOW_COPY_AND_ASSIGN(PolicyEngine);
}; };

View File

@@ -8,9 +8,6 @@
namespace wvcdm { namespace wvcdm {
// Listener for events from the Content Decryption Module. // Listener for events from the Content Decryption Module.
// The caller of the CDM API must provide an implementation for OnEvent
// and signal its intent by using the Attach/DetachEventListener methods
// in the WvContentDecryptionModule class.
class WvCdmEventListener { class WvCdmEventListener {
public: public:
WvCdmEventListener() {} WvCdmEventListener() {}

View File

@@ -76,6 +76,7 @@ CdmEngine::~CdmEngine() {
CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system, CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system,
const CdmClientPropertySet* property_set, const CdmClientPropertySet* property_set,
WvCdmEventListener* event_listener,
CdmSessionId* session_id) { CdmSessionId* session_id) {
LOGI("CdmEngine::OpenSession"); LOGI("CdmEngine::OpenSession");
@@ -89,7 +90,8 @@ CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system,
return KEY_ERROR; return KEY_ERROR;
} }
scoped_ptr<CdmSession> new_session(new CdmSession(property_set)); scoped_ptr<CdmSession> new_session(
new CdmSession(property_set, event_listener));
if (new_session->session_id().empty()) { if (new_session->session_id().empty()) {
LOGE("CdmEngine::OpenSession: failure to generate session ID"); LOGE("CdmEngine::OpenSession: failure to generate session ID");
return UNKNOWN_ERROR; return UNKNOWN_ERROR;
@@ -112,7 +114,8 @@ CdmResponseType CdmEngine::OpenSession(const CdmKeySystem& key_system,
} }
CdmResponseType CdmEngine::OpenKeySetSession( CdmResponseType CdmEngine::OpenKeySetSession(
const CdmKeySetId& key_set_id, const CdmClientPropertySet* property_set) { const CdmKeySetId& key_set_id, const CdmClientPropertySet* property_set,
WvCdmEventListener* event_listener) {
LOGI("CdmEngine::OpenKeySetSession"); LOGI("CdmEngine::OpenKeySetSession");
if (key_set_id.empty()) { if (key_set_id.empty()) {
@@ -121,7 +124,8 @@ CdmResponseType CdmEngine::OpenKeySetSession(
} }
CdmSessionId session_id; CdmSessionId session_id;
CdmResponseType sts = OpenSession(KEY_SYSTEM, property_set, &session_id); CdmResponseType sts =
OpenSession(KEY_SYSTEM, property_set, event_listener, &session_id);
if (sts != NO_ERROR) return sts; if (sts != NO_ERROR) return sts;
@@ -587,7 +591,7 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
} }
usage_property_set_->set_security_level(kLevelDefault); usage_property_set_->set_security_level(kLevelDefault);
usage_property_set_->set_app_id(app_id); usage_property_set_->set_app_id(app_id);
usage_session_.reset(new CdmSession(usage_property_set_.get())); usage_session_.reset(new CdmSession(usage_property_set_.get(), NULL));
CdmResponseType status = usage_session_->Init(); CdmResponseType status = usage_session_->Init();
if (NO_ERROR != status) { if (NO_ERROR != status) {
LOGE("CdmEngine::GetUsageInfo: session init error"); LOGE("CdmEngine::GetUsageInfo: session init error");
@@ -605,7 +609,7 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
&license_response)) { &license_response)) {
usage_property_set_->set_security_level(kLevel3); usage_property_set_->set_security_level(kLevel3);
usage_property_set_->set_app_id(app_id); usage_property_set_->set_app_id(app_id);
usage_session_.reset(new CdmSession(usage_property_set_.get())); usage_session_.reset(new CdmSession(usage_property_set_.get(), NULL));
status = usage_session_->Init(); status = usage_session_->Init();
if (NO_ERROR != status) { if (NO_ERROR != status) {
LOGE("CdmEngine::GetUsageInfo: session init error"); LOGE("CdmEngine::GetUsageInfo: session init error");
@@ -673,7 +677,7 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
usage_property_set_->set_security_level(requested_security_level); usage_property_set_->set_security_level(requested_security_level);
usage_property_set_->set_app_id(app_id); usage_property_set_->set_app_id(app_id);
usage_session_.reset(new CdmSession(usage_property_set_.get())); usage_session_.reset(new CdmSession(usage_property_set_.get(), NULL));
CdmResponseType status = usage_session_->Init(); CdmResponseType status = usage_session_->Init();
if (NO_ERROR != status) { if (NO_ERROR != status) {
@@ -856,26 +860,6 @@ bool CdmEngine::FindSessionForKey(const KeyId& key_id,
return false; return false;
} }
bool CdmEngine::AttachEventListener(const CdmSessionId& session_id,
WvCdmEventListener* listener) {
CdmSessionMap::iterator iter = sessions_.find(session_id);
if (iter == sessions_.end()) {
return false;
}
return iter->second->AttachEventListener(listener);
}
bool CdmEngine::DetachEventListener(const CdmSessionId& session_id,
WvCdmEventListener* listener) {
CdmSessionMap::iterator iter = sessions_.find(session_id);
if (iter == sessions_.end()) {
return false;
}
return iter->second->DetachEventListener(listener);
}
void CdmEngine::NotifyResolution(const CdmSessionId& session_id, uint32_t width, void CdmEngine::NotifyResolution(const CdmSessionId& session_id, uint32_t width,
uint32_t height) { uint32_t height) {
CdmSessionMap::iterator iter = sessions_.find(session_id); CdmSessionMap::iterator iter = sessions_.find(session_id);

View File

@@ -23,68 +23,32 @@ const size_t kKeySetIdLength = 14;
namespace wvcdm { namespace wvcdm {
typedef std::set<WvCdmEventListener*>::iterator CdmEventListenerIter; CdmSession::CdmSession(const CdmClientPropertySet* cdm_client_property_set,
WvCdmEventListener* event_listener)
CdmSession::CdmSession(const CdmClientPropertySet* cdm_client_property_set) { : initialized_(false),
CryptoSession* crypto_session = new CryptoSession(); session_id_(GenerateSessionId()),
Create(new CdmLicense(), crypto_session, new PolicyEngine(crypto_session), event_listener_(event_listener),
new DeviceFiles(), cdm_client_property_set); license_parser_(new CdmLicense),
} crypto_session_(new CryptoSession),
policy_engine_(new PolicyEngine(crypto_session_.get())),
CdmSession::CdmSession(CdmLicense* license_parser, file_handle_(new DeviceFiles),
CryptoSession* crypto_session, license_received_(false),
PolicyEngine* policy_engine, DeviceFiles* file_handle, is_offline_(false),
const CdmClientPropertySet* cdm_client_property_set) { is_release_(false),
Create(license_parser, crypto_session, policy_engine, file_handle, security_level_(kSecurityLevelUninitialized),
cdm_client_property_set); requested_security_level_(kLevelDefault),
} is_initial_decryption_(true),
has_decrypted_since_last_report_(false),
void CdmSession::Create(CdmLicense* license_parser, is_initial_usage_update_(true),
CryptoSession* crypto_session, is_usage_update_needed_(false) {
PolicyEngine* policy_engine, DeviceFiles* file_handle, if (cdm_client_property_set) {
const CdmClientPropertySet* cdm_client_property_set) { if (cdm_client_property_set->security_level() ==
// Just return on failures. Failures will be signaled in Init. QUERY_VALUE_SECURITY_LEVEL_L3) {
if (NULL == license_parser) {
LOGE("CdmSession::Create: License parser not provided");
return;
}
if (NULL == crypto_session) {
LOGE("CdmSession::Create: Crypto session not provided");
return;
}
if (NULL == policy_engine) {
LOGE("CdmSession::Create: Policy engine not provided");
return;
}
if (NULL == file_handle) {
LOGE("CdmSession::Create: Device files not provided");
return;
}
initialized_ = false;
session_id_ = GenerateSessionId();
license_parser_.reset(license_parser);
crypto_session_.reset(crypto_session);
file_handle_.reset(file_handle);
policy_engine_.reset(policy_engine);
license_received_ = false;
is_offline_ = false;
is_release_ = false;
is_initial_usage_update_ = true;
is_usage_update_needed_ = false;
is_initial_decryption_ = true;
has_decrypted_since_last_report_ = false;
requested_security_level_ = kLevelDefault;
if (NULL != cdm_client_property_set) {
if (QUERY_VALUE_SECURITY_LEVEL_L3.compare(
cdm_client_property_set->security_level()) == 0) {
requested_security_level_ = kLevel3; requested_security_level_ = kLevel3;
security_level_ = kSecurityLevelL3;
} }
Properties::AddSessionPropertySet(session_id_, cdm_client_property_set); Properties::AddSessionPropertySet(session_id_, cdm_client_property_set);
} }
security_level_ =
GetRequestedSecurityLevel() == kLevel3 ? kSecurityLevelL3
: kSecurityLevelUninitialized;
app_id_.clear();
} }
CdmSession::~CdmSession() { Properties::RemoveSessionPropertySet(session_id_); } CdmSession::~CdmSession() { Properties::RemoveSessionPropertySet(session_id_); }
@@ -546,15 +510,6 @@ bool CdmSession::DeleteLicense() {
} }
} }
bool CdmSession::AttachEventListener(WvCdmEventListener* listener) {
std::pair<CdmEventListenerIter, bool> result = listeners_.insert(listener);
return result.second;
}
bool CdmSession::DetachEventListener(WvCdmEventListener* listener) {
return (listeners_.erase(listener) == 1);
}
void CdmSession::NotifyResolution(uint32_t width, uint32_t height) { void CdmSession::NotifyResolution(uint32_t width, uint32_t height) {
policy_engine_->NotifyResolution(width, height); policy_engine_->NotifyResolution(width, height);
} }
@@ -573,19 +528,14 @@ void CdmSession::OnTimerEvent(bool update_usage) {
policy_engine_->OnTimerEvent(&event_occurred, &event); policy_engine_->OnTimerEvent(&event_occurred, &event);
if (event_occurred) { if (event_occurred) {
for (CdmEventListenerIter iter = listeners_.begin(); if (event_listener_) event_listener_->OnEvent(session_id_, event);
iter != listeners_.end(); ++iter) {
(*iter)->OnEvent(session_id_, event);
}
} }
} }
void CdmSession::OnKeyReleaseEvent(const CdmKeySetId& key_set_id) { void CdmSession::OnKeyReleaseEvent(const CdmKeySetId& key_set_id) {
if (key_set_id_ == key_set_id) { if (key_set_id_ == key_set_id) {
for (CdmEventListenerIter iter = listeners_.begin(); if (event_listener_)
iter != listeners_.end(); ++iter) { event_listener_->OnEvent(session_id_, LICENSE_EXPIRED_EVENT);
(*iter)->OnEvent(session_id_, LICENSE_EXPIRED_EVENT);
}
} }
} }
@@ -610,4 +560,20 @@ CdmResponseType CdmSession::ReleaseCrypto() {
return NO_ERROR; return NO_ERROR;
} }
void CdmSession::set_license_parser(CdmLicense* license_parser) {
license_parser_.reset(license_parser);
}
void CdmSession::set_crypto_session(CryptoSession* crypto_session) {
crypto_session_.reset(crypto_session);
}
void CdmSession::set_policy_engine(PolicyEngine* policy_engine) {
policy_engine_.reset(policy_engine);
}
void CdmSession::set_file_handle(DeviceFiles* file_handle) {
file_handle_.reset(file_handle);
}
} // namespace wvcdm } // namespace wvcdm

View File

@@ -17,29 +17,17 @@
namespace wvcdm { namespace wvcdm {
PolicyEngine::PolicyEngine(CryptoSession* crypto_session) PolicyEngine::PolicyEngine(CryptoSession* crypto_session)
: max_res_engine_(crypto_session) { : license_state_(kLicenseStateInitial),
Init(new Clock()); can_decrypt_(false),
} license_start_time_(0),
playback_start_time_(0),
last_playback_time_(0),
next_renewal_time_(0),
policy_max_duration_seconds_(0),
max_res_engine_(crypto_session),
clock_(new Clock) {}
PolicyEngine::PolicyEngine(CryptoSession* crypto_session, Clock* clock) PolicyEngine::~PolicyEngine() {}
: max_res_engine_(crypto_session) {
Init(clock);
}
PolicyEngine::~PolicyEngine() {
if (clock_) delete clock_;
}
void PolicyEngine::Init(Clock* clock) {
license_state_ = kLicenseStateInitial;
can_decrypt_ = false;
license_start_time_ = 0;
playback_start_time_ = 0;
last_playback_time_ = 0;
next_renewal_time_ = 0;
policy_max_duration_seconds_ = 0;
clock_ = clock;
}
bool PolicyEngine::CanDecrypt(const KeyId& key_id) { bool PolicyEngine::CanDecrypt(const KeyId& key_id) {
return can_decrypt_ && max_res_engine_.CanDecrypt(key_id); return can_decrypt_ && max_res_engine_.CanDecrypt(key_id);
@@ -316,4 +304,6 @@ bool PolicyEngine::IsRenewalRetryIntervalExpired(int64_t current_time) {
next_renewal_time_ <= current_time; next_renewal_time_ <= current_time;
} }
void PolicyEngine::set_clock(Clock* clock) { clock_.reset(clock); }
} // wvcdm } // wvcdm

View File

@@ -47,10 +47,10 @@ class WvCdmEngineTest : public testing::Test {
public: public:
virtual void SetUp() { virtual void SetUp() {
CdmResponseType status = CdmResponseType status =
cdm_engine_.OpenSession(g_key_system, NULL, &session_id_); cdm_engine_.OpenSession(g_key_system, NULL, NULL, &session_id_);
if (status == NEED_PROVISIONING) { if (status == NEED_PROVISIONING) {
Provision(); Provision();
status = cdm_engine_.OpenSession(g_key_system, NULL, &session_id_); status = cdm_engine_.OpenSession(g_key_system, NULL, NULL, &session_id_);
} }
ASSERT_EQ(NO_ERROR, status); ASSERT_EQ(NO_ERROR, status);
ASSERT_NE("", session_id_) << "Could not open CDM session."; ASSERT_NE("", session_id_) << "Could not open CDM session.";

View File

@@ -5,6 +5,7 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "properties.h" #include "properties.h"
#include "scoped_ptr.h"
#include "string_conversions.h" #include "string_conversions.h"
#include "test_printers.h" #include "test_printers.h"
@@ -126,25 +127,19 @@ class MockCdmLicense : public CdmLicense {
class CdmSessionTest : public ::testing::Test { class CdmSessionTest : public ::testing::Test {
protected: protected:
virtual void SetUp() { virtual void SetUp() {
cdm_session_.reset(new CdmSession(NULL, NULL));
// Inject testing mocks.
license_parser_ = new MockCdmLicense(); license_parser_ = new MockCdmLicense();
cdm_session_->set_license_parser(license_parser_);
crypto_session_ = new MockCryptoSession(); crypto_session_ = new MockCryptoSession();
cdm_session_->set_crypto_session(crypto_session_);
policy_engine_ = new MockPolicyEngine(); policy_engine_ = new MockPolicyEngine();
cdm_session_->set_policy_engine(policy_engine_);
file_handle_ = new MockDeviceFiles(); file_handle_ = new MockDeviceFiles();
cdm_session_->set_file_handle(file_handle_);
} }
virtual void TearDown() { scoped_ptr<CdmSession> cdm_session_;
if (cdm_session_) delete cdm_session_;
}
void CreateSession() { CreateSession(NULL); }
void CreateSession(const CdmClientPropertySet* cdm_client_property_set) {
cdm_session_ =
new CdmSession(license_parser_, crypto_session_, policy_engine_,
file_handle_, cdm_client_property_set);
}
CdmSession* cdm_session_;
MockCdmLicense* license_parser_; MockCdmLicense* license_parser_;
MockCryptoSession* crypto_session_; MockCryptoSession* crypto_session_;
MockPolicyEngine* policy_engine_; MockPolicyEngine* policy_engine_;
@@ -173,7 +168,6 @@ TEST_F(CdmSessionTest, InitWithCertificate) {
Properties::set_use_certificates_as_identification(true); Properties::set_use_certificates_as_identification(true);
CreateSession();
ASSERT_EQ(NO_ERROR, cdm_session_->Init()); ASSERT_EQ(NO_ERROR, cdm_session_->Init());
} }
@@ -195,7 +189,6 @@ TEST_F(CdmSessionTest, InitWithKeybox) {
Properties::set_use_certificates_as_identification(false); Properties::set_use_certificates_as_identification(false);
CreateSession();
ASSERT_EQ(NO_ERROR, cdm_session_->Init()); ASSERT_EQ(NO_ERROR, cdm_session_->Init());
} }
@@ -221,7 +214,6 @@ TEST_F(CdmSessionTest, ReInitFail) {
Properties::set_use_certificates_as_identification(true); Properties::set_use_certificates_as_identification(true);
CreateSession();
ASSERT_EQ(NO_ERROR, cdm_session_->Init()); ASSERT_EQ(NO_ERROR, cdm_session_->Init());
ASSERT_EQ(UNKNOWN_ERROR, cdm_session_->Init()); ASSERT_EQ(UNKNOWN_ERROR, cdm_session_->Init());
} }
@@ -233,7 +225,6 @@ TEST_F(CdmSessionTest, InitFailCryptoError) {
Properties::set_use_certificates_as_identification(true); Properties::set_use_certificates_as_identification(true);
CreateSession();
ASSERT_EQ(UNKNOWN_ERROR, cdm_session_->Init()); ASSERT_EQ(UNKNOWN_ERROR, cdm_session_->Init());
} }
@@ -252,7 +243,6 @@ TEST_F(CdmSessionTest, InitNeedsProvisioning) {
Properties::set_use_certificates_as_identification(true); Properties::set_use_certificates_as_identification(true);
CreateSession();
ASSERT_EQ(NEED_PROVISIONING, cdm_session_->Init()); ASSERT_EQ(NEED_PROVISIONING, cdm_session_->Init());
} }

View File

@@ -10,6 +10,7 @@
#include "license.h" #include "license.h"
#include "mock_clock.h" #include "mock_clock.h"
#include "policy_engine.h" #include "policy_engine.h"
#include "scoped_ptr.h"
#include "test_printers.h" #include "test_printers.h"
#include "wv_cdm_constants.h" #include "wv_cdm_constants.h"
@@ -58,8 +59,10 @@ using ::testing::AtLeast;
class PolicyEngineTest : public ::testing::Test { class PolicyEngineTest : public ::testing::Test {
protected: protected:
virtual void SetUp() { virtual void SetUp() {
policy_engine_.reset(new PolicyEngine(NULL));
// Inject testing clock.
mock_clock_ = new MockClock(); mock_clock_ = new MockClock();
policy_engine_ = new PolicyEngine(NULL, mock_clock_); policy_engine_->set_clock(mock_clock_);
license_.set_license_start_time(kLicenseStartTime); license_.set_license_start_time(kLicenseStartTime);
@@ -85,13 +88,6 @@ class PolicyEngineTest : public ::testing::Test {
policy->set_renew_with_usage(false); policy->set_renew_with_usage(false);
} }
virtual void TearDown() {
delete policy_engine_;
// Done by policy engine: delete mock_clock_;
policy_engine_ = NULL;
mock_clock_ = NULL;
}
int64_t GetMinOfRentalPlaybackLicenseDurations() { int64_t GetMinOfRentalPlaybackLicenseDurations() {
const License_Policy& policy = license_.policy(); const License_Policy& policy = license_.policy();
int64_t rental_duration = policy.rental_duration_seconds(); int64_t rental_duration = policy.rental_duration_seconds();
@@ -105,7 +101,7 @@ class PolicyEngineTest : public ::testing::Test {
} }
MockClock* mock_clock_; MockClock* mock_clock_;
PolicyEngine* policy_engine_; scoped_ptr<PolicyEngine> policy_engine_;
License license_; License license_;
}; };

View File

@@ -26,10 +26,10 @@ class WvContentDecryptionModule : public TimerHandler {
static bool IsWebm(const std::string& init_data_type); static bool IsWebm(const std::string& init_data_type);
// Session related methods // Session related methods
virtual CdmResponseType OpenSession( virtual CdmResponseType OpenSession(const CdmKeySystem& key_system,
const CdmKeySystem& key_system, CdmClientPropertySet* property_set,
CdmClientPropertySet* property_set, WvCdmEventListener* event_listener,
CdmSessionId* session_id); CdmSessionId* session_id);
virtual CdmResponseType CloseSession(const CdmSessionId& session_id); virtual CdmResponseType CloseSession(const CdmSessionId& session_id);
// Construct a valid license request. // Construct a valid license request.
@@ -103,12 +103,6 @@ class WvContentDecryptionModule : public TimerHandler {
bool validate_key_id, bool validate_key_id,
const CdmDecryptionParameters& parameters); const CdmDecryptionParameters& parameters);
// Event listener related methods
virtual bool AttachEventListener(const CdmSessionId& session_id,
WvCdmEventListener* listener);
virtual bool DetachEventListener(const CdmSessionId& session_id,
WvCdmEventListener* listener);
virtual void NotifyResolution(const CdmSessionId& session_id, uint32_t width, virtual void NotifyResolution(const CdmSessionId& session_id, uint32_t width,
uint32_t height); uint32_t height);

View File

@@ -38,16 +38,16 @@ bool WvContentDecryptionModule::IsWebm(const std::string& init_data_type) {
} }
CdmResponseType WvContentDecryptionModule::OpenSession( CdmResponseType WvContentDecryptionModule::OpenSession(
const CdmKeySystem& key_system, const CdmKeySystem& key_system, CdmClientPropertySet* property_set,
CdmClientPropertySet* property_set, WvCdmEventListener* event_listener, CdmSessionId* session_id) {
CdmSessionId* session_id) {
if (property_set && property_set->is_session_sharing_enabled()) { if (property_set && property_set->is_session_sharing_enabled()) {
AutoLock auto_lock(session_sharing_id_generation_lock_); AutoLock auto_lock(session_sharing_id_generation_lock_);
if (property_set->session_sharing_id() == 0) if (property_set->session_sharing_id() == 0)
property_set->set_session_sharing_id(GenerateSessionSharingId()); property_set->set_session_sharing_id(GenerateSessionSharingId());
} }
return cdm_engine_->OpenSession(key_system, property_set, session_id); return cdm_engine_->OpenSession(key_system, property_set, event_listener,
session_id);
} }
CdmResponseType WvContentDecryptionModule::CloseSession( CdmResponseType WvContentDecryptionModule::CloseSession(
@@ -69,9 +69,8 @@ CdmResponseType WvContentDecryptionModule::GenerateKeyRequest(
std::string* server_url) { std::string* server_url) {
CdmResponseType sts; CdmResponseType sts;
if (license_type == kLicenseTypeRelease) { if (license_type == kLicenseTypeRelease) {
sts = cdm_engine_->OpenKeySetSession(key_set_id, property_set); sts = cdm_engine_->OpenKeySetSession(key_set_id, property_set, NULL);
if (sts != NO_ERROR) if (sts != NO_ERROR) return sts;
return sts;
} }
InitializationData initialization_data(init_data_type, init_data); InitializationData initialization_data(init_data_type, init_data);
sts = cdm_engine_->GenerateKeyRequest(session_id, key_set_id, sts = cdm_engine_->GenerateKeyRequest(session_id, key_set_id,
@@ -195,16 +194,6 @@ CdmResponseType WvContentDecryptionModule::Decrypt(
return cdm_engine_->Decrypt(local_session_id, parameters); return cdm_engine_->Decrypt(local_session_id, parameters);
} }
bool WvContentDecryptionModule::AttachEventListener(
const CdmSessionId& session_id, WvCdmEventListener* listener) {
return cdm_engine_->AttachEventListener(session_id, listener);
}
bool WvContentDecryptionModule::DetachEventListener(
const CdmSessionId& session_id, WvCdmEventListener* listener) {
return cdm_engine_->DetachEventListener(session_id, listener);
}
void WvContentDecryptionModule::NotifyResolution(const CdmSessionId& session_id, void WvContentDecryptionModule::NotifyResolution(const CdmSessionId& session_id,
uint32_t width, uint32_t width,
uint32_t height) { uint32_t height) {

View File

@@ -406,7 +406,7 @@ class WvCdmExtendedDurationTest : public testing::Test {
void Provision() { void Provision() {
CdmResponseType status = CdmResponseType status =
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
switch (status) { switch (status) {
case NO_ERROR: case NO_ERROR:
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
@@ -654,7 +654,7 @@ class WvCdmExtendedDurationTest : public testing::Test {
} }
std::string GetSecurityLevel(TestWvCdmClientPropertySet* property_set) { std::string GetSecurityLevel(TestWvCdmClientPropertySet* property_set) {
decryptor_.OpenSession(g_key_system, property_set, &session_id_); decryptor_.OpenSession(g_key_system, property_set, NULL, &session_id_);
CdmQueryMap query_info; CdmQueryMap query_info;
EXPECT_EQ(wvcdm::NO_ERROR, EXPECT_EQ(wvcdm::NO_ERROR,
decryptor_.QuerySessionStatus(session_id_, &query_info)); decryptor_.QuerySessionStatus(session_id_, &query_info));
@@ -688,7 +688,7 @@ class WvCdmExtendedDurationTest : public testing::Test {
TEST_F(WvCdmExtendedDurationTest, VerifyLicenseRequestTest) { TEST_F(WvCdmExtendedDurationTest, VerifyLicenseRequestTest) {
Provision(); Provision();
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming); GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
EXPECT_TRUE(!key_msg_.empty()); EXPECT_TRUE(!key_msg_.empty());
@@ -756,7 +756,7 @@ TEST_F(WvCdmExtendedDurationTest, VerifyLicenseRequestTest) {
TEST_F(WvCdmExtendedDurationTest, VerifyLicenseRenewalTest) { TEST_F(WvCdmExtendedDurationTest, VerifyLicenseRenewalTest) {
Provision(); Provision();
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming); GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false); VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
@@ -848,7 +848,7 @@ TEST_F(WvCdmExtendedDurationTest, UsageOverflowTest) {
EXPECT_TRUE(handle.DeleteAllUsageInfoForApp("", &provider_session_tokens)); EXPECT_TRUE(handle.DeleteAllUsageInfoForApp("", &provider_session_tokens));
for (size_t i = 0; i < kMaxUsageTableSize + 100; ++i) { for (size_t i = 0; i < kMaxUsageTableSize + 100; ++i) {
decryptor_.OpenSession(g_key_system, property_set, &session_id_); decryptor_.OpenSession(g_key_system, property_set, NULL, &session_id_);
std::string key_id = a2bs_hex( std::string key_id = a2bs_hex(
"000000427073736800000000" // blob size and pssh "000000427073736800000000" // blob size and pssh
"EDEF8BA979D64ACEA3C827DCD51D21ED00000022" // Widevine system id "EDEF8BA979D64ACEA3C827DCD51D21ED00000022" // Widevine system id
@@ -888,7 +888,7 @@ TEST_P(WvCdmStreamingNoPstTest, UsageTest) {
Unprovision(); Unprovision();
Provision(); Provision();
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming); GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false); VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
@@ -967,7 +967,7 @@ TEST_P(WvCdmStreamingPstTest, UsageTest) {
Unprovision(); Unprovision();
Provision(); Provision();
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(kStreamingClip1PstInitData, kLicenseTypeStreaming); GenerateKeyRequest(kStreamingClip1PstInitData, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false); VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
@@ -1046,7 +1046,7 @@ TEST_P(WvCdmStreamingUsageReportTest, UsageTest) {
Unprovision(); Unprovision();
Provision(); Provision();
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(kStreamingClip1PstInitData, kLicenseTypeStreaming); GenerateKeyRequest(kStreamingClip1PstInitData, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false); VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
@@ -1147,7 +1147,7 @@ TEST_P(WvCdmOfflineUsageReportTest, UsageTest) {
Unprovision(); Unprovision();
Provision(); Provision();
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(kOfflineClip2PstInitData, kLicenseTypeOffline); GenerateKeyRequest(kOfflineClip2PstInitData, kLicenseTypeOffline);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false); VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
@@ -1170,7 +1170,7 @@ TEST_P(WvCdmOfflineUsageReportTest, UsageTest) {
for (size_t i = 0; i < GetParam(); ++i) { for (size_t i = 0; i < GetParam(); ++i) {
session_id_.clear(); session_id_.clear();
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id)); EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id));
// Query and validate usage information // Query and validate usage information
@@ -1217,7 +1217,7 @@ TEST_P(WvCdmOfflineUsageReportTest, UsageTest) {
} }
session_id_.clear(); session_id_.clear();
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id)); EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id));
// Query and validate usage information // Query and validate usage information

View File

@@ -636,7 +636,7 @@ class WvCdmRequestLicenseTest : public testing::Test {
} }
CdmResponseType status = CdmResponseType status =
decryptor_.OpenSession(g_key_system, property_set, &session_id_); decryptor_.OpenSession(g_key_system, property_set, NULL, &session_id_);
switch (status) { switch (status) {
case NO_ERROR: case NO_ERROR:
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
@@ -670,8 +670,8 @@ class WvCdmRequestLicenseTest : public testing::Test {
} }
std::string GetSecurityLevel(TestWvCdmClientPropertySet* property_set) { std::string GetSecurityLevel(TestWvCdmClientPropertySet* property_set) {
EXPECT_EQ(NO_ERROR, EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, property_set, NULL,
decryptor_.OpenSession(g_key_system, property_set, &session_id_)); &session_id_));
CdmQueryMap query_info; CdmQueryMap query_info;
EXPECT_EQ(wvcdm::NO_ERROR, EXPECT_EQ(wvcdm::NO_ERROR,
decryptor_.QuerySessionStatus(session_id_, &query_info)); decryptor_.QuerySessionStatus(session_id_, &query_info));
@@ -707,7 +707,7 @@ class WvCdmRequestLicenseTest : public testing::Test {
}; };
TEST_F(WvCdmRequestLicenseTest, ProvisioningTest) { TEST_F(WvCdmRequestLicenseTest, ProvisioningTest) {
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
std::string provisioning_server_url; std::string provisioning_server_url;
CdmCertificateType cert_type = kCertificateWidevine; CdmCertificateType cert_type = kCertificateWidevine;
std::string cert_authority, cert, wrapped_key; std::string cert_authority, cert, wrapped_key;
@@ -742,7 +742,7 @@ TEST_F(WvCdmRequestLicenseTest, UnprovisionTest) {
} }
TEST_F(WvCdmRequestLicenseTest, ProvisioningRetryTest) { TEST_F(WvCdmRequestLicenseTest, ProvisioningRetryTest) {
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
std::string provisioning_server_url; std::string provisioning_server_url;
CdmCertificateType cert_type = kCertificateWidevine; CdmCertificateType cert_type = kCertificateWidevine;
std::string cert_authority, cert, wrapped_key; std::string cert_authority, cert, wrapped_key;
@@ -776,7 +776,7 @@ TEST_F(WvCdmRequestLicenseTest, ProvisioningRetryTest) {
} }
TEST_F(WvCdmRequestLicenseTest, DISABLED_X509ProvisioningTest) { TEST_F(WvCdmRequestLicenseTest, DISABLED_X509ProvisioningTest) {
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
std::string provisioning_server_url; std::string provisioning_server_url;
CdmCertificateType cert_type = kCertificateX509; CdmCertificateType cert_type = kCertificateX509;
// TODO(rfrias): insert appropriate CA here // TODO(rfrias): insert appropriate CA here
@@ -808,12 +808,12 @@ TEST_F(WvCdmRequestLicenseTest, PropertySetTest) {
property_set_L1.set_security_level(QUERY_VALUE_SECURITY_LEVEL_L1); property_set_L1.set_security_level(QUERY_VALUE_SECURITY_LEVEL_L1);
property_set_L1.set_use_privacy_mode(true); property_set_L1.set_use_privacy_mode(true);
decryptor_.OpenSession(g_key_system, &property_set_L1, &session_id_L1); decryptor_.OpenSession(g_key_system, &property_set_L1, NULL, &session_id_L1);
property_set_L3.set_security_level(QUERY_VALUE_SECURITY_LEVEL_L3); property_set_L3.set_security_level(QUERY_VALUE_SECURITY_LEVEL_L3);
property_set_L3.set_use_privacy_mode(false); property_set_L3.set_use_privacy_mode(false);
CdmResponseType sts = CdmResponseType sts = decryptor_.OpenSession(g_key_system, &property_set_L3,
decryptor_.OpenSession(g_key_system, &property_set_L3, &session_id_L3); NULL, &session_id_L3);
if (NEED_PROVISIONING == sts) { if (NEED_PROVISIONING == sts) {
std::string provisioning_server_url; std::string provisioning_server_url;
@@ -829,13 +829,13 @@ TEST_F(WvCdmRequestLicenseTest, PropertySetTest) {
EXPECT_EQ(NO_ERROR, decryptor_.HandleProvisioningResponse(response, &cert, EXPECT_EQ(NO_ERROR, decryptor_.HandleProvisioningResponse(response, &cert,
&wrapped_key)); &wrapped_key));
EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, &property_set_L3, EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, &property_set_L3,
&session_id_L3)); NULL, &session_id_L3));
} else { } else {
EXPECT_EQ(NO_ERROR, sts); EXPECT_EQ(NO_ERROR, sts);
} }
property_set_Ln.set_security_level(""); property_set_Ln.set_security_level("");
decryptor_.OpenSession(g_key_system, &property_set_Ln, &session_id_Ln); decryptor_.OpenSession(g_key_system, &property_set_Ln, NULL, &session_id_Ln);
std::string security_level; std::string security_level;
EXPECT_TRUE(Properties::GetSecurityLevel(session_id_L1, &security_level)); EXPECT_TRUE(Properties::GetSecurityLevel(session_id_L1, &security_level));
@@ -874,8 +874,9 @@ TEST_F(WvCdmRequestLicenseTest, ForceL3Test) {
handle.SetTestFile(&file); handle.SetTestFile(&file);
EXPECT_TRUE(handle.DeleteAllFiles()); EXPECT_TRUE(handle.DeleteAllFiles());
EXPECT_EQ(NEED_PROVISIONING, EXPECT_EQ(
decryptor_.OpenSession(g_key_system, &property_set, &session_id_)); NEED_PROVISIONING,
decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_));
std::string provisioning_server_url; std::string provisioning_server_url;
CdmCertificateType cert_type = kCertificateWidevine; CdmCertificateType cert_type = kCertificateWidevine;
std::string cert_authority, cert, wrapped_key; std::string cert_authority, cert, wrapped_key;
@@ -889,8 +890,8 @@ TEST_F(WvCdmRequestLicenseTest, ForceL3Test) {
EXPECT_EQ(NO_ERROR, decryptor_.HandleProvisioningResponse(response, &cert, EXPECT_EQ(NO_ERROR, decryptor_.HandleProvisioningResponse(response, &cert,
&wrapped_key)); &wrapped_key));
EXPECT_EQ(NO_ERROR, EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, &property_set, NULL,
decryptor_.OpenSession(g_key_system, &property_set, &session_id_)); &session_id_));
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming); GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false); VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
@@ -900,7 +901,7 @@ TEST_F(WvCdmRequestLicenseTest, PrivacyModeTest) {
TestWvCdmClientPropertySet property_set; TestWvCdmClientPropertySet property_set;
property_set.set_use_privacy_mode(true); property_set.set_use_privacy_mode(true);
decryptor_.OpenSession(g_key_system, &property_set, &session_id_); decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_);
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming); GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
std::string resp = GetKeyRequestResponse(g_license_server, g_client_auth); std::string resp = GetKeyRequestResponse(g_license_server, g_client_auth);
@@ -916,21 +917,21 @@ TEST_F(WvCdmRequestLicenseTest, PrivacyModeWithServiceCertificateTest) {
property_set.set_use_privacy_mode(true); property_set.set_use_privacy_mode(true);
property_set.set_service_certificate(a2bs_hex(kServiceCertificate)); property_set.set_service_certificate(a2bs_hex(kServiceCertificate));
decryptor_.OpenSession(g_key_system, &property_set, &session_id_); decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_);
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming); GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false); VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
} }
TEST_F(WvCdmRequestLicenseTest, BaseMessageTest) { TEST_F(WvCdmRequestLicenseTest, BaseMessageTest) {
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming); GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
GetKeyRequestResponse(g_license_server, g_client_auth); GetKeyRequestResponse(g_license_server, g_client_auth);
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
} }
TEST_F(WvCdmRequestLicenseTest, WrongMessageTest) { TEST_F(WvCdmRequestLicenseTest, WrongMessageTest) {
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
std::string wrong_message = wvcdm::a2bs_hex(g_wrong_key_id); std::string wrong_message = wvcdm::a2bs_hex(g_wrong_key_id);
GenerateKeyRequest(wrong_message, kLicenseTypeStreaming); GenerateKeyRequest(wrong_message, kLicenseTypeStreaming);
@@ -958,7 +959,7 @@ TEST_F(WvCdmRequestLicenseTest, WrongMessageTest) {
} }
TEST_F(WvCdmRequestLicenseTest, AddStreamingKeyTest) { TEST_F(WvCdmRequestLicenseTest, AddStreamingKeyTest) {
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming); GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false); VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
@@ -973,7 +974,7 @@ TEST_F(WvCdmRequestLicenseTest, AddKeyOfflineTest) {
std::string client_auth; std::string client_auth;
GetOfflineConfiguration(&key_id, &client_auth); GetOfflineConfiguration(&key_id, &client_auth);
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(key_id, kLicenseTypeOffline); GenerateKeyRequest(key_id, kLicenseTypeOffline);
VerifyKeyRequestResponse(g_license_server, client_auth, false); VerifyKeyRequestResponse(g_license_server, client_auth, false);
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
@@ -988,7 +989,7 @@ TEST_F(WvCdmRequestLicenseTest, RestoreOfflineKeyTest) {
std::string client_auth; std::string client_auth;
GetOfflineConfiguration(&key_id, &client_auth); GetOfflineConfiguration(&key_id, &client_auth);
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(key_id, kLicenseTypeOffline); GenerateKeyRequest(key_id, kLicenseTypeOffline);
VerifyKeyRequestResponse(g_license_server, client_auth, false); VerifyKeyRequestResponse(g_license_server, client_auth, false);
@@ -997,7 +998,7 @@ TEST_F(WvCdmRequestLicenseTest, RestoreOfflineKeyTest) {
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
session_id_.clear(); session_id_.clear();
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id)); EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id));
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
} }
@@ -1011,7 +1012,7 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseOfflineKeyTest) {
std::string client_auth; std::string client_auth;
GetOfflineConfiguration(&key_id, &client_auth); GetOfflineConfiguration(&key_id, &client_auth);
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(key_id, kLicenseTypeOffline); GenerateKeyRequest(key_id, kLicenseTypeOffline);
VerifyKeyRequestResponse(g_license_server, client_auth, false); VerifyKeyRequestResponse(g_license_server, client_auth, false);
@@ -1021,7 +1022,7 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseOfflineKeyTest) {
session_id_.clear(); session_id_.clear();
key_set_id_.clear(); key_set_id_.clear();
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id)); EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id));
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
@@ -1041,7 +1042,7 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseRetryOfflineKeyTest) {
std::string client_auth; std::string client_auth;
GetOfflineConfiguration(&key_id, &client_auth); GetOfflineConfiguration(&key_id, &client_auth);
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(key_id, kLicenseTypeOffline); GenerateKeyRequest(key_id, kLicenseTypeOffline);
VerifyKeyRequestResponse(g_license_server, client_auth, false); VerifyKeyRequestResponse(g_license_server, client_auth, false);
@@ -1051,7 +1052,7 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseRetryOfflineKeyTest) {
session_id_.clear(); session_id_.clear();
key_set_id_.clear(); key_set_id_.clear();
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id)); EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id));
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
@@ -1060,7 +1061,7 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseRetryOfflineKeyTest) {
GenerateKeyRelease(key_set_id); GenerateKeyRelease(key_set_id);
session_id_.clear(); session_id_.clear();
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
EXPECT_EQ(wvcdm::UNKNOWN_ERROR, decryptor_.RestoreKey(session_id_, key_set_id)); EXPECT_EQ(wvcdm::UNKNOWN_ERROR, decryptor_.RestoreKey(session_id_, key_set_id));
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
@@ -1083,7 +1084,7 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseRetryL3OfflineKeyTest) {
GetOfflineConfiguration(&key_id, &client_auth); GetOfflineConfiguration(&key_id, &client_auth);
CdmResponseType sts = CdmResponseType sts =
decryptor_.OpenSession(g_key_system, &property_set, &session_id_); decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_);
if (NEED_PROVISIONING == sts) { if (NEED_PROVISIONING == sts) {
std::string provisioning_server_url; std::string provisioning_server_url;
@@ -1099,12 +1100,12 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseRetryL3OfflineKeyTest) {
EXPECT_EQ(NO_ERROR, decryptor_.HandleProvisioningResponse(response, &cert, EXPECT_EQ(NO_ERROR, decryptor_.HandleProvisioningResponse(response, &cert,
&wrapped_key)); &wrapped_key));
EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, &property_set, EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, &property_set,
&session_id_)); NULL, &session_id_));
} else { } else {
EXPECT_EQ(NO_ERROR, sts); EXPECT_EQ(NO_ERROR, sts);
} }
decryptor_.OpenSession(g_key_system, &property_set, &session_id_); decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_);
GenerateKeyRequest(key_id, kLicenseTypeOffline, &property_set); GenerateKeyRequest(key_id, kLicenseTypeOffline, &property_set);
VerifyKeyRequestResponse(g_license_server, client_auth, false); VerifyKeyRequestResponse(g_license_server, client_auth, false);
@@ -1114,7 +1115,7 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseRetryL3OfflineKeyTest) {
session_id_.clear(); session_id_.clear();
key_set_id_.clear(); key_set_id_.clear();
decryptor_.OpenSession(g_key_system, &property_set, &session_id_); decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_);
EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id)); EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id));
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
@@ -1123,7 +1124,7 @@ TEST_F(WvCdmRequestLicenseTest, ReleaseRetryL3OfflineKeyTest) {
GenerateKeyRelease(key_set_id, &property_set); GenerateKeyRelease(key_set_id, &property_set);
session_id_.clear(); session_id_.clear();
decryptor_.OpenSession(g_key_system, &property_set, &session_id_); decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_);
EXPECT_EQ( EXPECT_EQ(
wvcdm::UNKNOWN_ERROR, decryptor_.RestoreKey(session_id_, key_set_id)); wvcdm::UNKNOWN_ERROR, decryptor_.RestoreKey(session_id_, key_set_id));
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
@@ -1144,7 +1145,7 @@ TEST_F(WvCdmRequestLicenseTest, ExpiryOnReleaseOfflineKeyTest) {
std::string client_auth; std::string client_auth;
GetOfflineConfiguration(&key_id, &client_auth); GetOfflineConfiguration(&key_id, &client_auth);
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(key_id, kLicenseTypeOffline); GenerateKeyRequest(key_id, kLicenseTypeOffline);
VerifyKeyRequestResponse(g_license_server, client_auth, false); VerifyKeyRequestResponse(g_license_server, client_auth, false);
@@ -1154,10 +1155,9 @@ TEST_F(WvCdmRequestLicenseTest, ExpiryOnReleaseOfflineKeyTest) {
session_id_.clear(); session_id_.clear();
key_set_id_.clear(); key_set_id_.clear();
decryptor_.OpenSession(g_key_system, NULL, &session_id_);
CdmSessionId restore_session_id = session_id_;
TestWvCdmEventListener listener; TestWvCdmEventListener listener;
EXPECT_TRUE(decryptor_.AttachEventListener(restore_session_id, &listener)); decryptor_.OpenSession(g_key_system, NULL, &listener, &session_id_);
CdmSessionId restore_session_id = session_id_;
EXPECT_EQ(wvcdm::KEY_ADDED, EXPECT_EQ(wvcdm::KEY_ADDED,
decryptor_.RestoreKey(restore_session_id, key_set_id)); decryptor_.RestoreKey(restore_session_id, key_set_id));
@@ -1174,7 +1174,7 @@ TEST_F(WvCdmRequestLicenseTest, ExpiryOnReleaseOfflineKeyTest) {
} }
TEST_F(WvCdmRequestLicenseTest, StreamingLicenseRenewal) { TEST_F(WvCdmRequestLicenseTest, StreamingLicenseRenewal) {
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming); GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false); VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
@@ -1191,7 +1191,7 @@ TEST_F(WvCdmRequestLicenseTest, OfflineLicenseRenewal) {
std::string client_auth; std::string client_auth;
GetOfflineConfiguration(&key_id, &client_auth); GetOfflineConfiguration(&key_id, &client_auth);
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(key_id, kLicenseTypeOffline); GenerateKeyRequest(key_id, kLicenseTypeOffline);
VerifyKeyRequestResponse(g_license_server, client_auth, false); VerifyKeyRequestResponse(g_license_server, client_auth, false);
@@ -1203,7 +1203,8 @@ TEST_F(WvCdmRequestLicenseTest, OfflineLicenseRenewal) {
} }
TEST_F(WvCdmRequestLicenseTest, RemoveKeys) { TEST_F(WvCdmRequestLicenseTest, RemoveKeys) {
ASSERT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, NULL, &session_id_)); ASSERT_EQ(NO_ERROR,
decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_));
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming); GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false); VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
ASSERT_EQ(NO_ERROR, decryptor_.RemoveKeys(session_id_)); ASSERT_EQ(NO_ERROR, decryptor_.RemoveKeys(session_id_));
@@ -1224,7 +1225,7 @@ TEST_F(WvCdmRequestLicenseTest, UsageInfoRetryTest) {
EXPECT_TRUE(handle.DeleteAllUsageInfoForApp(app_id, &psts)); EXPECT_TRUE(handle.DeleteAllUsageInfoForApp(app_id, &psts));
SubSampleInfo* data = &usage_info_sub_samples_icp[0]; SubSampleInfo* data = &usage_info_sub_samples_icp[0];
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
std::string key_id = a2bs_hex( std::string key_id = a2bs_hex(
"000000427073736800000000" // blob size and pssh "000000427073736800000000" // blob size and pssh
"EDEF8BA979D64ACEA3C827DCD51D21ED00000022" // Widevine system id "EDEF8BA979D64ACEA3C827DCD51D21ED00000022" // Widevine system id
@@ -1302,7 +1303,7 @@ TEST_P(WvCdmUsageInfoTest, UsageInfo) {
for (size_t i = 0; i < usage_info_data->usage_info; ++i) { for (size_t i = 0; i < usage_info_data->usage_info; ++i) {
SubSampleInfo* data = usage_info_data->sub_sample + i; SubSampleInfo* data = usage_info_data->sub_sample + i;
decryptor_.OpenSession(g_key_system, property_set, &session_id_); decryptor_.OpenSession(g_key_system, property_set, NULL, &session_id_);
std::string key_id = a2bs_hex( std::string key_id = a2bs_hex(
"000000427073736800000000" // blob size and pssh "000000427073736800000000" // blob size and pssh
"EDEF8BA979D64ACEA3C827DCD51D21ED00000022" // Widevine system id "EDEF8BA979D64ACEA3C827DCD51D21ED00000022" // Widevine system id
@@ -1378,7 +1379,7 @@ TEST_F(WvCdmRequestLicenseTest, QueryModifiedSessionStatus) {
} }
TEST_F(WvCdmRequestLicenseTest, QueryKeyStatus) { TEST_F(WvCdmRequestLicenseTest, QueryKeyStatus) {
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming); GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false); VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
@@ -1448,7 +1449,7 @@ TEST_F(WvCdmRequestLicenseTest, QueryStatus) {
} }
TEST_F(WvCdmRequestLicenseTest, QueryKeyControlInfo) { TEST_F(WvCdmRequestLicenseTest, QueryKeyControlInfo) {
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming); GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false); VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
@@ -1510,7 +1511,7 @@ TEST_F(WvCdmRequestLicenseTest, SecurityLevelPathBackwardCompatibility) {
file.Remove(path); file.Remove(path);
} }
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
std::string provisioning_server_url; std::string provisioning_server_url;
CdmCertificateType cert_type = kCertificateWidevine; CdmCertificateType cert_type = kCertificateWidevine;
std::string cert_authority, cert, wrapped_key; std::string cert_authority, cert, wrapped_key;
@@ -1529,7 +1530,7 @@ TEST_F(WvCdmRequestLicenseTest, SecurityLevelPathBackwardCompatibility) {
EXPECT_TRUE(file.List(base_path, &files)); EXPECT_TRUE(file.List(base_path, &files));
size_t number_of_files = files.size(); size_t number_of_files = files.size();
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(key_id, kLicenseTypeOffline); GenerateKeyRequest(key_id, kLicenseTypeOffline);
VerifyKeyRequestResponse(g_license_server, client_auth, false); VerifyKeyRequestResponse(g_license_server, client_auth, false);
CdmKeySetId key_set_id = key_set_id_; CdmKeySetId key_set_id = key_set_id_;
@@ -1555,11 +1556,11 @@ TEST_F(WvCdmRequestLicenseTest, SecurityLevelPathBackwardCompatibility) {
// Setup complete to earlier version (non-security level based) path. // Setup complete to earlier version (non-security level based) path.
// Restore persistent license, retrieve L1, L3 streaming licenses to verify // Restore persistent license, retrieve L1, L3 streaming licenses to verify
session_id_.clear(); session_id_.clear();
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id)); EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id));
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming); GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, client_auth, false); VerifyKeyRequestResponse(g_license_server, client_auth, false);
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
@@ -1569,8 +1570,8 @@ TEST_F(WvCdmRequestLicenseTest, SecurityLevelPathBackwardCompatibility) {
TestWvCdmClientPropertySet property_set; TestWvCdmClientPropertySet property_set;
property_set.set_security_level(QUERY_VALUE_SECURITY_LEVEL_L3); property_set.set_security_level(QUERY_VALUE_SECURITY_LEVEL_L3);
EXPECT_EQ(NO_ERROR, EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, &property_set, NULL,
decryptor_.OpenSession(g_key_system, &property_set, &session_id_)); &session_id_));
wvcdm::CdmAppParameterMap app_parameters; wvcdm::CdmAppParameterMap app_parameters;
std::string server_url; std::string server_url;
@@ -1589,15 +1590,15 @@ TEST_F(WvCdmRequestLicenseTest, SecurityLevelPathBackwardCompatibility) {
EXPECT_EQ(NO_ERROR, decryptor_.HandleProvisioningResponse(response, &cert, EXPECT_EQ(NO_ERROR, decryptor_.HandleProvisioningResponse(response, &cert,
&wrapped_key)); &wrapped_key));
EXPECT_EQ(NO_ERROR, EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, &property_set, NULL,
decryptor_.OpenSession(g_key_system, &property_set, &session_id_)); &session_id_));
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming); GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, client_auth, false); VerifyKeyRequestResponse(g_license_server, client_auth, false);
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
} }
TEST_F(WvCdmRequestLicenseTest, DISABLED_OfflineLicenseDecryptionTest) { TEST_F(WvCdmRequestLicenseTest, DISABLED_OfflineLicenseDecryptionTest) {
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(g_key_id, kLicenseTypeOffline); GenerateKeyRequest(g_key_id, kLicenseTypeOffline);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false); VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
@@ -1650,7 +1651,7 @@ TEST_F(WvCdmRequestLicenseTest, DISABLED_OfflineLicenseDecryptionTest) {
} }
TEST_F(WvCdmRequestLicenseTest, DISABLED_RestoreOfflineLicenseDecryptionTest) { TEST_F(WvCdmRequestLicenseTest, DISABLED_RestoreOfflineLicenseDecryptionTest) {
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
GenerateKeyRequest(g_key_id, kLicenseTypeOffline); GenerateKeyRequest(g_key_id, kLicenseTypeOffline);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false); VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
CdmKeySetId key_set_id = key_set_id_; CdmKeySetId key_set_id = key_set_id_;
@@ -1658,7 +1659,7 @@ TEST_F(WvCdmRequestLicenseTest, DISABLED_RestoreOfflineLicenseDecryptionTest) {
decryptor_.CloseSession(session_id_); decryptor_.CloseSession(session_id_);
session_id_.clear(); session_id_.clear();
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id)); EXPECT_EQ(wvcdm::KEY_ADDED, decryptor_.RestoreKey(session_id_, key_set_id));
/* /*
// key 1, encrypted, 256b // key 1, encrypted, 256b
@@ -1775,7 +1776,7 @@ TEST_P(WvCdmSessionSharingTest, SessionSharingTest) {
property_set.set_session_sharing_mode( property_set.set_session_sharing_mode(
session_sharing_info->session_sharing_enabled); session_sharing_info->session_sharing_enabled);
decryptor_.OpenSession(g_key_system, &property_set, &session_id_); decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_);
CdmSessionId gp_session_id_1 = session_id_; CdmSessionId gp_session_id_1 = session_id_;
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming); GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false); VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
@@ -1788,7 +1789,7 @@ TEST_P(WvCdmSessionSharingTest, SessionSharingTest) {
"edef8ba979d64acea3c827dcd51d21ed00000014" // Widevine system id "edef8ba979d64acea3c827dcd51d21ed00000014" // Widevine system id
"08011210bdf1cb4fffc6506b8b7945b0bd2917fb"); // pssh data "08011210bdf1cb4fffc6506b8b7945b0bd2917fb"); // pssh data
decryptor_.OpenSession(g_key_system, &property_set, &session_id_); decryptor_.OpenSession(g_key_system, &property_set, NULL, &session_id_);
CdmSessionId gp_session_id_2 = session_id_; CdmSessionId gp_session_id_2 = session_id_;
GenerateKeyRequest(gp_key_id2, kLicenseTypeStreaming); GenerateKeyRequest(gp_key_id2, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, gp_client_auth2, false); VerifyKeyRequestResponse(g_license_server, gp_client_auth2, false);
@@ -1823,7 +1824,7 @@ TEST_F(WvCdmRequestLicenseTest, DecryptionKeyExpiredTest) {
"EDEF8BA979D64ACEA3C827DCD51D21ED00000014" // Widevine system id "EDEF8BA979D64ACEA3C827DCD51D21ED00000014" // Widevine system id
"0801121030313233343536373839616263646566"); // pssh data "0801121030313233343536373839616263646566"); // pssh data
SubSampleInfo* data = &single_encrypted_sub_sample_short_expiry; SubSampleInfo* data = &single_encrypted_sub_sample_short_expiry;
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
if (data->retrieve_key) { if (data->retrieve_key) {
GenerateKeyRequest(kCpKeyId, kLicenseTypeStreaming); GenerateKeyRequest(kCpKeyId, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false); VerifyKeyRequestResponse(g_license_server, g_client_auth, false);
@@ -1853,7 +1854,7 @@ class WvCdmDecryptionTest
TEST_P(WvCdmDecryptionTest, DecryptionTest) { TEST_P(WvCdmDecryptionTest, DecryptionTest) {
SubSampleInfo* data = GetParam(); SubSampleInfo* data = GetParam();
decryptor_.OpenSession(g_key_system, NULL, &session_id_); decryptor_.OpenSession(g_key_system, NULL, NULL, &session_id_);
if (data->retrieve_key) { if (data->retrieve_key) {
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming); GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
VerifyKeyRequestResponse(g_license_server, g_client_auth, false); VerifyKeyRequestResponse(g_license_server, g_client_auth, false);

View File

@@ -42,13 +42,6 @@ WVDrmPlugin::~WVDrmPlugin() {
for (mapIterator iter = mCryptoSessions.begin(); for (mapIterator iter = mCryptoSessions.begin();
iter != mCryptoSessions.end(); iter != mCryptoSessions.end();
++iter) { ++iter) {
bool bRes = mCDM->DetachEventListener(iter->first, this);
if (!bRes) {
ALOGE("Received failure when trying to detach WVDrmPlugin as an event "
"listener.");
}
CdmResponseType res = mCDM->CloseSession(iter->first); CdmResponseType res = mCDM->CloseSession(iter->first);
if (!isCdmResponseTypeSuccess(res)) { if (!isCdmResponseTypeSuccess(res)) {
ALOGE("Failed to close session while destroying WVDrmPlugin"); ALOGE("Failed to close session while destroying WVDrmPlugin");
@@ -59,8 +52,8 @@ WVDrmPlugin::~WVDrmPlugin() {
status_t WVDrmPlugin::openSession(Vector<uint8_t>& sessionId) { status_t WVDrmPlugin::openSession(Vector<uint8_t>& sessionId) {
CdmSessionId cdmSessionId; CdmSessionId cdmSessionId;
CdmResponseType res = mCDM->OpenSession("com.widevine", &mPropertySet, CdmResponseType res =
&cdmSessionId); mCDM->OpenSession("com.widevine", &mPropertySet, this, &cdmSessionId);
if (!isCdmResponseTypeSuccess(res)) { if (!isCdmResponseTypeSuccess(res)) {
return mapAndNotifyOfCdmResponseType(sessionId, res); return mapAndNotifyOfCdmResponseType(sessionId, res);
@@ -68,32 +61,23 @@ status_t WVDrmPlugin::openSession(Vector<uint8_t>& sessionId) {
bool success = false; bool success = false;
// Register for events // Construct a CryptoSession
bool listenerAttached = mCDM->AttachEventListener(cdmSessionId, this); CdmQueryMap info;
res = mCDM->QueryKeyControlInfo(cdmSessionId, &info);
if (listenerAttached) { if (isCdmResponseTypeSuccess(res) &&
// Construct a CryptoSession info.count(QUERY_KEY_OEMCRYPTO_SESSION_ID)) {
CdmQueryMap info; OEMCrypto_SESSION oecSessionId;
istringstream(info[QUERY_KEY_OEMCRYPTO_SESSION_ID]) >> oecSessionId;
res = mCDM->QueryKeyControlInfo(cdmSessionId, &info); {
Mutex::Autolock lock(mCryptoSessionsMutex);
if (isCdmResponseTypeSuccess(res) && mCryptoSessions[cdmSessionId] = CryptoSession(oecSessionId);
info.count(QUERY_KEY_OEMCRYPTO_SESSION_ID)) {
OEMCrypto_SESSION oecSessionId;
istringstream(info[QUERY_KEY_OEMCRYPTO_SESSION_ID]) >> oecSessionId;
{
Mutex::Autolock lock(mCryptoSessionsMutex);
mCryptoSessions[cdmSessionId] = CryptoSession(oecSessionId);
}
success = true;
} else {
ALOGE("Unable to query key control info.");
} }
success = true;
} else { } else {
ALOGE("Received failure when trying to attach WVDrmPlugin as an event" ALOGE("Unable to query key control info.");
"listener.");
} }
if (success) { if (success) {
@@ -104,10 +88,6 @@ status_t WVDrmPlugin::openSession(Vector<uint8_t>& sessionId) {
return android::OK; return android::OK;
} else { } else {
if (listenerAttached) {
mCDM->DetachEventListener(cdmSessionId, this);
}
mCDM->CloseSession(cdmSessionId); mCDM->CloseSession(cdmSessionId);
if (!isCdmResponseTypeSuccess(res)) { if (!isCdmResponseTypeSuccess(res)) {

View File

@@ -26,8 +26,9 @@ using namespace wvdrm;
class MockCDM : public WvContentDecryptionModule { class MockCDM : public WvContentDecryptionModule {
public: public:
MOCK_METHOD3(OpenSession, CdmResponseType(const CdmKeySystem&, MOCK_METHOD4(OpenSession, CdmResponseType(const CdmKeySystem&,
CdmClientPropertySet*, CdmClientPropertySet*,
WvCdmEventListener*,
CdmSessionId*)); CdmSessionId*));
MOCK_METHOD1(CloseSession, CdmResponseType(const CdmSessionId&)); MOCK_METHOD1(CloseSession, CdmResponseType(const CdmSessionId&));
@@ -79,12 +80,6 @@ class MockCDM : public WvContentDecryptionModule {
MOCK_METHOD1(ReleaseUsageInfo, MOCK_METHOD1(ReleaseUsageInfo,
CdmResponseType(const CdmUsageInfoReleaseMessage&)); CdmResponseType(const CdmUsageInfoReleaseMessage&));
MOCK_METHOD2(AttachEventListener, bool(const CdmSessionId&,
WvCdmEventListener*));
MOCK_METHOD2(DetachEventListener, bool(const CdmSessionId&,
WvCdmEventListener*));
}; };
class MockCrypto : public WVGenericCryptoInterface { class MockCrypto : public WVGenericCryptoInterface {
@@ -158,8 +153,8 @@ TEST_F(WVDrmPluginTest, OpensSessions) {
StrictMock<MockCrypto> crypto; StrictMock<MockCrypto> crypto;
WVDrmPlugin plugin(&cdm, &crypto); WVDrmPlugin plugin(&cdm, &crypto);
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _)) EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _))
.WillOnce(DoAll(SetArgPointee<2>(cdmSessionId), .WillOnce(DoAll(SetArgPointee<3>(cdmSessionId),
Return(wvcdm::NO_ERROR))); Return(wvcdm::NO_ERROR)));
// Provide expected behavior when plugin requests session control info // Provide expected behavior when plugin requests session control info
@@ -167,13 +162,6 @@ TEST_F(WVDrmPluginTest, OpensSessions) {
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(Invoke(setSessionIdOnMap<4>)); .WillRepeatedly(Invoke(setSessionIdOnMap<4>));
// Let gMock know these calls will happen but we aren't interested in them.
EXPECT_CALL(cdm, AttachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, DetachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_)) EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0)); .Times(AtLeast(0));
@@ -387,8 +375,8 @@ TEST_F(WVDrmPluginTest, HandlesPrivacyCertCaseOfAddKey) {
// Provide expected behavior in response to OpenSession and store the // Provide expected behavior in response to OpenSession and store the
// property set // property set
EXPECT_CALL(cdm, OpenSession(_, _, _)) EXPECT_CALL(cdm, OpenSession(_, _, _, _))
.WillRepeatedly(DoAll(SetArgPointee<2>(cdmSessionId), .WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
SaveArg<1>(&propertySet), SaveArg<1>(&propertySet),
Return(wvcdm::NO_ERROR))); Return(wvcdm::NO_ERROR)));
@@ -396,13 +384,6 @@ TEST_F(WVDrmPluginTest, HandlesPrivacyCertCaseOfAddKey) {
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _)) EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
.WillRepeatedly(Invoke(setSessionIdOnMap<4>)); .WillRepeatedly(Invoke(setSessionIdOnMap<4>));
// Let gMock know these calls will happen but we aren't interested in them.
EXPECT_CALL(cdm, AttachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, DetachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_)) EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0)); .Times(AtLeast(0));
@@ -824,22 +805,15 @@ TEST_F(WVDrmPluginTest, FailsGenericMethodsWithoutAnAlgorithmSet) {
bool match; bool match;
// Provide expected behavior to support session creation // Provide expected behavior to support session creation
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _)) EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _))
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(DoAll(SetArgPointee<2>(cdmSessionId), .WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
Return(wvcdm::NO_ERROR))); Return(wvcdm::NO_ERROR)));
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _)) EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(Invoke(setSessionIdOnMap<4>)); .WillRepeatedly(Invoke(setSessionIdOnMap<4>));
// Let gMock know these calls will happen but we aren't interested in them.
EXPECT_CALL(cdm, AttachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, DetachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_)) EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0)); .Times(AtLeast(0));
@@ -910,22 +884,15 @@ TEST_F(WVDrmPluginTest, CallsGenericEncrypt) {
} }
// Provide expected behavior to support session creation // Provide expected behavior to support session creation
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _)) EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _))
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(DoAll(SetArgPointee<2>(cdmSessionId), .WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
Return(wvcdm::NO_ERROR))); Return(wvcdm::NO_ERROR)));
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _)) EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(Invoke(setSessionIdOnMap<4>)); .WillRepeatedly(Invoke(setSessionIdOnMap<4>));
// Let gMock know these calls will happen but we aren't interested in them.
EXPECT_CALL(cdm, AttachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, DetachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_)) EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0)); .Times(AtLeast(0));
@@ -977,22 +944,15 @@ TEST_F(WVDrmPluginTest, CallsGenericDecrypt) {
} }
// Provide expected behavior to support session creation // Provide expected behavior to support session creation
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _)) EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _))
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(DoAll(SetArgPointee<2>(cdmSessionId), .WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
Return(wvcdm::NO_ERROR))); Return(wvcdm::NO_ERROR)));
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _)) EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(Invoke(setSessionIdOnMap<4>)); .WillRepeatedly(Invoke(setSessionIdOnMap<4>));
// Let gMock know these calls will happen but we aren't interested in them.
EXPECT_CALL(cdm, AttachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, DetachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_)) EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0)); .Times(AtLeast(0));
@@ -1046,22 +1006,15 @@ TEST_F(WVDrmPluginTest, CallsGenericSign) {
} }
// Provide expected behavior to support session creation // Provide expected behavior to support session creation
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _)) EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _))
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(DoAll(SetArgPointee<2>(cdmSessionId), .WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
Return(wvcdm::NO_ERROR))); Return(wvcdm::NO_ERROR)));
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _)) EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(Invoke(setSessionIdOnMap<4>)); .WillRepeatedly(Invoke(setSessionIdOnMap<4>));
// Let gMock know these calls will happen but we aren't interested in them.
EXPECT_CALL(cdm, AttachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, DetachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_)) EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0)); .Times(AtLeast(0));
@@ -1125,22 +1078,15 @@ TEST_F(WVDrmPluginTest, CallsGenericVerify) {
} }
// Provide expected behavior to support session creation // Provide expected behavior to support session creation
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _)) EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _))
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(DoAll(SetArgPointee<2>(cdmSessionId), .WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
Return(wvcdm::NO_ERROR))); Return(wvcdm::NO_ERROR)));
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _)) EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(Invoke(setSessionIdOnMap<4>)); .WillRepeatedly(Invoke(setSessionIdOnMap<4>));
// Let gMock know these calls will happen but we aren't interested in them.
EXPECT_CALL(cdm, AttachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, DetachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_)) EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0)); .Times(AtLeast(0));
@@ -1164,23 +1110,16 @@ TEST_F(WVDrmPluginTest, RegistersForEvents) {
StrictMock<MockCrypto> crypto; StrictMock<MockCrypto> crypto;
WVDrmPlugin plugin(&cdm, &crypto); WVDrmPlugin plugin(&cdm, &crypto);
EXPECT_CALL(cdm, AttachEventListener(cdmSessionId, &plugin))
.Times(1);
// Provide expected behavior to support session creation // Provide expected behavior to support session creation
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _)) EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, &plugin, _))
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(DoAll(SetArgPointee<2>(cdmSessionId), .WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
Return(wvcdm::NO_ERROR))); Return(wvcdm::NO_ERROR)));
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _)) EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(Invoke(setSessionIdOnMap<4>)); .WillRepeatedly(Invoke(setSessionIdOnMap<4>));
// Let gMock know this call will happen but we aren't interested in it.
EXPECT_CALL(cdm, DetachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_)) EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0)); .Times(AtLeast(0));
@@ -1205,10 +1144,10 @@ TEST_F(WVDrmPluginTest, UnregistersForAllEventsOnDestruction) {
CdmSessionId cdmSessionId1(sessionIdRaw1, sessionIdRaw1 + kSessionIdSize); CdmSessionId cdmSessionId1(sessionIdRaw1, sessionIdRaw1 + kSessionIdSize);
CdmSessionId cdmSessionId2(sessionIdRaw2, sessionIdRaw2 + kSessionIdSize); CdmSessionId cdmSessionId2(sessionIdRaw2, sessionIdRaw2 + kSessionIdSize);
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _)) EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _))
.WillOnce(DoAll(SetArgPointee<2>(cdmSessionId1), .WillOnce(DoAll(SetArgPointee<3>(cdmSessionId1),
Return(wvcdm::NO_ERROR))) Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<2>(cdmSessionId2), .WillOnce(DoAll(SetArgPointee<3>(cdmSessionId2),
Return(wvcdm::NO_ERROR))); Return(wvcdm::NO_ERROR)));
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId1, _)) EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId1, _))
@@ -1217,16 +1156,6 @@ TEST_F(WVDrmPluginTest, UnregistersForAllEventsOnDestruction) {
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId2, _)) EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId2, _))
.WillOnce(Invoke(setSessionIdOnMap<5>)); .WillOnce(Invoke(setSessionIdOnMap<5>));
EXPECT_CALL(cdm, DetachEventListener(cdmSessionId1, &plugin))
.Times(1);
EXPECT_CALL(cdm, DetachEventListener(cdmSessionId2, &plugin))
.Times(1);
// Let gMock know these calls will happen but we aren't interested in them.
EXPECT_CALL(cdm, AttachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_)) EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0)); .Times(AtLeast(0));
@@ -1283,18 +1212,11 @@ TEST_F(WVDrmPluginTest, GeneratesProvisioningNeededEvent) {
NULL)) NULL))
.Times(1); .Times(1);
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _)) EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _, _))
.Times(AtLeast(1)) .Times(AtLeast(1))
.WillRepeatedly(DoAll(SetArgPointee<2>(cdmSessionId), .WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
Return(wvcdm::NEED_PROVISIONING))); Return(wvcdm::NEED_PROVISIONING)));
// Let gMock know these calls will happen but we aren't interested in them.
EXPECT_CALL(cdm, AttachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, DetachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_)) EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0)); .Times(AtLeast(0));
@@ -1316,8 +1238,8 @@ TEST_F(WVDrmPluginTest, ProvidesExpectedDefaultPropertiesToCdm) {
{ {
// Provide expected behavior in response to OpenSession and store the // Provide expected behavior in response to OpenSession and store the
// property set // property set
EXPECT_CALL(cdm, OpenSession(_, _, _)) EXPECT_CALL(cdm, OpenSession(_, _, _, _))
.WillRepeatedly(DoAll(SetArgPointee<2>(cdmSessionId), .WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
SaveArg<1>(&propertySet), SaveArg<1>(&propertySet),
Return(wvcdm::NO_ERROR))); Return(wvcdm::NO_ERROR)));
@@ -1325,13 +1247,6 @@ TEST_F(WVDrmPluginTest, ProvidesExpectedDefaultPropertiesToCdm) {
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _)) EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
.WillRepeatedly(Invoke(setSessionIdOnMap<4>)); .WillRepeatedly(Invoke(setSessionIdOnMap<4>));
// Let gMock know these calls will happen but we aren't interested in them.
EXPECT_CALL(cdm, AttachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, DetachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_)) EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0)); .Times(AtLeast(0));
} }
@@ -1357,8 +1272,8 @@ TEST_F(WVDrmPluginTest, CanSetAppId) {
{ {
// Provide expected behavior in response to OpenSession and store the // Provide expected behavior in response to OpenSession and store the
// property set // property set
EXPECT_CALL(cdm, OpenSession(_, _, _)) EXPECT_CALL(cdm, OpenSession(_, _, _, _))
.WillRepeatedly(DoAll(SetArgPointee<2>(cdmSessionId), .WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
SaveArg<1>(&propertySet), SaveArg<1>(&propertySet),
Return(wvcdm::NO_ERROR))); Return(wvcdm::NO_ERROR)));
@@ -1366,13 +1281,6 @@ TEST_F(WVDrmPluginTest, CanSetAppId) {
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _)) EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
.WillRepeatedly(Invoke(setSessionIdOnMap<4>)); .WillRepeatedly(Invoke(setSessionIdOnMap<4>));
// Let gMock know these calls will happen but we aren't interested in them.
EXPECT_CALL(cdm, AttachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, DetachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_)) EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0)); .Times(AtLeast(0));
} }
@@ -1422,8 +1330,8 @@ TEST_F(WVDrmPluginTest, CanSetSecurityLevel) {
{ {
// Provide expected behavior in response to OpenSession and store the // Provide expected behavior in response to OpenSession and store the
// property set // property set
EXPECT_CALL(cdm, OpenSession(_, _, _)) EXPECT_CALL(cdm, OpenSession(_, _, _, _))
.WillRepeatedly(DoAll(SetArgPointee<2>(cdmSessionId), .WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
SaveArg<1>(&propertySet), SaveArg<1>(&propertySet),
Return(wvcdm::NO_ERROR))); Return(wvcdm::NO_ERROR)));
@@ -1431,13 +1339,6 @@ TEST_F(WVDrmPluginTest, CanSetSecurityLevel) {
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _)) EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
.WillRepeatedly(Invoke(setSessionIdOnMap<4>)); .WillRepeatedly(Invoke(setSessionIdOnMap<4>));
// Let gMock know these calls will happen but we aren't interested in them.
EXPECT_CALL(cdm, AttachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, DetachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_)) EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0)); .Times(AtLeast(0));
} }
@@ -1514,8 +1415,8 @@ TEST_F(WVDrmPluginTest, CanSetPrivacyMode) {
{ {
// Provide expected behavior in response to OpenSession and store the // Provide expected behavior in response to OpenSession and store the
// property set // property set
EXPECT_CALL(cdm, OpenSession(_, _, _)) EXPECT_CALL(cdm, OpenSession(_, _, _, _))
.WillRepeatedly(DoAll(SetArgPointee<2>(cdmSessionId), .WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
SaveArg<1>(&propertySet), SaveArg<1>(&propertySet),
Return(wvcdm::NO_ERROR))); Return(wvcdm::NO_ERROR)));
@@ -1523,13 +1424,6 @@ TEST_F(WVDrmPluginTest, CanSetPrivacyMode) {
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _)) EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
.WillRepeatedly(Invoke(setSessionIdOnMap<4>)); .WillRepeatedly(Invoke(setSessionIdOnMap<4>));
// Let gMock know these calls will happen but we aren't interested in them.
EXPECT_CALL(cdm, AttachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, DetachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_)) EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0)); .Times(AtLeast(0));
} }
@@ -1576,8 +1470,8 @@ TEST_F(WVDrmPluginTest, CanSetServiceCertificate) {
{ {
// Provide expected behavior in response to OpenSession and store the // Provide expected behavior in response to OpenSession and store the
// property set // property set
EXPECT_CALL(cdm, OpenSession(_, _, _)) EXPECT_CALL(cdm, OpenSession(_, _, _, _))
.WillRepeatedly(DoAll(SetArgPointee<2>(cdmSessionId), .WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
SaveArg<1>(&propertySet), SaveArg<1>(&propertySet),
Return(wvcdm::NO_ERROR))); Return(wvcdm::NO_ERROR)));
@@ -1585,13 +1479,6 @@ TEST_F(WVDrmPluginTest, CanSetServiceCertificate) {
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _)) EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
.WillRepeatedly(Invoke(setSessionIdOnMap<4>)); .WillRepeatedly(Invoke(setSessionIdOnMap<4>));
// Let gMock know these calls will happen but we aren't interested in them.
EXPECT_CALL(cdm, AttachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, DetachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_)) EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0)); .Times(AtLeast(0));
} }
@@ -1624,8 +1511,8 @@ TEST_F(WVDrmPluginTest, CanSetSessionSharing) {
{ {
// Provide expected behavior in response to OpenSession and store the // Provide expected behavior in response to OpenSession and store the
// property set // property set
EXPECT_CALL(cdm, OpenSession(_, _, _)) EXPECT_CALL(cdm, OpenSession(_, _, _, _))
.WillRepeatedly(DoAll(SetArgPointee<2>(cdmSessionId), .WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
SaveArg<1>(&propertySet), SaveArg<1>(&propertySet),
Return(wvcdm::NO_ERROR))); Return(wvcdm::NO_ERROR)));
@@ -1633,13 +1520,6 @@ TEST_F(WVDrmPluginTest, CanSetSessionSharing) {
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _)) EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
.WillRepeatedly(Invoke(setSessionIdOnMap<4>)); .WillRepeatedly(Invoke(setSessionIdOnMap<4>));
// Let gMock know these calls will happen but we aren't interested in them.
EXPECT_CALL(cdm, AttachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, DetachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_)) EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0)); .Times(AtLeast(0));
} }
@@ -1690,8 +1570,8 @@ TEST_F(WVDrmPluginTest, AllowsStoringOfSessionSharingId) {
{ {
// Provide expected behavior in response to OpenSession and store the // Provide expected behavior in response to OpenSession and store the
// property set // property set
EXPECT_CALL(cdm, OpenSession(_, _, _)) EXPECT_CALL(cdm, OpenSession(_, _, _, _))
.WillRepeatedly(DoAll(SetArgPointee<2>(cdmSessionId), .WillRepeatedly(DoAll(SetArgPointee<3>(cdmSessionId),
SaveArg<1>(&propertySet), SaveArg<1>(&propertySet),
Return(wvcdm::NO_ERROR))); Return(wvcdm::NO_ERROR)));
@@ -1699,13 +1579,6 @@ TEST_F(WVDrmPluginTest, AllowsStoringOfSessionSharingId) {
EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _)) EXPECT_CALL(cdm, QueryKeyControlInfo(cdmSessionId, _))
.WillRepeatedly(Invoke(setSessionIdOnMap<4>)); .WillRepeatedly(Invoke(setSessionIdOnMap<4>));
// Let gMock know these calls will happen but we aren't interested in them.
EXPECT_CALL(cdm, AttachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, DetachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_)) EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0)); .Times(AtLeast(0));
} }