Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: webkit/renderer/media/crypto/ppapi/clear_key_cdm.cc

Issue 17289006: Separate CDM initialization from GenerateKeyRequest & remove key_system parameters. (Closed) Base URL: master
Patch Set: rebase only Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/renderer/media/crypto/ppapi/clear_key_cdm.h" 5 #include "webkit/renderer/media/crypto/ppapi/clear_key_cdm.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <sstream> 8 #include <sstream>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 ClearKeyCdm::Client::~Client() {} 154 ClearKeyCdm::Client::~Client() {}
155 155
156 void ClearKeyCdm::Client::Reset() { 156 void ClearKeyCdm::Client::Reset() {
157 status_ = kKeyError; 157 status_ = kKeyError;
158 session_id_.clear(); 158 session_id_.clear();
159 key_message_.clear(); 159 key_message_.clear();
160 default_url_.clear(); 160 default_url_.clear();
161 } 161 }
162 162
163 void ClearKeyCdm::Client::KeyAdded(const std::string& key_system, 163 void ClearKeyCdm::Client::KeyAdded(const std::string& session_id) {
164 const std::string& session_id) {
165 status_ = kKeyAdded; 164 status_ = kKeyAdded;
166 session_id_ = session_id; 165 session_id_ = session_id;
167 } 166 }
168 167
169 void ClearKeyCdm::Client::KeyError(const std::string& key_system, 168 void ClearKeyCdm::Client::KeyError(const std::string& session_id,
170 const std::string& session_id,
171 media::MediaKeys::KeyError error_code, 169 media::MediaKeys::KeyError error_code,
172 int system_code) { 170 int system_code) {
173 status_ = kKeyError; 171 status_ = kKeyError;
174 session_id_ = session_id; 172 session_id_ = session_id;
175 } 173 }
176 174
177 void ClearKeyCdm::Client::KeyMessage(const std::string& key_system, 175 void ClearKeyCdm::Client::KeyMessage(const std::string& session_id,
178 const std::string& session_id,
179 const std::string& message, 176 const std::string& message,
180 const std::string& default_url) { 177 const std::string& default_url) {
181 status_ = kKeyMessage; 178 status_ = kKeyMessage;
182 session_id_ = session_id; 179 session_id_ = session_id;
183 key_message_ = message; 180 key_message_ = message;
184 default_url_ = default_url; 181 default_url_ = default_url;
185 } 182 }
186 183
187 void ClearKeyCdm::Client::NeedKey(const std::string& key_system, 184 void ClearKeyCdm::Client::NeedKey(const std::string& session_id,
188 const std::string& session_id,
189 const std::string& type, 185 const std::string& type,
190 scoped_ptr<uint8[]> init_data, 186 scoped_ptr<uint8[]> init_data,
191 int init_data_length) { 187 int init_data_length) {
192 // In the current implementation of AesDecryptor, NeedKey is not used. 188 // In the current implementation of AesDecryptor, NeedKey is not used.
193 // If no key is available to decrypt an input buffer, it returns kNoKey to 189 // If no key is available to decrypt an input buffer, it returns kNoKey to
194 // the caller instead of firing NeedKey. 190 // the caller instead of firing NeedKey.
195 NOTREACHED(); 191 NOTREACHED();
196 } 192 }
197 193
198 ClearKeyCdm::ClearKeyCdm(cdm::Host* host) 194 ClearKeyCdm::ClearKeyCdm(cdm::Host* host)
(...skipping 14 matching lines...) Expand all
213 } 209 }
214 210
215 ClearKeyCdm::~ClearKeyCdm() {} 211 ClearKeyCdm::~ClearKeyCdm() {}
216 212
217 cdm::Status ClearKeyCdm::GenerateKeyRequest(const char* type, int type_size, 213 cdm::Status ClearKeyCdm::GenerateKeyRequest(const char* type, int type_size,
218 const uint8_t* init_data, 214 const uint8_t* init_data,
219 int init_data_size) { 215 int init_data_size) {
220 DVLOG(1) << "GenerateKeyRequest()"; 216 DVLOG(1) << "GenerateKeyRequest()";
221 base::AutoLock auto_lock(client_lock_); 217 base::AutoLock auto_lock(client_lock_);
222 ScopedResetter<Client> auto_resetter(&client_); 218 ScopedResetter<Client> auto_resetter(&client_);
223 decryptor_.GenerateKeyRequest(kExternalClearKey, 219 decryptor_.GenerateKeyRequest(std::string(type, type_size),
224 std::string(type, type_size),
225 init_data, init_data_size); 220 init_data, init_data_size);
226 221
227 if (client_.status() != Client::kKeyMessage) { 222 if (client_.status() != Client::kKeyMessage) {
228 host_->SendKeyError(NULL, 0, cdm::kUnknownError, 0); 223 host_->SendKeyError(NULL, 0, cdm::kUnknownError, 0);
229 return cdm::kSessionError; 224 return cdm::kSessionError;
230 } 225 }
231 226
232 host_->SendKeyMessage( 227 host_->SendKeyMessage(
233 client_.session_id().data(), client_.session_id().size(), 228 client_.session_id().data(), client_.session_id().size(),
234 client_.key_message().data(), client_.key_message().size(), 229 client_.key_message().data(), client_.key_message().size(),
235 client_.default_url().data(), client_.default_url().size()); 230 client_.default_url().data(), client_.default_url().size());
236 231
237 // Only save the latest session ID for heartbeat messages. 232 // Only save the latest session ID for heartbeat messages.
238 heartbeat_session_id_ = client_.session_id(); 233 heartbeat_session_id_ = client_.session_id();
239 234
240 return cdm::kSuccess; 235 return cdm::kSuccess;
241 } 236 }
242 237
243 cdm::Status ClearKeyCdm::AddKey(const char* session_id, 238 cdm::Status ClearKeyCdm::AddKey(const char* session_id,
244 int session_id_size, 239 int session_id_size,
245 const uint8_t* key, 240 const uint8_t* key,
246 int key_size, 241 int key_size,
247 const uint8_t* key_id, 242 const uint8_t* key_id,
248 int key_id_size) { 243 int key_id_size) {
249 DVLOG(1) << "AddKey()"; 244 DVLOG(1) << "AddKey()";
250 base::AutoLock auto_lock(client_lock_); 245 base::AutoLock auto_lock(client_lock_);
251 ScopedResetter<Client> auto_resetter(&client_); 246 ScopedResetter<Client> auto_resetter(&client_);
252 decryptor_.AddKey(std::string(), 247 decryptor_.AddKey(key, key_size, key_id, key_id_size,
253 key,
254 key_size,
255 key_id,
256 key_id_size,
257 std::string(session_id, session_id_size)); 248 std::string(session_id, session_id_size));
258 249
259 if (client_.status() != Client::kKeyAdded) 250 if (client_.status() != Client::kKeyAdded)
260 return cdm::kSessionError; 251 return cdm::kSessionError;
261 252
262 if (!timer_set_) { 253 if (!timer_set_) {
263 ScheduleNextHeartBeat(); 254 ScheduleNextHeartBeat();
264 timer_set_ = true; 255 timer_set_ = true;
265 } 256 }
266 257
267 return cdm::kSuccess; 258 return cdm::kSuccess;
268 } 259 }
269 260
270 cdm::Status ClearKeyCdm::CancelKeyRequest(const char* session_id, 261 cdm::Status ClearKeyCdm::CancelKeyRequest(const char* session_id,
271 int session_id_size) { 262 int session_id_size) {
272 DVLOG(1) << "CancelKeyRequest()"; 263 DVLOG(1) << "CancelKeyRequest()";
273 base::AutoLock auto_lock(client_lock_); 264 base::AutoLock auto_lock(client_lock_);
274 ScopedResetter<Client> auto_resetter(&client_); 265 ScopedResetter<Client> auto_resetter(&client_);
275 decryptor_.CancelKeyRequest(std::string(), 266 decryptor_.CancelKeyRequest(std::string(session_id, session_id_size));
276 std::string(session_id, session_id_size));
277 return cdm::kSuccess; 267 return cdm::kSuccess;
278 } 268 }
279 269
280 void ClearKeyCdm::TimerExpired(void* context) { 270 void ClearKeyCdm::TimerExpired(void* context) {
281 std::string heartbeat_message; 271 std::string heartbeat_message;
282 if (!next_heartbeat_message_.empty() && 272 if (!next_heartbeat_message_.empty() &&
283 context == &next_heartbeat_message_[0]) { 273 context == &next_heartbeat_message_[0]) {
284 heartbeat_message = next_heartbeat_message_; 274 heartbeat_message = next_heartbeat_message_;
285 } else { 275 } else {
286 heartbeat_message = "ERROR: Invalid timer context found!"; 276 heartbeat_message = "ERROR: Invalid timer context found!";
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 int samples_generated = GenerateFakeAudioFramesFromDuration( 559 int samples_generated = GenerateFakeAudioFramesFromDuration(
570 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(), 560 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(),
571 audio_frames); 561 audio_frames);
572 total_samples_generated_ += samples_generated; 562 total_samples_generated_ += samples_generated;
573 563
574 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess; 564 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess;
575 } 565 }
576 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER 566 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER
577 567
578 } // namespace webkit_media 568 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/renderer/media/crypto/ppapi/clear_key_cdm.h ('k') | webkit/renderer/media/crypto/ppapi_decryptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698