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; |
71 virtual void Decrypt( | 73 virtual void Decrypt( |
72 pp::Buffer_Dev encrypted_buffer, | 74 pp::Buffer_Dev encrypted_buffer, |
73 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; | 75 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; |
74 virtual void InitializeAudioDecoder( | 76 virtual void InitializeAudioDecoder( |
75 const PP_AudioDecoderConfig& decoder_config, | 77 const PP_AudioDecoderConfig& decoder_config, |
76 pp::Buffer_Dev extra_data_buffer) OVERRIDE; | 78 pp::Buffer_Dev extra_data_buffer) OVERRIDE; |
77 virtual void InitializeVideoDecoder( | 79 virtual void InitializeVideoDecoder( |
78 const PP_VideoDecoderConfig& decoder_config, | 80 const PP_VideoDecoderConfig& decoder_config, |
79 pp::Buffer_Dev extra_data_buffer) OVERRIDE; | 81 pp::Buffer_Dev extra_data_buffer) OVERRIDE; |
80 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type, | 82 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type, |
81 uint32_t request_id) OVERRIDE; | 83 uint32_t request_id) OVERRIDE; |
82 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type, | 84 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type, |
83 uint32_t request_id) OVERRIDE; | 85 uint32_t request_id) OVERRIDE; |
84 virtual void DecryptAndDecode( | 86 virtual void DecryptAndDecode( |
85 PP_DecryptorStreamType decoder_type, | 87 PP_DecryptorStreamType decoder_type, |
86 pp::Buffer_Dev encrypted_buffer, | 88 pp::Buffer_Dev encrypted_buffer, |
87 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; | 89 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; |
88 | |
89 // cdm::Host_4 and cdm::Host_5 implementation. | |
90 virtual cdm::Buffer* Allocate(uint32_t capacity) OVERRIDE; | 90 virtual cdm::Buffer* Allocate(uint32_t capacity) OVERRIDE; |
ddorwin
2014/08/07 01:34:43
We should still note that this is cdm::Host to dif
jrummell
2014/08/07 20:44:30
Done.
| |
91 virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE; | 91 virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE; |
92 // TODO(jrummell): Pass these through Pepper. | |
ddorwin
2014/08/07 01:34:43
... and add OVERRIDE.
jrummell
2014/08/07 20:44:30
Done.
| |
93 virtual void GetUsableKeyIds(uint32_t promise_id, | |
ddorwin
2014/08/07 01:34:44
These aren't part of a Host interface. See also li
jrummell
2014/08/07 20:44:30
Done.
| |
94 const std::string& web_session_id); | |
95 virtual void RemoveSession(uint32_t promise_id, | |
ddorwin
2014/08/07 01:34:44
Swap order and move to line 73 to match cdm.h.
jrummell
2014/08/07 20:44:30
Done.
| |
96 const std::string& web_session_id); | |
92 | 97 |
93 // cdm::Host_4 implementation. | 98 // cdm::Host_4 implementation. |
94 virtual double GetCurrentWallTimeInSeconds() OVERRIDE; | 99 virtual double GetCurrentWallTimeInSeconds() OVERRIDE; |
95 virtual void OnSessionCreated(uint32_t session_id, | 100 virtual void OnSessionCreated(uint32_t session_id, |
96 const char* web_session_id, | 101 const char* web_session_id, |
97 uint32_t web_session_id_length) OVERRIDE; | 102 uint32_t web_session_id_length) OVERRIDE; |
98 virtual void OnSessionMessage(uint32_t session_id, | 103 virtual void OnSessionMessage(uint32_t session_id, |
99 const char* message, | 104 const char* message, |
100 uint32_t message_length, | 105 uint32_t message_length, |
101 const char* destination_url, | 106 const char* destination_url, |
(...skipping 17 matching lines...) Expand all Loading... | |
119 const char* error_message, | 124 const char* error_message, |
120 uint32_t error_message_length) OVERRIDE; | 125 uint32_t error_message_length) OVERRIDE; |
121 virtual void OnSessionMessage(const char* web_session_id, | 126 virtual void OnSessionMessage(const char* web_session_id, |
122 uint32_t web_session_id_length, | 127 uint32_t web_session_id_length, |
123 const char* message, | 128 const char* message, |
124 uint32_t message_length, | 129 uint32_t message_length, |
125 const char* destination_url, | 130 const char* destination_url, |
126 uint32_t destination_url_length) OVERRIDE; | 131 uint32_t destination_url_length) OVERRIDE; |
127 virtual void OnSessionKeysChange(const char* web_session_id, | 132 virtual void OnSessionKeysChange(const char* web_session_id, |
128 uint32_t web_session_id_length, | 133 uint32_t web_session_id_length, |
129 bool has_additional_usable_key); | 134 bool has_additional_usable_key) OVERRIDE; |
130 virtual void OnExpirationChange(const char* web_session_id, | 135 virtual void OnExpirationChange(const char* web_session_id, |
131 uint32_t web_session_id_length, | 136 uint32_t web_session_id_length, |
132 cdm::Time new_expiry_time); | 137 cdm::Time new_expiry_time) OVERRIDE; |
133 virtual void OnSessionReady(const char* web_session_id, | 138 virtual void OnSessionReady(const char* web_session_id, |
134 uint32_t web_session_id_length) OVERRIDE; | 139 uint32_t web_session_id_length) OVERRIDE; |
135 virtual void OnSessionClosed(const char* web_session_id, | 140 virtual void OnSessionClosed(const char* web_session_id, |
136 uint32_t web_session_id_length) OVERRIDE; | 141 uint32_t web_session_id_length) OVERRIDE; |
137 virtual void OnSessionError(const char* web_session_id, | 142 virtual void OnSessionError(const char* web_session_id, |
138 uint32_t web_session_id_length, | 143 uint32_t web_session_id_length, |
139 cdm::Error error, | 144 cdm::Error error, |
140 uint32_t system_code, | 145 uint32_t system_code, |
141 const char* error_message, | 146 const char* error_message, |
142 uint32_t error_message_length) OVERRIDE; | 147 uint32_t error_message_length) OVERRIDE; |
143 | 148 |
144 // cdm::Host_4 and cdm::Host_5 implementation. | 149 // cdm::Host_6 implementation. |
150 virtual cdm::Time GetCurrentWallTime() OVERRIDE; | |
151 virtual void OnResolveKeyIdsPromise(uint32_t promise_id, | |
152 const cdm::BinaryData* usable_key_ids, | |
153 uint32_t usable_key_ids_length) OVERRIDE; | |
154 virtual void OnSessionUsableKeysChange( | |
155 const char* web_session_id, | |
156 uint32_t web_session_id_length, | |
157 bool has_additional_usable_key) OVERRIDE; | |
158 | |
159 // cdm::Host_4, cdm::Host_5 and cdm::Host_6 implementation. | |
145 virtual void SendPlatformChallenge(const char* service_id, | 160 virtual void SendPlatformChallenge(const char* service_id, |
146 uint32_t service_id_length, | 161 uint32_t service_id_length, |
147 const char* challenge, | 162 const char* challenge, |
148 uint32_t challenge_length) OVERRIDE; | 163 uint32_t challenge_length) OVERRIDE; |
149 virtual void EnableOutputProtection( | 164 virtual void EnableOutputProtection( |
150 uint32_t desired_protection_mask) OVERRIDE; | 165 uint32_t desired_protection_mask) OVERRIDE; |
151 virtual void QueryOutputProtectionStatus() OVERRIDE; | 166 virtual void QueryOutputProtectionStatus() OVERRIDE; |
152 virtual void OnDeferredInitializationDone( | 167 virtual void OnDeferredInitializationDone( |
153 cdm::StreamType stream_type, | 168 cdm::StreamType stream_type, |
154 cdm::Status decoder_status) OVERRIDE; | 169 cdm::Status decoder_status) OVERRIDE; |
(...skipping 24 matching lines...) Expand all Loading... | |
179 bool CreateCdmInstance(const std::string& key_system); | 194 bool CreateCdmInstance(const std::string& key_system); |
180 | 195 |
181 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to | 196 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to |
182 // <code>callback_factory_</code> to ensure that calls into | 197 // <code>callback_factory_</code> to ensure that calls into |
183 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. | 198 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. |
184 void SendPromiseResolvedInternal(int32_t result, uint32_t promise_id); | 199 void SendPromiseResolvedInternal(int32_t result, uint32_t promise_id); |
185 void SendPromiseResolvedWithSessionInternal( | 200 void SendPromiseResolvedWithSessionInternal( |
186 int32_t result, | 201 int32_t result, |
187 uint32_t promise_id, | 202 uint32_t promise_id, |
188 const std::string& web_session_id); | 203 const std::string& web_session_id); |
204 void SendPromiseResolvedWithUsableKeyIdsInternal( | |
205 int32_t result, | |
206 uint32_t promise_id, | |
207 std::vector<std::vector<uint8> > key_ids); | |
189 void SendPromiseRejectedInternal(int32_t result, | 208 void SendPromiseRejectedInternal(int32_t result, |
190 uint32_t promise_id, | 209 uint32_t promise_id, |
191 const SessionError& error); | 210 const SessionError& error); |
192 void SendSessionMessageInternal(int32_t result, | 211 void SendSessionMessageInternal(int32_t result, |
193 const std::string& web_session_id, | 212 const std::string& web_session_id, |
194 const std::vector<uint8>& message, | 213 const std::vector<uint8>& message, |
195 const std::string& destination_url); | 214 const std::string& destination_url); |
196 void SendSessionReadyInternal(int32_t result, | 215 void SendSessionReadyInternal(int32_t result, |
197 const std::string& web_session_id); | 216 const std::string& web_session_id); |
198 void SendSessionClosedInternal(int32_t result, | 217 void SendSessionClosedInternal(int32_t result, |
199 const std::string& web_session_id); | 218 const std::string& web_session_id); |
200 void SendSessionErrorInternal(int32_t result, | 219 void SendSessionErrorInternal(int32_t result, |
201 const std::string& web_session_id, | 220 const std::string& web_session_id, |
202 const SessionError& error); | 221 const SessionError& error); |
222 void SendSessionUsableKeysChangeInternal(int32_t result, | |
223 const std::string& web_session_id, | |
224 bool has_additional_usable_key); | |
225 void SendExpirationChangeInternal(int32_t result, | |
226 const std::string& web_session_id, | |
227 cdm::Time new_expiry_time); | |
203 void RejectPromise(uint32_t promise_id, | 228 void RejectPromise(uint32_t promise_id, |
204 cdm::Error error, | 229 cdm::Error error, |
205 uint32_t system_code, | 230 uint32_t system_code, |
206 const std::string& error_message); | 231 const std::string& error_message); |
207 | 232 |
208 void DeliverBlock(int32_t result, | 233 void DeliverBlock(int32_t result, |
209 const cdm::Status& status, | 234 const cdm::Status& status, |
210 const LinkedDecryptedBlock& decrypted_block, | 235 const LinkedDecryptedBlock& decrypted_block, |
211 const PP_DecryptTrackingInfo& tracking_info); | 236 const PP_DecryptTrackingInfo& tracking_info); |
212 void DecoderInitializeDone(int32_t result, | 237 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_; | 308 uint32_t deferred_audio_decoder_config_id_; |
284 bool deferred_initialize_video_decoder_; | 309 bool deferred_initialize_video_decoder_; |
285 uint32_t deferred_video_decoder_config_id_; | 310 uint32_t deferred_video_decoder_config_id_; |
286 | 311 |
287 DISALLOW_COPY_AND_ASSIGN(CdmAdapter); | 312 DISALLOW_COPY_AND_ASSIGN(CdmAdapter); |
288 }; | 313 }; |
289 | 314 |
290 } // namespace media | 315 } // namespace media |
291 | 316 |
292 #endif // MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ | 317 #endif // MEDIA_CDM_PPAPI_CDM_ADAPTER_H_ |
OLD | NEW |