| 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 <list> | 7 #include <list> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "crypto/encryptor.h" | 13 #include "crypto/encryptor.h" |
| 14 #include "crypto/symmetric_key.h" | 14 #include "crypto/symmetric_key.h" |
| 15 #include "media/base/audio_decoder_config.h" | 15 #include "media/base/audio_decoder_config.h" |
| 16 #include "media/base/cdm_key_information.h" |
| 16 #include "media/base/cdm_promise.h" | 17 #include "media/base/cdm_promise.h" |
| 17 #include "media/base/decoder_buffer.h" | 18 #include "media/base/decoder_buffer.h" |
| 18 #include "media/base/decrypt_config.h" | 19 #include "media/base/decrypt_config.h" |
| 19 #include "media/base/video_decoder_config.h" | 20 #include "media/base/video_decoder_config.h" |
| 20 #include "media/base/video_frame.h" | 21 #include "media/base/video_frame.h" |
| 21 #include "media/cdm/json_web_key.h" | 22 #include "media/cdm/json_web_key.h" |
| 22 | 23 |
| 23 namespace media { | 24 namespace media { |
| 24 | 25 |
| 25 // Keeps track of the session IDs and DecryptionKeys. The keys are ordered by | 26 // Keeps track of the session IDs and DecryptionKeys. The keys are ordered by |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 | 323 |
| 323 if (!new_audio_key_cb_.is_null()) | 324 if (!new_audio_key_cb_.is_null()) |
| 324 new_audio_key_cb_.Run(); | 325 new_audio_key_cb_.Run(); |
| 325 | 326 |
| 326 if (!new_video_key_cb_.is_null()) | 327 if (!new_video_key_cb_.is_null()) |
| 327 new_video_key_cb_.Run(); | 328 new_video_key_cb_.Run(); |
| 328 } | 329 } |
| 329 | 330 |
| 330 promise->resolve(); | 331 promise->resolve(); |
| 331 | 332 |
| 333 // Create the list of all available keys for this session. |
| 334 CdmKeysInfo keys_info; |
| 335 base::AutoLock auto_lock(key_map_lock_); |
| 336 for (const auto& item : key_map_) { |
| 337 if (item.second->Contains(web_session_id)) { |
| 338 scoped_ptr<CdmKeyInformation> key_info(new CdmKeyInformation); |
| 339 key_info->key_id.assign(item.first.begin(), item.first.end()); |
| 340 key_info->status = CdmKeyInformation::USABLE; |
| 341 key_info->system_code = 0; |
| 342 keys_info.push_back(key_info.release()); |
| 343 } |
| 344 } |
| 345 |
| 332 // Assume that at least 1 new key has been successfully added and thus | 346 // Assume that at least 1 new key has been successfully added and thus |
| 333 // sending true. | 347 // sending true for |has_additional_usable_key|. |
| 334 session_keys_change_cb_.Run(web_session_id, true); | 348 session_keys_change_cb_.Run(web_session_id, true, keys_info.Pass()); |
| 335 } | 349 } |
| 336 | 350 |
| 337 void AesDecryptor::CloseSession(const std::string& web_session_id, | 351 void AesDecryptor::CloseSession(const std::string& web_session_id, |
| 338 scoped_ptr<SimpleCdmPromise> promise) { | 352 scoped_ptr<SimpleCdmPromise> promise) { |
| 339 // Validate that this is a reference to an active session and then forget it. | 353 // Validate that this is a reference to an active session and then forget it. |
| 340 std::set<std::string>::iterator it = valid_sessions_.find(web_session_id); | 354 std::set<std::string>::iterator it = valid_sessions_.find(web_session_id); |
| 341 DCHECK(it != valid_sessions_.end()); | 355 DCHECK(it != valid_sessions_.end()); |
| 342 | 356 |
| 343 valid_sessions_.erase(it); | 357 valid_sessions_.erase(it); |
| 344 | 358 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 bool AesDecryptor::DecryptionKey::Init() { | 545 bool AesDecryptor::DecryptionKey::Init() { |
| 532 CHECK(!secret_.empty()); | 546 CHECK(!secret_.empty()); |
| 533 decryption_key_.reset(crypto::SymmetricKey::Import( | 547 decryption_key_.reset(crypto::SymmetricKey::Import( |
| 534 crypto::SymmetricKey::AES, secret_)); | 548 crypto::SymmetricKey::AES, secret_)); |
| 535 if (!decryption_key_) | 549 if (!decryption_key_) |
| 536 return false; | 550 return false; |
| 537 return true; | 551 return true; |
| 538 } | 552 } |
| 539 | 553 |
| 540 } // namespace media | 554 } // namespace media |
| OLD | NEW |