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

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

Issue 10899021: Add CDM video decoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Maybe sorta could work... 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"
11 #include "ppapi/c/pp_errors.h" 11 #include "ppapi/c/pp_errors.h"
12 #include "ppapi/c/pp_stdint.h" 12 #include "ppapi/c/pp_stdint.h"
13 #include "ppapi/c/private/pp_content_decryptor.h" 13 #include "ppapi/c/private/pp_content_decryptor.h"
14 #include "ppapi/cpp/completion_callback.h" 14 #include "ppapi/cpp/completion_callback.h"
15 #include "ppapi/cpp/core.h" 15 #include "ppapi/cpp/core.h"
16 #include "ppapi/cpp/instance.h" 16 #include "ppapi/cpp/instance.h"
17 #include "ppapi/cpp/logging.h" 17 #include "ppapi/cpp/logging.h"
18 #include "ppapi/cpp/module.h" 18 #include "ppapi/cpp/module.h"
19 #include "ppapi/cpp/pass_ref.h" 19 #include "ppapi/cpp/pass_ref.h"
20 #include "ppapi/cpp/resource.h" 20 #include "ppapi/cpp/resource.h"
21 #include "ppapi/cpp/var.h" 21 #include "ppapi/cpp/var.h"
22 #include "ppapi/cpp/var_array_buffer.h" 22 #include "ppapi/cpp/var_array_buffer.h"
23 #include "ppapi/cpp/dev/buffer_dev.h" 23 #include "ppapi/cpp/dev/buffer_dev.h"
24 #include "ppapi/cpp/private/content_decryptor_private.h" 24 #include "ppapi/cpp/private/content_decryptor_private.h"
25 #include "ppapi/utility/completion_callback_factory.h" 25 #include "ppapi/utility/completion_callback_factory.h"
26 #include "webkit/media/crypto/ppapi/content_decryption_module.h"
26 #include "webkit/media/crypto/ppapi/linked_ptr.h" 27 #include "webkit/media/crypto/ppapi/linked_ptr.h"
27 #include "webkit/media/crypto/ppapi/content_decryption_module.h"
28 28
29 namespace { 29 namespace {
30 30
31 // This must be consistent with MediaKeyError defined in the spec: 31 // This must be consistent with MediaKeyError defined in the spec:
32 // http://goo.gl/rbdnR 32 // http://goo.gl/rbdnR
33 // TODO(xhwang): Add PP_MediaKeyError enum to avoid later static_cast in 33 // TODO(xhwang): Add PP_MediaKeyError enum to avoid later static_cast in
34 // PluginInstance. 34 // PluginInstance.
35 enum MediaKeyError { 35 enum MediaKeyError {
36 kUnknownError = 1, 36 kUnknownError = 1,
37 kClientError, 37 kClientError,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 if (format == PP_DECRYPTEDFRAMEFORMAT_YV12) 119 if (format == PP_DECRYPTEDFRAMEFORMAT_YV12)
120 return cdm::kYv12; 120 return cdm::kYv12;
121 else if (format == PP_DECRYPTEDFRAMEFORMAT_I420) 121 else if (format == PP_DECRYPTEDFRAMEFORMAT_I420)
122 return cdm::kI420; 122 return cdm::kI420;
123 else if (format == PP_DECRYPTEDFRAMEFORMAT_EMPTY) 123 else if (format == PP_DECRYPTEDFRAMEFORMAT_EMPTY)
124 return cdm::kEmptyVideoFrame; 124 return cdm::kEmptyVideoFrame;
125 125
126 return cdm::kUnknownVideoFormat; 126 return cdm::kUnknownVideoFormat;
127 } 127 }
128 128
129 cdm::StreamType PpDecryptorStreamTypeToCdmStreamType(
130 PP_DecryptorStreamType stream_type) {
131 if (stream_type == PP_DECRYPTORSTREAMTYPE_AUDIO)
ddorwin 2012/10/13 03:54:42 Use switch. Depending on settings, can ensure you
Tom Finegan 2012/10/13 23:47:26 Done.
132 return cdm::kStreamTypeAudio;
133
134 return cdm::kStreamTypeVideo;
135 }
136
129 } // namespace 137 } // namespace
130 138
131 namespace webkit_media { 139 namespace webkit_media {
132 140
133 // Provides access to memory owned by a pp::Buffer_Dev created by 141 // Provides access to memory owned by a pp::Buffer_Dev created by
134 // PpbBufferAllocator::Allocate(). This class holds a reference to the 142 // PpbBufferAllocator::Allocate(). This class holds a reference to the
135 // Buffer_Dev throughout its lifetime. 143 // Buffer_Dev throughout its lifetime.
136 class PpbBuffer : public cdm::Buffer { 144 class PpbBuffer : public cdm::Buffer {
137 public: 145 public:
138 // cdm::Buffer methods. 146 // cdm::Buffer methods.
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 cdm_decoder_config.extra_data = 603 cdm_decoder_config.extra_data =
596 static_cast<uint8_t*>(extra_data_buffer.data()); 604 static_cast<uint8_t*>(extra_data_buffer.data());
597 cdm_decoder_config.extra_data_size = 605 cdm_decoder_config.extra_data_size =
598 static_cast<int32_t>(extra_data_buffer.size()); 606 static_cast<int32_t>(extra_data_buffer.size());
599 cdm::Status status = cdm_->InitializeVideoDecoder(cdm_decoder_config); 607 cdm::Status status = cdm_->InitializeVideoDecoder(cdm_decoder_config);
600 608
601 CallOnMain(callback_factory_.NewCallback( 609 CallOnMain(callback_factory_.NewCallback(
602 &CdmWrapper::DecoderInitialized, 610 &CdmWrapper::DecoderInitialized,
603 status == cdm::kSuccess, 611 status == cdm::kSuccess,
604 decoder_config.request_id)); 612 decoder_config.request_id));
605
606 } 613 }
607 614
608 void CdmWrapper::DeinitializeDecoder(PP_DecryptorStreamType decoder_type, 615 void CdmWrapper::DeinitializeDecoder(PP_DecryptorStreamType decoder_type,
609 uint32_t request_id) { 616 uint32_t request_id) {
610 // TODO(tomfinegan): Implement DeinitializeDecoder in clear key CDM, and call 617 cdm_->DeinitializeDecoder(PpDecryptorStreamTypeToCdmStreamType(decoder_type));
611 // it here.
612 CallOnMain(callback_factory_.NewCallback( 618 CallOnMain(callback_factory_.NewCallback(
613 &CdmWrapper::DecoderDeinitializeDone, 619 &CdmWrapper::DecoderDeinitializeDone,
614 decoder_type, 620 decoder_type,
615 request_id)); 621 request_id));
616 } 622 }
617 623
618 void CdmWrapper::ResetDecoder(PP_DecryptorStreamType decoder_type, 624 void CdmWrapper::ResetDecoder(PP_DecryptorStreamType decoder_type,
619 uint32_t request_id) { 625 uint32_t request_id) {
620 // TODO(tomfinegan): Implement ResetDecoder in clear key CDM, and call it 626 cdm_->ResetDecoder(PpDecryptorStreamTypeToCdmStreamType(decoder_type));
621 // here.
622 CallOnMain(callback_factory_.NewCallback(&CdmWrapper::DecoderResetDone, 627 CallOnMain(callback_factory_.NewCallback(&CdmWrapper::DecoderResetDone,
623 decoder_type, 628 decoder_type,
624 request_id)); 629 request_id));
625 } 630 }
626 631
627 void CdmWrapper::DecryptAndDecode( 632 void CdmWrapper::DecryptAndDecode(
628 PP_DecryptorStreamType decoder_type, 633 PP_DecryptorStreamType decoder_type,
629 pp::Buffer_Dev encrypted_buffer, 634 pp::Buffer_Dev encrypted_buffer,
630 const PP_EncryptedBlockInfo& encrypted_block_info) { 635 const PP_EncryptedBlockInfo& encrypted_block_info) {
631 // TODO(tomfinegan): Remove this check when audio decoding is added. 636 // TODO(tomfinegan): Remove this check when audio decoding is added.
632 PP_DCHECK(decoder_type == PP_DECRYPTORSTREAMTYPE_VIDEO); 637 PP_DCHECK(decoder_type == PP_DECRYPTORSTREAMTYPE_VIDEO);
633 638
634 PP_DCHECK(!encrypted_buffer.is_null());
635 PP_DCHECK(cdm_); 639 PP_DCHECK(cdm_);
636 640
637 cdm::InputBuffer input_buffer; 641 cdm::InputBuffer input_buffer;
638 std::vector<cdm::SubsampleEntry> subsamples; 642 std::vector<cdm::SubsampleEntry> subsamples;
639 ConfigureInputBuffer(encrypted_buffer, 643 if (!encrypted_buffer.is_null()) {
640 encrypted_block_info, 644 ConfigureInputBuffer(encrypted_buffer,
641 &subsamples, 645 encrypted_block_info,
642 &input_buffer); 646 &subsamples,
647 &input_buffer);
648 }
643 649
644 LinkedVideoFrame video_frame(new VideoFrameImpl()); 650 LinkedVideoFrame video_frame(new VideoFrameImpl());
645 cdm::Status status = cdm_->DecryptAndDecodeFrame(input_buffer, 651 cdm::Status status = cdm_->DecryptAndDecodeFrame(input_buffer,
646 video_frame.get()); 652 video_frame.get());
647 CallOnMain(callback_factory_.NewCallback( 653 CallOnMain(callback_factory_.NewCallback(
648 &CdmWrapper::DeliverFrame, 654 &CdmWrapper::DeliverFrame,
649 status, 655 status,
650 video_frame, 656 video_frame,
651 encrypted_block_info.tracking_info)); 657 encrypted_block_info.tracking_info));
652 } 658 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 } // namespace webkit_media 834 } // namespace webkit_media
829 835
830 namespace pp { 836 namespace pp {
831 837
832 // Factory function for your specialization of the Module object. 838 // Factory function for your specialization of the Module object.
833 Module* CreateModule() { 839 Module* CreateModule() {
834 return new webkit_media::CdmWrapperModule(); 840 return new webkit_media::CdmWrapperModule();
835 } 841 }
836 842
837 } // namespace pp 843 } // namespace pp
OLDNEW
« no previous file with comments | « no previous file | webkit/media/crypto/ppapi/clear_key_cdm.h » ('j') | webkit/media/crypto/ppapi/clear_key_cdm.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698