Corrections for limited duration licenses
[ Merge of http://go/wvgerrit/74627 ] Limited duration licenses (where license duration is unlimited and playback window is set to a small value) did not work correctly when the initial decrypt call occured before the license was received. Bug: 109653883 Test: WV unit/integration tests Change-Id: I0738e97db525b239455e2ac93ab0bedd6611b311
This commit is contained in:
@@ -520,6 +520,16 @@ std::string kPsshStreamingClip7 = wvcdm::a2bs_hex(
|
||||
"EDEF8BA979D64ACEA3C827DCD51D21ED00000022" // Widevine system id
|
||||
"08011a0d7769646576696e655f74657374220f73" // pssh data
|
||||
"747265616d696e675f636c697037");
|
||||
std::string kPsshStreamingClip20 = wvcdm::a2bs_hex(
|
||||
"000000437073736800000000" // blob size and pssh
|
||||
"EDEF8BA979D64ACEA3C827DCD51D21ED00000023" // Widevine system id
|
||||
"08011a0d7769646576696e655f746573" // pssh data
|
||||
"74221073747265616d696e675f636c69703230");
|
||||
std::string kPsshStreamingClip21 = wvcdm::a2bs_hex(
|
||||
"000000437073736800000000" // blob size and pssh
|
||||
"EDEF8BA979D64ACEA3C827DCD51D21ED00000023" // Widevine system id
|
||||
"08011a0d7769646576696e655f746573" // pssh data
|
||||
"74221073747265616d696e675f636c69703231");
|
||||
|
||||
std::string kProviderSessionTokenStreamingClip3 = wvcdm::a2bs_hex(
|
||||
"4851305A4A4156485A554936444E4931");
|
||||
@@ -527,6 +537,15 @@ std::string kProviderSessionTokenStreamingClip4 = wvcdm::a2bs_hex(
|
||||
"4942524F4355544E5557553145463243");
|
||||
std::string kProviderSessionTokenStreamingClip7 = wvcdm::a2bs_hex(
|
||||
"44434C53524F4E30394C4E5535544B4C");
|
||||
std::string kProviderSessionTokenStreamingClip20 = wvcdm::a2bs_hex(
|
||||
"4851305A4A4156485A554936444E4931");
|
||||
std::string kProviderSessionTokenStreamingClip21 = wvcdm::a2bs_hex(
|
||||
"4851305A4A4156485A554936444E4931");
|
||||
|
||||
// playback duration is 10 seconds+uncertainty window
|
||||
const std::chrono::milliseconds
|
||||
kExpirationStreamingClip21PlaybackDurationTimeMs =
|
||||
std::chrono::milliseconds(12*1000);
|
||||
|
||||
UsageLicenseAndSubSampleInfo kUsageLicenseTestVector1[] = {
|
||||
{ kPsshStreamingClip3, &usage_info_sub_samples_icp[0],
|
||||
@@ -1634,6 +1653,12 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
|
||||
|
||||
bool VerifyDecryption(const CdmSessionId& session_id,
|
||||
const SubSampleInfo& data) {
|
||||
return VerifyDecryption(session_id, data, NO_ERROR);
|
||||
}
|
||||
|
||||
bool VerifyDecryption(const CdmSessionId& session_id,
|
||||
const SubSampleInfo& data,
|
||||
CdmResponseType expected_response) {
|
||||
std::vector<uint8_t> decrypt_buffer(data.encrypt_data.size());
|
||||
CdmDecryptionParameters decryption_parameters(
|
||||
&data.key_id, &data.encrypt_data.front(), data.encrypt_data.size(),
|
||||
@@ -1644,7 +1669,7 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
|
||||
CdmResponseType status = decryptor_.Decrypt(session_id,
|
||||
data.validate_key_id,
|
||||
decryption_parameters);
|
||||
EXPECT_EQ(NO_ERROR, status);
|
||||
EXPECT_EQ(expected_response, status);
|
||||
if (status != NO_ERROR)
|
||||
return false;
|
||||
|
||||
@@ -4981,6 +5006,70 @@ TEST_F(WvCdmRequestLicenseTest, DecryptionKeyExpiredTest) {
|
||||
decryptor_.CloseSession(session_id_);
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, PlaybackExpiry) {
|
||||
StrictMock<TestWvCdmEventListener> listener;
|
||||
DecryptCallbackTester decrypt_callback(
|
||||
&decryptor_,
|
||||
&usage_info_sub_samples_icp[0]);
|
||||
decryptor_.OpenSession(config_.key_system(), NULL, kDefaultCdmIdentifier,
|
||||
&listener, &session_id_);
|
||||
|
||||
EXPECT_CALL(
|
||||
listener,
|
||||
OnSessionKeysChange(
|
||||
session_id_,
|
||||
AllOf(Each(Pair(_, kKeyStatusUsable)), Not(IsEmpty())), true))
|
||||
.WillOnce(Invoke(&decrypt_callback, &DecryptCallbackTester::Decrypt));
|
||||
EXPECT_CALL(listener, OnExpirationUpdate(session_id_, _));
|
||||
|
||||
GenerateKeyRequest(kPsshStreamingClip21, kLicenseTypeStreaming, NULL);
|
||||
VerifyKeyRequestResponse(config_.license_server(), config_.client_auth());
|
||||
|
||||
EXPECT_CALL(
|
||||
listener,
|
||||
OnSessionKeysChange(
|
||||
session_id_,
|
||||
AllOf(Each(Pair(_, kKeyStatusExpired)), Not(IsEmpty())), false));
|
||||
|
||||
// Elapse time so that the key should now be considered expired.
|
||||
std::this_thread::sleep_for(kExpirationStreamingClip21PlaybackDurationTimeMs);
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, PlaybackExpiry_DecryptBeforeLicense) {
|
||||
StrictMock<TestWvCdmEventListener> listener;
|
||||
DecryptCallbackTester decrypt_callback(
|
||||
&decryptor_,
|
||||
&usage_info_sub_samples_icp[0]);
|
||||
decryptor_.OpenSession(config_.key_system(), NULL, kDefaultCdmIdentifier,
|
||||
&listener, &session_id_);
|
||||
|
||||
// Decrypt before license is received is expected to fail but should
|
||||
// not start the playback timer
|
||||
EXPECT_FALSE(VerifyDecryption(session_id_,
|
||||
usage_info_sub_samples_icp[0], NEED_KEY));
|
||||
std::this_thread::sleep_for(kExpirationStreamingClip21PlaybackDurationTimeMs);
|
||||
|
||||
EXPECT_CALL(
|
||||
listener,
|
||||
OnSessionKeysChange(
|
||||
session_id_,
|
||||
AllOf(Each(Pair(_, kKeyStatusUsable)), Not(IsEmpty())), true))
|
||||
.WillOnce(Invoke(&decrypt_callback, &DecryptCallbackTester::Decrypt));
|
||||
EXPECT_CALL(listener, OnExpirationUpdate(session_id_, _));
|
||||
|
||||
GenerateKeyRequest(kPsshStreamingClip21, kLicenseTypeStreaming, NULL);
|
||||
VerifyKeyRequestResponse(config_.license_server(), config_.client_auth());
|
||||
|
||||
EXPECT_CALL(
|
||||
listener,
|
||||
OnSessionKeysChange(
|
||||
session_id_,
|
||||
AllOf(Each(Pair(_, kKeyStatusExpired)), Not(IsEmpty())), false));
|
||||
|
||||
// Elapse time so that the key should now be considered expired.
|
||||
std::this_thread::sleep_for(kExpirationStreamingClip21PlaybackDurationTimeMs);
|
||||
}
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, SessionKeyChangeNotificationTest) {
|
||||
StrictMock<TestWvCdmEventListener> listener;
|
||||
DecryptCallbackTester decrypt_callback(
|
||||
|
||||
Reference in New Issue
Block a user