Create unique cdm engines per WVDrmPlugin instance
This change creates a unique id in the cdm identifier in order to force a one-to-one mapping between WVDrmPlugin instances and CDM Engines. This change simplifies some assumptions. This includes ensuring that the metrics for a given MediaDrm instance map to a given CdmEngine instance. This change contains the original change go/ag/3819203 and a fix to the deadlock that was seen on Marlin and Taimen. Bug: 73724453 Test: Updated unit tests. GTS test pass. Shaka Player, Netflix and Google Play test. Change-Id: Ib208204a1b794df9f306fa11d13a8bb6cd6889f7
This commit is contained in:
@@ -53,7 +53,8 @@ const int kHttpInternalServerError = 500;
|
||||
const wvcdm::CdmIdentifier kExampleIdentifier = {
|
||||
wvcdm::EMPTY_SPOID,
|
||||
"com.example",
|
||||
"com.example"
|
||||
"com.example",
|
||||
7
|
||||
};
|
||||
|
||||
// Protobuf generated classes
|
||||
@@ -394,15 +395,19 @@ const uint32_t kSingleEncryptedSubSampleIcpLicenseExpirationWindow = 2;
|
||||
struct SessionSharingSubSampleInfo {
|
||||
SubSampleInfo* sub_sample;
|
||||
bool session_sharing_enabled;
|
||||
wvcdm::CdmIdentifier cdm_identifier;
|
||||
};
|
||||
|
||||
SessionSharingSubSampleInfo session_sharing_sub_samples[] = {
|
||||
{&clear_sub_sample, false},
|
||||
{&clear_sub_sample, true},
|
||||
{&clear_sub_sample_no_key, false},
|
||||
{&clear_sub_sample_no_key, true},
|
||||
{&single_encrypted_sub_sample, false},
|
||||
{&single_encrypted_sub_sample, true}};
|
||||
{&clear_sub_sample, false, wvcdm::kDefaultCdmIdentifier},
|
||||
{&clear_sub_sample, true, wvcdm::kDefaultCdmIdentifier},
|
||||
{&clear_sub_sample_no_key, false, wvcdm::kDefaultCdmIdentifier},
|
||||
{&clear_sub_sample_no_key, true, wvcdm::kDefaultCdmIdentifier},
|
||||
{&single_encrypted_sub_sample, false, wvcdm::kDefaultCdmIdentifier},
|
||||
{&single_encrypted_sub_sample, true, wvcdm::kDefaultCdmIdentifier},
|
||||
// The last entry simulates session sharing using the non default
|
||||
// identifier.
|
||||
{&single_encrypted_sub_sample, true, kExampleIdentifier}};
|
||||
|
||||
struct UsageInfoSubSampleInfo {
|
||||
SubSampleInfo* sub_sample;
|
||||
@@ -1303,6 +1308,14 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
|
||||
GenerateKeyRequest(init_data, license_type, NULL);
|
||||
}
|
||||
|
||||
void GenerateKeyRequest(const std::string& init_data,
|
||||
CdmLicenseType license_type,
|
||||
const CdmIdentifier& identifier) {
|
||||
CdmAppParameterMap app_parameters;
|
||||
GenerateKeyRequest(wvcdm::KEY_MESSAGE, "video/mp4", init_data,
|
||||
app_parameters, license_type, identifier, NULL);
|
||||
}
|
||||
|
||||
void GenerateKeyRequest(const std::string& init_data,
|
||||
CdmLicenseType license_type,
|
||||
CdmClientPropertySet* property_set) {
|
||||
@@ -1344,7 +1357,13 @@ class WvCdmRequestLicenseTest : public WvCdmTestBase {
|
||||
decryptor_.GenerateKeyRequest(
|
||||
session_id_, key_set_id, init_data_type, init_data,
|
||||
license_type, app_parameters, property_set,
|
||||
cdm_identifier, &key_request));
|
||||
cdm_identifier, &key_request))
|
||||
<< "session_id_ " << session_id_ << std::endl
|
||||
<< "init_data (hex) " << wvcdm::b2a_hex(init_data) << std::endl
|
||||
<< "key_set_id " << key_set_id << std::endl
|
||||
<< "cdm_identifier.origin " << cdm_identifier.origin << std::endl
|
||||
<< "cdm_identifier.app_package_name " << cdm_identifier.app_package_name << std::endl
|
||||
<< "cdm_identifier.unique_id " << cdm_identifier.unique_id << std::endl;
|
||||
key_msg_ = key_request.message;
|
||||
EXPECT_EQ(0u, key_request.url.size());
|
||||
}
|
||||
@@ -4186,14 +4205,20 @@ class WvCdmSessionSharingTest
|
||||
TEST_P(WvCdmSessionSharingTest, SessionSharingTest) {
|
||||
SessionSharingSubSampleInfo* session_sharing_info = GetParam();
|
||||
|
||||
CdmIdentifier cdm_identifier = session_sharing_info->cdm_identifier;
|
||||
if (!cdm_identifier.IsEquivalentToDefault()) {
|
||||
Provision(session_sharing_info->cdm_identifier, kLevelDefault);
|
||||
}
|
||||
|
||||
TestWvCdmClientPropertySet property_set;
|
||||
property_set.set_session_sharing_mode(
|
||||
session_sharing_info->session_sharing_enabled);
|
||||
|
||||
decryptor_.OpenSession(g_key_system, &property_set, kDefaultCdmIdentifier,
|
||||
NULL, &session_id_);
|
||||
ASSERT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, &property_set,
|
||||
cdm_identifier, NULL,
|
||||
&session_id_));
|
||||
CdmSessionId gp_session_id_1 = session_id_;
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming);
|
||||
GenerateKeyRequest(g_key_id, kLicenseTypeStreaming, cdm_identifier);
|
||||
VerifyKeyRequestResponse(g_license_server, g_client_auth);
|
||||
|
||||
// TODO(rfrias): Move content information to ConfigTestEnv
|
||||
@@ -4204,10 +4229,11 @@ TEST_P(WvCdmSessionSharingTest, SessionSharingTest) {
|
||||
"edef8ba979d64acea3c827dcd51d21ed00000014" // Widevine system id
|
||||
"08011210bdf1cb4fffc6506b8b7945b0bd2917fb"); // pssh data
|
||||
|
||||
decryptor_.OpenSession(g_key_system, &property_set, kDefaultCdmIdentifier,
|
||||
NULL, &session_id_);
|
||||
ASSERT_EQ(NO_ERROR, decryptor_.OpenSession(g_key_system, &property_set,
|
||||
cdm_identifier, NULL,
|
||||
&session_id_));
|
||||
CdmSessionId gp_session_id_2 = session_id_;
|
||||
GenerateKeyRequest(gp_key_id2, kLicenseTypeStreaming);
|
||||
GenerateKeyRequest(gp_key_id2, kLicenseTypeStreaming, cdm_identifier);
|
||||
VerifyKeyRequestResponse(g_license_server, gp_client_auth2);
|
||||
|
||||
SubSampleInfo* data = session_sharing_info->sub_sample;
|
||||
@@ -4222,7 +4248,10 @@ TEST_P(WvCdmSessionSharingTest, SessionSharingTest) {
|
||||
if (session_sharing_info->session_sharing_enabled || !data->is_encrypted) {
|
||||
EXPECT_EQ(NO_ERROR,
|
||||
decryptor_.Decrypt(gp_session_id_2, data->validate_key_id,
|
||||
decryption_parameters));
|
||||
decryption_parameters))
|
||||
<< "session_sharing_info->session_sharing_enabled "
|
||||
<< session_sharing_info->session_sharing_enabled << std::endl
|
||||
<< "data->is_encrypted " << data->is_encrypted << std::endl;
|
||||
EXPECT_TRUE(std::equal(data->decrypt_data.begin(), data->decrypt_data.end(),
|
||||
decrypt_buffer.begin()));
|
||||
} else {
|
||||
@@ -4231,13 +4260,19 @@ TEST_P(WvCdmSessionSharingTest, SessionSharingTest) {
|
||||
decryption_parameters));
|
||||
}
|
||||
|
||||
if (!cdm_identifier.IsEquivalentToDefault()) {
|
||||
// Unprovision both security level certs.
|
||||
decryptor_.Unprovision(kSecurityLevelL1, cdm_identifier);
|
||||
decryptor_.Unprovision(kSecurityLevelL3, cdm_identifier);
|
||||
}
|
||||
|
||||
decryptor_.CloseSession(gp_session_id_1);
|
||||
decryptor_.CloseSession(gp_session_id_2);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Cdm, WvCdmSessionSharingTest,
|
||||
::testing::Range(&session_sharing_sub_samples[0],
|
||||
&session_sharing_sub_samples[6]));
|
||||
&session_sharing_sub_samples[7]));
|
||||
|
||||
TEST_F(WvCdmRequestLicenseTest, SessionSharingTest) {
|
||||
TestWvCdmClientPropertySet property_set;
|
||||
|
||||
Reference in New Issue
Block a user