diff options
author | xhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-06 22:35:00 +0000 |
---|---|---|
committer | xhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-06 22:35:00 +0000 |
commit | 5714b81d0c7ee2bdfbbe6c89001906666e13aa9e (patch) | |
tree | 44c11c6021d42ae6aac14afacd58db3b7c0b9f11 /media/crypto | |
parent | bd5831fb4aafd270ee8fccfe09791ab5c9b2eeaa (diff) | |
download | chromium_src-5714b81d0c7ee2bdfbbe6c89001906666e13aa9e.zip chromium_src-5714b81d0c7ee2bdfbbe6c89001906666e13aa9e.tar.gz chromium_src-5714b81d0c7ee2bdfbbe6c89001906666e13aa9e.tar.bz2 |
Encrypted Media: Use std::string for key message in media pipeline.
This is part of the changes to use string for key messages. We also need to make the same change in CDM.h, CDMs and PPAPI.
TBR=dmichael@chromium.org
BUG=164498
TEST=media_unittests; EME demo works.
Review URL: https://chromiumcodereview.appspot.com/11459005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171608 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/crypto')
-rw-r--r-- | media/crypto/aes_decryptor.cc | 12 | ||||
-rw-r--r-- | media/crypto/aes_decryptor_unittest.cc | 15 |
2 files changed, 10 insertions, 17 deletions
diff --git a/media/crypto/aes_decryptor.cc b/media/crypto/aes_decryptor.cc index a1dd46a..a4b6bc6 100644 --- a/media/crypto/aes_decryptor.cc +++ b/media/crypto/aes_decryptor.cc @@ -141,17 +141,13 @@ bool AesDecryptor::GenerateKeyRequest(const std::string& key_system, // For now, the AesDecryptor does not care about |key_system| and |type|; // just fire the event with the |init_data| as the request. - scoped_array<uint8> message; - int message_length = 0; - + std::string message; if (init_data && init_data_length) { - message_length = init_data_length; - message.reset(new uint8[message_length]); - memcpy(message.get(), init_data, message_length); + message = std::string(reinterpret_cast<const char*>(init_data), + init_data_length); } - client_->KeyMessage(key_system, session_id_string, - message.Pass(), message_length, ""); + client_->KeyMessage(key_system, session_id_string, message, ""); return true; } diff --git a/media/crypto/aes_decryptor_unittest.cc b/media/crypto/aes_decryptor_unittest.cc index 8a35b06..2fab86d 100644 --- a/media/crypto/aes_decryptor_unittest.cc +++ b/media/crypto/aes_decryptor_unittest.cc @@ -20,14 +20,11 @@ using ::testing::Gt; using ::testing::IsNull; using ::testing::NotNull; using ::testing::SaveArg; +using ::testing::StrEq; using ::testing::StrNe; namespace media { -MATCHER_P2(ArrayEq, array, size, "") { - return !memcmp(arg, array, size); -} - // |encrypted_data| is encrypted from |plain_text| using |key|. |key_id| is // used to distinguish |key|. struct WebmEncryptedData { @@ -239,9 +236,10 @@ class AesDecryptorTest : public testing::Test { protected: void GenerateKeyRequest(const uint8* key_id, int key_id_size) { - EXPECT_CALL(client_, KeyMessageMock(kClearKeySystem, StrNe(""), - ArrayEq(key_id, key_id_size), - key_id_size, "")) + std::string key_id_string(reinterpret_cast<const char*>(key_id), + key_id_size); + EXPECT_CALL(client_, KeyMessage(kClearKeySystem, + StrNe(""), StrEq(key_id_string), "")) .WillOnce(SaveArg<1>(&session_id_string_)); EXPECT_TRUE(decryptor_.GenerateKeyRequest(kClearKeySystem, "", key_id, key_id_size)); @@ -316,8 +314,7 @@ class AesDecryptorTest : public testing::Test { }; TEST_F(AesDecryptorTest, GenerateKeyRequestWithNullInitData) { - EXPECT_CALL(client_, KeyMessageMock(kClearKeySystem, StrNe(""), - IsNull(), 0, "")); + EXPECT_CALL(client_, KeyMessage(kClearKeySystem, StrNe(""), "", "")); EXPECT_TRUE(decryptor_.GenerateKeyRequest(kClearKeySystem, "", NULL, 0)); } |