| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/cdm/aes_decryptor.h" | 5 #include "media/cdm/aes_decryptor.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <list> | 8 #include <list> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" |
| 14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 15 #include "crypto/encryptor.h" | 16 #include "crypto/encryptor.h" |
| 16 #include "crypto/symmetric_key.h" | 17 #include "crypto/symmetric_key.h" |
| 17 #include "media/base/audio_decoder_config.h" | 18 #include "media/base/audio_decoder_config.h" |
| 18 #include "media/base/cdm_promise.h" | 19 #include "media/base/cdm_promise.h" |
| 19 #include "media/base/decoder_buffer.h" | 20 #include "media/base/decoder_buffer.h" |
| 20 #include "media/base/decrypt_config.h" | 21 #include "media/base/decrypt_config.h" |
| 21 #include "media/base/limits.h" | 22 #include "media/base/limits.h" |
| 22 #include "media/base/video_decoder_config.h" | 23 #include "media/base/video_decoder_config.h" |
| 23 #include "media/base/video_frame.h" | 24 #include "media/base/video_frame.h" |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 | 649 |
| 649 CdmKeysInfo AesDecryptor::GenerateKeysInfoList( | 650 CdmKeysInfo AesDecryptor::GenerateKeysInfoList( |
| 650 const std::string& session_id, | 651 const std::string& session_id, |
| 651 CdmKeyInformation::KeyStatus status) { | 652 CdmKeyInformation::KeyStatus status) { |
| 652 // Create the list of all available keys for this session. | 653 // Create the list of all available keys for this session. |
| 653 CdmKeysInfo keys_info; | 654 CdmKeysInfo keys_info; |
| 654 { | 655 { |
| 655 base::AutoLock auto_lock(key_map_lock_); | 656 base::AutoLock auto_lock(key_map_lock_); |
| 656 for (const auto& item : key_map_) { | 657 for (const auto& item : key_map_) { |
| 657 if (item.second->Contains(session_id)) { | 658 if (item.second->Contains(session_id)) { |
| 658 keys_info.push_back(new CdmKeyInformation(item.first, status, 0)); | 659 keys_info.push_back( |
| 660 base::MakeUnique<CdmKeyInformation>(item.first, status, 0)); |
| 659 } | 661 } |
| 660 } | 662 } |
| 661 } | 663 } |
| 662 return keys_info; | 664 return keys_info; |
| 663 } | 665 } |
| 664 | 666 |
| 665 AesDecryptor::DecryptionKey::DecryptionKey(const std::string& secret) | 667 AesDecryptor::DecryptionKey::DecryptionKey(const std::string& secret) |
| 666 : secret_(secret) { | 668 : secret_(secret) { |
| 667 } | 669 } |
| 668 | 670 |
| 669 AesDecryptor::DecryptionKey::~DecryptionKey() {} | 671 AesDecryptor::DecryptionKey::~DecryptionKey() {} |
| 670 | 672 |
| 671 bool AesDecryptor::DecryptionKey::Init() { | 673 bool AesDecryptor::DecryptionKey::Init() { |
| 672 CHECK(!secret_.empty()); | 674 CHECK(!secret_.empty()); |
| 673 decryption_key_ = | 675 decryption_key_ = |
| 674 crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, secret_); | 676 crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, secret_); |
| 675 if (!decryption_key_) | 677 if (!decryption_key_) |
| 676 return false; | 678 return false; |
| 677 return true; | 679 return true; |
| 678 } | 680 } |
| 679 | 681 |
| 680 } // namespace media | 682 } // namespace media |
| OLD | NEW |