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

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 11091005: Update PluginInstance for decrypt-and-decode video. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: a lot of change, need to be reviewed again 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
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 "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/callback_helpers.h"
8 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/memory/linked_ptr.h" 11 #include "base/memory/linked_ptr.h"
11 #include "base/message_loop.h" 12 #include "base/message_loop.h"
12 #include "base/stl_util.h" 13 #include "base/stl_util.h"
13 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
14 #include "base/time.h" 15 #include "base/time.h"
15 #include "base/utf_offset_string_conversions.h" 16 #include "base/utf_offset_string_conversions.h"
16 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 // TODO(xhwang): Move media specific code out of this class.
17 #include "media/base/decoder_buffer.h" 19 #include "media/base/decoder_buffer.h"
18 #include "media/base/decryptor_client.h" 20 #include "media/base/decryptor_client.h"
19 #include "media/base/video_decoder_config.h" 21 #include "media/base/video_decoder_config.h"
20 #include "media/base/video_frame.h" 22 #include "media/base/video_frame.h"
23 #include "media/base/video_util.h"
21 #include "ppapi/c/dev/ppb_find_dev.h" 24 #include "ppapi/c/dev/ppb_find_dev.h"
22 #include "ppapi/c/dev/ppb_zoom_dev.h" 25 #include "ppapi/c/dev/ppb_zoom_dev.h"
23 #include "ppapi/c/dev/ppp_find_dev.h" 26 #include "ppapi/c/dev/ppp_find_dev.h"
24 #include "ppapi/c/dev/ppp_selection_dev.h" 27 #include "ppapi/c/dev/ppp_selection_dev.h"
25 #include "ppapi/c/dev/ppp_text_input_dev.h" 28 #include "ppapi/c/dev/ppp_text_input_dev.h"
26 #include "ppapi/c/dev/ppp_zoom_dev.h" 29 #include "ppapi/c/dev/ppp_zoom_dev.h"
27 #include "ppapi/c/pp_rect.h" 30 #include "ppapi/c/pp_rect.h"
28 #include "ppapi/c/ppb_audio_config.h" 31 #include "ppapi/c/ppb_audio_config.h"
29 #include "ppapi/c/ppb_core.h" 32 #include "ppapi/c/ppb_core.h"
30 #include "ppapi/c/ppb_gamepad.h" 33 #include "ppapi/c/ppb_gamepad.h"
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 template <uint32_t array_size> 340 template <uint32_t array_size>
338 bool CopyStringToArray(const std::string& str, uint8 (&array)[array_size]) { 341 bool CopyStringToArray(const std::string& str, uint8 (&array)[array_size]) {
339 if (array_size < str.size()) 342 if (array_size < str.size())
340 return false; 343 return false;
341 344
342 memcpy(array, str.data(), str.size()); 345 memcpy(array, str.data(), str.size());
343 return true; 346 return true;
344 } 347 }
345 348
346 // Fills the |block_info| with information from |decrypt_config|, |timestamp| 349 // Fills the |block_info| with information from |decrypt_config|, |timestamp|
347 // and |request_id|. 350 // and |request_id|. |decrypt_config| can be NULL if the block is not encrypted.
351 // This is useful for end-of-stream blocks.
348 // Returns true if |block_info| is successfully filled. Returns false 352 // Returns true if |block_info| is successfully filled. Returns false
349 // otherwise. 353 // otherwise.
350 bool MakeEncryptedBlockInfo( 354 bool MakeEncryptedBlockInfo(
351 const media::DecryptConfig& decrypt_config, 355 const media::DecryptConfig* decrypt_config,
352 int64_t timestamp, 356 int64_t timestamp,
353 uint32_t request_id, 357 uint32_t request_id,
354 PP_EncryptedBlockInfo* block_info) { 358 PP_EncryptedBlockInfo* block_info) {
355 DCHECK(block_info); 359 DCHECK(block_info);
356 360
357 // TODO(xhwang): Fix initialization of PP_EncryptedBlockInfo here and 361 // TODO(xhwang): Fix initialization of PP_EncryptedBlockInfo here and
358 // anywhere else. 362 // anywhere else.
359 memset(block_info, 0, sizeof(*block_info)); 363 memset(block_info, 0, sizeof(*block_info));
360 364
361 block_info->tracking_info.request_id = request_id; 365 block_info->tracking_info.request_id = request_id;
362 block_info->tracking_info.timestamp = timestamp; 366 block_info->tracking_info.timestamp = timestamp;
363 block_info->data_offset = decrypt_config.data_offset();
364 367
365 if (!CopyStringToArray(decrypt_config.key_id(), block_info->key_id) || 368 if (!decrypt_config)
366 !CopyStringToArray(decrypt_config.iv(), block_info->iv)) 369 return true;
370
371 block_info->data_offset = decrypt_config->data_offset();
372
373 if (!CopyStringToArray(decrypt_config->key_id(), block_info->key_id) ||
374 !CopyStringToArray(decrypt_config->iv(), block_info->iv))
367 return false; 375 return false;
368 376
369 block_info->key_id_size = decrypt_config.key_id().size(); 377 block_info->key_id_size = decrypt_config->key_id().size();
370 block_info->iv_size = decrypt_config.iv().size(); 378 block_info->iv_size = decrypt_config->iv().size();
371 379
372 if (decrypt_config.subsamples().size() > arraysize(block_info->subsamples)) 380 if (decrypt_config->subsamples().size() > arraysize(block_info->subsamples))
373 return false; 381 return false;
374 382
375 block_info->num_subsamples = decrypt_config.subsamples().size(); 383 block_info->num_subsamples = decrypt_config->subsamples().size();
376 for (uint32_t i = 0; i < block_info->num_subsamples; ++i) { 384 for (uint32_t i = 0; i < block_info->num_subsamples; ++i) {
377 block_info->subsamples[i].clear_bytes = 385 block_info->subsamples[i].clear_bytes =
378 decrypt_config.subsamples()[i].clear_bytes; 386 decrypt_config->subsamples()[i].clear_bytes;
379 block_info->subsamples[i].cipher_bytes = 387 block_info->subsamples[i].cipher_bytes =
380 decrypt_config.subsamples()[i].cypher_bytes; 388 decrypt_config->subsamples()[i].cypher_bytes;
381 } 389 }
382 390
383 return true; 391 return true;
384 } 392 }
385 393
386 PP_VideoCodec MediaVideoCodecToPpVideoCodec(media::VideoCodec codec) { 394 PP_VideoCodec MediaVideoCodecToPpVideoCodec(media::VideoCodec codec) {
387 if (codec == media::kCodecVP8) 395 if (codec == media::kCodecVP8)
388 return PP_VIDEOCODEC_VP8; 396 return PP_VIDEOCODEC_VP8;
389 397
390 return PP_VIDEOCODEC_UNKNOWN; 398 return PP_VIDEOCODEC_UNKNOWN;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 filtered_input_event_mask_(0), 484 filtered_input_event_mask_(0),
477 text_input_type_(kPluginDefaultTextInputType), 485 text_input_type_(kPluginDefaultTextInputType),
478 text_input_caret_(0, 0, 0, 0), 486 text_input_caret_(0, 0, 0, 0),
479 text_input_caret_bounds_(0, 0, 0, 0), 487 text_input_caret_bounds_(0, 0, 0, 0),
480 text_input_caret_set_(false), 488 text_input_caret_set_(false),
481 selection_caret_(0), 489 selection_caret_(0),
482 selection_anchor_(0), 490 selection_anchor_(0),
483 pending_user_gesture_(0.0), 491 pending_user_gesture_(0.0),
484 flash_impl_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 492 flash_impl_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
485 decryptor_client_(NULL), 493 decryptor_client_(NULL),
486 next_decryption_request_id_(1) { 494 next_decryption_request_id_(1),
495 pending_video_decoder_init_request_id_(0),
496 pending_video_decode_request_id_(0) {
487 pp_instance_ = HostGlobals::Get()->AddInstance(this); 497 pp_instance_ = HostGlobals::Get()->AddInstance(this);
488 498
489 memset(&current_print_settings_, 0, sizeof(current_print_settings_)); 499 memset(&current_print_settings_, 0, sizeof(current_print_settings_));
490 DCHECK(delegate); 500 DCHECK(delegate);
491 module_->InstanceCreated(this); 501 module_->InstanceCreated(this);
492 delegate_->InstanceCreated(this); 502 delegate_->InstanceCreated(this);
493 message_channel_.reset(new MessageChannel(this)); 503 message_channel_.reset(new MessageChannel(this));
494 504
495 view_data_.is_page_visible = delegate->IsPageVisible(); 505 view_data_.is_page_visible = delegate->IsPageVisible();
496 506
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 return false; 1558 return false;
1549 1559
1550 ScopedPPResource encrypted_resource( 1560 ScopedPPResource encrypted_resource(
1551 ScopedPPResource::PassRef(), 1561 ScopedPPResource::PassRef(),
1552 MakeBufferResource(pp_instance(), 1562 MakeBufferResource(pp_instance(),
1553 encrypted_buffer->GetData(), 1563 encrypted_buffer->GetData(),
1554 encrypted_buffer->GetDataSize())); 1564 encrypted_buffer->GetDataSize()));
1555 if (!encrypted_resource.get()) 1565 if (!encrypted_resource.get())
1556 return false; 1566 return false;
1557 1567
1558 uint32_t request_id = next_decryption_request_id_++; 1568 uint32_t request_id = next_decryption_request_id_++;
ddorwin 2012/10/13 01:40:28 const like below.
xhwang 2012/10/15 19:53:01 Done.
1559 1569
1560 PP_EncryptedBlockInfo block_info; 1570 PP_EncryptedBlockInfo block_info;
1561 DCHECK(encrypted_buffer->GetDecryptConfig()); 1571 DCHECK(encrypted_buffer->GetDecryptConfig());
1562 if (!MakeEncryptedBlockInfo(*encrypted_buffer->GetDecryptConfig(), 1572 if (!MakeEncryptedBlockInfo(encrypted_buffer->GetDecryptConfig(),
1563 encrypted_buffer->GetTimestamp().InMicroseconds(), 1573 encrypted_buffer->GetTimestamp().InMicroseconds(),
1564 request_id, 1574 request_id,
1565 &block_info)) { 1575 &block_info)) {
1566 return false; 1576 return false;
1567 } 1577 }
1568 1578
1569 DCHECK(!ContainsKey(pending_decryption_cbs_, request_id)); 1579 DCHECK(!ContainsKey(pending_decryption_cbs_, request_id));
1570 pending_decryption_cbs_.insert(std::make_pair(request_id, decrypt_cb)); 1580 pending_decryption_cbs_.insert(std::make_pair(request_id, decrypt_cb));
1571 1581
1572 plugin_decryption_interface_->Decrypt(pp_instance(), 1582 plugin_decryption_interface_->Decrypt(pp_instance(),
1573 encrypted_resource, 1583 encrypted_resource,
1574 &block_info); 1584 &block_info);
1575 return true; 1585 return true;
1576 } 1586 }
1577 1587
1578 bool PluginInstance::InitializeVideoDecoder( 1588 bool PluginInstance::InitializeVideoDecoder(
1579 const media::VideoDecoderConfig& decoder_config, 1589 const media::VideoDecoderConfig& decoder_config,
1580 const media::Decryptor::DecryptCB& decrypt_cb) { 1590 const media::Decryptor::DecoderInitCB& init_cb) {
1581 PP_VideoDecoderConfig pp_decoder_config; 1591 PP_VideoDecoderConfig pp_decoder_config;
1582 pp_decoder_config.codec = 1592 pp_decoder_config.codec =
1583 MediaVideoCodecToPpVideoCodec(decoder_config.codec()); 1593 MediaVideoCodecToPpVideoCodec(decoder_config.codec());
1584 pp_decoder_config.profile = 1594 pp_decoder_config.profile =
1585 MediaVideoCodecProfileToPpVideoCodecProfile(decoder_config.profile()); 1595 MediaVideoCodecProfileToPpVideoCodecProfile(decoder_config.profile());
1586 pp_decoder_config.format = 1596 pp_decoder_config.format =
1587 MediaVideoFormatToPpDecryptedFrameFormat(decoder_config.format()); 1597 MediaVideoFormatToPpDecryptedFrameFormat(decoder_config.format());
1588 pp_decoder_config.width = decoder_config.coded_size().width(); 1598 pp_decoder_config.width = decoder_config.coded_size().width();
1589 pp_decoder_config.height = decoder_config.coded_size().height(); 1599 pp_decoder_config.height = decoder_config.coded_size().height();
1590 pp_decoder_config.request_id = next_decryption_request_id_++; 1600 pp_decoder_config.request_id = next_decryption_request_id_++;
1591 1601
1592 // TODO(xhwang): Use individual variables for decoder init request tracking.
1593 DCHECK(!ContainsKey(pending_decryption_cbs_, pp_decoder_config.request_id));
1594 pending_decryption_cbs_.insert(std::make_pair(pp_decoder_config.request_id,
1595 decrypt_cb));
1596
1597 ScopedPPResource extra_data_resource( 1602 ScopedPPResource extra_data_resource(
1598 ScopedPPResource::PassRef(), 1603 ScopedPPResource::PassRef(),
1599 MakeBufferResource(pp_instance(), 1604 MakeBufferResource(pp_instance(),
1600 decoder_config.extra_data(), 1605 decoder_config.extra_data(),
1601 decoder_config.extra_data_size())); 1606 decoder_config.extra_data_size()));
1602 1607
1608 DCHECK_EQ(pending_video_decoder_init_request_id_, 0u);
1609 DCHECK(pending_video_decoder_init_cb_.is_null());
1610 pending_video_decoder_init_request_id_ = pp_decoder_config.request_id;
1611 pending_video_decoder_init_cb_ = init_cb;
1612
1603 plugin_decryption_interface_->InitializeVideoDecoder(pp_instance(), 1613 plugin_decryption_interface_->InitializeVideoDecoder(pp_instance(),
1604 &pp_decoder_config, 1614 &pp_decoder_config,
1605 extra_data_resource); 1615 extra_data_resource);
1606 return true; 1616 return true;
1607 } 1617 }
1608 1618
1609 bool PluginInstance::DeinitializeDecoder() { 1619 bool PluginInstance::DeinitializeDecoder() {
1610 if (!LoadContentDecryptorInterface()) 1620 if (!LoadContentDecryptorInterface())
1611 return false; 1621 return false;
1612 1622
(...skipping 13 matching lines...) Expand all
1626 // TODO(tomfinegan): Add decoder reset request tracking, and get 1636 // TODO(tomfinegan): Add decoder reset request tracking, and get
1627 // stream type from media stack. 1637 // stream type from media stack.
1628 plugin_decryption_interface_->ResetDecoder(pp_instance(), 1638 plugin_decryption_interface_->ResetDecoder(pp_instance(),
1629 PP_DECRYPTORSTREAMTYPE_VIDEO, 1639 PP_DECRYPTORSTREAMTYPE_VIDEO,
1630 0); 1640 0);
1631 return true; 1641 return true;
1632 } 1642 }
1633 1643
1634 bool PluginInstance::DecryptAndDecode( 1644 bool PluginInstance::DecryptAndDecode(
1635 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, 1645 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer,
1636 const media::Decryptor::DecryptCB& decrypt_cb) { 1646 const media::Decryptor::VideoDecodeCB& video_decode_cb) {
1637 if (!LoadContentDecryptorInterface()) 1647 if (!LoadContentDecryptorInterface())
1638 return false; 1648 return false;
1639 1649
1640 ScopedPPResource encrypted_resource(MakeBufferResource( 1650 ScopedPPResource encrypted_resource;
1641 pp_instance(), 1651 PP_EncryptedBlockInfo block_info;
1642 encrypted_buffer->GetData(),
1643 encrypted_buffer->GetDataSize()));
1644 if (!encrypted_resource.get())
1645 return false;
1646
1647 const uint32_t request_id = next_decryption_request_id_++; 1652 const uint32_t request_id = next_decryption_request_id_++;
1648 1653
1649 PP_EncryptedBlockInfo block_info; 1654 if (!encrypted_buffer->IsEndOfStream()) {
1650 DCHECK(encrypted_buffer->GetDecryptConfig()); 1655 encrypted_resource = MakeBufferResource(pp_instance(),
1651 if (!MakeEncryptedBlockInfo(*encrypted_buffer->GetDecryptConfig(), 1656 encrypted_buffer->GetData(),
1652 encrypted_buffer->GetTimestamp().InMicroseconds(), 1657 encrypted_buffer->GetDataSize());
1653 request_id, 1658 if (!encrypted_resource.get())
1654 &block_info)) { 1659 return false;
1660 }
1661
1662 if (!MakeEncryptedBlockInfo(
1663 encrypted_buffer->GetDecryptConfig(),
1664 encrypted_buffer->GetTimestamp().InMicroseconds(),
1665 request_id,
1666 &block_info)) {
1655 return false; 1667 return false;
1656 } 1668 }
1657 1669
1658 DCHECK(!ContainsKey(pending_decryption_cbs_, request_id)); 1670 // Only one pending video decode request at any time. This is enforced by the
1659 pending_decryption_cbs_.insert(std::make_pair(request_id, decrypt_cb)); 1671 // media pipeline.
1672 DCHECK_EQ(pending_video_decode_request_id_, 0u);
1673 DCHECK(pending_video_decode_cb_.is_null());
1674 pending_video_decode_request_id_ = request_id;
1675 pending_video_decode_cb_ = video_decode_cb;
1660 1676
1661 // TODO(tomfinegan): Need to get stream type from media stack. 1677 // TODO(tomfinegan): Need to get stream type from media stack.
1662 plugin_decryption_interface_->DecryptAndDecode(pp_instance(), 1678 plugin_decryption_interface_->DecryptAndDecode(pp_instance(),
1663 PP_DECRYPTORSTREAMTYPE_VIDEO, 1679 PP_DECRYPTORSTREAMTYPE_VIDEO,
1664 encrypted_resource, 1680 encrypted_resource,
1665 &block_info); 1681 &block_info);
1666 return true; 1682 return true;
1667 } 1683 }
1668 1684
1669 bool PluginInstance::FlashIsFullscreenOrPending() { 1685 bool PluginInstance::FlashIsFullscreenOrPending() {
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
2355 decryptor_client_->KeyError( 2371 decryptor_client_->KeyError(
2356 key_system_string->value(), 2372 key_system_string->value(),
2357 session_id_string->value(), 2373 session_id_string->value(),
2358 static_cast<media::Decryptor::KeyError>(media_error), 2374 static_cast<media::Decryptor::KeyError>(media_error),
2359 system_code); 2375 system_code);
2360 } 2376 }
2361 2377
2362 void PluginInstance::DecoderInitialized(PP_Instance instance, 2378 void PluginInstance::DecoderInitialized(PP_Instance instance,
2363 PP_Bool success, 2379 PP_Bool success,
2364 uint32_t request_id) { 2380 uint32_t request_id) {
2365 // TODO(xhwang): Use individual variables for decoder init request tracking. 2381 // If the request ID is not valid or does not match what's saved, do nothing.
2366 DecryptionCBMap::iterator found = pending_decryption_cbs_.find(request_id); 2382 if (request_id == 0 || request_id != pending_video_decoder_init_request_id_)
2367 if (found == pending_decryption_cbs_.end())
2368 return; 2383 return;
2369 media::Decryptor::DecryptCB decrypt_cb = found->second;
2370 pending_decryption_cbs_.erase(found);
2371 2384
2372 media::Decryptor::Status status = 2385 DCHECK(!pending_video_decoder_init_cb_.is_null());
2373 success == PP_TRUE ? media::Decryptor::kSuccess : 2386 pending_video_decoder_init_request_id_ = 0;
2374 media::Decryptor::kError; 2387 base::ResetAndReturn(&pending_video_decoder_init_cb_).Run(PP_ToBool(success));
2375 decrypt_cb.Run(status, NULL);
2376 } 2388 }
2377 2389
2378 void PluginInstance::DecoderDeinitializeDone( 2390 void PluginInstance::DecoderDeinitializeDone(
2379 PP_Instance instance, 2391 PP_Instance instance,
2380 PP_DecryptorStreamType decoder_type, 2392 PP_DecryptorStreamType decoder_type,
2381 uint32_t request_id) { 2393 uint32_t request_id) {
2382 // TODO(tomfinegan): Add decoder stop completion handling. 2394 // TODO(tomfinegan): Add decoder stop completion handling.
2383 } 2395 }
2384 2396
2385 void PluginInstance::DecoderResetDone(PP_Instance instance, 2397 void PluginInstance::DecoderResetDone(PP_Instance instance,
(...skipping 10 matching lines...) Expand all
2396 block_info->tracking_info.request_id); 2408 block_info->tracking_info.request_id);
2397 if (found == pending_decryption_cbs_.end()) 2409 if (found == pending_decryption_cbs_.end())
2398 return; 2410 return;
2399 media::Decryptor::DecryptCB decrypt_cb = found->second; 2411 media::Decryptor::DecryptCB decrypt_cb = found->second;
2400 pending_decryption_cbs_.erase(found); 2412 pending_decryption_cbs_.erase(found);
2401 2413
2402 if (block_info->result == PP_DECRYPTRESULT_DECRYPT_NOKEY) { 2414 if (block_info->result == PP_DECRYPTRESULT_DECRYPT_NOKEY) {
2403 decrypt_cb.Run(media::Decryptor::kNoKey, NULL); 2415 decrypt_cb.Run(media::Decryptor::kNoKey, NULL);
2404 return; 2416 return;
2405 } 2417 }
2418
2406 if (block_info->result != PP_DECRYPTRESULT_SUCCESS) { 2419 if (block_info->result != PP_DECRYPTRESULT_SUCCESS) {
2407 decrypt_cb.Run(media::Decryptor::kError, NULL); 2420 decrypt_cb.Run(media::Decryptor::kError, NULL);
2408 return; 2421 return;
2409 } 2422 }
2410 2423
2411 EnterResourceNoLock<PPB_Buffer_API> enter(decrypted_block, true); 2424 EnterResourceNoLock<PPB_Buffer_API> enter(decrypted_block, true);
2412 if (!enter.succeeded()) { 2425 if (!enter.succeeded()) {
2413 decrypt_cb.Run(media::Decryptor::kError, NULL); 2426 decrypt_cb.Run(media::Decryptor::kError, NULL);
2414 return; 2427 return;
2415 } 2428 }
2416 BufferAutoMapper mapper(enter.object()); 2429 BufferAutoMapper mapper(enter.object());
2417 if (!mapper.data() || !mapper.size()) { 2430 if (!mapper.data() || !mapper.size()) {
2418 decrypt_cb.Run(media::Decryptor::kError, NULL); 2431 decrypt_cb.Run(media::Decryptor::kError, NULL);
2419 return; 2432 return;
2420 } 2433 }
2421 2434
2422 // TODO(tomfinegan): Find a way to take ownership of the shared memory 2435 // TODO(tomfinegan): Find a way to take ownership of the shared memory
2423 // managed by the PPB_Buffer_Dev, and avoid the extra copy. 2436 // managed by the PPB_Buffer_Dev, and avoid the extra copy.
2424 scoped_refptr<media::DecoderBuffer> decrypted_buffer( 2437 scoped_refptr<media::DecoderBuffer> decrypted_buffer(
2425 media::DecoderBuffer::CopyFrom( 2438 media::DecoderBuffer::CopyFrom(
2426 reinterpret_cast<const uint8*>(mapper.data()), mapper.size())); 2439 reinterpret_cast<const uint8*>(mapper.data()), mapper.size()));
2427 decrypted_buffer->SetTimestamp(base::TimeDelta::FromMicroseconds( 2440 decrypted_buffer->SetTimestamp(base::TimeDelta::FromMicroseconds(
2428 block_info->tracking_info.timestamp)); 2441 block_info->tracking_info.timestamp));
2429 decrypt_cb.Run(media::Decryptor::kSuccess, decrypted_buffer); 2442 decrypt_cb.Run(media::Decryptor::kSuccess, decrypted_buffer);
2430 } 2443 }
2431 2444
2432 void PluginInstance::DeliverFrame(PP_Instance instance, 2445 void PluginInstance::DeliverFrame(PP_Instance instance,
2433 PP_Resource decrypted_frame, 2446 PP_Resource decrypted_frame,
2434 const PP_DecryptedFrameInfo* frame_info) { 2447 const PP_DecryptedFrameInfo* frame_info) {
2435 // TODO(tomfinegan): To be implemented after completion of v0.1 of the 2448 DCHECK(frame_info);
2436 // EME/CDM work. 2449 uint32_t request_id = frame_info->tracking_info.request_id;
ddorwin 2012/10/13 01:40:28 nit: Since this is just an alias, I think it shoul
xhwang 2012/10/15 19:53:01 Done.
2450
2451 // If the request ID is not valid or does not match what's saved, do nothing.
2452 if (request_id == 0 || request_id != pending_video_decode_request_id_)
ddorwin 2012/10/13 01:40:28 DCHECK?
xhwang 2012/10/15 19:53:01 My whole point is that I treat CDM as a third part
ddorwin 2012/10/15 23:31:38 Well, we want to catch bugs in these third-party m
2453 return;
2454
2455 DCHECK(!pending_video_decode_cb_.is_null());
2456 pending_video_decode_request_id_ = 0;
2457 media::Decryptor::VideoDecodeCB video_decode_cb =
2458 base::ResetAndReturn(&pending_video_decode_cb_);
2459
2460 if (frame_info->result == PP_DECRYPTRESULT_DECRYPT_NOKEY) {
2461 video_decode_cb.Run(media::Decryptor::kNoKey, NULL);
2462 return;
2463 }
2464
2465 if (frame_info->result != PP_DECRYPTRESULT_SUCCESS) {
2466 video_decode_cb.Run(media::Decryptor::kError, NULL);
2467 return;
2468 }
2469
2470 if (frame_info->format == PP_DECRYPTEDFRAMEFORMAT_EMPTY) {
2471 video_decode_cb.Run(media::Decryptor::kSuccess,
2472 media::VideoFrame::CreateEmptyFrame());
2473 return;
2474 }
2475
2476 EnterResourceNoLock<PPB_Buffer_API> enter(decrypted_frame, true);
2477 if (!enter.succeeded()) {
2478 video_decode_cb.Run(media::Decryptor::kError, NULL);
2479 return;
2480 }
2481 BufferAutoMapper mapper(enter.object());
2482 if (!mapper.data() || !mapper.size()) {
2483 video_decode_cb.Run(media::Decryptor::kError, NULL);
2484 return;
2485 }
2486
2487 const uint8* frame_data = reinterpret_cast<uint8*>(mapper.data());
2488
2489 // TODO(tomfinegan): Find a way to take ownership of the shared memory
ddorwin 2012/10/13 01:40:28 Should this be before 2494 instead?
xhwang 2012/10/15 19:53:01 Done.
2490 // managed by the PPB_Buffer_Dev, and avoid the extra copy.
2491 DCHECK(frame_info->format == PP_DECRYPTEDFRAMEFORMAT_YV12);
ddorwin 2012/10/13 01:40:28 This should be closer to the use of the YV12 enum.
xhwang 2012/10/15 19:53:01 Done.
2492 gfx::Size frame_size(frame_info->width, frame_info->height);
2493
2494 scoped_refptr<media::VideoFrame> decoded_frame(
2495 media::VideoFrame::CreateFrame(
2496 media::VideoFrame::YV12, frame_size, frame_size,
2497 base::TimeDelta::FromMicroseconds(
2498 frame_info->tracking_info.timestamp)));
2499
2500 media::CopyYPlane(
2501 frame_data + frame_info->plane_offsets[PP_DECRYPTEDFRAMEPLANES_Y],
2502 frame_info->strides[PP_DECRYPTEDFRAMEPLANES_Y],
2503 frame_info->height,
2504 decoded_frame.get());
2505
2506 media::CopyUPlane(
2507 frame_data + frame_info->plane_offsets[PP_DECRYPTEDFRAMEPLANES_U],
2508 frame_info->strides[PP_DECRYPTEDFRAMEPLANES_U],
2509 frame_info->height,
2510 decoded_frame.get());
2511
2512 media::CopyVPlane(
2513 frame_data + frame_info->plane_offsets[PP_DECRYPTEDFRAMEPLANES_V],
2514 frame_info->strides[PP_DECRYPTEDFRAMEPLANES_V],
2515 frame_info->height,
2516 decoded_frame.get());
2517
2518 video_decode_cb.Run(media::Decryptor::kSuccess, decoded_frame);
2437 } 2519 }
2438 2520
2439 void PluginInstance::DeliverSamples(PP_Instance instance, 2521 void PluginInstance::DeliverSamples(PP_Instance instance,
2440 PP_Resource decrypted_samples, 2522 PP_Resource decrypted_samples,
2441 const PP_DecryptedBlockInfo* block_info) { 2523 const PP_DecryptedBlockInfo* block_info) {
2442 // TODO(tomfinegan): To be implemented after completion of v0.1 of the 2524 // TODO(tomfinegan): To be implemented after completion of v0.1 of the
2443 // EME/CDM work. 2525 // EME/CDM work.
2444 } 2526 }
2445 2527
2446 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance, 2528 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance,
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
2823 screen_size_for_fullscreen_ = gfx::Size(); 2905 screen_size_for_fullscreen_ = gfx::Size();
2824 WebElement element = container_->element(); 2906 WebElement element = container_->element();
2825 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2907 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2826 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2908 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2827 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2909 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2828 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2910 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2829 } 2911 }
2830 2912
2831 } // namespace ppapi 2913 } // namespace ppapi
2832 } // namespace webkit 2914 } // namespace webkit
OLDNEW
« webkit/plugins/ppapi/ppapi_plugin_instance.h ('K') | « webkit/plugins/ppapi/ppapi_plugin_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698