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_WRAPPER_H_ | 5 #ifndef MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ |
6 #define MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ | 6 #define MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <queue> | 9 #include <queue> |
10 #include <string> | 10 #include <string> |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 bool HasHeader(const uint8* data, | 175 bool HasHeader(const uint8* data, |
176 int data_length, | 176 int data_length, |
177 const std::string& header) { | 177 const std::string& header) { |
178 return static_cast<size_t>(data_length) > header.length() && | 178 return static_cast<size_t>(data_length) > header.length() && |
179 std::equal(data, data + header.length(), header.begin()); | 179 std::equal(data, data + header.length(), header.begin()); |
180 } | 180 } |
181 | 181 |
182 virtual bool SetServerCertificate( | 182 virtual bool SetServerCertificate( |
183 uint32_t promise_id, | 183 uint32_t promise_id, |
184 const uint8_t* server_certificate_data, | 184 const uint8_t* server_certificate_data, |
185 uint32_t server_certificate_data_size) OVERRIDE { | 185 uint32_t server_certificate_data_size) override { |
186 cdm_->SetServerCertificate( | 186 cdm_->SetServerCertificate( |
187 promise_id, server_certificate_data, server_certificate_data_size); | 187 promise_id, server_certificate_data, server_certificate_data_size); |
188 return true; | 188 return true; |
189 } | 189 } |
190 | 190 |
191 virtual void CreateSession(uint32_t promise_id, | 191 virtual void CreateSession(uint32_t promise_id, |
192 const char* init_data_type, | 192 const char* init_data_type, |
193 uint32_t init_data_type_size, | 193 uint32_t init_data_type_size, |
194 const uint8_t* init_data, | 194 const uint8_t* init_data, |
195 uint32_t init_data_size, | 195 uint32_t init_data_size, |
196 cdm::SessionType session_type) OVERRIDE { | 196 cdm::SessionType session_type) override { |
197 // TODO(jrummell): Remove this code once |session_type| is passed through | 197 // TODO(jrummell): Remove this code once |session_type| is passed through |
198 // Pepper. When removing, add the header back in for CDM4. | 198 // Pepper. When removing, add the header back in for CDM4. |
199 PP_DCHECK(session_type == cdm::kTemporary); | 199 PP_DCHECK(session_type == cdm::kTemporary); |
200 const char kPersistentSessionHeader[] = "PERSISTENT|"; | 200 const char kPersistentSessionHeader[] = "PERSISTENT|"; |
201 if (HasHeader(init_data, init_data_size, kPersistentSessionHeader)) { | 201 if (HasHeader(init_data, init_data_size, kPersistentSessionHeader)) { |
202 cdm_->CreateSession(promise_id, | 202 cdm_->CreateSession(promise_id, |
203 init_data_type, | 203 init_data_type, |
204 init_data_type_size, | 204 init_data_type_size, |
205 init_data + strlen(kPersistentSessionHeader), | 205 init_data + strlen(kPersistentSessionHeader), |
206 init_data_size - strlen(kPersistentSessionHeader), | 206 init_data_size - strlen(kPersistentSessionHeader), |
207 cdm::kPersistent); | 207 cdm::kPersistent); |
208 return; | 208 return; |
209 } | 209 } |
210 | 210 |
211 cdm_->CreateSession(promise_id, | 211 cdm_->CreateSession(promise_id, |
212 init_data_type, | 212 init_data_type, |
213 init_data_type_size, | 213 init_data_type_size, |
214 init_data, | 214 init_data, |
215 init_data_size, | 215 init_data_size, |
216 session_type); | 216 session_type); |
217 } | 217 } |
218 | 218 |
219 virtual void LoadSession(uint32_t promise_id, | 219 virtual void LoadSession(uint32_t promise_id, |
220 const char* web_session_id, | 220 const char* web_session_id, |
221 uint32_t web_session_id_size) OVERRIDE { | 221 uint32_t web_session_id_size) override { |
222 cdm_->LoadSession(promise_id, web_session_id, web_session_id_size); | 222 cdm_->LoadSession(promise_id, web_session_id, web_session_id_size); |
223 } | 223 } |
224 | 224 |
225 virtual void UpdateSession(uint32_t promise_id, | 225 virtual void UpdateSession(uint32_t promise_id, |
226 const char* web_session_id, | 226 const char* web_session_id, |
227 uint32_t web_session_id_size, | 227 uint32_t web_session_id_size, |
228 const uint8_t* response, | 228 const uint8_t* response, |
229 uint32_t response_size) OVERRIDE { | 229 uint32_t response_size) override { |
230 cdm_->UpdateSession(promise_id, | 230 cdm_->UpdateSession(promise_id, |
231 web_session_id, | 231 web_session_id, |
232 web_session_id_size, | 232 web_session_id_size, |
233 response, | 233 response, |
234 response_size); | 234 response_size); |
235 } | 235 } |
236 | 236 |
237 virtual bool CloseSession(uint32_t promise_id, | 237 virtual bool CloseSession(uint32_t promise_id, |
238 const char* web_session_id, | 238 const char* web_session_id, |
239 uint32_t web_session_id_size) OVERRIDE { | 239 uint32_t web_session_id_size) override { |
240 cdm_->CloseSession(promise_id, web_session_id, web_session_id_size); | 240 cdm_->CloseSession(promise_id, web_session_id, web_session_id_size); |
241 return true; | 241 return true; |
242 } | 242 } |
243 | 243 |
244 virtual void RemoveSession(uint32_t promise_id, | 244 virtual void RemoveSession(uint32_t promise_id, |
245 const char* web_session_id, | 245 const char* web_session_id, |
246 uint32_t web_session_id_size) OVERRIDE { | 246 uint32_t web_session_id_size) override { |
247 cdm_->RemoveSession(promise_id, web_session_id, web_session_id_size); | 247 cdm_->RemoveSession(promise_id, web_session_id, web_session_id_size); |
248 } | 248 } |
249 | 249 |
250 virtual bool GetUsableKeyIds(uint32_t promise_id, | 250 virtual bool GetUsableKeyIds(uint32_t promise_id, |
251 const char* web_session_id, | 251 const char* web_session_id, |
252 uint32_t web_session_id_size) OVERRIDE { | 252 uint32_t web_session_id_size) override { |
253 cdm_->GetUsableKeyIds(promise_id, web_session_id, web_session_id_size); | 253 cdm_->GetUsableKeyIds(promise_id, web_session_id, web_session_id_size); |
254 return true; | 254 return true; |
255 } | 255 } |
256 | 256 |
257 virtual void TimerExpired(void* context) OVERRIDE { | 257 virtual void TimerExpired(void* context) override { |
258 cdm_->TimerExpired(context); | 258 cdm_->TimerExpired(context); |
259 } | 259 } |
260 | 260 |
261 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, | 261 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, |
262 cdm::DecryptedBlock* decrypted_buffer) OVERRIDE { | 262 cdm::DecryptedBlock* decrypted_buffer) override { |
263 return cdm_->Decrypt(encrypted_buffer, decrypted_buffer); | 263 return cdm_->Decrypt(encrypted_buffer, decrypted_buffer); |
264 } | 264 } |
265 | 265 |
266 virtual cdm::Status InitializeAudioDecoder( | 266 virtual cdm::Status InitializeAudioDecoder( |
267 const cdm::AudioDecoderConfig& audio_decoder_config) OVERRIDE { | 267 const cdm::AudioDecoderConfig& audio_decoder_config) override { |
268 return cdm_->InitializeAudioDecoder(audio_decoder_config); | 268 return cdm_->InitializeAudioDecoder(audio_decoder_config); |
269 } | 269 } |
270 | 270 |
271 virtual cdm::Status InitializeVideoDecoder( | 271 virtual cdm::Status InitializeVideoDecoder( |
272 const cdm::VideoDecoderConfig& video_decoder_config) OVERRIDE { | 272 const cdm::VideoDecoderConfig& video_decoder_config) override { |
273 return cdm_->InitializeVideoDecoder(video_decoder_config); | 273 return cdm_->InitializeVideoDecoder(video_decoder_config); |
274 } | 274 } |
275 | 275 |
276 virtual void DeinitializeDecoder(cdm::StreamType decoder_type) OVERRIDE { | 276 virtual void DeinitializeDecoder(cdm::StreamType decoder_type) override { |
277 cdm_->DeinitializeDecoder(decoder_type); | 277 cdm_->DeinitializeDecoder(decoder_type); |
278 } | 278 } |
279 | 279 |
280 virtual void ResetDecoder(cdm::StreamType decoder_type) OVERRIDE { | 280 virtual void ResetDecoder(cdm::StreamType decoder_type) override { |
281 cdm_->ResetDecoder(decoder_type); | 281 cdm_->ResetDecoder(decoder_type); |
282 } | 282 } |
283 | 283 |
284 virtual cdm::Status DecryptAndDecodeFrame( | 284 virtual cdm::Status DecryptAndDecodeFrame( |
285 const cdm::InputBuffer& encrypted_buffer, | 285 const cdm::InputBuffer& encrypted_buffer, |
286 cdm::VideoFrame* video_frame) OVERRIDE { | 286 cdm::VideoFrame* video_frame) override { |
287 return cdm_->DecryptAndDecodeFrame(encrypted_buffer, video_frame); | 287 return cdm_->DecryptAndDecodeFrame(encrypted_buffer, video_frame); |
288 } | 288 } |
289 | 289 |
290 virtual cdm::Status DecryptAndDecodeSamples( | 290 virtual cdm::Status DecryptAndDecodeSamples( |
291 const cdm::InputBuffer& encrypted_buffer, | 291 const cdm::InputBuffer& encrypted_buffer, |
292 cdm::AudioFrames* audio_frames) OVERRIDE { | 292 cdm::AudioFrames* audio_frames) override { |
293 return cdm_->DecryptAndDecodeSamples(encrypted_buffer, audio_frames); | 293 return cdm_->DecryptAndDecodeSamples(encrypted_buffer, audio_frames); |
294 } | 294 } |
295 | 295 |
296 virtual void OnPlatformChallengeResponse( | 296 virtual void OnPlatformChallengeResponse( |
297 const cdm::PlatformChallengeResponse& response) OVERRIDE { | 297 const cdm::PlatformChallengeResponse& response) override { |
298 cdm_->OnPlatformChallengeResponse(response); | 298 cdm_->OnPlatformChallengeResponse(response); |
299 } | 299 } |
300 | 300 |
301 virtual void OnQueryOutputProtectionStatus( | 301 virtual void OnQueryOutputProtectionStatus( |
302 uint32_t link_mask, | 302 uint32_t link_mask, |
303 uint32_t output_protection_mask) OVERRIDE { | 303 uint32_t output_protection_mask) override { |
304 cdm_->OnQueryOutputProtectionStatus(link_mask, output_protection_mask); | 304 cdm_->OnQueryOutputProtectionStatus(link_mask, output_protection_mask); |
305 } | 305 } |
306 | 306 |
307 uint32_t CreateSessionId() { | 307 uint32_t CreateSessionId() { |
308 return next_session_id_++; | 308 return next_session_id_++; |
309 } | 309 } |
310 | 310 |
311 void RegisterPromise(uint32_t session_id, uint32_t promise_id) { | 311 void RegisterPromise(uint32_t session_id, uint32_t promise_id) { |
312 PP_DCHECK(promise_to_session_id_map_.find(session_id) == | 312 PP_DCHECK(promise_to_session_id_map_.find(session_id) == |
313 promise_to_session_id_map_.end()); | 313 promise_to_session_id_map_.end()); |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 // stub implementations for new or modified methods that the older CDM interface | 571 // stub implementations for new or modified methods that the older CDM interface |
572 // does not have. | 572 // does not have. |
573 // Also update supported_cdm_versions.h. | 573 // Also update supported_cdm_versions.h. |
574 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == | 574 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == |
575 cdm::ContentDecryptionModule_6::kVersion, | 575 cdm::ContentDecryptionModule_6::kVersion, |
576 ensure_cdm_wrapper_templates_have_old_version_support); | 576 ensure_cdm_wrapper_templates_have_old_version_support); |
577 | 577 |
578 } // namespace media | 578 } // namespace media |
579 | 579 |
580 #endif // MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ | 580 #endif // MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ |
OLD | NEW |