Chromium Code Reviews| Index: webkit/media/crypto/ppapi/cdm_wrapper.cc |
| diff --git a/webkit/media/crypto/ppapi/cdm_wrapper.cc b/webkit/media/crypto/ppapi/cdm_wrapper.cc |
| index b531a8a6f29a5df1f5a8b3d727036a06a837f9b7..38cff28fedf633166e1315399f0ef00d2c2630be 100644 |
| --- a/webkit/media/crypto/ppapi/cdm_wrapper.cc |
| +++ b/webkit/media/crypto/ppapi/cdm_wrapper.cc |
| @@ -23,8 +23,8 @@ |
| #include "ppapi/cpp/dev/buffer_dev.h" |
| #include "ppapi/cpp/private/content_decryptor_private.h" |
| #include "ppapi/utility/completion_callback_factory.h" |
| -#include "webkit/media/crypto/ppapi/linked_ptr.h" |
| #include "webkit/media/crypto/ppapi/content_decryption_module.h" |
| +#include "webkit/media/crypto/ppapi/linked_ptr.h" |
| namespace { |
| @@ -126,6 +126,19 @@ cdm::VideoFormat PpDecryptedFrameFormatToCdmVideoFormat( |
| return cdm::kUnknownVideoFormat; |
| } |
| +cdm::StreamType PpDecryptorStreamTypeToCdmStreamType( |
| + PP_DecryptorStreamType stream_type) { |
| + switch (stream_type) { |
| + case PP_DECRYPTORSTREAMTYPE_AUDIO: |
| + return cdm::kStreamTypeAudio; |
| + case PP_DECRYPTORSTREAMTYPE_VIDEO: |
| + return cdm::kStreamTypeVideo; |
| + } |
| + |
| + PP_NOTREACHED(); |
| + return cdm::kStreamTypeVideo; |
| +} |
| + |
| } // namespace |
| namespace webkit_media { |
| @@ -481,6 +494,7 @@ PpbBufferAllocator::~PpbBufferAllocator() { |
| cdm::Buffer* PpbBufferAllocator::Allocate(int32_t size) { |
| PP_DCHECK(size > 0); |
| + PP_DCHECK(IsMainThread()); |
| pp::Buffer_Dev buffer(instance_, size); |
| if (buffer.is_null()) |
| @@ -616,13 +630,11 @@ void CdmWrapper::InitializeVideoDecoder( |
| &CdmWrapper::DecoderInitialized, |
| status == cdm::kSuccess, |
| decoder_config.request_id)); |
| - |
| } |
| void CdmWrapper::DeinitializeDecoder(PP_DecryptorStreamType decoder_type, |
| uint32_t request_id) { |
| - // TODO(tomfinegan): Implement DeinitializeDecoder in clear key CDM, and call |
| - // it here. |
| + cdm_->DeinitializeDecoder(PpDecryptorStreamTypeToCdmStreamType(decoder_type)); |
| CallOnMain(callback_factory_.NewCallback( |
| &CdmWrapper::DecoderDeinitializeDone, |
| decoder_type, |
| @@ -631,8 +643,7 @@ void CdmWrapper::DeinitializeDecoder(PP_DecryptorStreamType decoder_type, |
| void CdmWrapper::ResetDecoder(PP_DecryptorStreamType decoder_type, |
| uint32_t request_id) { |
| - // TODO(tomfinegan): Implement ResetDecoder in clear key CDM, and call it |
| - // here. |
| + cdm_->ResetDecoder(PpDecryptorStreamTypeToCdmStreamType(decoder_type)); |
| CallOnMain(callback_factory_.NewCallback(&CdmWrapper::DecoderResetDone, |
| decoder_type, |
| request_id)); |
| @@ -645,15 +656,16 @@ void CdmWrapper::DecryptAndDecode( |
| // TODO(tomfinegan): Remove this check when audio decoding is added. |
| PP_DCHECK(decoder_type == PP_DECRYPTORSTREAMTYPE_VIDEO); |
| - PP_DCHECK(!encrypted_buffer.is_null()); |
| PP_DCHECK(cdm_); |
| cdm::InputBuffer input_buffer; |
| std::vector<cdm::SubsampleEntry> subsamples; |
| - ConfigureInputBuffer(encrypted_buffer, |
| - encrypted_block_info, |
| - &subsamples, |
| - &input_buffer); |
| + if (!encrypted_buffer.is_null()) { |
| + ConfigureInputBuffer(encrypted_buffer, |
| + encrypted_block_info, |
| + &subsamples, |
| + &input_buffer); |
| + } |
| LinkedVideoFrame video_frame(new VideoFrameImpl()); |
| cdm::Status status = cdm_->DecryptAndDecodeFrame(input_buffer, |
| @@ -783,6 +795,7 @@ void CdmWrapper::DeliverFrame( |
| decrypted_frame_info.tracking_info = tracking_info; |
| switch (status) { |
| + // TODO(xhwang): Handle cdm::kNeedMoreData. |
|
xhwang
2012/10/17 18:43:00
thanks!
|
| case cdm::kSuccess: |
| PP_DCHECK(video_frame->format() == cdm::kI420 || |
| video_frame->format() == cdm::kYv12); |