Bug 1409670 - Skip decrypting request when receiving an unencrypted sample in Clearkey implementation. r?cpearce
MozReview-Commit-ID: 5XIUeFc3PSD
--- a/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
+++ b/media/gmp-clearkey/0.1/ClearKeySessionManager.cpp
@@ -634,19 +634,24 @@ ClearKeySessionManager::Decrypt(const In
Buffer* buffer = mHost->Allocate(aBuffer.data_size);
assert(buffer != nullptr);
assert(buffer->Data() != nullptr);
assert(buffer->Capacity() >= aBuffer.data_size);
memcpy(buffer->Data(), aBuffer.data, aBuffer.data_size);
- Status status = mDecryptionManager->Decrypt(buffer->Data(),
- buffer->Size(),
- CryptoMetaData(&aBuffer));
+ Status status = Status::kSuccess;
+ // According to the comment `If |iv_size| = 0, the data is unencrypted.`
+ // Use iv_size to determine if the sample is encrypted.
+ if (aBuffer.iv_size != 0) {
+ status = mDecryptionManager->Decrypt(buffer->Data(),
+ buffer->Size(),
+ CryptoMetaData(&aBuffer));
+ }
aDecryptedBlock->SetDecryptedBuffer(buffer);
aDecryptedBlock->SetTimestamp(aBuffer.timestamp);
return status;
}
void