Merge "Fix invalid iterator in CloseCdm"
This commit is contained in:
@@ -434,9 +434,12 @@ CdmResponseType WvContentDecryptionModule::CloseCdm(
|
|||||||
return UNKNOWN_ERROR;
|
return UNKNOWN_ERROR;
|
||||||
}
|
}
|
||||||
// Remove any sessions that point to this engine.
|
// Remove any sessions that point to this engine.
|
||||||
for (auto session_it : cdm_by_session_id_) {
|
for (auto session_it = cdm_by_session_id_.begin();
|
||||||
if (session_it.second == it->second.cdm_engine.get()) {
|
session_it != cdm_by_session_id_.end();) {
|
||||||
cdm_by_session_id_.erase(session_it.first);
|
if (session_it->second == it->second.cdm_engine.get()) {
|
||||||
|
session_it = cdm_by_session_id_.erase(session_it);
|
||||||
|
} else {
|
||||||
|
++session_it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cdms_.erase(it);
|
cdms_.erase(it);
|
||||||
|
|||||||
@@ -55,6 +55,13 @@ const wvcdm::CdmIdentifier kExampleIdentifier = {
|
|||||||
7
|
7
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const wvcdm::CdmIdentifier kAlternateCdmIdentifier1 = {
|
||||||
|
"alternate_spoid_1",
|
||||||
|
"alternate_origin_1",
|
||||||
|
"com.alternate1.url",
|
||||||
|
8
|
||||||
|
};
|
||||||
|
|
||||||
const std::string kEmptyServiceCertificate;
|
const std::string kEmptyServiceCertificate;
|
||||||
|
|
||||||
// Protobuf generated classes
|
// Protobuf generated classes
|
||||||
@@ -5041,4 +5048,48 @@ INSTANTIATE_TEST_CASE_P(
|
|||||||
::testing::Range(&kCenc30SwitchCipherData[0],
|
::testing::Range(&kCenc30SwitchCipherData[0],
|
||||||
&kCenc30SwitchCipherData[8]));
|
&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
|
} // namespace wvcdm
|
||||||
|
|||||||
Reference in New Issue
Block a user