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 #ifndef MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ | 5 #ifndef MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ |
6 #define MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ | 6 #define MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 namespace media { | 36 namespace media { |
37 | 37 |
38 // GetCdmHostFunc implementation. | 38 // GetCdmHostFunc implementation. |
39 void* GetCdmHost(int host_interface_version, void* user_data); | 39 void* GetCdmHost(int host_interface_version, void* user_data); |
40 | 40 |
41 // An adapter class for abstracting away PPAPI interaction and threading for a | 41 // An adapter class for abstracting away PPAPI interaction and threading for a |
42 // Content Decryption Module (CDM). | 42 // Content Decryption Module (CDM). |
43 class CdmAdapter : public pp::Instance, | 43 class CdmAdapter : public pp::Instance, |
44 public pp::ContentDecryptor_Private, | 44 public pp::ContentDecryptor_Private, |
45 public cdm::Host_4, | 45 public cdm::Host_4, |
46 public cdm::Host_5 { | 46 public cdm::Host_5, |
| 47 public cdm::Host_6 { |
47 public: | 48 public: |
48 CdmAdapter(PP_Instance instance, pp::Module* module); | 49 CdmAdapter(PP_Instance instance, pp::Module* module); |
49 virtual ~CdmAdapter(); | 50 virtual ~CdmAdapter(); |
50 | 51 |
51 // pp::Instance implementation. | 52 // pp::Instance implementation. |
52 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { | 53 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { |
53 return true; | 54 return true; |
54 } | 55 } |
55 | 56 |
56 // PPP_ContentDecryptor_Private implementation. | 57 // PPP_ContentDecryptor_Private implementation. |
57 // Note: Results of calls to these methods must be reported through the | 58 // Note: Results of calls to these methods must be reported through the |
58 // PPB_ContentDecryptor_Private interface. | 59 // PPB_ContentDecryptor_Private interface. |
59 virtual void Initialize(const std::string& key_system) OVERRIDE; | 60 virtual void Initialize(const std::string& key_system) OVERRIDE; |
60 virtual void CreateSession(uint32_t promise_id, | 61 virtual void CreateSession(uint32_t promise_id, |
61 const std::string& init_data_type, | 62 const std::string& init_data_type, |
62 pp::VarArrayBuffer init_data, | 63 pp::VarArrayBuffer init_data, |
63 PP_SessionType session_type) OVERRIDE; | 64 PP_SessionType session_type) OVERRIDE; |
64 virtual void LoadSession(uint32_t promise_id, | 65 virtual void LoadSession(uint32_t promise_id, |
65 const std::string& web_session_id) OVERRIDE; | 66 const std::string& web_session_id) OVERRIDE; |
66 virtual void UpdateSession(uint32_t promise_id, | 67 virtual void UpdateSession(uint32_t promise_id, |
67 const std::string& web_session_id, | 68 const std::string& web_session_id, |
68 pp::VarArrayBuffer response) OVERRIDE; | 69 pp::VarArrayBuffer response) OVERRIDE; |
| 70 // TODO(jrummell): Rename to CloseSession(). |
69 virtual void ReleaseSession(uint32_t promise_id, | 71 virtual void ReleaseSession(uint32_t promise_id, |
70 const std::string& web_session_id) OVERRIDE; | 72 const std::string& web_session_id) OVERRIDE; |
| 73 // TODO(jrummell): Pass these 2 functions through Pepper and add OVERRIDE. |
| 74 virtual void RemoveSession(uint32_t promise_id, |
| 75 const std::string& web_session_id); |
| 76 virtual void GetUsableKeyIds(uint32_t promise_id, |
| 77 const std::string& web_session_id); |
71 virtual void Decrypt( | 78 virtual void Decrypt( |
72 pp::Buffer_Dev encrypted_buffer, | 79 pp::Buffer_Dev encrypted_buffer, |
73 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; | 80 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; |
74 virtual void InitializeAudioDecoder( | 81 virtual void InitializeAudioDecoder( |
75 const PP_AudioDecoderConfig& decoder_config, | 82 const PP_AudioDecoderConfig& decoder_config, |
76 pp::Buffer_Dev extra_data_buffer) OVERRIDE; | 83 pp::Buffer_Dev extra_data_buffer) OVERRIDE; |
77 virtual void InitializeVideoDecoder( | 84 virtual void InitializeVideoDecoder( |
78 const PP_VideoDecoderConfig& decoder_config, | 85 const PP_VideoDecoderConfig& decoder_config, |
79 pp::Buffer_Dev extra_data_buffer) OVERRIDE; | 86 pp::Buffer_Dev extra_data_buffer) OVERRIDE; |
80 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type, | 87 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type, |
81 uint32_t request_id) OVERRIDE; | 88 uint32_t request_id) OVERRIDE; |
82 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type, | 89 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type, |
83 uint32_t request_id) OVERRIDE; | 90 uint32_t request_id) OVERRIDE; |
84 virtual void DecryptAndDecode( | 91 virtual void DecryptAndDecode( |
85 PP_DecryptorStreamType decoder_type, | 92 PP_DecryptorStreamType decoder_type, |
86 pp::Buffer_Dev encrypted_buffer, | 93 pp::Buffer_Dev encrypted_buffer, |
87 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; | 94 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; |
88 | 95 |
89 // cdm::Host_4 and cdm::Host_5 implementation. | 96 // cdm::Host_4, cdm::Host_5 and cdm::Host_6 implementation. |
90 virtual cdm::Buffer* Allocate(uint32_t capacity) OVERRIDE; | 97 virtual cdm::Buffer* Allocate(uint32_t capacity) OVERRIDE; |
91 virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE; | 98 virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE; |
92 | 99 |
93 // cdm::Host_4 implementation. | 100 // cdm::Host_4 implementation. |
94 virtual double GetCurrentWallTimeInSeconds() OVERRIDE; | 101 virtual double GetCurrentWallTimeInSeconds() OVERRIDE; |
95 virtual void OnSessionCreated(uint32_t session_id, | 102 virtual void OnSessionCreated(uint32_t session_id, |
96 const char* web_session_id, | 103 const char* web_session_id, |
97 uint32_t web_session_id_length) OVERRIDE; | 104 uint32_t web_session_id_length) OVERRIDE; |
98 virtual void OnSessionMessage(uint32_t session_id, | 105 virtual void OnSessionMessage(uint32_t session_id, |
99 const char* message, | 106 const char* message, |
(...skipping 19 matching lines...) Expand all Loading... |
119 const char* error_message, | 126 const char* error_message, |
120 uint32_t error_message_length) OVERRIDE; | 127 uint32_t error_message_length) OVERRIDE; |
121 virtual void OnSessionMessage(const char* web_session_id, | 128 virtual void OnSessionMessage(const char* web_session_id, |
122 uint32_t web_session_id_length, | 129 uint32_t web_session_id_length, |
123 const char* message, | 130 const char* message, |
124 uint32_t message_length, | 131 uint32_t message_length, |
125 const char* destination_url, | 132 const char* destination_url, |
126 uint32_t destination_url_length) OVERRIDE; | 133 uint32_t destination_url_length) OVERRIDE; |
127 virtual void OnSessionKeysChange(const char* web_session_id, | 134 virtual void OnSessionKeysChange(const char* web_session_id, |
128 uint32_t web_session_id_length, | 135 uint32_t web_session_id_length, |
129 bool has_additional_usable_key); | 136 bool has_additional_usable_key) OVERRIDE; |
130 virtual void OnExpirationChange(const char* web_session_id, | 137 virtual void OnExpirationChange(const char* web_session_id, |
131 uint32_t web_session_id_length, | 138 uint32_t web_session_id_length, |
132 cdm::Time new_expiry_time); | 139 cdm::Time new_expiry_time) OVERRIDE; |
133 virtual void OnSessionReady(const char* web_session_id, | 140 virtual void OnSessionReady(const char* web_session_id, |
134 uint32_t web_session_id_length) OVERRIDE; | 141 uint32_t web_session_id_length) OVERRIDE; |
135 virtual void OnSessionClosed(const char* web_session_id, | 142 virtual void OnSessionClosed(const char* web_session_id, |
136 uint32_t web_session_id_length) OVERRIDE; | 143 uint32_t web_session_id_length) OVERRIDE; |
137 virtual void OnSessionError(const char* web_session_id, | 144 virtual void OnSessionError(const char* web_session_id, |
138 uint32_t web_session_id_length, | 145 uint32_t web_session_id_length, |
139 cdm::Error error, | 146 cdm::Error error, |
140 uint32_t system_code, | 147 uint32_t system_code, |
141 const char* error_message, | 148 const char* error_message, |
142 uint32_t error_message_length) OVERRIDE; | 149 uint32_t error_message_length) OVERRIDE; |
143 | 150 |
144 // cdm::Host_4 and cdm::Host_5 implementation. | 151 // cdm::Host_6 implementation. |
| 152 virtual cdm::Time GetCurrentWallTime() OVERRIDE; |
| 153 virtual void OnResolveKeyIdsPromise(uint32_t promise_id, |
| 154 const cdm::BinaryData* usable_key_ids, |
| 155 uint32_t usable_key_ids_length) OVERRIDE; |
| 156 virtual void OnSessionUsableKeysChange( |
| 157 const char* web_session_id, |
| 158 uint32_t web_session_id_length, |
| 159 bool has_additional_usable_key) OVERRIDE; |
| 160 |
| 161 // cdm::Host_4, cdm::Host_5 and cdm::Host_6 implementation. |
145 virtual void SendPlatformChallenge(const char* service_id, | 162 virtual void SendPlatformChallenge(const char* service_id, |
146 uint32_t service_id_length, | 163 uint32_t service_id_length, |
147 const char* challenge, | 164 const char* challenge, |
148 uint32_t challenge_length) OVERRIDE; | 165 uint32_t challenge_length) OVERRIDE; |
149 virtual void EnableOutputProtection( | 166 virtual void EnableOutputProtection( |
150 uint32_t desired_protection_mask) OVERRIDE; | 167 uint32_t desired_protection_mask) OVERRIDE; |
151 virtual void QueryOutputProtectionStatus() OVERRIDE; | 168 virtual void QueryOutputProtectionStatus() OVERRIDE; |
152 virtual void OnDeferredInitializationDone( | 169 virtual void OnDeferredInitializationDone( |
153 cdm::StreamType stream_type, | 170 cdm::StreamType stream_type, |
154 cdm::Status decoder_status) OVERRIDE; | 171 cdm::Status decoder_status) OVERRIDE; |
(...skipping 24 matching lines...) Expand all Loading... |
179 bool CreateCdmInstance(const std::string& key_system); | 196 bool CreateCdmInstance(const std::string& key_system); |
180 | 197 |
181 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to | 198 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to |
182 // <code>callback_factory_</code> to ensure that calls into | 199 // <code>callback_factory_</code> to ensure that calls into |
183 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. | 200 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. |
184 void SendPromiseResolvedInternal(int32_t result, uint32_t promise_id); | 201 void SendPromiseResolvedInternal(int32_t result, uint32_t promise_id); |
185 void SendPromiseResolvedWithSessionInternal( | 202 void SendPromiseResolvedWithSessionInternal( |
186 int32_t result, | 203 int32_t result, |
187 uint32_t promise_id, | 204 uint32_t promise_id, |
188 const std::string& web_session_id); | 205 const std::string& web_session_id); |
| 206 void SendPromiseResolvedWithUsableKeyIdsInternal( |
| 207 int32_t result, |
| 208 uint32_t promise_id, |
| 209 std::vector<std::vector<uint8> > key_ids); |
189 void SendPromiseRejectedInternal(int32_t result, | 210 void SendPromiseRejectedInternal(int32_t result, |
190 uint32_t promise_id, | 211 uint32_t promise_id, |
191 const SessionError& error); | 212 const SessionError& error); |
192 void SendSessionMessageInternal(int32_t result, | 213 void SendSessionMessageInternal(int32_t result, |
193 const std::string& web_session_id, | 214 const std::string& web_session_id, |
194 const std::vector<uint8>& message, | 215 const std::vector<uint8>& message, |
195 const std::string& destination_url); | 216 const std::string& destination_url); |
196 void SendSessionReadyInternal(int32_t result, | 217 void SendSessionReadyInternal(int32_t result, |
197 const std::string& web_session_id); | 218 const std::string& web_session_id); |
198 void SendSessionClosedInternal(int32_t result, | 219 void SendSessionClosedInternal(int32_t result, |
199 const std::string& web_session_id); | 220 const std::string& web_session_id); |
200 void SendSessionErrorInternal(int32_t result, | 221 void SendSessionErrorInternal(int32_t result, |
201 const std::string& web_session_id, | 222 const std::string& web_session_id, |
202 const SessionError& error); | 223 const SessionError& error); |
| 224 void SendSessionUsableKeysChangeInternal(int32_t result, |
| 225 const std::string& web_session_id, |
| 226 bool has_additional_usable_key); |
| 227 void SendExpirationChangeInternal(int32_t result, |
| 228 const std::string& web_session_id, |
| 229 cdm::Time new_expiry_time); |
203 void RejectPromise(uint32_t promise_id, | 230 void RejectPromise(uint32_t promise_id, |
204 cdm::Error error, | 231 cdm::Error error, |
205 uint32_t system_code, | 232 uint32_t system_code, |
206 const std::string& error_message); | 233 const std::string& error_message); |
207 | 234 |
208 void DeliverBlock(int32_t result, | 235 void DeliverBlock(int32_t result, |
209 const cdm::Status& status, | 236 const cdm::Status& status, |
210 const LinkedDecryptedBlock& decrypted_block, | 237 const LinkedDecryptedBlock& decrypted_block, |
211 const PP_DecryptTrackingInfo& tracking_info); | 238 const PP_DecryptTrackingInfo& tracking_info); |
212 void DecoderInitializeDone(int32_t result, | 239 void DecoderInitializeDone(int32_t result, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 uint32_t deferred_audio_decoder_config_id_; | 310 uint32_t deferred_audio_decoder_config_id_; |
284 bool deferred_initialize_video_decoder_; | 311 bool deferred_initialize_video_decoder_; |
285 uint32_t deferred_video_decoder_config_id_; | 312 uint32_t deferred_video_decoder_config_id_; |
286 | 313 |
287 DISALLOW_COPY_AND_ASSIGN(CdmAdapter); | 314 DISALLOW_COPY_AND_ASSIGN(CdmAdapter); |
288 }; | 315 }; |
289 | 316 |
290 } // namespace media | 317 } // namespace media |
291 | 318 |
292 #endif // MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ | 319 #endif // MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ |
OLD | NEW |