OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/test/fake_encrypted_media.h" | 5 #include "media/test/fake_encrypted_media.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "media/base/cdm_key_information.h" | 8 #include "media/base/cdm_key_information.h" |
9 #include "media/cdm/aes_decryptor.h" | 9 #include "media/cdm/aes_decryptor.h" |
10 | 10 |
11 namespace media { | 11 namespace media { |
12 | 12 |
13 FakeEncryptedMedia::TestCdmContext::TestCdmContext(Decryptor* decryptor) | 13 FakeEncryptedMedia::TestCdmContext::TestCdmContext(Decryptor* decryptor) |
14 : decryptor_(decryptor) {} | 14 : decryptor_(decryptor) {} |
15 | 15 |
16 Decryptor* FakeEncryptedMedia::TestCdmContext::GetDecryptor() { | 16 Decryptor* FakeEncryptedMedia::TestCdmContext::GetDecryptor() { |
17 return decryptor_; | 17 return decryptor_; |
18 } | 18 } |
19 | 19 |
20 int FakeEncryptedMedia::TestCdmContext::GetCdmId() const { | 20 int FakeEncryptedMedia::TestCdmContext::GetCdmId() const { |
21 return kInvalidCdmId; | 21 return kInvalidCdmId; |
22 } | 22 } |
23 | 23 |
24 FakeEncryptedMedia::FakeEncryptedMedia(AppBase* app) | 24 FakeEncryptedMedia::FakeEncryptedMedia(AppBase* app) |
25 : decryptor_( | 25 : decryptor_(new AesDecryptor( |
26 new AesDecryptor(GURL::EmptyGURL(), | 26 GURL::EmptyGURL(), |
27 base::Bind(&FakeEncryptedMedia::OnSessionMessage, | 27 base::Bind(&FakeEncryptedMedia::OnSessionMessage, |
28 base::Unretained(this)), | 28 base::Unretained(this)), |
29 base::Bind(&FakeEncryptedMedia::OnSessionClosed, | 29 base::Bind(&FakeEncryptedMedia::OnSessionClosed, |
30 base::Unretained(this)), | 30 base::Unretained(this)), |
31 base::Bind(&FakeEncryptedMedia::OnSessionKeysChange, | 31 base::Bind(&FakeEncryptedMedia::OnSessionKeysChange, |
32 base::Unretained(this)))), | 32 base::Unretained(this)), |
| 33 base::Bind(&FakeEncryptedMedia::OnSessionExpirationUpdate, |
| 34 base::Unretained(this)))), |
33 cdm_context_(decryptor_.get()), | 35 cdm_context_(decryptor_.get()), |
34 app_(app) {} | 36 app_(app) {} |
35 | 37 |
36 FakeEncryptedMedia::~FakeEncryptedMedia() {} | 38 FakeEncryptedMedia::~FakeEncryptedMedia() {} |
37 | 39 |
38 CdmContext* FakeEncryptedMedia::GetCdmContext() { | 40 CdmContext* FakeEncryptedMedia::GetCdmContext() { |
39 return &cdm_context_; | 41 return &cdm_context_; |
40 } | 42 } |
41 | 43 |
42 // Callbacks for firing session events. Delegate to |app_|. | 44 // Callbacks for firing session events. Delegate to |app_|. |
43 void FakeEncryptedMedia::OnSessionMessage( | 45 void FakeEncryptedMedia::OnSessionMessage( |
44 const std::string& session_id, | 46 const std::string& session_id, |
45 ContentDecryptionModule::MessageType message_type, | 47 ContentDecryptionModule::MessageType message_type, |
46 const std::vector<uint8_t>& message) { | 48 const std::vector<uint8_t>& message) { |
47 app_->OnSessionMessage(session_id, message_type, message, decryptor_.get()); | 49 app_->OnSessionMessage(session_id, message_type, message, decryptor_.get()); |
48 } | 50 } |
49 | 51 |
50 void FakeEncryptedMedia::OnSessionClosed(const std::string& session_id) { | 52 void FakeEncryptedMedia::OnSessionClosed(const std::string& session_id) { |
51 app_->OnSessionClosed(session_id); | 53 app_->OnSessionClosed(session_id); |
52 } | 54 } |
53 | 55 |
54 void FakeEncryptedMedia::OnSessionKeysChange(const std::string& session_id, | 56 void FakeEncryptedMedia::OnSessionKeysChange(const std::string& session_id, |
55 bool has_additional_usable_key, | 57 bool has_additional_usable_key, |
56 CdmKeysInfo keys_info) { | 58 CdmKeysInfo keys_info) { |
57 app_->OnSessionKeysChange(session_id, has_additional_usable_key, | 59 app_->OnSessionKeysChange(session_id, has_additional_usable_key, |
58 std::move(keys_info)); | 60 std::move(keys_info)); |
59 } | 61 } |
60 | 62 |
| 63 void FakeEncryptedMedia::OnSessionExpirationUpdate( |
| 64 const std::string& session_id, |
| 65 base::Time new_expiry_time) { |
| 66 app_->OnSessionExpirationUpdate(session_id, new_expiry_time); |
| 67 } |
| 68 |
61 void FakeEncryptedMedia::OnEncryptedMediaInitData( | 69 void FakeEncryptedMedia::OnEncryptedMediaInitData( |
62 EmeInitDataType init_data_type, | 70 EmeInitDataType init_data_type, |
63 const std::vector<uint8_t>& init_data) { | 71 const std::vector<uint8_t>& init_data) { |
64 app_->OnEncryptedMediaInitData(init_data_type, init_data, decryptor_.get()); | 72 app_->OnEncryptedMediaInitData(init_data_type, init_data, decryptor_.get()); |
65 } | 73 } |
66 | 74 |
67 } // namespace media | 75 } // namespace media |
OLD | NEW |