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 std::vector<uint8_t> key_id_vector(item.first.begin(), item.first.end()); | |
340 key_info->key_id = key_id_vector; | |
xhwang
2015/01/05 22:53:15
You can avoid the extra copy here by using
key_i
jrummell
2015/01/06 02:36:25
Done.
| |
341 key_info->status = CdmKeyInformation::USABLE; | |
342 key_info->system_code = 0; | |
343 keys_info.push_back(key_info.release()); | |
344 } | |
345 } | |
346 | |
332 // Assume that at least 1 new key has been successfully added and thus | 347 // Assume that at least 1 new key has been successfully added and thus |
333 // sending true. | 348 // sending true for |has_additional_usable_key|. |
334 session_keys_change_cb_.Run(web_session_id, true); | 349 session_keys_change_cb_.Run(web_session_id, true, keys_info); |
335 } | 350 } |
336 | 351 |
337 void AesDecryptor::CloseSession(const std::string& web_session_id, | 352 void AesDecryptor::CloseSession(const std::string& web_session_id, |
338 scoped_ptr<SimpleCdmPromise> promise) { | 353 scoped_ptr<SimpleCdmPromise> promise) { |
339 // Validate that this is a reference to an active session and then forget it. | 354 // 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); | 355 std::set<std::string>::iterator it = valid_sessions_.find(web_session_id); |
341 DCHECK(it != valid_sessions_.end()); | 356 DCHECK(it != valid_sessions_.end()); |
342 | 357 |
343 valid_sessions_.erase(it); | 358 valid_sessions_.erase(it); |
344 | 359 |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
531 bool AesDecryptor::DecryptionKey::Init() { | 546 bool AesDecryptor::DecryptionKey::Init() { |
532 CHECK(!secret_.empty()); | 547 CHECK(!secret_.empty()); |
533 decryption_key_.reset(crypto::SymmetricKey::Import( | 548 decryption_key_.reset(crypto::SymmetricKey::Import( |
534 crypto::SymmetricKey::AES, secret_)); | 549 crypto::SymmetricKey::AES, secret_)); |
535 if (!decryption_key_) | 550 if (!decryption_key_) |
536 return false; | 551 return false; |
537 return true; | 552 return true; |
538 } | 553 } |
539 | 554 |
540 } // namespace media | 555 } // namespace media |
OLD | NEW |