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 24 matching lines...) Expand all Loading... | |
35 // (just a shim layer in most cases), everything is done in this header file. | 35 // (just a shim layer in most cases), everything is done in this header file. |
36 class CdmWrapper { | 36 class CdmWrapper { |
37 public: | 37 public: |
38 static CdmWrapper* Create(const char* key_system, | 38 static CdmWrapper* Create(const char* key_system, |
39 uint32_t key_system_size, | 39 uint32_t key_system_size, |
40 GetCdmHostFunc get_cdm_host_func, | 40 GetCdmHostFunc get_cdm_host_func, |
41 void* user_data); | 41 void* user_data); |
42 | 42 |
43 virtual ~CdmWrapper() {}; | 43 virtual ~CdmWrapper() {}; |
44 | 44 |
45 virtual bool SetServerCertificate(uint32_t promise_id, | |
ddorwin
2014/08/22 20:49:20
Is there a reason this has a return value?
Should
jrummell
2014/08/25 21:54:36
You are correct. Added comment to match other meth
| |
46 const uint8_t* server_certificate_data, | |
47 uint32_t server_certificate_data_size) = 0; | |
45 virtual void CreateSession(uint32_t promise_id, | 48 virtual void CreateSession(uint32_t promise_id, |
46 const char* init_data_type, | 49 const char* init_data_type, |
47 uint32_t init_data_type_size, | 50 uint32_t init_data_type_size, |
48 const uint8_t* init_data, | 51 const uint8_t* init_data, |
49 uint32_t init_data_size, | 52 uint32_t init_data_size, |
50 cdm::SessionType session_type) = 0; | 53 cdm::SessionType session_type) = 0; |
51 virtual void LoadSession(uint32_t promise_id, | 54 virtual void LoadSession(uint32_t promise_id, |
52 const char* web_session_id, | 55 const char* web_session_id, |
53 uint32_t web_session_id_size) = 0; | 56 uint32_t web_session_id_size) = 0; |
54 virtual void UpdateSession(uint32_t promise_id, | 57 virtual void UpdateSession(uint32_t promise_id, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 | 169 |
167 // Returns true if |data| is prefixed with |header| and has data after the | 170 // Returns true if |data| is prefixed with |header| and has data after the |
168 // |header|. | 171 // |header|. |
169 bool HasHeader(const uint8* data, | 172 bool HasHeader(const uint8* data, |
170 int data_length, | 173 int data_length, |
171 const std::string& header) { | 174 const std::string& header) { |
172 return static_cast<size_t>(data_length) > header.length() && | 175 return static_cast<size_t>(data_length) > header.length() && |
173 std::equal(data, data + header.length(), header.begin()); | 176 std::equal(data, data + header.length(), header.begin()); |
174 } | 177 } |
175 | 178 |
179 virtual bool SetServerCertificate( | |
180 uint32_t promise_id, | |
181 const uint8_t* server_certificate_data, | |
182 uint32_t server_certificate_data_size) OVERRIDE { | |
183 cdm_->SetServerCertificate( | |
184 promise_id, server_certificate_data, server_certificate_data_size); | |
185 return true; | |
186 } | |
187 | |
176 virtual void CreateSession(uint32_t promise_id, | 188 virtual void CreateSession(uint32_t promise_id, |
177 const char* init_data_type, | 189 const char* init_data_type, |
178 uint32_t init_data_type_size, | 190 uint32_t init_data_type_size, |
179 const uint8_t* init_data, | 191 const uint8_t* init_data, |
180 uint32_t init_data_size, | 192 uint32_t init_data_size, |
181 cdm::SessionType session_type) OVERRIDE { | 193 cdm::SessionType session_type) OVERRIDE { |
182 // TODO(jrummell): Remove this code once |session_type| is passed through | 194 // TODO(jrummell): Remove this code once |session_type| is passed through |
183 // Pepper. When removing, add the header back in for CDM4. | 195 // Pepper. When removing, add the header back in for CDM4. |
184 PP_DCHECK(session_type == cdm::kTemporary); | 196 PP_DCHECK(session_type == cdm::kTemporary); |
185 const char kPersistentSessionHeader[] = "PERSISTENT|"; | 197 const char kPersistentSessionHeader[] = "PERSISTENT|"; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
397 // LoadSession(), UpdateSession(), and ReleaseSession() pass in promise ids, | 409 // LoadSession(), UpdateSession(), and ReleaseSession() pass in promise ids, |
398 // but the CDM interface needs session ids. For create and load, we need to | 410 // but the CDM interface needs session ids. For create and load, we need to |
399 // create a new session_id to pass to the CDM. For update and release, we need | 411 // create a new session_id to pass to the CDM. For update and release, we need |
400 // to look up |web_session_id| and convert it into the existing |session_id|. | 412 // to look up |web_session_id| and convert it into the existing |session_id|. |
401 // Since the callbacks don't come through this interface, cdm_adapter needs to | 413 // Since the callbacks don't come through this interface, cdm_adapter needs to |
402 // create the mapping (and delete it on release). Finally, for create, we need | 414 // create the mapping (and delete it on release). Finally, for create, we need |
403 // to translate |init_data_type| to a MIME type. | 415 // to translate |init_data_type| to a MIME type. |
404 // TODO(jrummell): Remove these once Host_4 interface is removed. | 416 // TODO(jrummell): Remove these once Host_4 interface is removed. |
405 | 417 |
406 template <> | 418 template <> |
419 bool CdmWrapperImpl<cdm::ContentDecryptionModule_4>::SetServerCertificate( | |
420 uint32_t promise_id, | |
421 const uint8_t* server_certificate_data, | |
422 uint32_t server_certificate_data_size) { | |
423 return false; | |
424 } | |
425 | |
426 template <> | |
407 void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::CreateSession( | 427 void CdmWrapperImpl<cdm::ContentDecryptionModule_4>::CreateSession( |
408 uint32_t promise_id, | 428 uint32_t promise_id, |
409 const char* init_data_type, | 429 const char* init_data_type, |
410 uint32_t init_data_type_size, | 430 uint32_t init_data_type_size, |
411 const uint8_t* init_data, | 431 const uint8_t* init_data, |
412 uint32_t init_data_size, | 432 uint32_t init_data_size, |
413 cdm::SessionType session_type) { | 433 cdm::SessionType session_type) { |
414 uint32_t session_id = CreateSessionId(); | 434 uint32_t session_id = CreateSessionId(); |
415 RegisterPromise(session_id, promise_id); | 435 RegisterPromise(session_id, promise_id); |
416 std::string converted_init_data_type = ConvertInitDataTypeToContentType( | 436 std::string converted_init_data_type = ConvertInitDataTypeToContentType( |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
506 cdm::AudioFrames* audio_frames) { | 526 cdm::AudioFrames* audio_frames) { |
507 cdm::InputBuffer_1 buffer; | 527 cdm::InputBuffer_1 buffer; |
508 ConvertInputBuffer(encrypted_buffer, &buffer); | 528 ConvertInputBuffer(encrypted_buffer, &buffer); |
509 return cdm_->DecryptAndDecodeSamples(buffer, audio_frames); | 529 return cdm_->DecryptAndDecodeSamples(buffer, audio_frames); |
510 } | 530 } |
511 | 531 |
512 // Overrides for the cdm::Host_5 methods. | 532 // Overrides for the cdm::Host_5 methods. |
513 // TODO(jrummell): Remove these once Host_5 interface is removed. | 533 // TODO(jrummell): Remove these once Host_5 interface is removed. |
514 | 534 |
515 template <> | 535 template <> |
536 bool CdmWrapperImpl<cdm::ContentDecryptionModule_5>::SetServerCertificate( | |
537 uint32_t promise_id, | |
538 const uint8_t* server_certificate_data, | |
539 uint32_t server_certificate_data_size) { | |
540 return false; | |
541 } | |
542 | |
543 template <> | |
516 void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::CreateSession( | 544 void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::CreateSession( |
517 uint32_t promise_id, | 545 uint32_t promise_id, |
518 const char* init_data_type, | 546 const char* init_data_type, |
519 uint32_t init_data_type_size, | 547 uint32_t init_data_type_size, |
520 const uint8_t* init_data, | 548 const uint8_t* init_data, |
521 uint32_t init_data_size, | 549 uint32_t init_data_size, |
522 cdm::SessionType session_type) { | 550 cdm::SessionType session_type) { |
523 std::string converted_init_data_type = ConvertInitDataTypeToContentType( | 551 std::string converted_init_data_type = ConvertInitDataTypeToContentType( |
524 std::string(init_data_type, init_data_type_size)); | 552 std::string(init_data_type, init_data_type_size)); |
525 // TODO(jrummell): Remove this code once |session_type| is passed through | 553 // TODO(jrummell): Remove this code once |session_type| is passed through |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
668 // stub implementations for new or modified methods that the older CDM interface | 696 // stub implementations for new or modified methods that the older CDM interface |
669 // does not have. | 697 // does not have. |
670 // Also update supported_cdm_versions.h. | 698 // Also update supported_cdm_versions.h. |
671 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == | 699 COMPILE_ASSERT(cdm::ContentDecryptionModule::kVersion == |
672 cdm::ContentDecryptionModule_6::kVersion, | 700 cdm::ContentDecryptionModule_6::kVersion, |
673 ensure_cdm_wrapper_templates_have_old_version_support); | 701 ensure_cdm_wrapper_templates_have_old_version_support); |
674 | 702 |
675 } // namespace media | 703 } // namespace media |
676 | 704 |
677 #endif // MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ | 705 #endif // MEDIA_CDM_PPAPI_CDM_WRAPPER_H_ |
OLD | NEW |