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