| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/media/crypto/ppapi/clear_key_cdm.h" | 5 #include "webkit/media/crypto/ppapi/clear_key_cdm.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 FilePath file_path; | 47 FilePath file_path; |
| 48 CHECK(PathService::Get(base::DIR_EXE, &file_path)); | 48 CHECK(PathService::Get(base::DIR_EXE, &file_path)); |
| 49 CHECK(media::InitializeMediaLibrary(file_path)); | 49 CHECK(media::InitializeMediaLibrary(file_path)); |
| 50 return true; | 50 return true; |
| 51 } | 51 } |
| 52 | 52 |
| 53 static bool g_cdm_module_initialized = InitializeFFmpegLibraries(); | 53 static bool g_cdm_module_initialized = InitializeFFmpegLibraries(); |
| 54 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER | 54 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER |
| 55 | 55 |
| 56 static const char kClearKeyCdmVersion[] = "0.1.0.0"; | 56 static const char kClearKeyCdmVersion[] = "0.1.0.0"; |
| 57 static const char kExternalClearKey[] = "org.chromium.externalclearkey"; |
| 57 | 58 |
| 58 // Copies |input_buffer| into a media::DecoderBuffer. If the |input_buffer| is | 59 // Copies |input_buffer| into a media::DecoderBuffer. If the |input_buffer| is |
| 59 // empty, an empty (end-of-stream) media::DecoderBuffer is returned. | 60 // empty, an empty (end-of-stream) media::DecoderBuffer is returned. |
| 60 static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom( | 61 static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom( |
| 61 const cdm::InputBuffer& input_buffer) { | 62 const cdm::InputBuffer& input_buffer) { |
| 62 if (!input_buffer.data) { | 63 if (!input_buffer.data) { |
| 63 DCHECK_EQ(input_buffer.data_size, 0); | 64 DCHECK_EQ(input_buffer.data_size, 0); |
| 64 return media::DecoderBuffer::CreateEOSBuffer(); | 65 return media::DecoderBuffer::CreateEOSBuffer(); |
| 65 } | 66 } |
| 66 | 67 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 return copy; | 110 return copy; |
| 110 } | 111 } |
| 111 | 112 |
| 112 void INITIALIZE_CDM_MODULE() { | 113 void INITIALIZE_CDM_MODULE() { |
| 113 av_register_all(); | 114 av_register_all(); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void DeInitializeCdmModule() { | 117 void DeInitializeCdmModule() { |
| 117 } | 118 } |
| 118 | 119 |
| 119 cdm::ContentDecryptionModule* CreateCdmInstance( | 120 cdm::ContentDecryptionModule* CreateCdmInstance(const char* key_system_arg, |
| 120 cdm::Allocator* allocator, cdm::CdmHost* host) { | 121 int key_system_size, |
| 122 cdm::Allocator* allocator, |
| 123 cdm::CdmHost* host) { |
| 121 DVLOG(1) << "CreateCdmInstance()"; | 124 DVLOG(1) << "CreateCdmInstance()"; |
| 125 DCHECK_EQ(std::string(key_system_arg, key_system_size), kExternalClearKey); |
| 122 return new webkit_media::ClearKeyCdm(allocator, host); | 126 return new webkit_media::ClearKeyCdm(allocator, host); |
| 123 } | 127 } |
| 124 | 128 |
| 125 void DestroyCdmInstance(cdm::ContentDecryptionModule* instance) { | 129 void DestroyCdmInstance(cdm::ContentDecryptionModule* instance) { |
| 126 DVLOG(1) << "DestroyCdmInstance()"; | 130 DVLOG(1) << "DestroyCdmInstance()"; |
| 127 delete instance; | 131 delete instance; |
| 128 } | 132 } |
| 129 | 133 |
| 130 const char* GetCdmVersion() { | 134 const char* GetCdmVersion() { |
| 131 return kClearKeyCdmVersion; | 135 return kClearKeyCdmVersion; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 channel_count_ = 0; | 193 channel_count_ = 0; |
| 190 bits_per_channel_ = 0; | 194 bits_per_channel_ = 0; |
| 191 samples_per_second_ = 0; | 195 samples_per_second_ = 0; |
| 192 output_timestamp_base_in_microseconds_ = kNoTimestamp; | 196 output_timestamp_base_in_microseconds_ = kNoTimestamp; |
| 193 total_samples_generated_ = 0; | 197 total_samples_generated_ = 0; |
| 194 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 198 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
| 195 } | 199 } |
| 196 | 200 |
| 197 ClearKeyCdm::~ClearKeyCdm() {} | 201 ClearKeyCdm::~ClearKeyCdm() {} |
| 198 | 202 |
| 199 cdm::Status ClearKeyCdm::GenerateKeyRequest(const uint8_t* init_data, | 203 cdm::Status ClearKeyCdm::GenerateKeyRequest(const char* type, int type_size, |
| 204 const uint8_t* init_data, |
| 200 int init_data_size, | 205 int init_data_size, |
| 201 cdm::KeyMessage* key_request) { | 206 cdm::KeyMessage* key_request) { |
| 202 DVLOG(1) << "GenerateKeyRequest()"; | 207 DVLOG(1) << "GenerateKeyRequest()"; |
| 203 base::AutoLock auto_lock(client_lock_); | 208 base::AutoLock auto_lock(client_lock_); |
| 204 ScopedResetter<Client> auto_resetter(&client_); | 209 ScopedResetter<Client> auto_resetter(&client_); |
| 205 // TODO(tomfinegan): Pass "type" here once ContentDecryptionModule is updated. | 210 decryptor_.GenerateKeyRequest(kExternalClearKey, |
| 206 decryptor_.GenerateKeyRequest("", "", init_data, init_data_size); | 211 std::string(type, type_size), |
| 212 init_data, init_data_size); |
| 207 | 213 |
| 208 if (client_.status() != Client::kKeyMessage) | 214 if (client_.status() != Client::kKeyMessage) |
| 209 return cdm::kSessionError; | 215 return cdm::kSessionError; |
| 210 | 216 |
| 211 DCHECK(key_request); | 217 DCHECK(key_request); |
| 212 key_request->set_session_id(client_.session_id().data(), | 218 key_request->set_session_id(client_.session_id().data(), |
| 213 client_.session_id().size()); | 219 client_.session_id().size()); |
| 214 | 220 |
| 215 // TODO(tomfinegan): Get rid of this copy. | 221 // TODO(tomfinegan): Get rid of this copy. |
| 216 key_request->set_message(allocator_->Allocate(client_.key_message_length())); | 222 key_request->set_message(allocator_->Allocate(client_.key_message_length())); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 | 561 |
| 556 static unsigned char color = 0; | 562 static unsigned char color = 0; |
| 557 color += 10; | 563 color += 10; |
| 558 | 564 |
| 559 memset(reinterpret_cast<void*>(video_frame->frame_buffer()->data()), | 565 memset(reinterpret_cast<void*>(video_frame->frame_buffer()->data()), |
| 560 color, frame_size); | 566 color, frame_size); |
| 561 } | 567 } |
| 562 #endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER | 568 #endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER |
| 563 | 569 |
| 564 } // namespace webkit_media | 570 } // namespace webkit_media |
| OLD | NEW |