| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 int message_length, | 159 int message_length, |
| 160 const std::string& default_url) { | 160 const std::string& default_url) { |
| 161 status_ = kKeyMessage; | 161 status_ = kKeyMessage; |
| 162 session_id_ = session_id; | 162 session_id_ = session_id; |
| 163 key_message_ = message.Pass(); | 163 key_message_ = message.Pass(); |
| 164 key_message_length_ = message_length; | 164 key_message_length_ = message_length; |
| 165 } | 165 } |
| 166 | 166 |
| 167 void ClearKeyCdm::Client::NeedKey(const std::string& key_system, | 167 void ClearKeyCdm::Client::NeedKey(const std::string& key_system, |
| 168 const std::string& session_id, | 168 const std::string& session_id, |
| 169 const std::string& type, |
| 169 scoped_array<uint8> init_data, | 170 scoped_array<uint8> init_data, |
| 170 int init_data_length) { | 171 int init_data_length) { |
| 171 // In the current implementation of AesDecryptor, NeedKey is not used. | 172 // In the current implementation of AesDecryptor, NeedKey is not used. |
| 172 // If no key is available to decrypt an input buffer, it returns kNoKey to | 173 // If no key is available to decrypt an input buffer, it returns kNoKey to |
| 173 // the caller instead of firing NeedKey. | 174 // the caller instead of firing NeedKey. |
| 174 NOTREACHED(); | 175 NOTREACHED(); |
| 175 } | 176 } |
| 176 | 177 |
| 177 ClearKeyCdm::ClearKeyCdm(cdm::Allocator* allocator, cdm::CdmHost*) | 178 ClearKeyCdm::ClearKeyCdm(cdm::Allocator* allocator, cdm::CdmHost*) |
| 178 : decryptor_(&client_), | 179 : decryptor_(&client_), |
| 179 allocator_(allocator) { | 180 allocator_(allocator) { |
| 180 DCHECK(allocator_); | 181 DCHECK(allocator_); |
| 181 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) | 182 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) |
| 182 channel_count_ = 0; | 183 channel_count_ = 0; |
| 183 bits_per_channel_ = 0; | 184 bits_per_channel_ = 0; |
| 184 samples_per_second_ = 0; | 185 samples_per_second_ = 0; |
| 185 last_timestamp_ = media::kNoTimestamp(); | 186 last_timestamp_ = media::kNoTimestamp(); |
| 186 last_duration_ = media::kInfiniteDuration(); | 187 last_duration_ = media::kInfiniteDuration(); |
| 187 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 188 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
| 188 } | 189 } |
| 189 | 190 |
| 190 ClearKeyCdm::~ClearKeyCdm() {} | 191 ClearKeyCdm::~ClearKeyCdm() {} |
| 191 | 192 |
| 192 cdm::Status ClearKeyCdm::GenerateKeyRequest(const uint8_t* init_data, | 193 cdm::Status ClearKeyCdm::GenerateKeyRequest(const uint8_t* init_data, |
| 193 int init_data_size, | 194 int init_data_size, |
| 194 cdm::KeyMessage* key_request) { | 195 cdm::KeyMessage* key_request) { |
| 195 DVLOG(1) << "GenerateKeyRequest()"; | 196 DVLOG(1) << "GenerateKeyRequest()"; |
| 196 base::AutoLock auto_lock(client_lock_); | 197 base::AutoLock auto_lock(client_lock_); |
| 197 ScopedResetter<Client> auto_resetter(&client_); | 198 ScopedResetter<Client> auto_resetter(&client_); |
| 198 decryptor_.GenerateKeyRequest("", init_data, init_data_size); | 199 // TODO(xhwang): Pass type here. |
| 200 decryptor_.GenerateKeyRequest("", "", init_data, init_data_size); |
| 199 | 201 |
| 200 if (client_.status() != Client::kKeyMessage) | 202 if (client_.status() != Client::kKeyMessage) |
| 201 return cdm::kSessionError; | 203 return cdm::kSessionError; |
| 202 | 204 |
| 203 DCHECK(key_request); | 205 DCHECK(key_request); |
| 204 key_request->set_session_id(client_.session_id().data(), | 206 key_request->set_session_id(client_.session_id().data(), |
| 205 client_.session_id().size()); | 207 client_.session_id().size()); |
| 206 | 208 |
| 207 // TODO(tomfinegan): Get rid of this copy. | 209 // TODO(tomfinegan): Get rid of this copy. |
| 208 key_request->set_message(allocator_->Allocate(client_.key_message_length())); | 210 key_request->set_message(allocator_->Allocate(client_.key_message_length())); |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 | 539 |
| 538 static unsigned char color = 0; | 540 static unsigned char color = 0; |
| 539 color += 10; | 541 color += 10; |
| 540 | 542 |
| 541 memset(reinterpret_cast<void*>(video_frame->frame_buffer()->data()), | 543 memset(reinterpret_cast<void*>(video_frame->frame_buffer()->data()), |
| 542 color, frame_size); | 544 color, frame_size); |
| 543 } | 545 } |
| 544 #endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER | 546 #endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER |
| 545 | 547 |
| 546 } // namespace webkit_media | 548 } // namespace webkit_media |
| OLD | NEW |