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