Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <cstring> | 5 #include <cstring> |
| 6 #include <map> | 6 #include <map> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 471 private: | 471 private: |
| 472 PpbBuffer* buffer_; | 472 PpbBuffer* buffer_; |
| 473 | 473 |
| 474 DISALLOW_COPY_AND_ASSIGN(AudioFramesImpl); | 474 DISALLOW_COPY_AND_ASSIGN(AudioFramesImpl); |
| 475 }; | 475 }; |
| 476 | 476 |
| 477 // A wrapper class for abstracting away PPAPI interaction and threading for a | 477 // A wrapper class for abstracting away PPAPI interaction and threading for a |
| 478 // Content Decryption Module (CDM). | 478 // Content Decryption Module (CDM). |
| 479 class CdmWrapper : public pp::Instance, | 479 class CdmWrapper : public pp::Instance, |
| 480 public pp::ContentDecryptor_Private, | 480 public pp::ContentDecryptor_Private, |
| 481 public cdm::HostFactory, | |
| 481 public cdm::Host { | 482 public cdm::Host { |
| 482 public: | 483 public: |
| 483 CdmWrapper(PP_Instance instance, pp::Module* module); | 484 CdmWrapper(PP_Instance instance, pp::Module* module); |
| 484 virtual ~CdmWrapper(); | 485 virtual ~CdmWrapper(); |
| 485 | 486 |
| 486 // pp::Instance implementation. | 487 // pp::Instance implementation. |
| 487 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { | 488 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { |
| 488 return true; | 489 return true; |
| 489 } | 490 } |
| 490 | 491 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 509 pp::Buffer_Dev extra_data_buffer) OVERRIDE; | 510 pp::Buffer_Dev extra_data_buffer) OVERRIDE; |
| 510 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type, | 511 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type, |
| 511 uint32_t request_id) OVERRIDE; | 512 uint32_t request_id) OVERRIDE; |
| 512 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type, | 513 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type, |
| 513 uint32_t request_id) OVERRIDE; | 514 uint32_t request_id) OVERRIDE; |
| 514 virtual void DecryptAndDecode( | 515 virtual void DecryptAndDecode( |
| 515 PP_DecryptorStreamType decoder_type, | 516 PP_DecryptorStreamType decoder_type, |
| 516 pp::Buffer_Dev encrypted_buffer, | 517 pp::Buffer_Dev encrypted_buffer, |
| 517 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; | 518 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; |
| 518 | 519 |
| 520 // GetCdmHost implementation. | |
|
ddorwin
2013/02/07 23:50:21
HostFactory
xhwang
2013/02/08 01:23:12
Done.
| |
| 521 virtual void* GetCdmHost(const char* host_version) OVERRIDE; | |
| 522 | |
| 519 // cdm::Host implementation. | 523 // cdm::Host implementation. |
| 520 virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE; | 524 virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE; |
| 521 virtual double GetCurrentWallTimeInSeconds() OVERRIDE; | 525 virtual double GetCurrentWallTimeInSeconds() OVERRIDE; |
| 522 virtual void SendKeyMessage( | 526 virtual void SendKeyMessage( |
| 523 const char* session_id, int32_t session_id_length, | 527 const char* session_id, int32_t session_id_length, |
| 524 const char* message, int32_t message_length, | 528 const char* message, int32_t message_length, |
| 525 const char* default_url, int32_t default_url_length) OVERRIDE; | 529 const char* default_url, int32_t default_url_length) OVERRIDE; |
| 526 virtual void SendKeyError(const char* session_id, | 530 virtual void SendKeyError(const char* session_id, |
| 527 int32_t session_id_length, | 531 int32_t session_id_length, |
| 528 cdm::MediaKeyError error_code, | 532 cdm::MediaKeyError error_code, |
| 529 uint32_t system_code) OVERRIDE; | 533 uint32_t system_code) OVERRIDE; |
| 534 virtual void GetPrivateData(int32_t* instance, | |
| 535 GetPrivateInterface* get_interface) OVERRIDE; | |
| 530 | 536 |
| 531 private: | 537 private: |
| 532 struct SessionInfo { | 538 struct SessionInfo { |
| 533 SessionInfo(const std::string& key_system_in, | 539 SessionInfo(const std::string& key_system_in, |
| 534 const std::string& session_id_in) | 540 const std::string& session_id_in) |
| 535 : key_system(key_system_in), | 541 : key_system(key_system_in), |
| 536 session_id(session_id_in) {} | 542 session_id(session_id_in) {} |
| 537 const std::string key_system; | 543 const std::string key_system; |
| 538 const std::string session_id; | 544 const std::string session_id; |
| 539 }; | 545 }; |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 852 encrypted_block_info.tracking_info)); | 858 encrypted_block_info.tracking_info)); |
| 853 return; | 859 return; |
| 854 } | 860 } |
| 855 | 861 |
| 856 default: | 862 default: |
| 857 PP_NOTREACHED(); | 863 PP_NOTREACHED(); |
| 858 return; | 864 return; |
| 859 } | 865 } |
| 860 } | 866 } |
| 861 | 867 |
| 868 void* CdmWrapper::GetCdmHost(const char* host_version) { | |
| 869 if (strcmp(host_version, CDM_HOST_INTERFACE) == 0) | |
| 870 return static_cast<cdm::Host*>(this); | |
| 871 return NULL; | |
| 872 } | |
| 873 | |
| 862 void CdmWrapper::SetTimer(int64_t delay_ms, void* context) { | 874 void CdmWrapper::SetTimer(int64_t delay_ms, void* context) { |
| 863 // NOTE: doesn't really need to run on the main thread; could just as well run | 875 // NOTE: doesn't really need to run on the main thread; could just as well run |
| 864 // on a helper thread if |cdm_| were thread-friendly and care was taken. We | 876 // on a helper thread if |cdm_| were thread-friendly and care was taken. We |
| 865 // only use CallOnMainThread() here to get delayed-execution behavior. | 877 // only use CallOnMainThread() here to get delayed-execution behavior. |
| 866 pp::Module::Get()->core()->CallOnMainThread( | 878 pp::Module::Get()->core()->CallOnMainThread( |
| 867 delay_ms, | 879 delay_ms, |
| 868 callback_factory_.NewCallback(&CdmWrapper::TimerExpired, context), | 880 callback_factory_.NewCallback(&CdmWrapper::TimerExpired, context), |
| 869 PP_OK); | 881 PP_OK); |
| 870 } | 882 } |
| 871 | 883 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 894 void CdmWrapper::SendKeyError(const char* session_id, | 906 void CdmWrapper::SendKeyError(const char* session_id, |
| 895 int32_t session_id_length, | 907 int32_t session_id_length, |
| 896 cdm::MediaKeyError error_code, | 908 cdm::MediaKeyError error_code, |
| 897 uint32_t system_code) { | 909 uint32_t system_code) { |
| 898 SendKeyErrorInternal(key_system_, | 910 SendKeyErrorInternal(key_system_, |
| 899 std::string(session_id, session_id_length), | 911 std::string(session_id, session_id_length), |
| 900 error_code, | 912 error_code, |
| 901 system_code); | 913 system_code); |
| 902 } | 914 } |
| 903 | 915 |
| 916 void CdmWrapper::GetPrivateData(int32_t* instance, | |
| 917 cdm::Host::GetPrivateInterface* get_interface) { | |
| 918 *instance = pp_instance(); | |
| 919 *get_interface = pp::Module::Get()->get_browser_interface(); | |
| 920 } | |
| 921 | |
| 904 void CdmWrapper::SendUnknownKeyError(const std::string& key_system, | 922 void CdmWrapper::SendUnknownKeyError(const std::string& key_system, |
| 905 const std::string& session_id) { | 923 const std::string& session_id) { |
| 906 SendKeyErrorInternal(key_system, session_id, cdm::kUnknownError, 0); | 924 SendKeyErrorInternal(key_system, session_id, cdm::kUnknownError, 0); |
| 907 } | 925 } |
| 908 | 926 |
| 909 | |
| 910 void CdmWrapper::SendKeyAdded(const std::string& key_system, | 927 void CdmWrapper::SendKeyAdded(const std::string& key_system, |
| 911 const std::string& session_id) { | 928 const std::string& session_id) { |
| 912 PostOnMain(callback_factory_.NewCallback( | 929 PostOnMain(callback_factory_.NewCallback( |
| 913 &CdmWrapper::KeyAdded, | 930 &CdmWrapper::KeyAdded, |
| 914 SessionInfo(key_system_, session_id))); | 931 SessionInfo(key_system_, session_id))); |
| 915 } | 932 } |
| 916 | 933 |
| 917 void CdmWrapper::SendKeyErrorInternal(const std::string& key_system, | 934 void CdmWrapper::SendKeyErrorInternal(const std::string& key_system, |
| 918 const std::string& session_id, | 935 const std::string& session_id, |
| 919 cdm::MediaKeyError error_code, | 936 cdm::MediaKeyError error_code, |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1137 } // namespace webkit_media | 1154 } // namespace webkit_media |
| 1138 | 1155 |
| 1139 namespace pp { | 1156 namespace pp { |
| 1140 | 1157 |
| 1141 // Factory function for your specialization of the Module object. | 1158 // Factory function for your specialization of the Module object. |
| 1142 Module* CreateModule() { | 1159 Module* CreateModule() { |
| 1143 return new webkit_media::CdmWrapperModule(); | 1160 return new webkit_media::CdmWrapperModule(); |
| 1144 } | 1161 } |
| 1145 | 1162 |
| 1146 } // namespace pp | 1163 } // namespace pp |
| OLD | NEW |