Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | |
|
DaleCurtis
2017/04/20 21:40:25
No (c).
xjz
2017/04/20 22:07:44
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_TEST_FAKE_ENCRYPTED_MEDIA_H_ | |
| 6 #define MEDIA_TEST_FAKE_ENCRYPTED_MEDIA_H_ | |
| 7 | |
| 8 #include "media/base/cdm_context.h" | |
| 9 #include "media/base/content_decryption_module.h" | |
| 10 | |
| 11 namespace media { | |
| 12 | |
| 13 class AesDecryptor; | |
| 14 | |
| 15 // Note: Tests using this class only exercise the DecryptingDemuxerStream path. | |
| 16 // They do not exercise the Decrypting{Audio|Video}Decoder path. | |
| 17 class FakeEncryptedMedia { | |
| 18 public: | |
| 19 // Defines the behavior of the "app" that responds to EME events. | |
| 20 class AppBase { | |
| 21 public: | |
| 22 virtual ~AppBase() {} | |
| 23 | |
| 24 virtual void OnSessionMessage( | |
| 25 const std::string& session_id, | |
| 26 ContentDecryptionModule::MessageType message_type, | |
| 27 const std::vector<uint8_t>& message, | |
| 28 AesDecryptor* decryptor) = 0; | |
| 29 | |
| 30 virtual void OnSessionClosed(const std::string& session_id) = 0; | |
| 31 | |
| 32 virtual void OnSessionKeysChange(const std::string& session_id, | |
| 33 bool has_additional_usable_key, | |
| 34 CdmKeysInfo keys_info) = 0; | |
| 35 | |
| 36 virtual void OnEncryptedMediaInitData(EmeInitDataType init_data_type, | |
| 37 const std::vector<uint8_t>& init_data, | |
| 38 AesDecryptor* decryptor) = 0; | |
| 39 }; | |
| 40 | |
| 41 FakeEncryptedMedia(AppBase* app); | |
| 42 ~FakeEncryptedMedia(); | |
| 43 CdmContext* GetCdmContext(); | |
| 44 // Callbacks for firing session events. Delegate to |app_|. | |
| 45 void OnSessionMessage(const std::string& session_id, | |
| 46 ContentDecryptionModule::MessageType message_type, | |
| 47 const std::vector<uint8_t>& message); | |
| 48 void OnSessionClosed(const std::string& session_id); | |
| 49 void OnSessionKeysChange(const std::string& session_id, | |
| 50 bool has_additional_usable_key, | |
| 51 CdmKeysInfo keys_info); | |
| 52 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, | |
| 53 const std::vector<uint8_t>& init_data); | |
| 54 | |
| 55 private: | |
| 56 class TestCdmContext : public CdmContext { | |
| 57 public: | |
| 58 TestCdmContext(Decryptor* decryptor); | |
| 59 Decryptor* GetDecryptor() final; | |
| 60 int GetCdmId() const final; | |
| 61 | |
| 62 private: | |
| 63 Decryptor* decryptor_; | |
| 64 }; | |
| 65 | |
| 66 scoped_refptr<AesDecryptor> decryptor_; | |
| 67 TestCdmContext cdm_context_; | |
| 68 std::unique_ptr<AppBase> app_; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(FakeEncryptedMedia); | |
| 71 }; | |
| 72 | |
| 73 } // namespace media | |
| 74 | |
| 75 #endif // MEDIA_TEST_FAKE_ENCRYPTED_MEDIA_H_ | |
| OLD | NEW |