| 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..ef353b40d148bb258c4b4d3e37c072e8b1edd04f 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_cdm_video_decoder.h"
|
|
|
| static const char kClearKeyCdmVersion[] = "0.1.0.0";
|
|
|
| @@ -235,23 +236,49 @@ cdm::Status ClearKeyCdm::Decrypt(
|
|
|
| cdm::Status ClearKeyCdm::InitializeVideoDecoder(
|
| const cdm::VideoDecoderConfig& video_decoder_config) {
|
| - NOTIMPLEMENTED();
|
| - return cdm::kSessionError;
|
| + if (!video_decoder_)
|
| + video_decoder_.reset(new webkit_media::FFmpegCdmVideoDecoder(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::kError)
|
| + return cdm::kDecryptError;
|
| + if (status == media::Decryptor::kNoKey)
|
| + return cdm::kNoKey;
|
| +
|
| + DCHECK(status == media::Decryptor::kSuccess);
|
| +
|
| + DCHECK(buffer);
|
| + return video_decoder_->DecodeFrame(buffer.get()->GetData(),
|
| + buffer->GetDataSize(),
|
| + encrypted_buffer.timestamp,
|
| + decoded_frame);
|
| }
|
|
|
| } // namespace webkit_media
|
|
|