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

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

Issue 11189082: Update PluginInstance for audio support for content decryption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update CdmWrapper for audio support. Comment not resolved yet. 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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 void DecoderDeinitializeDone(int32_t result, 469 void DecoderDeinitializeDone(int32_t result,
470 PP_DecryptorStreamType decoder_type, 470 PP_DecryptorStreamType decoder_type,
471 uint32_t request_id); 471 uint32_t request_id);
472 void DecoderResetDone(int32_t result, 472 void DecoderResetDone(int32_t result,
473 PP_DecryptorStreamType decoder_type, 473 PP_DecryptorStreamType decoder_type,
474 uint32_t request_id); 474 uint32_t request_id);
475 void DeliverFrame(int32_t result, 475 void DeliverFrame(int32_t result,
476 const cdm::Status& status, 476 const cdm::Status& status,
477 const LinkedVideoFrame& video_frame, 477 const LinkedVideoFrame& video_frame,
478 const PP_DecryptTrackingInfo& tracking_info); 478 const PP_DecryptTrackingInfo& tracking_info);
479 void DeliverSamples(int32_t result,
480 const cdm::Status& status,
481 const LinkedDecryptedBlock& audio_frames,
482 const PP_DecryptTrackingInfo& tracking_info);
479 483
480 // Helper for SetTimer(). 484 // Helper for SetTimer().
481 void TimerExpired(int32 result); 485 void TimerExpired(int32 result);
482 486
483 PpbBufferAllocator allocator_; 487 PpbBufferAllocator allocator_;
484 pp::CompletionCallbackFactory<CdmWrapper> callback_factory_; 488 pp::CompletionCallbackFactory<CdmWrapper> callback_factory_;
485 cdm::ContentDecryptionModule* cdm_; 489 cdm::ContentDecryptionModule* cdm_;
486 std::string key_system_; 490 std::string key_system_;
487 }; 491 };
488 492
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 // here. 675 // here.
672 CallOnMain(callback_factory_.NewCallback(&CdmWrapper::DecoderResetDone, 676 CallOnMain(callback_factory_.NewCallback(&CdmWrapper::DecoderResetDone,
673 decoder_type, 677 decoder_type,
674 request_id)); 678 request_id));
675 } 679 }
676 680
677 void CdmWrapper::DecryptAndDecode( 681 void CdmWrapper::DecryptAndDecode(
678 PP_DecryptorStreamType decoder_type, 682 PP_DecryptorStreamType decoder_type,
679 pp::Buffer_Dev encrypted_buffer, 683 pp::Buffer_Dev encrypted_buffer,
680 const PP_EncryptedBlockInfo& encrypted_block_info) { 684 const PP_EncryptedBlockInfo& encrypted_block_info) {
681 // TODO(tomfinegan): Remove this check when audio decoding is added.
682 PP_DCHECK(decoder_type == PP_DECRYPTORSTREAMTYPE_VIDEO);
683 PP_DCHECK(cdm_); 685 PP_DCHECK(cdm_);
684 686
685 cdm::InputBuffer input_buffer; 687 cdm::InputBuffer input_buffer;
686 std::vector<cdm::SubsampleEntry> subsamples; 688 std::vector<cdm::SubsampleEntry> subsamples;
687 if (!encrypted_buffer.is_null()) { 689 if (!encrypted_buffer.is_null()) {
688 ConfigureInputBuffer(encrypted_buffer, 690 ConfigureInputBuffer(encrypted_buffer,
689 encrypted_block_info, 691 encrypted_block_info,
690 &subsamples, 692 &subsamples,
691 &input_buffer); 693 &input_buffer);
692 } 694 }
693 695
694 LinkedVideoFrame video_frame(new VideoFrameImpl()); 696 if (decoder_type == PP_DECRYPTORSTREAMTYPE_AUDIO) {
695 cdm::Status status = cdm_->DecryptAndDecodeFrame(input_buffer, 697 LinkedDecryptedBlock audio_frames(new DecryptedBlockImpl());
696 video_frame.get()); 698 cdm::Status status = cdm_->DecryptAndDecodeSamples(input_buffer,
697 CallOnMain(callback_factory_.NewCallback( 699 audio_frames.get());
698 &CdmWrapper::DeliverFrame, 700 CallOnMain(callback_factory_.NewCallback(
699 status, 701 &CdmWrapper::DeliverSamples,
700 video_frame, 702 status,
701 encrypted_block_info.tracking_info)); 703 audio_frames,
704 encrypted_block_info.tracking_info));
705 } else { // decoder_type == PP_DECRYPTORSTREAMTYPE_VIDEO
706 LinkedVideoFrame video_frame(new VideoFrameImpl());
707 cdm::Status status = cdm_->DecryptAndDecodeFrame(input_buffer,
708 video_frame.get());
709 CallOnMain(callback_factory_.NewCallback(
710 &CdmWrapper::DeliverFrame,
711 status,
712 video_frame,
713 encrypted_block_info.tracking_info));
714 }
702 } 715 }
703 716
704 void CdmWrapper::SetTimer(int64 delay_ms) { 717 void CdmWrapper::SetTimer(int64 delay_ms) {
705 // NOTE: doesn't really need to run on the main thread; could just as well run 718 // NOTE: doesn't really need to run on the main thread; could just as well run
706 // on a helper thread if |cdm_| were thread-friendly and care was taken. We 719 // on a helper thread if |cdm_| were thread-friendly and care was taken. We
707 // only use CallOnMainThread() here to get delayed-execution behavior. 720 // only use CallOnMainThread() here to get delayed-execution behavior.
708 pp::Module::Get()->core()->CallOnMainThread( 721 pp::Module::Get()->core()->CallOnMainThread(
709 delay_ms, 722 delay_ms,
710 callback_factory_.NewCallback(&CdmWrapper::TimerExpired), 723 callback_factory_.NewCallback(&CdmWrapper::TimerExpired),
711 PP_OK); 724 PP_OK);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 } 881 }
869 882
870 const pp::Buffer_Dev& buffer = 883 const pp::Buffer_Dev& buffer =
871 video_frame.get() && video_frame->frame_buffer() ? 884 video_frame.get() && video_frame->frame_buffer() ?
872 static_cast<PpbBuffer*>(video_frame->frame_buffer())->buffer_dev() : 885 static_cast<PpbBuffer*>(video_frame->frame_buffer())->buffer_dev() :
873 pp::Buffer_Dev(); 886 pp::Buffer_Dev();
874 887
875 pp::ContentDecryptor_Private::DeliverFrame(buffer, decrypted_frame_info); 888 pp::ContentDecryptor_Private::DeliverFrame(buffer, decrypted_frame_info);
876 } 889 }
877 890
891 void CdmWrapper::DeliverSamples(int32_t result,
892 const cdm::Status& status,
893 const LinkedDecryptedBlock& audio_frames,
894 const PP_DecryptTrackingInfo& tracking_info) {
895 PP_DCHECK(result == PP_OK);
896 PP_DecryptedBlockInfo decrypted_block_info;
897 decrypted_block_info.tracking_info = tracking_info;
898 decrypted_block_info.tracking_info.timestamp = audio_frames->timestamp();
899
900 switch (status) {
901 case cdm::kSuccess:
902 decrypted_block_info.result = PP_DECRYPTRESULT_SUCCESS;
903 PP_DCHECK(audio_frames.get() && audio_frames->buffer());
904 break;
905 case cdm::kNeedMoreData:
906 decrypted_block_info.result = PP_DECRYPTRESULT_SUCCESS;
xhwang 2012/10/21 19:05:06 Need to update this when NeedMoreData patch (11234
907 break;
908 case cdm::kNoKey:
909 decrypted_block_info.result = PP_DECRYPTRESULT_DECRYPT_NOKEY;
910 break;
911 case cdm::kDecryptError:
912 decrypted_block_info.result = PP_DECRYPTRESULT_DECRYPT_ERROR;
913 break;
914 default:
915 PP_DCHECK(false);
916 decrypted_block_info.result = PP_DECRYPTRESULT_DECRYPT_ERROR;
917 }
918
919 const pp::Buffer_Dev& buffer =
920 audio_frames.get() && audio_frames->buffer() ?
921 static_cast<PpbBuffer*>(audio_frames->buffer())->buffer_dev() :
922 pp::Buffer_Dev();
923
924 pp::ContentDecryptor_Private::DeliverSamples(buffer, decrypted_block_info);
925 }
926
878 927
879 // This object is the global object representing this plugin library as long 928 // This object is the global object representing this plugin library as long
880 // as it is loaded. 929 // as it is loaded.
881 class CdmWrapperModule : public pp::Module { 930 class CdmWrapperModule : public pp::Module {
882 public: 931 public:
883 CdmWrapperModule() : pp::Module() {} 932 CdmWrapperModule() : pp::Module() {}
884 virtual ~CdmWrapperModule() {} 933 virtual ~CdmWrapperModule() {}
885 934
886 virtual pp::Instance* CreateInstance(PP_Instance instance) { 935 virtual pp::Instance* CreateInstance(PP_Instance instance) {
887 return new CdmWrapper(instance, this); 936 return new CdmWrapper(instance, this);
888 } 937 }
889 }; 938 };
890 939
891 } // namespace webkit_media 940 } // namespace webkit_media
892 941
893 namespace pp { 942 namespace pp {
894 943
895 // Factory function for your specialization of the Module object. 944 // Factory function for your specialization of the Module object.
896 Module* CreateModule() { 945 Module* CreateModule() {
897 return new webkit_media::CdmWrapperModule(); 946 return new webkit_media::CdmWrapperModule();
898 } 947 }
899 948
900 } // namespace pp 949 } // namespace pp
OLDNEW
« no previous file with comments | « no previous file | webkit/media/crypto/ppapi/clear_key_cdm.h » ('j') | webkit/media/crypto/ppapi/content_decryption_module.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698