| 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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| (...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 StringVar::StringToPPVar(session_id))); | 1442 StringVar::StringToPPVar(session_id))); |
| 1443 } | 1443 } |
| 1444 | 1444 |
| 1445 bool PluginInstance::Decrypt( | 1445 bool PluginInstance::Decrypt( |
| 1446 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, | 1446 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, |
| 1447 const media::Decryptor::DecryptCB& decrypt_cb) { | 1447 const media::Decryptor::DecryptCB& decrypt_cb) { |
| 1448 if (!LoadContentDecryptorInterface()) | 1448 if (!LoadContentDecryptorInterface()) |
| 1449 return false; | 1449 return false; |
| 1450 | 1450 |
| 1451 ScopedPPResource encrypted_resource( | 1451 ScopedPPResource encrypted_resource( |
| 1452 ScopedPPResource::PassRef(), |
| 1452 MakeBufferResource(pp_instance(), | 1453 MakeBufferResource(pp_instance(), |
| 1453 encrypted_buffer->GetData(), | 1454 encrypted_buffer->GetData(), |
| 1454 encrypted_buffer->GetDataSize())); | 1455 encrypted_buffer->GetDataSize())); |
| 1455 if (!encrypted_resource.get()) | 1456 if (!encrypted_resource.get()) |
| 1456 return false; | 1457 return false; |
| 1457 | 1458 |
| 1458 uint32_t request_id = next_decryption_request_id_++; | 1459 uint32_t request_id = next_decryption_request_id_++; |
| 1459 | 1460 |
| 1460 PP_EncryptedBlockInfo block_info; | 1461 PP_EncryptedBlockInfo block_info; |
| 1461 DCHECK(encrypted_buffer->GetDecryptConfig()); | 1462 DCHECK(encrypted_buffer->GetDecryptConfig()); |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2171 key_system_string->value(), | 2172 key_system_string->value(), |
| 2172 session_id_string->value(), | 2173 session_id_string->value(), |
| 2173 static_cast<media::Decryptor::KeyError>(media_error), | 2174 static_cast<media::Decryptor::KeyError>(media_error), |
| 2174 system_code); | 2175 system_code); |
| 2175 } | 2176 } |
| 2176 | 2177 |
| 2177 void PluginInstance::DeliverBlock(PP_Instance instance, | 2178 void PluginInstance::DeliverBlock(PP_Instance instance, |
| 2178 PP_Resource decrypted_block, | 2179 PP_Resource decrypted_block, |
| 2179 const PP_DecryptedBlockInfo* block_info) { | 2180 const PP_DecryptedBlockInfo* block_info) { |
| 2180 DCHECK(block_info); | 2181 DCHECK(block_info); |
| 2181 | |
| 2182 DecryptionCBMap::iterator found = pending_decryption_cbs_.find( | 2182 DecryptionCBMap::iterator found = pending_decryption_cbs_.find( |
| 2183 block_info->tracking_info.request_id); | 2183 block_info->tracking_info.request_id); |
| 2184 | |
| 2185 if (found == pending_decryption_cbs_.end()) | 2184 if (found == pending_decryption_cbs_.end()) |
| 2186 return; | 2185 return; |
| 2187 media::Decryptor::DecryptCB decrypt_cb = found->second; | 2186 media::Decryptor::DecryptCB decrypt_cb = found->second; |
| 2188 pending_decryption_cbs_.erase(found); | 2187 pending_decryption_cbs_.erase(found); |
| 2189 | 2188 |
| 2190 if (block_info->result == PP_DECRYPTRESULT_DECRYPT_NOKEY) { | 2189 if (block_info->result == PP_DECRYPTRESULT_DECRYPT_NOKEY) { |
| 2191 decrypt_cb.Run(media::Decryptor::kNoKey, NULL); | 2190 decrypt_cb.Run(media::Decryptor::kNoKey, NULL); |
| 2192 return; | 2191 return; |
| 2193 } | 2192 } |
| 2194 if (block_info->result != PP_DECRYPTRESULT_SUCCESS) { | 2193 if (block_info->result != PP_DECRYPTRESULT_SUCCESS) { |
| 2195 decrypt_cb.Run(media::Decryptor::kError, NULL); | 2194 decrypt_cb.Run(media::Decryptor::kError, NULL); |
| 2196 return; | 2195 return; |
| 2197 } | 2196 } |
| 2197 |
| 2198 EnterResourceNoLock<PPB_Buffer_API> enter(decrypted_block, true); | 2198 EnterResourceNoLock<PPB_Buffer_API> enter(decrypted_block, true); |
| 2199 | |
| 2200 if (!enter.succeeded()) { | 2199 if (!enter.succeeded()) { |
| 2201 decrypt_cb.Run(media::Decryptor::kError, NULL); | 2200 decrypt_cb.Run(media::Decryptor::kError, NULL); |
| 2202 return; | 2201 return; |
| 2203 } | 2202 } |
| 2204 BufferAutoMapper mapper(enter.object()); | 2203 BufferAutoMapper mapper(enter.object()); |
| 2205 if (!mapper.data() || !mapper.size()) { | 2204 if (!mapper.data() || !mapper.size()) { |
| 2206 decrypt_cb.Run(media::Decryptor::kError, NULL); | 2205 decrypt_cb.Run(media::Decryptor::kError, NULL); |
| 2207 return; | 2206 return; |
| 2208 } | 2207 } |
| 2209 | 2208 |
| 2209 // TODO(tomfinegan): Find a way to take ownership of the shared memory |
| 2210 // managed by the PPB_Buffer_Dev, and avoid the extra copy. |
| 2210 scoped_refptr<media::DecoderBuffer> decrypted_buffer( | 2211 scoped_refptr<media::DecoderBuffer> decrypted_buffer( |
| 2211 media::DecoderBuffer::CopyFrom( | 2212 media::DecoderBuffer::CopyFrom( |
| 2212 reinterpret_cast<const uint8*>(mapper.data()), mapper.size())); | 2213 reinterpret_cast<const uint8*>(mapper.data()), mapper.size())); |
| 2213 decrypted_buffer->SetTimestamp(base::TimeDelta::FromMicroseconds( | 2214 decrypted_buffer->SetTimestamp(base::TimeDelta::FromMicroseconds( |
| 2214 block_info->tracking_info.timestamp)); | 2215 block_info->tracking_info.timestamp)); |
| 2215 decrypt_cb.Run(media::Decryptor::kSuccess, decrypted_buffer); | 2216 decrypt_cb.Run(media::Decryptor::kSuccess, decrypted_buffer); |
| 2216 } | 2217 } |
| 2217 | 2218 |
| 2218 void PluginInstance::DeliverFrame(PP_Instance instance, | 2219 void PluginInstance::DeliverFrame(PP_Instance instance, |
| 2219 PP_Resource decrypted_frame, | 2220 PP_Resource decrypted_frame, |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2602 screen_size_for_fullscreen_ = gfx::Size(); | 2603 screen_size_for_fullscreen_ = gfx::Size(); |
| 2603 WebElement element = container_->element(); | 2604 WebElement element = container_->element(); |
| 2604 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2605 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 2605 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2606 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 2606 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2607 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 2607 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2608 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 2608 } | 2609 } |
| 2609 | 2610 |
| 2610 } // namespace ppapi | 2611 } // namespace ppapi |
| 2611 } // namespace webkit | 2612 } // namespace webkit |
| OLD | NEW |