| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 session_id_ = session_id; | 168 session_id_ = session_id; |
| 169 } | 169 } |
| 170 | 170 |
| 171 void ClearKeyCdm::Client::KeyMessage(const std::string& key_system, | 171 void ClearKeyCdm::Client::KeyMessage(const std::string& key_system, |
| 172 const std::string& session_id, | 172 const std::string& session_id, |
| 173 const std::string& message, | 173 const std::string& message, |
| 174 const std::string& default_url) { | 174 const std::string& default_url) { |
| 175 status_ = kKeyMessage; | 175 status_ = kKeyMessage; |
| 176 session_id_ = session_id; | 176 session_id_ = session_id; |
| 177 key_message_ = message; | 177 key_message_ = message; |
| 178 default_url_ = default_url; |
| 178 } | 179 } |
| 179 | 180 |
| 180 void ClearKeyCdm::Client::NeedKey(const std::string& key_system, | 181 void ClearKeyCdm::Client::NeedKey(const std::string& key_system, |
| 181 const std::string& session_id, | 182 const std::string& session_id, |
| 182 const std::string& type, | 183 const std::string& type, |
| 183 scoped_array<uint8> init_data, | 184 scoped_array<uint8> init_data, |
| 184 int init_data_length) { | 185 int init_data_length) { |
| 185 // In the current implementation of AesDecryptor, NeedKey is not used. | 186 // In the current implementation of AesDecryptor, NeedKey is not used. |
| 186 // If no key is available to decrypt an input buffer, it returns kNoKey to | 187 // If no key is available to decrypt an input buffer, it returns kNoKey to |
| 187 // the caller instead of firing NeedKey. | 188 // the caller instead of firing NeedKey. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 cdm::Status ClearKeyCdm::CancelKeyRequest(const char* session_id, | 259 cdm::Status ClearKeyCdm::CancelKeyRequest(const char* session_id, |
| 259 int session_id_size) { | 260 int session_id_size) { |
| 260 DVLOG(1) << "CancelKeyRequest()"; | 261 DVLOG(1) << "CancelKeyRequest()"; |
| 261 base::AutoLock auto_lock(client_lock_); | 262 base::AutoLock auto_lock(client_lock_); |
| 262 ScopedResetter<Client> auto_resetter(&client_); | 263 ScopedResetter<Client> auto_resetter(&client_); |
| 263 decryptor_.CancelKeyRequest("", std::string(session_id, session_id_size)); | 264 decryptor_.CancelKeyRequest("", std::string(session_id, session_id_size)); |
| 264 return cdm::kSuccess; | 265 return cdm::kSuccess; |
| 265 } | 266 } |
| 266 | 267 |
| 267 void ClearKeyCdm::TimerExpired(void* context) { | 268 void ClearKeyCdm::TimerExpired(void* context) { |
| 268 std::string heartbeat_message = | 269 std::string heartbeat_message; |
| 269 (!next_heartbeat_message_.empty() && | 270 if (!next_heartbeat_message_.empty() && |
| 270 context == &next_heartbeat_message_[0]) ? | 271 context == &next_heartbeat_message_[0]) { |
| 271 next_heartbeat_message_ : | 272 heartbeat_message = next_heartbeat_message_; |
| 272 "ERROR: Invalid timer context found!"; | 273 } else { |
| 274 heartbeat_message = "ERROR: Invalid timer context found!"; |
| 275 } |
| 276 |
| 277 // This URL is only used for testing the code path for defaultURL. |
| 278 // There is no service at this URL, so applications should ignore it. |
| 279 const char url[] = "http://test.externalclearkey.chromium.org"; |
| 273 | 280 |
| 274 host_->SendKeyMessage( | 281 host_->SendKeyMessage( |
| 275 heartbeat_session_id_.data(), heartbeat_session_id_.size(), | 282 heartbeat_session_id_.data(), heartbeat_session_id_.size(), |
| 276 heartbeat_message.data(), heartbeat_message.size(), | 283 heartbeat_message.data(), heartbeat_message.size(), |
| 277 NULL, 0); | 284 url, arraysize(url) - 1); |
| 278 | 285 |
| 279 ScheduleNextHeartBeat(); | 286 ScheduleNextHeartBeat(); |
| 280 } | 287 } |
| 281 | 288 |
| 282 static void CopyDecryptResults( | 289 static void CopyDecryptResults( |
| 283 media::Decryptor::Status* status_copy, | 290 media::Decryptor::Status* status_copy, |
| 284 scoped_refptr<media::DecoderBuffer>* buffer_copy, | 291 scoped_refptr<media::DecoderBuffer>* buffer_copy, |
| 285 media::Decryptor::Status status, | 292 media::Decryptor::Status status, |
| 286 const scoped_refptr<media::DecoderBuffer>& buffer) { | 293 const scoped_refptr<media::DecoderBuffer>& buffer) { |
| 287 *status_copy = status; | 294 *status_copy = status; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 int samples_generated = GenerateFakeAudioFramesFromDuration( | 542 int samples_generated = GenerateFakeAudioFramesFromDuration( |
| 536 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(), | 543 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(), |
| 537 audio_frames); | 544 audio_frames); |
| 538 total_samples_generated_ += samples_generated; | 545 total_samples_generated_ += samples_generated; |
| 539 | 546 |
| 540 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess; | 547 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess; |
| 541 } | 548 } |
| 542 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 549 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
| 543 | 550 |
| 544 } // namespace webkit_media | 551 } // namespace webkit_media |
| OLD | NEW |