Chromium Code Reviews| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 uint32_t init_data_size, | 49 uint32_t init_data_size, |
| 50 cdm::SessionType session_type) = 0; | 50 cdm::SessionType session_type) = 0; |
| 51 virtual void LoadSession(uint32_t promise_id, | 51 virtual void LoadSession(uint32_t promise_id, |
| 52 const char* web_session_id, | 52 const char* web_session_id, |
| 53 uint32_t web_session_id_size) = 0; | 53 uint32_t web_session_id_size) = 0; |
| 54 virtual void UpdateSession(uint32_t promise_id, | 54 virtual void UpdateSession(uint32_t promise_id, |
| 55 const char* web_session_id, | 55 const char* web_session_id, |
| 56 uint32_t web_session_id_size, | 56 uint32_t web_session_id_size, |
| 57 const uint8_t* response, | 57 const uint8_t* response, |
| 58 uint32_t response_size) = 0; | 58 uint32_t response_size) = 0; |
| 59 virtual void ReleaseSession(uint32_t promise_id, | 59 virtual void CloseSession(uint32_t promise_id, |
| 60 const char* web_session_id, | 60 const char* web_session_id, |
| 61 uint32_t web_session_id_size) = 0; | 61 uint32_t web_session_id_size) = 0; |
| 62 virtual bool RemoveSession(uint32_t promise_id, | |
| 63 const char* web_session_id, | |
| 64 uint32_t web_session_id_size) = 0; | |
| 65 virtual bool GetUsableKeyIds(uint32_t promise_id, | |
| 66 const char* web_session_id, | |
| 67 uint32_t web_session_id_size) = 0; | |
| 62 virtual void TimerExpired(void* context) = 0; | 68 virtual void TimerExpired(void* context) = 0; |
| 63 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, | 69 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, |
| 64 cdm::DecryptedBlock* decrypted_buffer) = 0; | 70 cdm::DecryptedBlock* decrypted_buffer) = 0; |
| 65 virtual cdm::Status InitializeAudioDecoder( | 71 virtual cdm::Status InitializeAudioDecoder( |
| 66 const cdm::AudioDecoderConfig& audio_decoder_config) = 0; | 72 const cdm::AudioDecoderConfig& audio_decoder_config) = 0; |
| 67 virtual cdm::Status InitializeVideoDecoder( | 73 virtual cdm::Status InitializeVideoDecoder( |
| 68 const cdm::VideoDecoderConfig& video_decoder_config) = 0; | 74 const cdm::VideoDecoderConfig& video_decoder_config) = 0; |
| 69 virtual void DeinitializeDecoder(cdm::StreamType decoder_type) = 0; | 75 virtual void DeinitializeDecoder(cdm::StreamType decoder_type) = 0; |
| 70 virtual void ResetDecoder(cdm::StreamType decoder_type) = 0; | 76 virtual void ResetDecoder(cdm::StreamType decoder_type) = 0; |
| 71 virtual cdm::Status DecryptAndDecodeFrame( | 77 virtual cdm::Status DecryptAndDecodeFrame( |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 88 // Since the callbacks don't come through this interface, cdm_adapter needs to | 94 // Since the callbacks don't come through this interface, cdm_adapter needs to |
| 89 // create the mapping (and delete it on release). | 95 // create the mapping (and delete it on release). |
| 90 // TODO(jrummell): Remove these once Host_4 interface is removed. | 96 // TODO(jrummell): Remove these once Host_4 interface is removed. |
| 91 virtual uint32_t LookupPromiseId(uint32_t session_id) = 0; | 97 virtual uint32_t LookupPromiseId(uint32_t session_id) = 0; |
| 92 virtual void AssignWebSessionId(uint32_t session_id, | 98 virtual void AssignWebSessionId(uint32_t session_id, |
| 93 const char* web_session_id, | 99 const char* web_session_id, |
| 94 uint32_t web_session_id_size) = 0; | 100 uint32_t web_session_id_size) = 0; |
| 95 virtual std::string LookupWebSessionId(uint32_t session_id) = 0; | 101 virtual std::string LookupWebSessionId(uint32_t session_id) = 0; |
| 96 virtual void DropWebSessionId(std::string web_session_id) = 0; | 102 virtual void DropWebSessionId(std::string web_session_id) = 0; |
| 97 | 103 |
| 104 // Helper functions for the cdm::Host_4 and cdm::Host_5 methods. | |
| 105 // CDMs using cdm::Host_6 will call OnSessionUsableKeys() as necessary when | |
| 106 // resolving LoadSession() and UpdateSession(). This needs to be simulated | |
| 107 // for the older CDMs. These must not be called for cdm::Host_6 and later. | |
| 108 // TODO(jrummell): Remove these once Host_4 and Host_5 interfaces are removed. | |
| 109 virtual bool SessionUsableKeysEventNeeded(uint32_t promise_id, | |
| 110 std::string* web_session_id) = 0; | |
| 111 virtual void SetSessionUsableKeysEventNeeded( | |
| 112 uint32_t promise_id, | |
| 113 const char* web_session_id, | |
| 114 uint32_t web_session_id_size) = 0; | |
| 115 | |
| 116 // cdm::Host_6 introduces InputBuffer_2 (aka InputBuffer). cdm::Host_4 and | |
| 117 // cdm::Host_5 methods still use InputBuffer_1, so this helper function | |
| 118 // converts InputBuffer_2 to InputBuffer_1. | |
| 119 // TODO(jrummell): Remove these once Host_4 and Host_5 interfaces are removed. | |
| 120 virtual void ConvertInputBuffer(const cdm::InputBuffer& in, | |
|
ddorwin
2014/08/07 22:10:43
s/in/v2/
s/out/v1/
?
jrummell
2014/08/08 00:15:08
Done.
| |
| 121 cdm::InputBuffer_1* out) = 0; | |
| 122 | |
| 98 protected: | 123 protected: |
| 99 CdmWrapper() {} | 124 CdmWrapper() {} |
| 100 | 125 |
| 101 private: | 126 private: |
| 102 DISALLOW_COPY_AND_ASSIGN(CdmWrapper); | 127 DISALLOW_COPY_AND_ASSIGN(CdmWrapper); |
| 103 }; | 128 }; |
| 104 | 129 |
| 105 // Template class that does the CdmWrapper -> CdmInterface conversion. Default | 130 // Template class that does the CdmWrapper -> CdmInterface conversion. Default |
| 106 // implementations are provided. Any methods that need special treatment should | 131 // implementations are provided. Any methods that need special treatment should |
| 107 // be specialized. | 132 // be specialized. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 uint32_t web_session_id_size, | 176 uint32_t web_session_id_size, |
| 152 const uint8_t* response, | 177 const uint8_t* response, |
| 153 uint32_t response_size) OVERRIDE { | 178 uint32_t response_size) OVERRIDE { |
| 154 cdm_->UpdateSession(promise_id, | 179 cdm_->UpdateSession(promise_id, |
| 155 web_session_id, | 180 web_session_id, |
| 156 web_session_id_size, | 181 web_session_id_size, |
| 157 response, | 182 response, |
| 158 response_size); | 183 response_size); |
| 159 } | 184 } |
| 160 | 185 |
| 161 virtual void ReleaseSession(uint32_t promise_id, | 186 virtual bool GetUsableKeyIds(uint32_t promise_id, |
| 162 const char* web_session_id, | 187 const char* web_session_id, |
| 163 uint32_t web_session_id_size) OVERRIDE { | 188 uint32_t web_session_id_size) OVERRIDE { |
| 164 cdm_->ReleaseSession(promise_id, web_session_id, web_session_id_size); | 189 cdm_->GetUsableKeyIds(promise_id, web_session_id, web_session_id_size); |
| 190 return true; | |
| 191 } | |
| 192 | |
| 193 virtual void CloseSession(uint32_t promise_id, | |
| 194 const char* web_session_id, | |
| 195 uint32_t web_session_id_size) OVERRIDE { | |
| 196 cdm_->CloseSession(promise_id, web_session_id, web_session_id_size); | |
| 197 } | |
| 198 | |
| 199 virtual bool RemoveSession(uint32_t promise_id, | |
| 200 const char* web_session_id, | |
| 201 uint32_t web_session_id_size) OVERRIDE { | |
| 202 cdm_->RemoveSession(promise_id, web_session_id, web_session_id_size); | |
| 203 return true; | |
| 165 } | 204 } |
| 166 | 205 |
| 167 virtual void TimerExpired(void* context) OVERRIDE { | 206 virtual void TimerExpired(void* context) OVERRIDE { |
| 168 cdm_->TimerExpired(context); | 207 cdm_->TimerExpired(context); |
| 169 } | 208 } |
| 170 | 209 |
| 171 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, | 210 virtual cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer, |
| 172 cdm::DecryptedBlock* decrypted_buffer) OVERRIDE { | 211 cdm::DecryptedBlock* decrypted_buffer) OVERRIDE { |
| 173 return cdm_->Decrypt(encrypted_buffer, decrypted_buffer); | 212 return cdm_->Decrypt(encrypted_buffer, decrypted_buffer); |
| 174 } | 213 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 return it->first; | 293 return it->first; |
| 255 } | 294 } |
| 256 PP_NOTREACHED(); | 295 PP_NOTREACHED(); |
| 257 return std::string(); | 296 return std::string(); |
| 258 } | 297 } |
| 259 | 298 |
| 260 virtual void DropWebSessionId(std::string web_session_id) { | 299 virtual void DropWebSessionId(std::string web_session_id) { |
| 261 web_session_to_session_id_map_.erase(web_session_id); | 300 web_session_to_session_id_map_.erase(web_session_id); |
| 262 } | 301 } |
| 263 | 302 |
| 303 virtual bool SessionUsableKeysEventNeeded(uint32_t promise_id, | |
| 304 std::string* web_session_id) { | |
| 305 std::map<uint32_t, std::string>::iterator it = | |
| 306 promises_needing_usable_keys_event_.find(promise_id); | |
| 307 if (it == promises_needing_usable_keys_event_.end()) | |
| 308 return false; | |
| 309 web_session_id->swap(it->second); | |
| 310 promises_needing_usable_keys_event_.erase(it); | |
| 311 return true; | |
| 312 } | |
| 313 | |
| 314 virtual void SetSessionUsableKeysEventNeeded(uint32_t promise_id, | |
| 315 const char* web_session_id, | |
| 316 uint32_t web_session_id_size) { | |
| 317 promises_needing_usable_keys_event_.insert(std::make_pair( | |
| 318 promise_id, std::string(web_session_id, web_session_id_size))); | |
| 319 } | |
| 320 | |
| 321 virtual void ConvertInputBuffer(const cdm::InputBuffer& in, | |
| 322 cdm::InputBuffer_1* out) { | |
| 323 out->data = in.data; | |
| 324 out->data_size = in.data_size; | |
| 325 out->data_offset = 0; | |
| 326 out->key_id = in.key_id; | |
| 327 out->key_id_size = in.key_id_size; | |
| 328 out->iv = in.iv; | |
| 329 out->iv_size = in.iv_size; | |
| 330 out->subsamples = in.subsamples; | |
| 331 out->num_subsamples = in.num_subsamples; | |
| 332 out->timestamp = in.timestamp; | |
| 333 } | |
| 334 | |
| 264 private: | 335 private: |
| 265 CdmWrapperImpl(CdmInterface* cdm) : cdm_(cdm), next_session_id_(100) { | 336 CdmWrapperImpl(CdmInterface* cdm) : cdm_(cdm), next_session_id_(100) { |
| 266 PP_DCHECK(cdm_); | 337 PP_DCHECK(cdm_); |
| 267 } | 338 } |
| 268 | 339 |
| 269 CdmInterface* cdm_; | 340 CdmInterface* cdm_; |
| 270 | 341 |
| 271 std::map<uint32_t, uint32_t> promise_to_session_id_map_; | 342 std::map<uint32_t, uint32_t> promise_to_session_id_map_; |
| 272 uint32_t next_session_id_; | 343 uint32_t next_session_id_; |
| 273 std::map<std::string, uint32_t> web_session_to_session_id_map_; | 344 std::map<std::string, uint32_t> web_session_to_session_id_map_; |
| 274 | 345 |
| 346 std::map<uint32_t, std::string> promises_needing_usable_keys_event_; | |
| 347 | |
| 275 DISALLOW_COPY_AND_ASSIGN(CdmWrapperImpl); | 348 DISALLOW_COPY_AND_ASSIGN(CdmWrapperImpl); |
| 276 }; | 349 }; |
| 277 | 350 |
| 278 // Overrides for the cdm::Host_4 methods. Calls to CreateSession(), | 351 // Overrides for the cdm::Host_4 methods. Calls to CreateSession(), |
| 279 // LoadSession(), UpdateSession(), and ReleaseSession() pass in promise ids, | 352 // LoadSession(), UpdateSession(), and ReleaseSession() pass in promise ids, |
| 280 // but the CDM interface needs session ids. For create and load, we need to | 353 // but the CDM interface needs session ids. For create and load, we need to |
| 281 // create a new session_id to pass to the CDM. For update and release, we need | 354 // create a new session_id to pass to the CDM. For update and release, we need |
| 282 // to look up |web_session_id| and convert it into the existing |session_id|. | 355 // to look up |web_session_id| and convert it into the existing |session_id|. |
| 283 // Since the callbacks don't come through this interface, cdm_adapter needs to | 356 // Since the callbacks don't come through this interface, cdm_adapter needs to |
| 284 // create the mapping (and delete it on release). | 357 // create the mapping (and delete it on release). |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 301 init_data_size); | 374 init_data_size); |
| 302 } | 375 } |
| 303 | 376 |
| 304 template <> | 377 template <> |
| 305 void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::LoadSession( | 378 void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::LoadSession( |
| 306 uint32_t promise_id, | 379 uint32_t promise_id, |
| 307 const char* web_session_id, | 380 const char* web_session_id, |
| 308 uint32_t web_session_id_size) { | 381 uint32_t web_session_id_size) { |
| 309 uint32_t session_id = CreateSessionId(); | 382 uint32_t session_id = CreateSessionId(); |
| 310 RegisterPromise(session_id, promise_id); | 383 RegisterPromise(session_id, promise_id); |
| 384 // As CDM_4 doesn't support OnSessionUsableKeysChange(), make sure to generate | |
| 385 // one when the promise is resolved. This may be overly aggressive. | |
| 386 SetSessionUsableKeysEventNeeded( | |
| 387 promise_id, web_session_id, web_session_id_size); | |
| 311 cdm_->LoadSession(session_id, web_session_id, web_session_id_size); | 388 cdm_->LoadSession(session_id, web_session_id, web_session_id_size); |
| 312 } | 389 } |
| 313 | 390 |
| 314 template <> | 391 template <> |
| 315 void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::UpdateSession( | 392 void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::UpdateSession( |
| 316 uint32_t promise_id, | 393 uint32_t promise_id, |
| 317 const char* web_session_id, | 394 const char* web_session_id, |
| 318 uint32_t web_session_id_size, | 395 uint32_t web_session_id_size, |
| 319 const uint8_t* response, | 396 const uint8_t* response, |
| 320 uint32_t response_size) { | 397 uint32_t response_size) { |
| 321 std::string web_session_str(web_session_id, web_session_id_size); | 398 std::string web_session_str(web_session_id, web_session_id_size); |
| 322 uint32_t session_id = LookupSessionId(web_session_str); | 399 uint32_t session_id = LookupSessionId(web_session_str); |
| 323 RegisterPromise(session_id, promise_id); | 400 RegisterPromise(session_id, promise_id); |
| 401 // As CDM_4 doesn't support OnSessionUsableKeysChange(), make sure to generate | |
| 402 // one when the promise is resolved. This may be overly aggressive. | |
| 403 SetSessionUsableKeysEventNeeded( | |
| 404 promise_id, web_session_id, web_session_id_size); | |
| 324 cdm_->UpdateSession(session_id, response, response_size); | 405 cdm_->UpdateSession(session_id, response, response_size); |
| 325 } | 406 } |
| 326 | 407 |
| 327 template <> | 408 template <> |
| 328 void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::ReleaseSession( | 409 void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::CloseSession( |
| 329 uint32_t promise_id, | 410 uint32_t promise_id, |
| 330 const char* web_session_id, | 411 const char* web_session_id, |
| 331 uint32_t web_session_id_size) { | 412 uint32_t web_session_id_size) { |
| 332 std::string web_session_str(web_session_id, web_session_id_size); | 413 std::string web_session_str(web_session_id, web_session_id_size); |
| 333 uint32_t session_id = LookupSessionId(web_session_str); | 414 uint32_t session_id = LookupSessionId(web_session_str); |
| 334 RegisterPromise(session_id, promise_id); | 415 RegisterPromise(session_id, promise_id); |
| 335 cdm_->ReleaseSession(session_id); | 416 cdm_->ReleaseSession(session_id); |
| 336 } | 417 } |
| 337 | 418 |
| 419 template <> | |
| 420 bool CdmWrapperImpl<cdm::ContentDecryptionModule_4>::RemoveSession( | |
| 421 uint32_t promise_id, | |
| 422 const char* web_session_id, | |
| 423 uint32_t web_session_id_size) { | |
| 424 return false; | |
| 425 } | |
| 426 | |
| 427 template <> | |
| 428 bool CdmWrapperImpl<cdm::ContentDecryptionModule_4>::GetUsableKeyIds( | |
| 429 uint32_t promise_id, | |
| 430 const char* web_session_id, | |
| 431 uint32_t web_session_id_size) { | |
| 432 return false; | |
| 433 } | |
| 434 | |
| 435 template <> | |
| 436 cdm::Status CdmWrapperImpl<cdm::ContentDecryptionModule_4>::Decrypt( | |
| 437 const cdm::InputBuffer& encrypted_buffer, | |
| 438 cdm::DecryptedBlock* decrypted_buffer) { | |
| 439 cdm::InputBuffer_1 buffer; | |
| 440 ConvertInputBuffer(encrypted_buffer, &buffer); | |
| 441 return cdm_->Decrypt(buffer, decrypted_buffer); | |
| 442 } | |
| 443 | |
| 444 template <> | |
| 445 cdm::Status | |
| 446 CdmWrapperImpl<cdm::ContentDecryptionModule_4>::DecryptAndDecodeFrame( | |
| 447 const cdm::InputBuffer& encrypted_buffer, | |
| 448 cdm::VideoFrame* video_frame) { | |
| 449 cdm::InputBuffer_1 buffer; | |
| 450 ConvertInputBuffer(encrypted_buffer, &buffer); | |
| 451 return cdm_->DecryptAndDecodeFrame(buffer, video_frame); | |
| 452 } | |
| 453 | |
| 454 template <> | |
| 455 cdm::Status | |
| 456 CdmWrapperImpl<cdm::ContentDecryptionModule_4>::DecryptAndDecodeSamples( | |
| 457 const cdm::InputBuffer& encrypted_buffer, | |
| 458 cdm::AudioFrames* audio_frames) { | |
| 459 cdm::InputBuffer_1 buffer; | |
| 460 ConvertInputBuffer(encrypted_buffer, &buffer); | |
| 461 return cdm_->DecryptAndDecodeSamples(buffer, audio_frames); | |
| 462 } | |
| 463 | |
| 464 // Overrides for the cdm::Host_5 methods. | |
| 465 // TODO(jrummell): Remove these once Host_5 interface is removed. | |
| 466 | |
| 467 template <> | |
| 468 void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::LoadSession( | |
| 469 uint32_t promise_id, | |
| 470 const char* web_session_id, | |
| 471 uint32_t web_session_id_size) { | |
| 472 // As CDM_5 doesn't support OnSessionUsableKeysChange(), make sure to generate | |
| 473 // one when the promise is resolved. This may be overly aggressive. | |
| 474 SetSessionUsableKeysEventNeeded( | |
| 475 promise_id, web_session_id, web_session_id_size); | |
| 476 cdm_->LoadSession(promise_id, web_session_id, web_session_id_size); | |
| 477 } | |
| 478 | |
| 479 template <> | |
| 480 void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::UpdateSession( | |
| 481 uint32_t promise_id, | |
| 482 const char* web_session_id, | |
| 483 uint32_t web_session_id_size, | |
| 484 const uint8_t* response, | |
| 485 uint32_t response_size) { | |
| 486 // As CDM_5 doesn't support OnSessionUsableKeysChange(), make sure to generate | |
| 487 // one when the promise is resolved. This may be overly aggressive. | |
| 488 SetSessionUsableKeysEventNeeded( | |
| 489 promise_id, web_session_id, web_session_id_size); | |
| 490 cdm_->UpdateSession( | |
| 491 promise_id, web_session_id, web_session_id_size, response, response_size); | |
| 492 } | |
| 493 | |
| 494 template <> | |
| 495 void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::CloseSession( | |
| 496 uint32_t promise_id, | |
| 497 const char* web_session_id, | |
| 498 uint32_t web_session_id_size) { | |
| 499 cdm_->ReleaseSession(promise_id, web_session_id, web_session_id_size); | |
| 500 } | |
| 501 | |
| 502 template <> | |
| 503 bool CdmWrapperImpl<cdm::ContentDecryptionModule_5>::RemoveSession( | |
| 504 uint32_t promise_id, | |
| 505 const char* web_session_id, | |
| 506 uint32_t web_session_id_size) { | |
| 507 return false; | |
| 508 } | |
| 509 | |
| 510 template <> | |
| 511 bool CdmWrapperImpl<cdm::ContentDecryptionModule_5>::GetUsableKeyIds( | |
| 512 uint32_t promise_id, | |
| 513 const char* web_session_id, | |
| 514 uint32_t web_session_id_size) { | |
| 515 return false; | |
| 516 } | |
| 517 | |
| 518 template <> | |
| 519 cdm::Status CdmWrapperImpl<cdm::ContentDecryptionModule_5>::Decrypt( | |
| 520 const cdm::InputBuffer& encrypted_buffer, | |
| 521 cdm::DecryptedBlock* decrypted_buffer) { | |
| 522 cdm::InputBuffer_1 buffer; | |
| 523 ConvertInputBuffer(encrypted_buffer, &buffer); | |
| 524 return cdm_->Decrypt(buffer, decrypted_buffer); | |
| 525 } | |
| 526 | |
| 527 template <> | |
| 528 cdm::Status | |
| 529 CdmWrapperImpl<cdm::ContentDecryptionModule_5>::DecryptAndDecodeFrame( | |
| 530 const cdm::InputBuffer& encrypted_buffer, | |
| 531 cdm::VideoFrame* video_frame) { | |
| 532 cdm::InputBuffer_1 buffer; | |
| 533 ConvertInputBuffer(encrypted_buffer, &buffer); | |
| 534 return cdm_->DecryptAndDecodeFrame(buffer, video_frame); | |
| 535 } | |
| 536 | |
| 537 template <> | |
| 538 cdm::Status | |
| 539 CdmWrapperImpl<cdm::ContentDecryptionModule_5>::DecryptAndDecodeSamples( | |
| 540 const cdm::InputBuffer& encrypted_buffer, | |
| 541 cdm::AudioFrames* audio_frames) { | |
| 542 cdm::InputBuffer_1 buffer; | |
| 543 ConvertInputBuffer(encrypted_buffer, &buffer); | |
| 544 return cdm_->DecryptAndDecodeSamples(buffer, audio_frames); | |
| 545 } | |
| 546 | |
| 338 CdmWrapper* CdmWrapper::Create(const char* key_system, | 547 CdmWrapper* CdmWrapper::Create(const char* key_system, |
| 339 uint32_t key_system_size, | 548 uint32_t key_system_size, |
| 340 GetCdmHostFunc get_cdm_host_func, | 549 GetCdmHostFunc get_cdm_host_func, |
| 341 void* user_data) { | 550 void* user_data) { |
| 342 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == | 551 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == |
| 343 cdm::ContentDecryptionModule_5::kVersion, | 552 cdm::ContentDecryptionModule_6::kVersion, |
| 344 update_code_below); | 553 update_code_below); |
| 345 | 554 |
| 346 // Ensure IsSupportedCdmInterfaceVersion() matches this implementation. | 555 // Ensure IsSupportedCdmInterfaceVersion() matches this implementation. |
| 347 // Always update this DCHECK when updating this function. | 556 // Always update this DCHECK when updating this function. |
| 348 // If this check fails, update this function and DCHECK or update | 557 // If this check fails, update this function and DCHECK or update |
| 349 // IsSupportedCdmInterfaceVersion(). | 558 // IsSupportedCdmInterfaceVersion(). |
| 350 PP_DCHECK( | 559 PP_DCHECK( |
| 351 !IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule::kVersion + | 560 !IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule::kVersion + |
| 352 1) && | 561 1) && |
| 353 IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule::kVersion) && | 562 IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule::kVersion) && |
| 354 IsSupportedCdmInterfaceVersion( | 563 IsSupportedCdmInterfaceVersion( |
| 355 cdm::ContentDecryptionModule_4::kVersion) && | 564 cdm::ContentDecryptionModule_4::kVersion) && |
| 356 !IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule_4::kVersion - | 565 !IsSupportedCdmInterfaceVersion(cdm::ContentDecryptionModule_4::kVersion - |
| 357 1)); | 566 1)); |
| 358 | 567 |
| 359 // Try to create the CDM using the latest CDM interface version. | 568 // Try to create the CDM using the latest CDM interface version. |
| 360 CdmWrapper* cdm_wrapper = | 569 CdmWrapper* cdm_wrapper = |
| 361 CdmWrapperImpl<cdm::ContentDecryptionModule>::Create( | 570 CdmWrapperImpl<cdm::ContentDecryptionModule>::Create( |
| 362 key_system, key_system_size, get_cdm_host_func, user_data); | 571 key_system, key_system_size, get_cdm_host_func, user_data); |
| 363 if (cdm_wrapper) | 572 if (cdm_wrapper) |
| 364 return cdm_wrapper; | 573 return cdm_wrapper; |
| 365 | 574 |
| 366 // If |cdm_wrapper| is NULL, try to create the CDM using older supported | 575 // If |cdm_wrapper| is NULL, try to create the CDM using older supported |
| 367 // versions of the CDM interface. | 576 // versions of the CDM interface. |
| 577 cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_5>::Create( | |
| 578 key_system, key_system_size, get_cdm_host_func, user_data); | |
| 579 if (cdm_wrapper) | |
| 580 return cdm_wrapper; | |
| 581 | |
| 368 cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_4>::Create( | 582 cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_4>::Create( |
| 369 key_system, key_system_size, get_cdm_host_func, user_data); | 583 key_system, key_system_size, get_cdm_host_func, user_data); |
| 370 return cdm_wrapper; | 584 return cdm_wrapper; |
| 371 } | 585 } |
| 372 | 586 |
| 373 // When updating the CdmAdapter, ensure you've updated the CdmWrapper to contain | 587 // When updating the CdmAdapter, ensure you've updated the CdmWrapper to contain |
| 374 // stub implementations for new or modified methods that the older CDM interface | 588 // stub implementations for new or modified methods that the older CDM interface |
| 375 // does not have. | 589 // does not have. |
| 376 // Also update supported_cdm_versions.h. | 590 // Also update supported_cdm_versions.h. |
| 377 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == | 591 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == |
| 378 cdm::ContentDecryptionModule_5::kVersion, | 592 cdm::ContentDecryptionModule_6::kVersion, |
| 379 ensure_cdm_wrapper_templates_have_old_version_support); | 593 ensure_cdm_wrapper_templates_have_old_version_support); |
| 380 | 594 |
| 381 } // namespace media | 595 } // namespace media |
| 382 | 596 |
| 383 #endif // MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ | 597 #endif // MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ |
| OLD | NEW |