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 <cstring> | 5 #include <cstring> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 // PPB_ContentDecryptor_Private interface. | 371 // PPB_ContentDecryptor_Private interface. |
| 372 virtual void GenerateKeyRequest(const std::string& key_system, | 372 virtual void GenerateKeyRequest(const std::string& key_system, |
| 373 pp::VarArrayBuffer init_data) OVERRIDE; | 373 pp::VarArrayBuffer init_data) OVERRIDE; |
| 374 virtual void AddKey(const std::string& session_id, | 374 virtual void AddKey(const std::string& session_id, |
| 375 pp::VarArrayBuffer key, | 375 pp::VarArrayBuffer key, |
| 376 pp::VarArrayBuffer init_data) OVERRIDE; | 376 pp::VarArrayBuffer init_data) OVERRIDE; |
| 377 virtual void CancelKeyRequest(const std::string& session_id) OVERRIDE; | 377 virtual void CancelKeyRequest(const std::string& session_id) OVERRIDE; |
| 378 virtual void Decrypt( | 378 virtual void Decrypt( |
| 379 pp::Buffer_Dev encrypted_buffer, | 379 pp::Buffer_Dev encrypted_buffer, |
| 380 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; | 380 const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE; |
| 381 virtual void InitializeVideoDecoder( | |
| 382 const PP_VideoDecoderConfig& decoder_config, | |
| 383 pp::Buffer_Dev extra_data_buffer) OVERRIDE; | |
| 381 virtual void DecryptAndDecodeFrame( | 384 virtual void DecryptAndDecodeFrame( |
| 382 pp::Buffer_Dev encrypted_frame, | 385 pp::Buffer_Dev encrypted_frame, |
| 383 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) OVERRIDE; | 386 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) OVERRIDE; |
| 384 | 387 |
| 385 private: | 388 private: |
| 386 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; | 389 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; |
| 387 typedef linked_ptr<KeyMessageImpl> LinkedKeyMessage; | 390 typedef linked_ptr<KeyMessageImpl> LinkedKeyMessage; |
| 388 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; | 391 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; |
| 389 | 392 |
| 390 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to | 393 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to |
| 391 // <code>callback_factory_</code> to ensure that calls into | 394 // <code>callback_factory_</code> to ensure that calls into |
| 392 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. | 395 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. |
| 393 void KeyAdded(int32_t result, const std::string& session_id); | 396 void KeyAdded(int32_t result, const std::string& session_id); |
| 394 void KeyMessage(int32_t result, const LinkedKeyMessage& message); | 397 void KeyMessage(int32_t result, const LinkedKeyMessage& message); |
| 395 void KeyError(int32_t result, const std::string& session_id); | 398 void KeyError(int32_t result, const std::string& session_id); |
| 396 void DeliverBlock(int32_t result, | 399 void DeliverBlock(int32_t result, |
| 397 const cdm::Status& status, | 400 const cdm::Status& status, |
| 398 const LinkedDecryptedBlock& decrypted_block, | 401 const LinkedDecryptedBlock& decrypted_block, |
| 399 const PP_DecryptTrackingInfo& tracking_info); | 402 const PP_DecryptTrackingInfo& tracking_info); |
| 403 void DecoderInitializeStatus(int32_t result, | |
| 404 bool success, | |
| 405 uint32_t request_id); | |
| 400 void DeliverFrame(int32_t result, | 406 void DeliverFrame(int32_t result, |
| 401 const cdm::Status& status, | 407 const cdm::Status& status, |
| 402 const LinkedVideoFrame& video_frame, | 408 const LinkedVideoFrame& video_frame, |
| 403 const PP_DecryptTrackingInfo& tracking_info); | 409 const PP_DecryptTrackingInfo& tracking_info); |
| 404 | 410 |
| 405 PpbBufferAllocator allocator_; | 411 PpbBufferAllocator allocator_; |
| 406 pp::CompletionCallbackFactory<CdmWrapper> callback_factory_; | 412 pp::CompletionCallbackFactory<CdmWrapper> callback_factory_; |
| 407 cdm::ContentDecryptionModule* cdm_; | 413 cdm::ContentDecryptionModule* cdm_; |
| 408 std::string key_system_; | 414 std::string key_system_; |
| 409 }; | 415 }; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 523 LinkedDecryptedBlock decrypted_block(new DecryptedBlockImpl()); | 529 LinkedDecryptedBlock decrypted_block(new DecryptedBlockImpl()); |
| 524 cdm::Status status = cdm_->Decrypt(input_buffer, decrypted_block.get()); | 530 cdm::Status status = cdm_->Decrypt(input_buffer, decrypted_block.get()); |
| 525 | 531 |
| 526 CallOnMain(callback_factory_.NewCallback( | 532 CallOnMain(callback_factory_.NewCallback( |
| 527 &CdmWrapper::DeliverBlock, | 533 &CdmWrapper::DeliverBlock, |
| 528 status, | 534 status, |
| 529 decrypted_block, | 535 decrypted_block, |
| 530 encrypted_block_info.tracking_info)); | 536 encrypted_block_info.tracking_info)); |
| 531 } | 537 } |
| 532 | 538 |
| 539 cdm::VideoDecoderConfig::VideoCodec PpVideoCodecToCdmVideoCodec( | |
| 540 PP_VideoCodec codec) { | |
| 541 switch (codec) { | |
| 542 case PP_VIDEOCODEC_VP8: | |
| 543 return cdm::VideoDecoderConfig::kCodecVP8; | |
| 544 | |
| 545 case PP_VIDEOCODEC_UNKNOWN: | |
| 546 default: | |
|
Ami GONE FROM CHROMIUM
2012/10/08 18:35:16
why default if you're handling all enum values?
(h
Tom Finegan
2012/10/08 23:23:27
Removed defaults.
Tom Finegan
2012/10/09 04:34:11
Defaults replaced, because MSVC:
d:\src\chromium\s
| |
| 547 PP_DCHECK(false); | |
|
xhwang
2012/10/08 17:16:13
We need to make clear assumptions about what codec
Tom Finegan
2012/10/08 23:23:27
I've removed DCHECKs (and moved these up with the
| |
| 548 } | |
| 549 return cdm::VideoDecoderConfig::kUnknownVideoCodec; | |
| 550 } | |
| 551 | |
| 552 cdm::VideoDecoderConfig::VideoCodecProfile | |
| 553 PpVideoCodecProfileToCdmVideoCodecProfile(PP_VideoCodecProfile profile) { | |
| 554 switch (profile) { | |
| 555 case PP_VIDEOCODECPROFILE_VP8_MAIN: | |
| 556 return cdm::VideoDecoderConfig::kVp8ProfileMain; | |
| 557 | |
| 558 case PP_VIDEOCODECPROFILE_UNKNOWN: | |
| 559 default: | |
| 560 PP_DCHECK(false); | |
|
xhwang
2012/10/08 17:16:13
ditto
Tom Finegan
2012/10/08 23:23:27
Done.
| |
| 561 } | |
| 562 return cdm::VideoDecoderConfig::kUnknownVideoCodecProfile; | |
| 563 } | |
| 564 | |
| 565 cdm::VideoFormat PpDecryptedFrameFormatToCdmVideoFormat( | |
| 566 PP_DecryptedFrameFormat format) { | |
| 567 switch (format) { | |
| 568 case PP_DECRYPTEDFRAMEFORMAT_YV12: | |
| 569 return cdm::kYv12; | |
| 570 | |
| 571 case PP_DECRYPTEDFRAMEFORMAT_I420: | |
| 572 return cdm::kI420; | |
| 573 | |
| 574 case PP_DECRYPTEDFRAMEFORMAT_UNKNOWN: | |
| 575 case PP_DECRYPTEDFRAMEFORMAT_EMPTY: | |
| 576 default: | |
| 577 PP_DCHECK(false); | |
|
xhwang
2012/10/08 17:16:13
ditto
Tom Finegan
2012/10/08 23:23:27
Done.
| |
| 578 } | |
| 579 return cdm::kUnknownVideoFormat; | |
| 580 } | |
| 581 | |
| 582 void CdmWrapper::InitializeVideoDecoder( | |
| 583 const PP_VideoDecoderConfig& decoder_config, | |
| 584 pp::Buffer_Dev extra_data_buffer) { | |
| 585 PP_DCHECK(cdm_); | |
| 586 cdm::VideoDecoderConfig cdm_decoder_config; | |
| 587 cdm_decoder_config.codec = PpVideoCodecToCdmVideoCodec(decoder_config.codec); | |
| 588 cdm_decoder_config.profile = | |
| 589 PpVideoCodecProfileToCdmVideoCodecProfile(decoder_config.profile); | |
| 590 cdm_decoder_config.format = | |
| 591 PpDecryptedFrameFormatToCdmVideoFormat(decoder_config.format); | |
| 592 cdm_decoder_config.coded_size.width = decoder_config.width; | |
| 593 cdm_decoder_config.coded_size.height = decoder_config.height; | |
| 594 cdm_decoder_config.extra_data = | |
| 595 static_cast<uint8_t*>(extra_data_buffer.data()); | |
| 596 cdm_decoder_config.extra_data_size = | |
| 597 static_cast<int32_t>(extra_data_buffer.size()); | |
| 598 cdm::Status status = cdm_->InitializeVideoDecoder(cdm_decoder_config); | |
| 599 | |
| 600 CallOnMain(callback_factory_.NewCallback( | |
| 601 &CdmWrapper::DecoderInitializeStatus, | |
| 602 status == cdm::kSuccess, | |
| 603 decoder_config.request_id)); | |
| 604 | |
| 605 } | |
| 606 | |
| 533 void CdmWrapper::DecryptAndDecodeFrame( | 607 void CdmWrapper::DecryptAndDecodeFrame( |
| 534 pp::Buffer_Dev encrypted_frame, | 608 pp::Buffer_Dev encrypted_frame, |
| 535 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) { | 609 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) { |
| 536 PP_DCHECK(!encrypted_frame.is_null()); | 610 PP_DCHECK(!encrypted_frame.is_null()); |
| 537 PP_DCHECK(cdm_); | 611 PP_DCHECK(cdm_); |
| 538 | 612 |
| 539 cdm::InputBuffer input_buffer; | 613 cdm::InputBuffer input_buffer; |
| 540 std::vector<cdm::SubsampleEntry> subsamples; | 614 std::vector<cdm::SubsampleEntry> subsamples; |
| 541 ConfigureInputBuffer(encrypted_frame, | 615 ConfigureInputBuffer(encrypted_frame, |
| 542 encrypted_video_frame_info.encryption_info, | 616 encrypted_video_frame_info.encryption_info, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 } | 674 } |
| 601 | 675 |
| 602 const pp::Buffer_Dev& buffer = | 676 const pp::Buffer_Dev& buffer = |
| 603 decrypted_block.get() && decrypted_block->buffer() ? | 677 decrypted_block.get() && decrypted_block->buffer() ? |
| 604 static_cast<PpbBuffer*>(decrypted_block->buffer())->buffer_dev() : | 678 static_cast<PpbBuffer*>(decrypted_block->buffer())->buffer_dev() : |
| 605 pp::Buffer_Dev(); | 679 pp::Buffer_Dev(); |
| 606 | 680 |
| 607 pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info); | 681 pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info); |
| 608 } | 682 } |
| 609 | 683 |
| 684 void CdmWrapper::DecoderInitializeStatus(int32_t result, | |
|
Ami GONE FROM CHROMIUM
2012/10/08 18:35:16
I'm confused about this being "result" and not "in
Tom Finegan
2012/10/08 23:23:27
The pp::CompletionCallback templates all require a
| |
| 685 bool success, | |
| 686 uint32_t request_id) { | |
| 687 pp::ContentDecryptor_Private::DecoderInitializeStatus(success, request_id); | |
| 688 } | |
| 689 | |
| 610 void CdmWrapper::DeliverFrame( | 690 void CdmWrapper::DeliverFrame( |
| 611 int32_t result, | 691 int32_t result, |
| 612 const cdm::Status& status, | 692 const cdm::Status& status, |
| 613 const LinkedVideoFrame& video_frame, | 693 const LinkedVideoFrame& video_frame, |
| 614 const PP_DecryptTrackingInfo& tracking_info) { | 694 const PP_DecryptTrackingInfo& tracking_info) { |
| 615 PP_DecryptedFrameInfo decrypted_frame_info; | 695 PP_DecryptedFrameInfo decrypted_frame_info; |
| 616 decrypted_frame_info.tracking_info = tracking_info; | 696 decrypted_frame_info.tracking_info = tracking_info; |
| 617 | 697 |
| 618 switch (status) { | 698 switch (status) { |
| 619 case cdm::kSuccess: | 699 case cdm::kSuccess: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 675 } // namespace webkit_media | 755 } // namespace webkit_media |
| 676 | 756 |
| 677 namespace pp { | 757 namespace pp { |
| 678 | 758 |
| 679 // Factory function for your specialization of the Module object. | 759 // Factory function for your specialization of the Module object. |
| 680 Module* CreateModule() { | 760 Module* CreateModule() { |
| 681 return new webkit_media::CdmWrapperModule(); | 761 return new webkit_media::CdmWrapperModule(); |
| 682 } | 762 } |
| 683 | 763 |
| 684 } // namespace pp | 764 } // namespace pp |
| OLD | NEW |