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

Side by Side Diff: webkit/media/crypto/ppapi/cdm_wrapper.cc

Issue 11087044: Generalize Pepper CDM API decrypt and decode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 <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
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 DecryptAndDecodeFrame( 381 virtual void DecryptAndDecode(
382 pp::Buffer_Dev encrypted_frame, 382 pp::Buffer_Dev encrypted_frame,
383 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) OVERRIDE; 383 const PP_EncryptedMediaInfo& encrypted_media_info) OVERRIDE;
384 384
385 private: 385 private:
386 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock; 386 typedef linked_ptr<DecryptedBlockImpl> LinkedDecryptedBlock;
387 typedef linked_ptr<KeyMessageImpl> LinkedKeyMessage; 387 typedef linked_ptr<KeyMessageImpl> LinkedKeyMessage;
388 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame; 388 typedef linked_ptr<VideoFrameImpl> LinkedVideoFrame;
389 389
390 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to 390 // <code>PPB_ContentDecryptor_Private</code> dispatchers. These are passed to
391 // <code>callback_factory_</code> to ensure that calls into 391 // <code>callback_factory_</code> to ensure that calls into
392 // <code>PPP_ContentDecryptor_Private</code> are asynchronous. 392 // <code>PPP_ContentDecryptor_Private</code> are asynchronous.
393 void KeyAdded(int32_t result, const std::string& session_id); 393 void KeyAdded(int32_t result, const std::string& session_id);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 LinkedDecryptedBlock decrypted_block(new DecryptedBlockImpl()); 523 LinkedDecryptedBlock decrypted_block(new DecryptedBlockImpl());
524 cdm::Status status = cdm_->Decrypt(input_buffer, decrypted_block.get()); 524 cdm::Status status = cdm_->Decrypt(input_buffer, decrypted_block.get());
525 525
526 CallOnMain(callback_factory_.NewCallback( 526 CallOnMain(callback_factory_.NewCallback(
527 &CdmWrapper::DeliverBlock, 527 &CdmWrapper::DeliverBlock,
528 status, 528 status,
529 decrypted_block, 529 decrypted_block,
530 encrypted_block_info.tracking_info)); 530 encrypted_block_info.tracking_info));
531 } 531 }
532 532
533 void CdmWrapper::DecryptAndDecodeFrame( 533 void CdmWrapper::DecryptAndDecode(
534 pp::Buffer_Dev encrypted_frame, 534 pp::Buffer_Dev encrypted_frame,
535 const PP_EncryptedVideoFrameInfo& encrypted_video_frame_info) { 535 const PP_EncryptedMediaInfo& encrypted_media_info) {
536 PP_DCHECK(!encrypted_frame.is_null()); 536 PP_DCHECK(!encrypted_frame.is_null());
537 PP_DCHECK(cdm_); 537 PP_DCHECK(cdm_);
538 538
539 cdm::InputBuffer input_buffer; 539 cdm::InputBuffer input_buffer;
540 std::vector<cdm::SubsampleEntry> subsamples; 540 std::vector<cdm::SubsampleEntry> subsamples;
541 ConfigureInputBuffer(encrypted_frame, 541 ConfigureInputBuffer(encrypted_frame,
542 encrypted_video_frame_info.encryption_info, 542 encrypted_media_info.encryption_info,
543 &subsamples, 543 &subsamples,
544 &input_buffer); 544 &input_buffer);
545 545
546 // TODO(tomfinegan): Remove this check when audio decoding is added.
547 if (encrypted_media_info.media_type == PP_STREAMTYPE_VIDEO) {
Ami GONE FROM CHROMIUM 2012/10/10 07:30:26 s/VIDEO/AUDIO/ but actually see below
Tom Finegan 2012/10/10 08:26:06 Done.
548 PP_DCHECK(false);
Ami GONE FROM CHROMIUM 2012/10/10 07:30:26 DCHECKs shouldn't be handled. I'd replace l547-550
Tom Finegan 2012/10/10 08:26:06 Done.
549 return;
550 }
551
546 LinkedVideoFrame video_frame(new VideoFrameImpl()); 552 LinkedVideoFrame video_frame(new VideoFrameImpl());
547 cdm::Status status = cdm_->DecryptAndDecodeFrame(input_buffer, 553 cdm::Status status = cdm_->DecryptAndDecodeFrame(input_buffer,
548 video_frame.get()); 554 video_frame.get());
549 CallOnMain(callback_factory_.NewCallback( 555 CallOnMain(callback_factory_.NewCallback(
550 &CdmWrapper::DeliverFrame, 556 &CdmWrapper::DeliverFrame,
551 status, 557 status,
552 video_frame, 558 video_frame,
553 encrypted_video_frame_info.encryption_info.tracking_info)); 559 encrypted_media_info.encryption_info.tracking_info));
554 } 560 }
555 561
556 void CdmWrapper::KeyAdded(int32_t result, const std::string& session_id) { 562 void CdmWrapper::KeyAdded(int32_t result, const std::string& session_id) {
557 pp::ContentDecryptor_Private::KeyAdded(key_system_, session_id); 563 pp::ContentDecryptor_Private::KeyAdded(key_system_, session_id);
558 } 564 }
559 565
560 void CdmWrapper::KeyMessage(int32_t result, 566 void CdmWrapper::KeyMessage(int32_t result,
561 const LinkedKeyMessage& key_message) { 567 const LinkedKeyMessage& key_message) {
562 pp::Buffer_Dev message_buffer = 568 pp::Buffer_Dev message_buffer =
563 static_cast<const PpbBuffer*>(key_message->message())->buffer_dev(); 569 static_cast<const PpbBuffer*>(key_message->message())->buffer_dev();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 pp::Buffer_Dev(); 611 pp::Buffer_Dev();
606 612
607 pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info); 613 pp::ContentDecryptor_Private::DeliverBlock(buffer, decrypted_block_info);
608 } 614 }
609 615
610 void CdmWrapper::DeliverFrame( 616 void CdmWrapper::DeliverFrame(
611 int32_t result, 617 int32_t result,
612 const cdm::Status& status, 618 const cdm::Status& status,
613 const LinkedVideoFrame& video_frame, 619 const LinkedVideoFrame& video_frame,
614 const PP_DecryptTrackingInfo& tracking_info) { 620 const PP_DecryptTrackingInfo& tracking_info) {
621 PP_DCHECK(result == PP_OK);
615 PP_DecryptedFrameInfo decrypted_frame_info; 622 PP_DecryptedFrameInfo decrypted_frame_info;
616 decrypted_frame_info.tracking_info = tracking_info; 623 decrypted_frame_info.tracking_info = tracking_info;
617 624
618 switch (status) { 625 switch (status) {
619 case cdm::kSuccess: 626 case cdm::kSuccess:
620 PP_DCHECK(video_frame->format() == cdm::kI420 || 627 PP_DCHECK(video_frame->format() == cdm::kI420 ||
621 video_frame->format() == cdm::kYv12); 628 video_frame->format() == cdm::kYv12);
622 PP_DCHECK(video_frame.get() && video_frame->frame_buffer()); 629 PP_DCHECK(video_frame.get() && video_frame->frame_buffer());
623 decrypted_frame_info.result = PP_DECRYPTRESULT_SUCCESS; 630 decrypted_frame_info.result = PP_DECRYPTRESULT_SUCCESS;
624 decrypted_frame_info.format = 631 decrypted_frame_info.format =
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 } // namespace webkit_media 682 } // namespace webkit_media
676 683
677 namespace pp { 684 namespace pp {
678 685
679 // Factory function for your specialization of the Module object. 686 // Factory function for your specialization of the Module object.
680 Module* CreateModule() { 687 Module* CreateModule() {
681 return new webkit_media::CdmWrapperModule(); 688 return new webkit_media::CdmWrapperModule();
682 } 689 }
683 690
684 } // namespace pp 691 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698