| 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> // For memcpy. | 5 #include <cstring> // For memcpy. |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" // For OVERRIDE. | 8 #include "base/compiler_specific.h" // For OVERRIDE. |
| 9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/c/pp_stdint.h" | 10 #include "ppapi/c/pp_stdint.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; | 83 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; |
| 84 virtual bool DecryptAndDecode( | 84 virtual bool DecryptAndDecode( |
| 85 pp::Buffer_Dev encrypted_buffer, | 85 pp::Buffer_Dev encrypted_buffer, |
| 86 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; | 86 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 // Creates a PP_Resource containing a PPB_Buffer_Impl, copies |data| into the | 89 // Creates a PP_Resource containing a PPB_Buffer_Impl, copies |data| into the |
| 90 // buffer resource, and returns it. Returns a an invalid PP_Resource with an | 90 // buffer resource, and returns it. Returns a an invalid PP_Resource with an |
| 91 // ID of 0 on failure. Upon success, the returned Buffer resource has a | 91 // ID of 0 on failure. Upon success, the returned Buffer resource has a |
| 92 // reference count of 1. | 92 // reference count of 1. |
| 93 PP_Resource MakeBufferResource(const uint8_t* data, uint32_t data_size); | 93 pp::Buffer_Dev MakeBufferResource(const uint8_t* data, uint32_t data_size); |
| 94 | 94 |
| 95 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to | 95 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to |
| 96 // <code>callback_factory_</code> to ensure that calls into | 96 // <code>callback_factory_</code> to ensure that calls into |
| 97 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. | 97 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. |
| 98 void KeyAdded(int32_t result, const std::string& session_id); | 98 void KeyAdded(int32_t result, const std::string& session_id); |
| 99 void KeyMessage(int32_t result, cdm::KeyMessage& key_message); | 99 void KeyMessage(int32_t result, cdm::KeyMessage& key_message); |
| 100 void KeyError(int32_t result, const std::string& session_id); | 100 void KeyError(int32_t result, const std::string& session_id); |
| 101 void DeliverBlock(int32_t result, | 101 void DeliverBlock(int32_t result, |
| 102 const cdm::Status& status, | 102 const cdm::Status& status, |
| 103 cdm::OutputBuffer& output_buffer, | 103 cdm::OutputBuffer& output_buffer, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 input_buffer.timestamp = encrypted_block_info.tracking_info.timestamp; | 226 input_buffer.timestamp = encrypted_block_info.tracking_info.timestamp; |
| 227 | 227 |
| 228 cdm::OutputBuffer output_buffer; | 228 cdm::OutputBuffer output_buffer; |
| 229 cdm::Status status = cdm_->Decrypt(input_buffer, &output_buffer); | 229 cdm::Status status = cdm_->Decrypt(input_buffer, &output_buffer); |
| 230 | 230 |
| 231 CallOnMain(callback_factory_.NewCallback( | 231 CallOnMain(callback_factory_.NewCallback( |
| 232 &CdmWrapper::DeliverBlock, | 232 &CdmWrapper::DeliverBlock, |
| 233 status, | 233 status, |
| 234 output_buffer, | 234 output_buffer, |
| 235 encrypted_block_info.tracking_info)); | 235 encrypted_block_info.tracking_info)); |
| 236 | |
| 237 return true; | 236 return true; |
| 238 } | 237 } |
| 239 | 238 |
| 240 bool CdmWrapper::DecryptAndDecode( | 239 bool CdmWrapper::DecryptAndDecode( |
| 241 pp::Buffer_Dev encrypted_buffer, | 240 pp::Buffer_Dev encrypted_buffer, |
| 242 const PP_EncryptedBlockInfo& encrypted_block_info) { | 241 const PP_EncryptedBlockInfo& encrypted_block_info) { |
| 243 return false; | 242 return false; |
| 244 } | 243 } |
| 245 | 244 |
| 246 PP_Resource CdmWrapper::MakeBufferResource(const uint8_t* data, | 245 pp::Buffer_Dev CdmWrapper::MakeBufferResource(const uint8_t* data, |
| 247 uint32_t data_size) { | 246 uint32_t data_size) { |
| 248 if (!data || !data_size) | 247 if (!data || !data_size) |
| 249 return 0; | 248 return pp::Buffer_Dev(); |
| 250 | 249 |
| 251 pp::Buffer_Dev buffer(this, data_size); | 250 pp::Buffer_Dev buffer(this, data_size); |
| 252 if (!buffer.data()) | 251 if (!buffer.data()) |
| 253 return 0; | 252 return pp::Buffer_Dev(); |
| 254 | 253 |
| 255 memcpy(buffer.data(), data, data_size); | 254 memcpy(buffer.data(), data, data_size); |
| 256 | 255 return buffer; |
| 257 return buffer.detach(); | |
| 258 } | 256 } |
| 259 | 257 |
| 260 void CdmWrapper::KeyAdded(int32_t result, const std::string& session_id) { | 258 void CdmWrapper::KeyAdded(int32_t result, const std::string& session_id) { |
| 261 pp::ContentDecryptor_Private::KeyAdded(key_system_, session_id); | 259 pp::ContentDecryptor_Private::KeyAdded(key_system_, session_id); |
| 262 } | 260 } |
| 263 | 261 |
| 264 void CdmWrapper::KeyMessage(int32_t result, | 262 void CdmWrapper::KeyMessage(int32_t result, |
| 265 cdm::KeyMessage& key_message) { | 263 cdm::KeyMessage& key_message) { |
| 266 pp::Buffer_Dev message_buffer(MakeBufferResource(key_message.message, | 264 pp::Buffer_Dev message_buffer(MakeBufferResource(key_message.message, |
| 267 key_message.message_size)); | 265 key_message.message_size)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 289 kUnknownError, | 287 kUnknownError, |
| 290 0); | 288 0); |
| 291 } | 289 } |
| 292 | 290 |
| 293 void CdmWrapper::DeliverBlock(int32_t result, | 291 void CdmWrapper::DeliverBlock(int32_t result, |
| 294 const cdm::Status& status, | 292 const cdm::Status& status, |
| 295 cdm::OutputBuffer& output_buffer, | 293 cdm::OutputBuffer& output_buffer, |
| 296 const PP_DecryptTrackingInfo& tracking_info) { | 294 const PP_DecryptTrackingInfo& tracking_info) { |
| 297 pp::Buffer_Dev decrypted_buffer(MakeBufferResource(output_buffer.data, | 295 pp::Buffer_Dev decrypted_buffer(MakeBufferResource(output_buffer.data, |
| 298 output_buffer.data_size)); | 296 output_buffer.data_size)); |
| 299 | |
| 300 PP_DecryptedBlockInfo decrypted_block_info; | 297 PP_DecryptedBlockInfo decrypted_block_info; |
| 301 decrypted_block_info.tracking_info.request_id = tracking_info.request_id; | 298 decrypted_block_info.tracking_info.request_id = tracking_info.request_id; |
| 302 decrypted_block_info.tracking_info.timestamp = output_buffer.timestamp; | 299 decrypted_block_info.tracking_info.timestamp = output_buffer.timestamp; |
| 303 | 300 |
| 304 switch (status) { | 301 switch (status) { |
| 305 case cdm::kSuccess: | 302 case cdm::kSuccess: |
| 306 decrypted_block_info.result = PP_DECRYPTRESULT_SUCCESS; | 303 decrypted_block_info.result = PP_DECRYPTRESULT_SUCCESS; |
| 307 break; | 304 break; |
| 308 case cdm::kErrorNoKey: | 305 case cdm::kErrorNoKey: |
| 309 decrypted_block_info.result = PP_DECRYPTRESULT_DECRYPT_NOKEY; | 306 decrypted_block_info.result = PP_DECRYPTRESULT_DECRYPT_NOKEY; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 336 } // namespace webkit_media | 333 } // namespace webkit_media |
| 337 | 334 |
| 338 namespace pp { | 335 namespace pp { |
| 339 | 336 |
| 340 // Factory function for your specialization of the Module object. | 337 // Factory function for your specialization of the Module object. |
| 341 Module* CreateModule() { | 338 Module* CreateModule() { |
| 342 return new webkit_media::MyModule(); | 339 return new webkit_media::MyModule(); |
| 343 } | 340 } |
| 344 | 341 |
| 345 } // namespace pp | 342 } // namespace pp |
| OLD | NEW |