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 CdmKeyInformationVector key_information; |
| 335 base::AutoLock auto_lock(key_map_lock_); |
| 336 for (const auto& item : key_map_) { |
| 337 if (item.second->Contains(web_session_id)) { |
| 338 CdmKeyInformation key_id(item.first, CdmKeyInformation::USABLE, 0); |
| 339 key_information.push_back(key_id); |
| 340 } |
| 341 } |
| 342 |
332 // Assume that at least 1 new key has been successfully added and thus | 343 // Assume that at least 1 new key has been successfully added and thus |
333 // sending true. | 344 // sending true for |has_additional_usable_key|. |
334 session_keys_change_cb_.Run(web_session_id, true); | 345 session_keys_change_cb_.Run(web_session_id, true, key_information); |
335 } | 346 } |
336 | 347 |
337 void AesDecryptor::CloseSession(const std::string& web_session_id, | 348 void AesDecryptor::CloseSession(const std::string& web_session_id, |
338 scoped_ptr<SimpleCdmPromise> promise) { | 349 scoped_ptr<SimpleCdmPromise> promise) { |
339 // Validate that this is a reference to an active session and then forget it. | 350 // 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); | 351 std::set<std::string>::iterator it = valid_sessions_.find(web_session_id); |
341 DCHECK(it != valid_sessions_.end()); | 352 DCHECK(it != valid_sessions_.end()); |
342 | 353 |
343 valid_sessions_.erase(it); | 354 valid_sessions_.erase(it); |
344 | 355 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 bool AesDecryptor::DecryptionKey::Init() { | 542 bool AesDecryptor::DecryptionKey::Init() { |
532 CHECK(!secret_.empty()); | 543 CHECK(!secret_.empty()); |
533 decryption_key_.reset(crypto::SymmetricKey::Import( | 544 decryption_key_.reset(crypto::SymmetricKey::Import( |
534 crypto::SymmetricKey::AES, secret_)); | 545 crypto::SymmetricKey::AES, secret_)); |
535 if (!decryption_key_) | 546 if (!decryption_key_) |
536 return false; | 547 return false; |
537 return true; | 548 return true; |
538 } | 549 } |
539 | 550 |
540 } // namespace media | 551 } // namespace media |
OLD | NEW |