Fix invalid iterator in CloseCdm

[ Merge of http://go/ag/5334065 and http://go/wvgerrit/65122 ]

Sessions were not being correctly released when CloseCdm() was called.
Broadcom noticed this issue and proposed the fix.

Bug: 117876077
Test: WV unit/integration tests, GtsMediaTestCases and playback tests
Change-Id: I8800744f2396f0955c76d5f3e187a69fe04330f6
This commit is contained in:
Rahul Frias
2018-10-23 00:12:45 -07:00
parent c0144ac97f
commit d374b17b7c
2 changed files with 57 additions and 3 deletions

View File

@@ -55,6 +55,13 @@ const wvcdm::CdmIdentifier kExampleIdentifier = {
7
};
const wvcdm::CdmIdentifier kAlternateCdmIdentifier1 = {
"alternate_spoid_1",
"alternate_origin_1",
"com.alternate1.url",
8
};
const std::string kEmptyServiceCertificate;
// Protobuf generated classes
@@ -5041,4 +5048,48 @@ INSTANTIATE_TEST_CASE_P(
::testing::Range(&kCenc30SwitchCipherData[0],
&kCenc30SwitchCipherData[8]));
TEST_F(WvCdmRequestLicenseTest, CloseCdmReleaseResourcesTest) {
Provision(kAlternateCdmIdentifier1, kLevelDefault);
// Retrieve a streaming license
EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(config_.key_system(), NULL,
kDefaultCdmIdentifier, NULL,
&session_id_));
GenerateKeyRequest(binary_key_id(), kLicenseTypeStreaming);
VerifyKeyRequestResponse(config_.license_server(), config_.client_auth());
// Open a few more sessions
CdmSessionId session_id1;
CdmSessionId session_id2;
CdmSessionId session_id3;
CdmSessionId session_id4;
CdmSessionId alternate_session_id;
EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(config_.key_system(), NULL,
kDefaultCdmIdentifier, NULL,
&session_id1));
EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(config_.key_system(), NULL,
kDefaultCdmIdentifier, NULL,
&session_id2));
EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(config_.key_system(), NULL,
kDefaultCdmIdentifier, NULL,
&session_id3));
EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(config_.key_system(), NULL,
kDefaultCdmIdentifier, NULL,
&session_id4));
EXPECT_EQ(NO_ERROR, decryptor_.OpenSession(config_.key_system(), NULL,
kAlternateCdmIdentifier1, NULL,
&alternate_session_id));
// Close all open sessions and disable the timer running for |session_id_|
decryptor_.CloseCdm(kDefaultCdmIdentifier);
EXPECT_FALSE(decryptor_.IsOpenSession(session_id_));
EXPECT_FALSE(decryptor_.IsOpenSession(session_id1));
EXPECT_FALSE(decryptor_.IsOpenSession(session_id2));
EXPECT_FALSE(decryptor_.IsOpenSession(session_id3));
EXPECT_FALSE(decryptor_.IsOpenSession(session_id4));
EXPECT_TRUE(decryptor_.IsOpenSession(alternate_session_id));
}
} // namespace wvcdm