Merge "Integrate OnExpirationUpdate and OnSessionKeysChange with Android"
This commit is contained in:
@@ -14,11 +14,9 @@ class WvCdmEventListener {
|
||||
virtual ~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 OnSessionKeysChange(const CdmSessionId& session_id,
|
||||
const CdmKeyStatusMap& keys_status,
|
||||
bool has_new_usable_key) = 0;
|
||||
virtual void OnExpirationUpdate(const CdmSessionId& session_id,
|
||||
int64_t new_expiry_time) = 0;
|
||||
|
||||
|
||||
@@ -51,12 +51,12 @@ enum CdmResponseType {
|
||||
|
||||
enum CdmKeyStatus {
|
||||
kKeyStatusUsable,
|
||||
kKeyStatusInternalError,
|
||||
kKeyStatusExpired,
|
||||
kKeyStatusOutputNotAllowed,
|
||||
kKeyStatusOutputDownscaled,
|
||||
kKeyStatusPending,
|
||||
kKeyStatusInternalError,
|
||||
};
|
||||
typedef std::map<KeyId, CdmKeyStatus> CdmKeyStatusMap;
|
||||
|
||||
#define CORE_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
TypeName(const TypeName&); \
|
||||
@@ -125,14 +125,6 @@ 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;
|
||||
|
||||
@@ -54,7 +54,6 @@ void PolicyEngine::OnTimerEvent() {
|
||||
license_state_ != kLicenseStateExpired) {
|
||||
license_state_ = kLicenseStateExpired;
|
||||
NotifyKeysChange(kKeyStatusExpired);
|
||||
if (event_listener_) event_listener_->OnSessionExpiration(session_id_);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -217,7 +216,6 @@ void PolicyEngine::NotifyResolution(uint32_t width, uint32_t height) {
|
||||
void PolicyEngine::NotifySessionExpiration() {
|
||||
license_state_ = kLicenseStateExpired;
|
||||
NotifyKeysChange(kKeyStatusExpired);
|
||||
if (event_listener_) event_listener_->OnSessionExpiration(session_id_);
|
||||
}
|
||||
|
||||
CdmResponseType PolicyEngine::Query(CdmQueryMap* key_info) {
|
||||
@@ -344,12 +342,7 @@ void PolicyEngine::NotifyKeysChange(CdmKeyStatus new_status) {
|
||||
}
|
||||
}
|
||||
if (keys_changed && event_listener_) {
|
||||
std::vector<CdmKeyInformation> keys_info;
|
||||
for (std::map<KeyId, CdmKeyStatus>::iterator it = keys_status_.begin();
|
||||
it != keys_status_.end(); ++it) {
|
||||
keys_info.push_back(CdmKeyInformation(it->first, it->second));
|
||||
}
|
||||
event_listener_->OnSessionKeysChange(session_id_, keys_info,
|
||||
event_listener_->OnSessionKeysChange(session_id_, keys_status_,
|
||||
has_new_usable_key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,11 +60,10 @@ using video_widevine_server::sdk::OFFLINE;
|
||||
|
||||
// gmock methods
|
||||
using ::testing::_;
|
||||
using ::testing::AllOf;
|
||||
using ::testing::AtLeast;
|
||||
using ::testing::Field;
|
||||
using ::testing::InSequence;
|
||||
using ::testing::MockFunction;
|
||||
using ::testing::Pair;
|
||||
using ::testing::Return;
|
||||
using ::testing::StrictMock;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
@@ -72,11 +71,9 @@ using ::testing::UnorderedElementsAre;
|
||||
class MockCdmEventListener : public WvCdmEventListener {
|
||||
public:
|
||||
MOCK_METHOD1(OnSessionRenewalNeeded, void(const CdmSessionId& session_id));
|
||||
MOCK_METHOD1(OnSessionExpiration, void(const CdmSessionId& session_id));
|
||||
MOCK_METHOD3(OnSessionKeysChange,
|
||||
void(const CdmSessionId& session_id,
|
||||
const std::vector<CdmKeyInformation>& cdm_keys_info,
|
||||
bool has_new_usable_key));
|
||||
MOCK_METHOD3(OnSessionKeysChange, void(const CdmSessionId& session_id,
|
||||
const CdmKeyStatusMap& keys_status,
|
||||
bool has_new_usable_key));
|
||||
MOCK_METHOD2(OnExpirationUpdate,
|
||||
void(const CdmSessionId& session_id, int64_t new_expiry_time));
|
||||
};
|
||||
@@ -149,11 +146,8 @@ class PolicyEngineTest : public ::testing::Test {
|
||||
bool expected_has_new_usable_key) {
|
||||
EXPECT_CALL(mock_event_listener_,
|
||||
OnSessionKeysChange(
|
||||
kSessionId,
|
||||
UnorderedElementsAre(
|
||||
AllOf(Field(&CdmKeyInformation::key_id, kKeyId),
|
||||
Field(&CdmKeyInformation::key_status,
|
||||
expected_key_status))),
|
||||
kSessionId, UnorderedElementsAre(
|
||||
Pair(kKeyId, expected_key_status)),
|
||||
expected_has_new_usable_key));
|
||||
}
|
||||
|
||||
@@ -162,14 +156,9 @@ class PolicyEngineTest : public ::testing::Test {
|
||||
bool expected_has_new_usable_key) {
|
||||
EXPECT_CALL(mock_event_listener_,
|
||||
OnSessionKeysChange(
|
||||
kSessionId,
|
||||
UnorderedElementsAre(
|
||||
AllOf(Field(&CdmKeyInformation::key_id, kKeyId),
|
||||
Field(&CdmKeyInformation::key_status,
|
||||
expected_key1_status)),
|
||||
AllOf(Field(&CdmKeyInformation::key_id, kAnotherKeyId),
|
||||
Field(&CdmKeyInformation::key_status,
|
||||
expected_key2_status))),
|
||||
kSessionId, UnorderedElementsAre(
|
||||
Pair(kKeyId, expected_key1_status),
|
||||
Pair(kAnotherKeyId, expected_key2_status)),
|
||||
expected_has_new_usable_key));
|
||||
}
|
||||
|
||||
@@ -242,7 +231,6 @@ TEST_F(PolicyEngineTest, PlaybackFails_RentalDurationExpired) {
|
||||
OnExpirationUpdate(_, kLicenseStartTime + kLowDuration));
|
||||
EXPECT_CALL(check_, Call(1));
|
||||
ExpectSessionKeysChange(kKeyStatusExpired, false);
|
||||
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(kSessionId));
|
||||
EXPECT_CALL(check_, Call(2));
|
||||
|
||||
policy_engine_->SetLicense(license_);
|
||||
@@ -278,7 +266,6 @@ TEST_F(PolicyEngineTest, PlaybackFails_PlaybackDurationExpired) {
|
||||
OnExpirationUpdate(_, playback_start_time + kPlaybackDuration));
|
||||
EXPECT_CALL(check_, Call(1));
|
||||
ExpectSessionKeysChange(kKeyStatusExpired, false);
|
||||
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
|
||||
EXPECT_CALL(check_, Call(2));
|
||||
|
||||
policy_engine_->SetLicense(license_);
|
||||
@@ -311,7 +298,6 @@ TEST_F(PolicyEngineTest, PlaybackFails_LicenseDurationExpired) {
|
||||
OnExpirationUpdate(_, kLicenseStartTime + kLowDuration));
|
||||
EXPECT_CALL(check_, Call(1));
|
||||
ExpectSessionKeysChange(kKeyStatusExpired, false);
|
||||
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
|
||||
EXPECT_CALL(check_, Call(2));
|
||||
|
||||
policy_engine_->SetLicense(license_);
|
||||
@@ -344,7 +330,6 @@ TEST_F(PolicyEngineTest, PlaybackFails_ExpiryBeforeRenewalDelay) {
|
||||
OnExpirationUpdate(_, kLicenseStartTime + kLowDuration));
|
||||
EXPECT_CALL(check_, Call(1));
|
||||
ExpectSessionKeysChange(kKeyStatusExpired, false);
|
||||
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
|
||||
EXPECT_CALL(check_, Call(2));
|
||||
|
||||
policy_engine_->SetLicense(license_);
|
||||
@@ -384,7 +369,6 @@ TEST_F(PolicyEngineTest, PlaybackOk_RentalDuration0) {
|
||||
EXPECT_CALL(mock_event_listener_, OnSessionRenewalNeeded(_));
|
||||
EXPECT_CALL(check_, Call(3));
|
||||
ExpectSessionKeysChange(kKeyStatusExpired, false);
|
||||
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
|
||||
EXPECT_CALL(check_, Call(4));
|
||||
|
||||
policy_engine_->SetLicense(license_);
|
||||
@@ -425,7 +409,6 @@ TEST_F(PolicyEngineTest, PlaybackOk_PlaybackDuration0) {
|
||||
EXPECT_CALL(mock_event_listener_, OnSessionRenewalNeeded(_));
|
||||
EXPECT_CALL(check_, Call(3));
|
||||
ExpectSessionKeysChange(kKeyStatusExpired, false);
|
||||
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
|
||||
EXPECT_CALL(check_, Call(4));
|
||||
|
||||
policy_engine_->SetLicense(license_);
|
||||
@@ -460,7 +443,6 @@ TEST_F(PolicyEngineTest, PlaybackOk_LicenseDuration0) {
|
||||
OnExpirationUpdate(_, kLicenseStartTime + kLowDuration));
|
||||
EXPECT_CALL(check_, Call(1));
|
||||
ExpectSessionKeysChange(kKeyStatusExpired, false);
|
||||
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
|
||||
EXPECT_CALL(check_, Call(2));
|
||||
|
||||
policy_engine_->SetLicense(license_);
|
||||
@@ -548,7 +530,6 @@ TEST_F(PolicyEngineTest, PlaybackFailed_CanRenewFalse) {
|
||||
EXPECT_CALL(check_, Call(1));
|
||||
EXPECT_CALL(check_, Call(2));
|
||||
ExpectSessionKeysChange(kKeyStatusExpired, false);
|
||||
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
|
||||
EXPECT_CALL(check_, Call(3));
|
||||
|
||||
policy_engine_->SetLicense(license_);
|
||||
@@ -689,7 +670,6 @@ TEST_F(PolicyEngineTest, PlaybackFailed_RenewFailedVersionNotUpdated) {
|
||||
EXPECT_CALL(mock_event_listener_, OnSessionRenewalNeeded(_));
|
||||
EXPECT_CALL(check_, Call(3));
|
||||
ExpectSessionKeysChange(kKeyStatusExpired, false);
|
||||
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
|
||||
EXPECT_CALL(check_, Call(4));
|
||||
|
||||
policy_engine_->SetLicense(license_);
|
||||
@@ -750,7 +730,6 @@ TEST_F(PolicyEngineTest, PlaybackFailed_RepeatedRenewFailures) {
|
||||
EXPECT_CALL(check_, Call(6));
|
||||
EXPECT_CALL(check_, Call(7));
|
||||
ExpectSessionKeysChange(kKeyStatusExpired, false);
|
||||
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
|
||||
EXPECT_CALL(check_, Call(8));
|
||||
|
||||
policy_engine_->SetLicense(license_);
|
||||
@@ -802,7 +781,6 @@ TEST_F(PolicyEngineTest, PlaybackOk_RenewSuccessAfterExpiry) {
|
||||
EXPECT_CALL(check_, Call(6));
|
||||
EXPECT_CALL(check_, Call(7));
|
||||
ExpectSessionKeysChange(kKeyStatusExpired, false);
|
||||
EXPECT_CALL(mock_event_listener_, OnSessionExpiration(_));
|
||||
EXPECT_CALL(check_, Call(8));
|
||||
ExpectSessionKeysChange(kKeyStatusUsable, true);
|
||||
EXPECT_CALL(
|
||||
|
||||
@@ -24,9 +24,12 @@
|
||||
#include "wv_content_decryption_module.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::AllOf;
|
||||
using ::testing::AtLeast;
|
||||
using ::testing::Each;
|
||||
using ::testing::Field;
|
||||
using ::testing::IsEmpty;
|
||||
using ::testing::Not;
|
||||
using ::testing::Pair;
|
||||
using ::testing::StrictMock;
|
||||
|
||||
namespace {
|
||||
@@ -449,11 +452,9 @@ class TestWvCdmEventListener : public WvCdmEventListener {
|
||||
TestWvCdmEventListener() : WvCdmEventListener() {}
|
||||
|
||||
MOCK_METHOD1(OnSessionRenewalNeeded, void(const CdmSessionId& session_id));
|
||||
MOCK_METHOD1(OnSessionExpiration, void(const CdmSessionId& session_id));
|
||||
MOCK_METHOD3(OnSessionKeysChange,
|
||||
void(const CdmSessionId& session_id,
|
||||
const std::vector<CdmKeyInformation>& cdm_keys_info,
|
||||
bool has_new_usable_key));
|
||||
MOCK_METHOD3(OnSessionKeysChange, void(const CdmSessionId& session_id,
|
||||
const CdmKeyStatusMap& keys_status,
|
||||
bool has_new_usable_key));
|
||||
MOCK_METHOD2(OnExpirationUpdate,
|
||||
void(const CdmSessionId& session_id, int64_t new_expiry_time));
|
||||
};
|
||||
@@ -1171,8 +1172,8 @@ TEST_F(WvCdmRequestLicenseTest, ExpiryOnReleaseOfflineKeyTest) {
|
||||
CdmSessionId restore_session_id = session_id_;
|
||||
EXPECT_CALL(listener,
|
||||
OnSessionKeysChange(restore_session_id,
|
||||
Each(Field(&CdmKeyInformation::key_status,
|
||||
kKeyStatusUsable)),
|
||||
AllOf(Each(Pair(_, kKeyStatusUsable)),
|
||||
Not(IsEmpty())),
|
||||
true));
|
||||
EXPECT_CALL(listener, OnExpirationUpdate(restore_session_id, _));
|
||||
EXPECT_EQ(wvcdm::KEY_ADDED,
|
||||
@@ -1185,10 +1186,9 @@ TEST_F(WvCdmRequestLicenseTest, ExpiryOnReleaseOfflineKeyTest) {
|
||||
.Times(AtLeast(0));
|
||||
EXPECT_CALL(listener,
|
||||
OnSessionKeysChange(restore_session_id,
|
||||
Each(Field(&CdmKeyInformation::key_status,
|
||||
kKeyStatusExpired)),
|
||||
AllOf(Each(Pair(_, kKeyStatusExpired)),
|
||||
Not(IsEmpty())),
|
||||
false));
|
||||
EXPECT_CALL(listener, OnSessionExpiration(restore_session_id));
|
||||
GenerateKeyRelease(key_set_id);
|
||||
key_set_id_ = key_set_id;
|
||||
VerifyKeyRequestResponse(g_license_server, client_auth, false);
|
||||
|
||||
Reference in New Issue
Block a user