OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef MEDIA_CDM_CDM_ADAPTER_H_ | 5 #ifndef MEDIA_CDM_CDM_ADAPTER_H_ |
6 #define MEDIA_CDM_CDM_ADAPTER_H_ | 6 #define MEDIA_CDM_CDM_ADAPTER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
20 #include "base/scoped_native_library.h" | 20 #include "base/scoped_native_library.h" |
21 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
22 #include "media/base/cdm_config.h" | 22 #include "media/base/cdm_config.h" |
23 #include "media/base/cdm_context.h" | 23 #include "media/base/cdm_context.h" |
24 #include "media/base/cdm_factory.h" | 24 #include "media/base/cdm_factory.h" |
25 #include "media/base/cdm_promise_adapter.h" | 25 #include "media/base/cdm_promise_adapter.h" |
| 26 #include "media/base/content_decryption_module.h" |
26 #include "media/base/decryptor.h" | 27 #include "media/base/decryptor.h" |
27 #include "media/base/media_export.h" | 28 #include "media/base/media_export.h" |
28 #include "media/base/media_keys.h" | |
29 #include "media/cdm/api/content_decryption_module.h" | 29 #include "media/cdm/api/content_decryption_module.h" |
30 #include "ui/gfx/geometry/size.h" | 30 #include "ui/gfx/geometry/size.h" |
31 | 31 |
32 namespace media { | 32 namespace media { |
33 | 33 |
34 class AudioFramesImpl; | 34 class AudioFramesImpl; |
35 class CdmAllocator; | 35 class CdmAllocator; |
36 class CdmFileIO; | 36 class CdmFileIO; |
37 class CdmWrapper; | 37 class CdmWrapper; |
38 | 38 |
39 // Called when the CDM needs a FileIO object from the host to do file IO | 39 // Called when the CDM needs a FileIO object from the host to do file IO |
40 // operations. Returns NULL if a FileIO object cannot be obtained. Once a | 40 // operations. Returns NULL if a FileIO object cannot be obtained. Once a |
41 // valid FileIO object is returned, |client| must be valid until | 41 // valid FileIO object is returned, |client| must be valid until |
42 // FileIO::Close() is called. The CDM can call this method multiple times | 42 // FileIO::Close() is called. The CDM can call this method multiple times |
43 // to operate on different files. | 43 // to operate on different files. |
44 using CreateCdmFileIOCB = | 44 using CreateCdmFileIOCB = |
45 base::Callback<std::unique_ptr<CdmFileIO>(cdm::FileIOClient* client)>; | 45 base::Callback<std::unique_ptr<CdmFileIO>(cdm::FileIOClient* client)>; |
46 | 46 |
47 class MEDIA_EXPORT CdmAdapter : public MediaKeys, | 47 class MEDIA_EXPORT CdmAdapter : public ContentDecryptionModule, |
48 public CdmContext, | 48 public CdmContext, |
49 public Decryptor, | 49 public Decryptor, |
50 NON_EXPORTED_BASE(public cdm::Host_8) { | 50 NON_EXPORTED_BASE(public cdm::Host_8) { |
51 public: | 51 public: |
52 // Create the CDM using |cdm_path| and initialize it using |key_system| and | 52 // Create the CDM using |cdm_path| and initialize it using |key_system| and |
53 // |cdm_config|. |allocator| is to be used whenever the CDM needs memory | 53 // |cdm_config|. |allocator| is to be used whenever the CDM needs memory |
54 // and to create VideoFrames. |file_io_provider| is to be used whenever the | 54 // and to create VideoFrames. |file_io_provider| is to be used whenever the |
55 // CDM needs access to the file system. Callbacks will be used for events | 55 // CDM needs access to the file system. Callbacks will be used for events |
56 // generated by the CDM. |cdm_created_cb| will be called when the CDM is | 56 // generated by the CDM. |cdm_created_cb| will be called when the CDM is |
57 // loaded and initialized. | 57 // loaded and initialized. |
58 static void Create( | 58 static void Create( |
59 const std::string& key_system, | 59 const std::string& key_system, |
60 const base::FilePath& cdm_path, | 60 const base::FilePath& cdm_path, |
61 const CdmConfig& cdm_config, | 61 const CdmConfig& cdm_config, |
62 std::unique_ptr<CdmAllocator> allocator, | 62 std::unique_ptr<CdmAllocator> allocator, |
63 const CreateCdmFileIOCB& create_cdm_file_io_cb, | 63 const CreateCdmFileIOCB& create_cdm_file_io_cb, |
64 const SessionMessageCB& session_message_cb, | 64 const SessionMessageCB& session_message_cb, |
65 const SessionClosedCB& session_closed_cb, | 65 const SessionClosedCB& session_closed_cb, |
66 const SessionKeysChangeCB& session_keys_change_cb, | 66 const SessionKeysChangeCB& session_keys_change_cb, |
67 const SessionExpirationUpdateCB& session_expiration_update_cb, | 67 const SessionExpirationUpdateCB& session_expiration_update_cb, |
68 const CdmCreatedCB& cdm_created_cb); | 68 const CdmCreatedCB& cdm_created_cb); |
69 | 69 |
70 // MediaKeys implementation. | 70 // ContentDecryptionModule implementation. |
71 void SetServerCertificate(const std::vector<uint8_t>& certificate, | 71 void SetServerCertificate(const std::vector<uint8_t>& certificate, |
72 std::unique_ptr<SimpleCdmPromise> promise) final; | 72 std::unique_ptr<SimpleCdmPromise> promise) final; |
73 void CreateSessionAndGenerateRequest( | 73 void CreateSessionAndGenerateRequest( |
74 SessionType session_type, | 74 SessionType session_type, |
75 EmeInitDataType init_data_type, | 75 EmeInitDataType init_data_type, |
76 const std::vector<uint8_t>& init_data, | 76 const std::vector<uint8_t>& init_data, |
77 std::unique_ptr<NewSessionCdmPromise> promise) final; | 77 std::unique_ptr<NewSessionCdmPromise> promise) final; |
78 void LoadSession(SessionType session_type, | 78 void LoadSession(SessionType session_type, |
79 const std::string& session_id, | 79 const std::string& session_id, |
80 std::unique_ptr<NewSessionCdmPromise> promise) final; | 80 std::unique_ptr<NewSessionCdmPromise> promise) final; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 226 |
227 // NOTE: Weak pointers must be invalidated before all other member variables. | 227 // NOTE: Weak pointers must be invalidated before all other member variables. |
228 base::WeakPtrFactory<CdmAdapter> weak_factory_; | 228 base::WeakPtrFactory<CdmAdapter> weak_factory_; |
229 | 229 |
230 DISALLOW_COPY_AND_ASSIGN(CdmAdapter); | 230 DISALLOW_COPY_AND_ASSIGN(CdmAdapter); |
231 }; | 231 }; |
232 | 232 |
233 } // namespace media | 233 } // namespace media |
234 | 234 |
235 #endif // MEDIA_CDM_CDM_ADAPTER_H_ | 235 #endif // MEDIA_CDM_CDM_ADAPTER_H_ |
OLD | NEW |