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

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

Issue 11028087: Add decoder de-initialize and reset to the Pepper CDM API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Finish first pass. 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 135 }
136 136
137 dispatcher->Send( 137 dispatcher->Send(
138 new PpapiMsg_PPPContentDecryptor_CancelKeyRequest( 138 new PpapiMsg_PPPContentDecryptor_CancelKeyRequest(
139 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE, 139 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE,
140 instance, 140 instance,
141 SerializedVarSendInput(dispatcher, session_id))); 141 SerializedVarSendInput(dispatcher, session_id)));
142 } 142 }
143 143
144 void Decrypt(PP_Instance instance, 144 void Decrypt(PP_Instance instance,
145 PP_Resource encrypted_block, 145 PP_Resource encrypted_block,
146 const PP_EncryptedBlockInfo* encrypted_block_info) { 146 const PP_EncryptedBlockInfo* encrypted_block_info) {
147 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); 147 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
148 if (!dispatcher) { 148 if (!dispatcher) {
149 NOTREACHED(); 149 NOTREACHED();
150 return; 150 return;
151 } 151 }
152 152
153 if (!AddRefResourceForPlugin(dispatcher, encrypted_block)) { 153 if (!AddRefResourceForPlugin(dispatcher, encrypted_block)) {
154 NOTREACHED(); 154 NOTREACHED();
155 return; 155 return;
156 } 156 }
(...skipping 21 matching lines...) Expand all
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 ResetVideoDecoder(PP_Instance instance, uint32_t request_id) {
189 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
190 if (!dispatcher) {
191 NOTREACHED();
192 return;
193 }
194
195 dispatcher->Send(
196 new PpapiMsg_PPPContentDecryptor_ResetVideoDecoder(
197 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE,
198 instance,
199 request_id));
200 }
201
202 void StopVideoDecoder(PP_Instance instance, uint32_t request_id) {
203 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
204 if (!dispatcher) {
205 NOTREACHED();
206 return;
207 }
208
209 dispatcher->Send(
210 new PpapiMsg_PPPContentDecryptor_StopVideoDecoder(
211 API_ID_PPP_CONTENT_DECRYPTOR_PRIVATE,
212 instance,
213 request_id));
214 }
215
188 void DecryptAndDecodeFrame( 216 void DecryptAndDecodeFrame(
189 PP_Instance instance, 217 PP_Instance instance,
190 PP_Resource encrypted_frame, 218 PP_Resource encrypted_frame,
191 const PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) { 219 const PP_EncryptedVideoFrameInfo* encrypted_video_frame_info) {
192 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); 220 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
193 if (!dispatcher) { 221 if (!dispatcher) {
194 NOTREACHED(); 222 NOTREACHED();
195 return; 223 return;
196 } 224 }
197 225
(...skipping 30 matching lines...) Expand all
228 instance, 256 instance,
229 buffer, 257 buffer,
230 serialized_frame_info)); 258 serialized_frame_info));
231 } 259 }
232 260
233 static const PPP_ContentDecryptor_Private content_decryptor_interface = { 261 static const PPP_ContentDecryptor_Private content_decryptor_interface = {
234 &GenerateKeyRequest, 262 &GenerateKeyRequest,
235 &AddKey, 263 &AddKey,
236 &CancelKeyRequest, 264 &CancelKeyRequest,
237 &Decrypt, 265 &Decrypt,
266 &ResetVideoDecoder,
267 &StopVideoDecoder,
238 &DecryptAndDecodeFrame 268 &DecryptAndDecodeFrame
239 }; 269 };
240 270
241 } // namespace 271 } // namespace
242 272
243 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy( 273 PPP_ContentDecryptor_Private_Proxy::PPP_ContentDecryptor_Private_Proxy(
244 Dispatcher* dispatcher) 274 Dispatcher* dispatcher)
245 : InterfaceProxy(dispatcher), 275 : InterfaceProxy(dispatcher),
246 ppp_decryptor_impl_(NULL) { 276 ppp_decryptor_impl_(NULL) {
247 if (dispatcher->IsPlugin()) { 277 if (dispatcher->IsPlugin()) {
(...skipping 17 matching lines...) Expand all
265 bool handled = true; 295 bool handled = true;
266 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg) 296 IPC_BEGIN_MESSAGE_MAP(PPP_ContentDecryptor_Private_Proxy, msg)
267 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest, 297 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_GenerateKeyRequest,
268 OnMsgGenerateKeyRequest) 298 OnMsgGenerateKeyRequest)
269 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey, 299 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_AddKey,
270 OnMsgAddKey) 300 OnMsgAddKey)
271 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest, 301 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_CancelKeyRequest,
272 OnMsgCancelKeyRequest) 302 OnMsgCancelKeyRequest)
273 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt, 303 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_Decrypt,
274 OnMsgDecrypt) 304 OnMsgDecrypt)
305 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_ResetVideoDecoder,
306 OnMsgResetVideoDecoder)
307 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_StopVideoDecoder,
308 OnMsgStopVideoDecoder)
275 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame, 309 IPC_MESSAGE_HANDLER(PpapiMsg_PPPContentDecryptor_DecryptAndDecodeFrame,
276 OnMsgDecryptAndDecodeFrame) 310 OnMsgDecryptAndDecodeFrame)
277 IPC_MESSAGE_UNHANDLED(handled = false) 311 IPC_MESSAGE_UNHANDLED(handled = false)
278 IPC_END_MESSAGE_MAP() 312 IPC_END_MESSAGE_MAP()
279 DCHECK(handled); 313 DCHECK(handled);
280 return handled; 314 return handled;
281 } 315 }
282 316
283 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest( 317 void PPP_ContentDecryptor_Private_Proxy::OnMsgGenerateKeyRequest(
284 PP_Instance instance, 318 PP_Instance instance,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 PP_EncryptedBlockInfo block_info; 362 PP_EncryptedBlockInfo block_info;
329 if (!DeserializeBlockInfo(serialized_block_info, &block_info)) 363 if (!DeserializeBlockInfo(serialized_block_info, &block_info))
330 return; 364 return;
331 CallWhileUnlocked(ppp_decryptor_impl_->Decrypt, 365 CallWhileUnlocked(ppp_decryptor_impl_->Decrypt,
332 instance, 366 instance,
333 plugin_resource, 367 plugin_resource,
334 const_cast<const PP_EncryptedBlockInfo*>(&block_info)); 368 const_cast<const PP_EncryptedBlockInfo*>(&block_info));
335 } 369 }
336 } 370 }
337 371
372 void PPP_ContentDecryptor_Private_Proxy::OnMsgResetVideoDecoder(
373 PP_Instance instance,
374 uint32_t request_id) {
375 if (ppp_decryptor_impl_) {
376 CallWhileUnlocked(
377 ppp_decryptor_impl_->ResetVideoDecoder,
378 instance,
379 request_id);
380 }
381 }
382
383 void PPP_ContentDecryptor_Private_Proxy::OnMsgStopVideoDecoder(
384 PP_Instance instance,
385 uint32_t request_id) {
386 if (ppp_decryptor_impl_) {
387 CallWhileUnlocked(
388 ppp_decryptor_impl_->StopVideoDecoder,
389 instance,
390 request_id);
391 }
392 }
393
338 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecodeFrame( 394 void PPP_ContentDecryptor_Private_Proxy::OnMsgDecryptAndDecodeFrame(
339 PP_Instance instance, 395 PP_Instance instance,
340 const PPPDecryptor_Buffer& encrypted_frame, 396 const PPPDecryptor_Buffer& encrypted_frame,
341 const std::string& serialized_frame_info) { 397 const std::string& serialized_frame_info) {
342 if (ppp_decryptor_impl_) { 398 if (ppp_decryptor_impl_) {
343 PP_Resource plugin_resource = 399 PP_Resource plugin_resource =
344 PPB_Buffer_Proxy::AddProxyResource(encrypted_frame.resource, 400 PPB_Buffer_Proxy::AddProxyResource(encrypted_frame.resource,
345 encrypted_frame.handle, 401 encrypted_frame.handle,
346 encrypted_frame.size); 402 encrypted_frame.size);
347 PP_EncryptedVideoFrameInfo frame_info; 403 PP_EncryptedVideoFrameInfo frame_info;
348 if (!DeserializeBlockInfo(serialized_frame_info, &frame_info)) 404 if (!DeserializeBlockInfo(serialized_frame_info, &frame_info))
349 return; 405 return;
350 CallWhileUnlocked( 406 CallWhileUnlocked(
351 ppp_decryptor_impl_->DecryptAndDecodeFrame, 407 ppp_decryptor_impl_->DecryptAndDecodeFrame,
352 instance, 408 instance,
353 plugin_resource, 409 plugin_resource,
354 const_cast<const PP_EncryptedVideoFrameInfo*>(&frame_info)); 410 const_cast<const PP_EncryptedVideoFrameInfo*>(&frame_info));
355 } 411 }
356 } 412 }
357 413
358 } // namespace proxy 414 } // namespace proxy
359 } // namespace ppapi 415 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698