Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: ppapi/proxy/ppp_content_decryptor_private_proxy.cc

Issue 11023004: Update PPP side of Pepper CDM API to support video decoding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Set PPP interface version to 0.2 Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ppapi/proxy/ppp_content_decryptor_private_proxy.h" 5 #include "ppapi/proxy/ppp_content_decryptor_private_proxy.h"
6 6
7 #include "base/platform_file.h" 7 #include "base/platform_file.h"
8 #include "ppapi/c/pp_bool.h" 8 #include "ppapi/c/pp_bool.h"
9 #include "ppapi/c/ppb_core.h" 9 #include "ppapi/c/ppb_core.h"
10 #include "ppapi/proxy/content_decryptor_private_serializer.h" 10 #include "ppapi/proxy/content_decryptor_private_serializer.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 return; 178 return;
179 179
180 dispatcher->Send( 180 dispatcher->Send(
181 new PpapiMsg_PPPContentDecryptor_Decrypt( 181 new PpapiMsg_PPPContentDecryptor_Decrypt(
182 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, 182 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE,
183 instance, 183 instance,
184 buffer, 184 buffer,
185 serialized_block_info)); 185 serialized_block_info));
186 } 186 }
187 187
188 void DecryptAndDecode(PP_Instance instance, 188 void DecryptAndDecodeFrame(
189 PP_Resource encrypted_block, 189 PP_Instance instance,
190 const PP_EncryptedBlockInfo* encrypted_block_info) { 190 PP_Resource encrypted_frame,
191 const PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) {
191 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); 192 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
192 if (!dispatcher) { 193 if (!dispatcher) {
193 NOTREACHED(); 194 NOTREACHED();
194 return; 195 return;
195 } 196 }
196 197
197 if (!AddRefResourceForPlugin(dispatcher, encrypted_block)) { 198 if (!AddRefResourceForPlugin(dispatcher, encrypted_frame)) {
198 NOTREACHED(); 199 NOTREACHED();
199 return; 200 return;
200 } 201 }
201 202
202 HostResource host_resource; 203 HostResource host_resource;
203 host_resource.SetHostResource(instance, encrypted_block); 204 host_resource.SetHostResource(instance, encrypted_frame);
204 205
205 uint32_t size = 0; 206 uint32_t size = 0;
206 if (DescribeHostBufferResource(encrypted_block, &size) == PP_FALSE) 207 if (DescribeHostBufferResource(encrypted_frame, &size) == PP_FALSE)
207 return; 208 return;
208 209
209 base::SharedMemoryHandle handle; 210 base::SharedMemoryHandle handle;
210 if (ShareHostBufferResourceToPlugin(dispatcher, 211 if (ShareHostBufferResourceToPlugin(dispatcher,
211 encrypted_block, 212 encrypted_frame,
212 &handle) == PP_FALSE) 213 &handle) == PP_FALSE)
213 return; 214 return;
214 215
215 PPPDecryptor_Buffer buffer; 216 PPPDecryptor_Buffer buffer;
216 buffer.resource = host_resource; 217 buffer.resource = host_resource;
217 buffer.handle = handle; 218 buffer.handle = handle;
218 buffer.size = size; 219 buffer.size = size;
219 220
220 std::string serialized_block_info; 221 std::string serialized_frame_info;
221 if (!SerializeBlockInfo(*encrypted_block_info, &serialized_block_info)) 222 if (!SerializeBlockInfo(*encrypted_video_frame_info, &serialized_frame_info))
222 return; 223 return;
223 224
224 dispatcher->Send( 225 dispatcher->Send(
225 new PpapiMsg_PPPContentDecryptor_DecryptAndDecode( 226 new PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame(
226 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, 227 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE,
227 instance, 228 instance,
228 buffer, 229 buffer,
229 serialized_block_info)); 230 serialized_frame_info));
230 } 231 }
231 232
232 static const PPP_ContentDecryptor_Private content_decryptor_interface = { 233 static const PPP_ContentDecryptor_Private content_decryptor_interface = {
233 &GenerateKeyRequest, 234 &GenerateKeyRequest,
234 &AddKey, 235 &AddKey,
235 &CancelKeyRequest, 236 &CancelKeyRequest,
236 &Decrypt, 237 &Decrypt,
237 &DecryptAndDecode 238 &DecryptAndDecodeFrame
238 }; 239 };
239 240
240 InterfaceProxy* CreateContentDecryptorPPPProxy(Dispatcher* dispatcher) { 241 InterfaceProxy* CreateContentDecryptorPPPProxy(Dispatcher* dispatcher) {
241 return new PPP_ContentDecryptor_Private_Proxy(dispatcher); 242 return new PPP_ContentDecryptor_Private_Proxy(dispatcher);
242 } 243 }
243 244
244 } // namespace 245 } // namespace
245 246
246 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy( 247 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy(
247 Dispatcher* dispatcher) 248 Dispatcher* dispatcher)
(...skipping 20 matching lines...) Expand all
268 bool handled = true; 269 bool handled = true;
269 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg) 270 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg)
270 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest, 271 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest,
271 OnMsgGenerateKeyRequest) 272 OnMsgGenerateKeyRequest)
272 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey, 273 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey,
273 OnMsgAddKey) 274 OnMsgAddKey)
274 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest, 275 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest,
275 OnMsgCancelKeyRequest) 276 OnMsgCancelKeyRequest)
276 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, 277 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt,
277 OnMsgDecrypt) 278 OnMsgDecrypt)
278 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecode, 279 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame,
279 OnMsgDecryptAndDecode) 280 OnMsgDecryptAndDecodeFrame)
280 IPC_MESSAGE_UNHANDLED(handled = false) 281 IPC_MESSAGE_UNHANDLED(handled = false)
281 IPC_END_MESSAGE_MAP() 282 IPC_END_MESSAGE_MAP()
282 DCHECK(handled); 283 DCHECK(handled);
283 return handled; 284 return handled;
284 } 285 }
285 286
286 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( 287 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest(
287 PP_Instance instance, 288 PP_Instance instance,
288 SerializedVarReceiveInput key_system, 289 SerializedVarReceiveInput key_system,
289 SerializedVarReceiveInput init_data) { 290 SerializedVarReceiveInput init_data) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 PP_EncryptedBlockInfo block_info; 332 PP_EncryptedBlockInfo block_info;
332 if (!DeserializeBlockInfo(serialized_block_info, &block_info)) 333 if (!DeserializeBlockInfo(serialized_block_info, &block_info))
333 return; 334 return;
334 CallWhileUnlocked(ppp_decryptor_impl_->Decrypt, 335 CallWhileUnlocked(ppp_decryptor_impl_->Decrypt,
335 instance, 336 instance,
336 plugin_resource, 337 plugin_resource,
337 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); 338 const_cast<const PP_EncryptedBlockInfo*>(&block_info));
338 } 339 }
339 } 340 }
340 341
341 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecode( 342 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecodeFrame(
342 PP_Instance instance, 343 PP_Instance instance,
343 const PPPDecryptor_Buffer& encrypted_buffer, 344 const PPPDecryptor_Buffer& encrypted_frame,
344 const std::string& serialized_block_info) { 345 const std::string& serialized_frame_info) {
345 if (ppp_decryptor_impl_) { 346 if (ppp_decryptor_impl_) {
346 PP_Resource plugin_resource = 347 PP_Resource plugin_resource =
347 PPB_Buffer_Proxy::AddProxyResource(encrypted_buffer.resource, 348 PPB_Buffer_Proxy::AddProxyResource(encrypted_frame.resource,
348 encrypted_buffer.handle, 349 encrypted_frame.handle,
349 encrypted_buffer.size); 350 encrypted_frame.size);
350 PP_EncryptedBlockInfo block_info; 351 PP_EncryptedVideoFrameInfo frame_info;
351 if (!DeserializeBlockInfo(serialized_block_info, &block_info)) 352 if (!DeserializeBlockInfo(serialized_frame_info, &frame_info))
352 return; 353 return;
353 CallWhileUnlocked(ppp_decryptor_impl_->DecryptAndDecode, 354 CallWhileUnlocked(
354 instance, 355 ppp_decryptor_impl_->DecryptAndDecodeFrame,
355 plugin_resource, 356 instance,
356 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); 357 plugin_resource,
358 const_cast<const PP_EncryptedVideoFrameInfo*>(&frame_info));
357 } 359 }
358 } 360 }
359 361
360 } // namespace proxy 362 } // namespace proxy
361 } // namespace ppapi 363 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698