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 6f7ea09284167abe3222a513dddd72c095a7a06e..becbf63e053b6c578c0304bfbd6af48c8e0db121 100644 |
--- a/webkit/media/crypto/ppapi/clear_key_cdm.cc |
+++ b/webkit/media/crypto/ppapi/clear_key_cdm.cc |
@@ -6,10 +6,15 @@ |
#include <vector> |
+#include "base/at_exit.h" |
+#include "base/file_path.h" |
#include "base/bind.h" |
#include "base/logging.h" |
+#include "base/path_service.h" |
#include "base/time.h" |
#include "media/base/decoder_buffer.h" |
+#include "media/base/media.h" |
+#include "webkit/media/crypto/ppapi/ffmpeg_cdm_video_decoder.h" |
static const char kClearKeyCdmVersion[] = "0.1.0.0"; |
@@ -65,10 +70,18 @@ static Type* AllocateAndCopy(const Type* data, int size) { |
cdm::ContentDecryptionModule* CreateCdmInstance( |
cdm::Allocator* allocator, cdm::CdmHost* host) { |
+ DVLOG(1) << "CreateCdmInstance()"; |
ddorwin
2012/10/21 22:10:53
This should all only be done once per module. That
Tom Finegan
2012/10/22 02:34:58
Discussed offline. Is this way OK, or do you want
ddorwin
2012/10/22 05:04:36
It's up to you. I'm fine with landing this then mo
|
+ base::AtExitManager at_exit_manager; |
+ |
+ FilePath file_path; |
+ CHECK(PathService::Get(base::DIR_EXE, &file_path)); |
+ CHECK(media::InitializeMediaLibrary(file_path)); |
+ |
return new webkit_media::ClearKeyCdm(allocator, host); |
} |
void DestroyCdmInstance(cdm::ContentDecryptionModule* instance) { |
+ DVLOG(1) << "DestroyCdmInstance()"; |
delete instance; |
} |
@@ -245,27 +258,36 @@ cdm::Status ClearKeyCdm::InitializeAudioDecoder( |
cdm::Status ClearKeyCdm::InitializeVideoDecoder( |
const cdm::VideoDecoderConfig& video_decoder_config) { |
#if !defined(CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER) |
- 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; |
#else |
video_size_ = video_decoder_config.coded_size; |
- return cdm::kSuccess; |
#endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER |
+ return cdm::kSuccess; |
} |
-void ClearKeyCdm::ResetDecoder(cdm::StreamType) { |
- NOTIMPLEMENTED(); |
+void ClearKeyCdm::ResetDecoder(cdm::StreamType decoder_type) { |
+#if !defined(CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER) |
+ DCHECK(decoder_type == cdm::kStreamTypeVideo); |
+ video_decoder_->Reset(); |
+#endif |
} |
-void ClearKeyCdm::DeinitializeDecoder(cdm::StreamType) { |
- NOTIMPLEMENTED(); |
+void ClearKeyCdm::DeinitializeDecoder(cdm::StreamType decoder_type) { |
+#if !defined(CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER) |
+ DCHECK(decoder_type == cdm::kStreamTypeVideo); |
+ video_decoder_->Deinitialize(); |
+#endif |
} |
cdm::Status ClearKeyCdm::DecryptAndDecodeFrame( |
const cdm::InputBuffer& encrypted_buffer, |
- cdm::VideoFrame* video_frame) { |
+ cdm::VideoFrame* decoded_frame) { |
if (!encrypted_buffer.data) { |
- video_frame->set_format(cdm::kEmptyVideoFrame); |
+ decoded_frame->set_format(cdm::kEmptyVideoFrame); |
return cdm::kSuccess; |
} |
@@ -286,10 +308,14 @@ cdm::Status ClearKeyCdm::DecryptAndDecodeFrame( |
return cdm::kNoKey; |
#if !defined(CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER) |
- NOTIMPLEMENTED(); |
- return cdm::kDecodeError; |
+ DCHECK(status == media::Decryptor::kSuccess); |
+ DCHECK(buffer); |
+ return video_decoder_->DecodeFrame(buffer.get()->GetData(), |
+ buffer->GetDataSize(), |
+ encrypted_buffer.timestamp, |
+ decoded_frame); |
#else |
- GenerateFakeVideoFrame(decoder_buffer->GetTimestamp(), video_frame); |
+ GenerateFakeVideoFrame(decoder_buffer->GetTimestamp(), decoded_frame); |
return cdm::kSuccess; |
#endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER |
} |