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 6f7ea09284167abe3222a513dddd72c095a7a06e..ff26421cb6ce2edfb50c4a7075ebf9eda2e71e17 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"; |
| @@ -63,12 +68,27 @@ static Type* AllocateAndCopy(const Type* data, int size) { |
| return copy; |
| } |
| +// This is required for running in the sandbox, and should no longer be required |
| +// after http://crbug.com/91970 is fixed. |
| +static bool InitializeFFmpegLibraries() { |
| + FilePath file_path; |
| + CHECK(PathService::Get(base::DIR_EXE, &file_path)); |
| + CHECK(media::InitializeMediaLibrary(file_path)); |
| + return true; |
| +} |
| + |
| +static base::AtExitManager g_at_exit_manager; |
| +static bool g_cdm_module_initialized = InitializeFFmpegLibraries(); |
| + |
| cdm::ContentDecryptionModule* CreateCdmInstance( |
| cdm::Allocator* allocator, cdm::CdmHost* host) { |
| + DVLOG(1) << "CreateCdmInstance()"; |
| + CHECK(g_cdm_module_initialized); |
|
ddorwin
2012/10/22 23:31:35
I don't think we need this.
Tom Finegan
2012/10/23 00:12:14
Done.
|
| return new webkit_media::ClearKeyCdm(allocator, host); |
| } |
| void DestroyCdmInstance(cdm::ContentDecryptionModule* instance) { |
| + DVLOG(1) << "DestroyCdmInstance()"; |
| delete instance; |
| } |
| @@ -245,27 +265,36 @@ cdm::Status ClearKeyCdm::InitializeAudioDecoder( |
| cdm::Status ClearKeyCdm::InitializeVideoDecoder( |
| const cdm::VideoDecoderConfig& video_decoder_config) { |
| #if !defined(CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER) |
|
ddorwin
2012/10/22 23:31:35
The correct fix for non-FFmpeg-using platforms is
Tom Finegan
2012/10/23 00:12:14
Done.
|
| - 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) |
|
ddorwin
2012/10/22 23:31:35
These would be #if defined(ENABLE_DECODE_SUPPORT),
Tom Finegan
2012/10/23 00:12:14
Didn't do this yet. Ok to leave for another CL?
|
| + 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 +315,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 |
| } |