Search for keys in shared sessions only when content is encrypted

Also return NEED_KEY rather than KEY_ERROR if keys are not found.

Merge of https://widevine-internal-review.googlesource.com/#/c/8250
from the widevine cdm repo.

b/11375092

Change-Id: Ibc629e8b4018f43f5f9528258563a2af79bdfb4b
This commit is contained in:
Rahul Frias
2013-10-25 13:09:40 -07:00
parent e385ff3a7f
commit 252a07316a
2 changed files with 13 additions and 8 deletions

View File

@@ -119,11 +119,12 @@ CdmResponseType WvContentDecryptionModule::Decrypt(
const CdmSessionId& session_id,
const CdmDecryptionParameters& parameters) {
CdmSessionId id = session_id;
if (Properties::GetSessionSharingId(session_id) != 0) {
if (parameters.is_encrypted &&
Properties::GetSessionSharingId(session_id) != 0) {
bool status = cdm_engine_->FindSessionForKey(*parameters.key_id, &id);
if (!status) {
LOGE("WvContentDecryptionModule::Decrypt: unable to find session");
return KEY_ERROR;
return NEED_KEY;
}
}
return cdm_engine_->Decrypt(id, parameters);

View File

@@ -575,12 +575,16 @@ TEST_P(WvCdmSessionSharingTest, SessionSharingTest) {
&decrypt_buffer[0]);
decryption_parameters.is_encrypted = data->is_encrypted;
decryption_parameters.is_secure = data->is_secure;
EXPECT_EQ(
NO_ERROR == decryptor_.Decrypt(gp_session_id_2, decryption_parameters),
enable_session_sharing);
EXPECT_EQ(std::equal(data->decrypt_data.begin(), data->decrypt_data.end(),
decrypt_buffer.begin()),
enable_session_sharing);
if (enable_session_sharing) {
EXPECT_EQ(NO_ERROR, decryptor_.Decrypt(gp_session_id_2,
decryption_parameters));
EXPECT_TRUE(std::equal(data->decrypt_data.begin(), data->decrypt_data.end(),
decrypt_buffer.begin()));
} else {
EXPECT_EQ(NEED_KEY, decryptor_.Decrypt(gp_session_id_2,
decryption_parameters));
}
decryptor_.CloseSession(gp_session_id_1);
decryptor_.CloseSession(gp_session_id_2);