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 "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 2160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2171 key_system_string->value(), | 2171 key_system_string->value(), |
| 2172 session_id_string->value(), | 2172 session_id_string->value(), |
| 2173 static_cast<media::Decryptor::KeyError>(media_error), | 2173 static_cast<media::Decryptor::KeyError>(media_error), |
| 2174 system_code); | 2174 system_code); |
| 2175 } | 2175 } |
| 2176 | 2176 |
| 2177 void PluginInstance::DeliverBlock(PP_Instance instance, | 2177 void PluginInstance::DeliverBlock(PP_Instance instance, |
| 2178 PP_Resource decrypted_block, | 2178 PP_Resource decrypted_block, |
| 2179 const PP_DecryptedBlockInfo* block_info) { | 2179 const PP_DecryptedBlockInfo* block_info) { |
| 2180 DCHECK(block_info); | 2180 DCHECK(block_info); |
| 2181 | |
| 2182 DecryptionCBMap::iterator found = pending_decryption_cbs_.find( | 2181 DecryptionCBMap::iterator found = pending_decryption_cbs_.find( |
| 2183 block_info->tracking_info.request_id); | 2182 block_info->tracking_info.request_id); |
| 2184 | |
| 2185 if (found == pending_decryption_cbs_.end()) | 2183 if (found == pending_decryption_cbs_.end()) |
| 2186 return; | 2184 return; |
| 2187 media::Decryptor::DecryptCB decrypt_cb = found->second; | 2185 media::Decryptor::DecryptCB decrypt_cb = found->second; |
| 2188 pending_decryption_cbs_.erase(found); | 2186 pending_decryption_cbs_.erase(found); |
| 2189 | 2187 |
| 2190 if (block_info->result == PP_DECRYPTRESULT_DECRYPT_NOKEY) { | 2188 if (block_info->result == PP_DECRYPTRESULT_DECRYPT_NOKEY) { |
| 2189 DCHECK(decrypted_block == 0); | |
|
dmichael (off chromium)
2012/09/05 17:13:06
Don't we get here via a call from the CDM plugin?
Tom Finegan
2012/09/05 19:21:43
Done.
ddorwin
2012/09/06 08:39:01
I suggested this. My concern was that we might lea
| |
| 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) { |
| 2194 DCHECK(decrypted_block == 0); | |
| 2195 decrypt_cb.Run(media::Decryptor::kError, NULL); | 2195 decrypt_cb.Run(media::Decryptor::kError, NULL); |
| 2196 return; | 2196 return; |
| 2197 } | 2197 } |
| 2198 | |
| 2199 ScopedPPResource decrypted_block_scoped(ScopedPPResource::PassRef(), | |
| 2200 decrypted_block); | |
|
dmichael (off chromium)
2012/09/05 17:13:06
Why is this necessary? The plugin isn't passing us
Tom Finegan
2012/09/05 19:21:43
The resource passed back from the plugin has a ref
| |
| 2198 EnterResourceNoLock<PPB_Buffer_API> enter(decrypted_block, true); | 2201 EnterResourceNoLock<PPB_Buffer_API> enter(decrypted_block, true); |
| 2199 | |
| 2200 if (!enter.succeeded()) { | 2202 if (!enter.succeeded()) { |
| 2201 decrypt_cb.Run(media::Decryptor::kError, NULL); | 2203 decrypt_cb.Run(media::Decryptor::kError, NULL); |
| 2202 return; | 2204 return; |
| 2203 } | 2205 } |
| 2204 BufferAutoMapper mapper(enter.object()); | 2206 BufferAutoMapper mapper(enter.object()); |
| 2205 if (!mapper.data() || !mapper.size()) { | 2207 if (!mapper.data() || !mapper.size()) { |
| 2206 decrypt_cb.Run(media::Decryptor::kError, NULL); | 2208 decrypt_cb.Run(media::Decryptor::kError, NULL); |
| 2207 return; | 2209 return; |
| 2208 } | 2210 } |
| 2209 | 2211 |
| 2212 // TODO(tomfinegan): Find a way to take ownership of the shared memory | |
| 2213 // managed by the PPB_Buffer_Dev, and avoid the extra copy. | |
| 2210 scoped_refptr<media::DecoderBuffer> decrypted_buffer( | 2214 scoped_refptr<media::DecoderBuffer> decrypted_buffer( |
| 2211 media::DecoderBuffer::CopyFrom( | 2215 media::DecoderBuffer::CopyFrom( |
| 2212 reinterpret_cast<const uint8*>(mapper.data()), mapper.size())); | 2216 reinterpret_cast<const uint8*>(mapper.data()), mapper.size())); |
| 2213 decrypted_buffer->SetTimestamp(base::TimeDelta::FromMicroseconds( | 2217 decrypted_buffer->SetTimestamp(base::TimeDelta::FromMicroseconds( |
| 2214 block_info->tracking_info.timestamp)); | 2218 block_info->tracking_info.timestamp)); |
| 2215 decrypt_cb.Run(media::Decryptor::kSuccess, decrypted_buffer); | 2219 decrypt_cb.Run(media::Decryptor::kSuccess, decrypted_buffer); |
| 2216 } | 2220 } |
| 2217 | 2221 |
| 2218 void PluginInstance::DeliverFrame(PP_Instance instance, | 2222 void PluginInstance::DeliverFrame(PP_Instance instance, |
| 2219 PP_Resource decrypted_frame, | 2223 PP_Resource decrypted_frame, |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2602 screen_size_for_fullscreen_ = gfx::Size(); | 2606 screen_size_for_fullscreen_ = gfx::Size(); |
| 2603 WebElement element = container_->element(); | 2607 WebElement element = container_->element(); |
| 2604 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2608 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 2605 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2609 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 2606 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2610 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 2607 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2611 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 2608 } | 2612 } |
| 2609 | 2613 |
| 2610 } // namespace ppapi | 2614 } // namespace ppapi |
| 2611 } // namespace webkit | 2615 } // namespace webkit |
| OLD | NEW |