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..2a983cf4d9eb0cad454d2e9c37de57443ec5f073 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,52 @@ cdm::Status ClearKeyCdm::Decrypt( |
cdm::Status ClearKeyCdm::InitializeVideoDecoder( |
const cdm::VideoDecoderConfig& video_decoder_config) { |
- NOTIMPLEMENTED(); |
- return cdm::kSessionError; |
+ video_decoder_.reset(new webkit_media::FFmpegCdmVideoDecoder(allocator_)); |
ddorwin
2012/10/16 18:04:30
What is the intended behavior if this is called a
Tom Finegan
2012/10/16 21:44:44
I think replacing the decoder is best, and not onl
xhwang
2012/10/16 21:59:53
If the decoder is initialized, DeinitializeDecoder
Tom Finegan
2012/10/17 02:39:10
Added is_initialized_ flag to FFmpegCdmVideoDecode
|
+ 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); |
+ if (!video_decoder_->DecodeFrame(buffer.get()->GetData(), |
+ buffer->GetDataSize(), |
+ encrypted_buffer.timestamp, |
+ decoded_frame)) { |
+ LOG(ERROR) << "DecryptAndDecodeFrame() DecodeFrame failed"; |
+ return cdm::kDecodeError; |
+ } |
+ |
+ return cdm::kSuccess; |
} |
} // namespace webkit_media |