Chromium Code Reviews| Index: webkit/media/crypto/ppapi/clear_key_cdm.cc |
| diff --git a/webkit/media/crypto/ppapi/clear_key_cdm.cc b/webkit/media/crypto/ppapi/clear_key_cdm.cc |
| index 4f0eaef613a9facb361ddb30548154d6914d4029..6dcc2c6d9d68d25f6ce917a57a87af801ba6237f 100644 |
| --- a/webkit/media/crypto/ppapi/clear_key_cdm.cc |
| +++ b/webkit/media/crypto/ppapi/clear_key_cdm.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/logging.h" |
| #include "base/time.h" |
| #include "media/base/decoder_buffer.h" |
| +#include "webkit/media/crypto/ppapi/ffmpeg_video_decoder.h" |
| static const char kClearKeyCdmVersion[] = "0.1.0.0"; |
| @@ -204,7 +205,7 @@ static void CopyDecryptResults( |
| cdm::Status ClearKeyCdm::Decrypt( |
| const cdm::InputBuffer& encrypted_buffer, |
| cdm::DecryptedBlock* decrypted_block) { |
| - DVLOG(1) << "Decrypt()"; |
| + DVLOG(1) << "ClearKeyCdm::Decrypt()"; |
|
ddorwin
2012/10/13 03:54:42
Filename is already included in the log message.
Tom Finegan
2012/10/13 23:47:26
Done.
|
| scoped_refptr<media::DecoderBuffer> decoder_buffer = |
| CopyDecoderBufferFrom(encrypted_buffer); |
| @@ -235,23 +236,49 @@ cdm::Status ClearKeyCdm::Decrypt( |
| cdm::Status ClearKeyCdm::InitializeVideoDecoder( |
| const cdm::VideoDecoderConfig& video_decoder_config) { |
| - NOTIMPLEMENTED(); |
| - return cdm::kSessionError; |
| + video_decoder_.reset(new webkit_media::FFmpegVideoDecoder(allocator_)); |
| + if (!video_decoder_->Initialize(video_decoder_config)) |
| + return cdm::kSessionError; |
| + |
| + return cdm::kSuccess; |
| } |
| -void ClearKeyCdm::ResetDecoder(cdm::StreamType) { |
| - NOTIMPLEMENTED(); |
| +void ClearKeyCdm::ResetDecoder(cdm::StreamType decoder_type) { |
| + DCHECK(decoder_type == cdm::kStreamTypeVideo); |
| + video_decoder_->Reset(); |
| } |
| -void ClearKeyCdm::DeinitializeDecoder(cdm::StreamType) { |
| - NOTIMPLEMENTED(); |
| +void ClearKeyCdm::DeinitializeDecoder(cdm::StreamType decoder_type) { |
| + DCHECK(decoder_type == cdm::kStreamTypeVideo); |
| + video_decoder_->Deinitialize(); |
| } |
| cdm::Status ClearKeyCdm::DecryptAndDecodeFrame( |
| const cdm::InputBuffer& encrypted_buffer, |
| - cdm::VideoFrame* video_frame) { |
| - NOTIMPLEMENTED(); |
| - return cdm::kDecryptError; |
| + cdm::VideoFrame* decoded_frame) { |
| + scoped_refptr<media::DecoderBuffer> decoder_buffer = |
| + CopyDecoderBufferFrom(encrypted_buffer); |
| + |
| + // Callback is called synchronously, so we can use variables on the stack. |
| + media::Decryptor::Status status; |
| + scoped_refptr<media::DecoderBuffer> buffer; |
| + decryptor_.Decrypt(decoder_buffer, |
| + base::Bind(&CopyDecryptResults, &status, &buffer)); |
| + |
| + if (status == media::Decryptor::kNoKey) |
| + return cdm::kNoKey; |
| + |
|
ddorwin
2012/10/13 03:54:42
Need to handle kDecryptError. Then DCHECK(kSuccess
Tom Finegan
2012/10/13 23:47:26
Done.
|
| + DCHECK(buffer); |
| + int data_size = buffer->GetDataSize(); |
|
ddorwin
2012/10/13 03:54:42
why do we need this?
Tom Finegan
2012/10/13 23:47:26
Removed.
|
| + |
| + if (!video_decoder_->DecodeFrame(buffer.get()->GetData(), data_size, |
| + encrypted_buffer.timestamp, |
| + decoded_frame)) { |
| + LOG(ERROR) << "ClearKeyCdm::DecryptAndDecodeFrame() DecodeFrame failed"; |
| + return cdm::kDecodeError; |
| + } |
| + |
| + return cdm::kSuccess; |
| } |
| } // namespace webkit_media |