| 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 #ifndef PPAPI_CPP_PRIVATE_CONTENT_DECRYPTOR_PRIVATE_H_ | 5 #ifndef PPAPI_CPP_PRIVATE_CONTENT_DECRYPTOR_PRIVATE_H_ |
| 6 #define PPAPI_CPP_PRIVATE_CONTENT_DECRYPTOR_PRIVATE_H_ | 6 #define PPAPI_CPP_PRIVATE_CONTENT_DECRYPTOR_PRIVATE_H_ |
| 7 | 7 |
| 8 #include <string> |
| 9 |
| 8 #include "ppapi/c/private/pp_content_decryptor.h" | 10 #include "ppapi/c/private/pp_content_decryptor.h" |
| 9 #include "ppapi/c/private/ppb_content_decryptor_private.h" | 11 #include "ppapi/c/private/ppb_content_decryptor_private.h" |
| 10 #include "ppapi/c/private/ppp_content_decryptor_private.h" | 12 #include "ppapi/c/private/ppp_content_decryptor_private.h" |
| 11 | 13 |
| 12 #include "ppapi/cpp/dev/buffer_dev.h" | 14 #include "ppapi/cpp/dev/buffer_dev.h" |
| 13 #include "ppapi/cpp/instance_handle.h" | 15 #include "ppapi/cpp/instance_handle.h" |
| 14 #include "ppapi/cpp/var.h" | 16 #include "ppapi/cpp/var.h" |
| 15 #include "ppapi/cpp/var_array_buffer.h" | 17 #include "ppapi/cpp/var_array_buffer.h" |
| 16 | 18 |
| 17 namespace pp { | 19 namespace pp { |
| 18 | 20 |
| 19 class Instance; | 21 class Instance; |
| 20 | 22 |
| 21 // TODO(tomfinegan): Remove redundant pp:: usage, and pass VarArrayBuffers as | 23 // TODO(tomfinegan): Remove redundant pp:: usage, and pass VarArrayBuffers as |
| 22 // const references. | 24 // const references. |
| 23 | 25 |
| 24 class ContentDecryptor_Private { | 26 class ContentDecryptor_Private { |
| 25 public: | 27 public: |
| 26 explicit ContentDecryptor_Private(Instance* instance); | 28 explicit ContentDecryptor_Private(Instance* instance); |
| 27 virtual ~ContentDecryptor_Private(); | 29 virtual ~ContentDecryptor_Private(); |
| 28 | 30 |
| 29 // PPP_ContentDecryptor_Private functions exposed as virtual functions | 31 // PPP_ContentDecryptor_Private functions exposed as virtual functions |
| 30 // for you to override. | 32 // for you to override. |
| 31 // TODO(tomfinegan): This could be optimized to pass pp::Var instead of | 33 // TODO(tomfinegan): This could be optimized to pass pp::Var instead of |
| 32 // strings. The change would allow the CDM wrapper to reuse vars when | 34 // strings. The change would allow the CDM wrapper to reuse vars when |
| 33 // replying to the browser. | 35 // replying to the browser. |
| 34 virtual void Initialize(const std::string& key_system) = 0; | 36 virtual void Initialize(const std::string& key_system) = 0; |
| 35 virtual void CreateSession(uint32_t session_id, | 37 virtual void CreateSession(uint32_t promise_id, |
| 36 const std::string& content_type, | 38 const std::string& init_data_type, |
| 37 pp::VarArrayBuffer init_data) = 0; | 39 pp::VarArrayBuffer init_data, |
| 38 virtual void LoadSession(uint32_t session_id, | 40 PP_SessionType session_type) = 0; |
| 41 virtual void LoadSession(uint32_t promise_id, |
| 39 const std::string& web_session_id) = 0; | 42 const std::string& web_session_id) = 0; |
| 40 virtual void UpdateSession(uint32_t session_id, | 43 virtual void UpdateSession(uint32_t promise_id, |
| 44 const std::string& web_session_id, |
| 41 pp::VarArrayBuffer response) = 0; | 45 pp::VarArrayBuffer response) = 0; |
| 42 virtual void ReleaseSession(uint32_t session_id) = 0; | 46 virtual void ReleaseSession(uint32_t promise_id, |
| 47 const std::string& web_session_id) = 0; |
| 43 virtual void Decrypt(pp::Buffer_Dev encrypted_buffer, | 48 virtual void Decrypt(pp::Buffer_Dev encrypted_buffer, |
| 44 const PP_EncryptedBlockInfo& encrypted_block_info) = 0; | 49 const PP_EncryptedBlockInfo& encrypted_block_info) = 0; |
| 45 virtual void InitializeAudioDecoder( | 50 virtual void InitializeAudioDecoder( |
| 46 const PP_AudioDecoderConfig& decoder_config, | 51 const PP_AudioDecoderConfig& decoder_config, |
| 47 pp::Buffer_Dev extra_data_resource) = 0; | 52 pp::Buffer_Dev extra_data_resource) = 0; |
| 48 virtual void InitializeVideoDecoder( | 53 virtual void InitializeVideoDecoder( |
| 49 const PP_VideoDecoderConfig& decoder_config, | 54 const PP_VideoDecoderConfig& decoder_config, |
| 50 pp::Buffer_Dev extra_data_resource) = 0; | 55 pp::Buffer_Dev extra_data_resource) = 0; |
| 51 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type, | 56 virtual void DeinitializeDecoder(PP_DecryptorStreamType decoder_type, |
| 52 uint32_t request_id) = 0; | 57 uint32_t request_id) = 0; |
| 53 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type, | 58 virtual void ResetDecoder(PP_DecryptorStreamType decoder_type, |
| 54 uint32_t request_id) = 0; | 59 uint32_t request_id) = 0; |
| 55 // Null |encrypted_frame| means end-of-stream buffer. | 60 // Null |encrypted_frame| means end-of-stream buffer. |
| 56 virtual void DecryptAndDecode( | 61 virtual void DecryptAndDecode( |
| 57 PP_DecryptorStreamType decoder_type, | 62 PP_DecryptorStreamType decoder_type, |
| 58 pp::Buffer_Dev encrypted_buffer, | 63 pp::Buffer_Dev encrypted_buffer, |
| 59 const PP_EncryptedBlockInfo& encrypted_block_info) = 0; | 64 const PP_EncryptedBlockInfo& encrypted_block_info) = 0; |
| 60 | 65 |
| 61 // PPB_ContentDecryptor_Private methods for passing data from the decryptor | 66 // PPB_ContentDecryptor_Private methods for passing data from the decryptor |
| 62 // to the browser. | 67 // to the browser. |
| 63 void SessionCreated(uint32_t session_id, const std::string& web_session_id); | 68 void PromiseResolved(uint32_t promise_id); |
| 64 void SessionMessage(uint32_t session_id, | 69 void PromiseResolvedWithSession(uint32_t promise_id, |
| 70 const std::string& web_session_id); |
| 71 void PromiseRejected(uint32_t promise_id, |
| 72 PP_ExceptionCodeType exception_code, |
| 73 uint32_t system_code, |
| 74 const std::string& error_description); |
| 75 void SessionMessage(const std::string& web_session_id, |
| 65 pp::VarArrayBuffer message, | 76 pp::VarArrayBuffer message, |
| 66 const std::string& default_url); | 77 const std::string& destination_url); |
| 67 void SessionReady(uint32_t session_id); | 78 void SessionReady(const std::string& web_session_id); |
| 68 void SessionClosed(uint32_t session_id); | 79 void SessionClosed(const std::string& web_session_id); |
| 69 void SessionError(uint32_t session_id, | 80 void SessionError(const std::string& web_session_id, |
| 70 int32_t media_error, | 81 PP_ExceptionCodeType exception_code, |
| 71 uint32_t system_code); | 82 uint32_t system_code, |
| 83 const std::string& error_description); |
| 72 | 84 |
| 73 // The plugin must not hold a reference to the encrypted buffer resource | 85 // The plugin must not hold a reference to the encrypted buffer resource |
| 74 // provided to Decrypt() when it calls this method. The browser will reuse | 86 // provided to Decrypt() when it calls this method. The browser will reuse |
| 75 // the buffer in a subsequent Decrypt() call. | 87 // the buffer in a subsequent Decrypt() call. |
| 76 void DeliverBlock(pp::Buffer_Dev decrypted_block, | 88 void DeliverBlock(pp::Buffer_Dev decrypted_block, |
| 77 const PP_DecryptedBlockInfo& decrypted_block_info); | 89 const PP_DecryptedBlockInfo& decrypted_block_info); |
| 78 | 90 |
| 79 void DecoderInitializeDone(PP_DecryptorStreamType decoder_type, | 91 void DecoderInitializeDone(PP_DecryptorStreamType decoder_type, |
| 80 uint32_t request_id, | 92 uint32_t request_id, |
| 81 bool status); | 93 bool status); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 96 void DeliverSamples(pp::Buffer_Dev audio_frames, | 108 void DeliverSamples(pp::Buffer_Dev audio_frames, |
| 97 const PP_DecryptedSampleInfo& decrypted_sample_info); | 109 const PP_DecryptedSampleInfo& decrypted_sample_info); |
| 98 | 110 |
| 99 private: | 111 private: |
| 100 InstanceHandle associated_instance_; | 112 InstanceHandle associated_instance_; |
| 101 }; | 113 }; |
| 102 | 114 |
| 103 } // namespace pp | 115 } // namespace pp |
| 104 | 116 |
| 105 #endif // PPAPI_CPP_PRIVATE_CONTENT_DECRYPTOR_PRIVATE_H_ | 117 #endif // PPAPI_CPP_PRIVATE_CONTENT_DECRYPTOR_PRIVATE_H_ |
| OLD | NEW |