OLD | NEW |
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 "media/cdm/aes_decryptor.h" | 5 #include "media/cdm/aes_decryptor.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 session_message_cb_(session_message_cb), | 224 session_message_cb_(session_message_cb), |
225 session_ready_cb_(session_ready_cb), | 225 session_ready_cb_(session_ready_cb), |
226 session_closed_cb_(session_closed_cb), | 226 session_closed_cb_(session_closed_cb), |
227 session_error_cb_(session_error_cb) {} | 227 session_error_cb_(session_error_cb) {} |
228 | 228 |
229 AesDecryptor::~AesDecryptor() { | 229 AesDecryptor::~AesDecryptor() { |
230 key_map_.clear(); | 230 key_map_.clear(); |
231 } | 231 } |
232 | 232 |
233 bool AesDecryptor::CreateSession(uint32 session_id, | 233 bool AesDecryptor::CreateSession(uint32 session_id, |
234 const std::string& type, | 234 const std::string& content_type, |
235 const uint8* init_data, | 235 const uint8* init_data, |
236 int init_data_length) { | 236 int init_data_length) { |
237 // Validate that this is a new session. | 237 // Validate that this is a new session. |
238 DCHECK(valid_sessions_.find(session_id) == valid_sessions_.end()); | 238 DCHECK(valid_sessions_.find(session_id) == valid_sessions_.end()); |
239 valid_sessions_.insert(session_id); | 239 valid_sessions_.insert(session_id); |
240 | 240 |
241 std::string web_session_id_string(base::UintToString(next_web_session_id_++)); | 241 std::string web_session_id_string(base::UintToString(next_web_session_id_++)); |
242 | 242 |
243 // For now, the AesDecryptor does not care about |type|; | 243 // For now, the AesDecryptor does not care about |content_type|; |
244 // just fire the event with the |init_data| as the request. | 244 // just fire the event with the |init_data| as the request. |
245 std::vector<uint8> message; | 245 std::vector<uint8> message; |
246 if (init_data && init_data_length) | 246 if (init_data && init_data_length) |
247 message.assign(init_data, init_data + init_data_length); | 247 message.assign(init_data, init_data + init_data_length); |
248 | 248 |
249 session_created_cb_.Run(session_id, web_session_id_string); | 249 session_created_cb_.Run(session_id, web_session_id_string); |
250 session_message_cb_.Run(session_id, message, std::string()); | 250 session_message_cb_.Run(session_id, message, std::string()); |
251 return true; | 251 return true; |
252 } | 252 } |
253 | 253 |
| 254 void AesDecryptor::LoadSession(uint32 session_id, |
| 255 const std::string& web_session_id) { |
| 256 // TODO(xhwang): Change this to NOTREACHED() when blink checks for key systems |
| 257 // that do not support loadSession. See http://crbug.com/342481 |
| 258 session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0); |
| 259 } |
| 260 |
254 void AesDecryptor::UpdateSession(uint32 session_id, | 261 void AesDecryptor::UpdateSession(uint32 session_id, |
255 const uint8* response, | 262 const uint8* response, |
256 int response_length) { | 263 int response_length) { |
257 CHECK(response); | 264 CHECK(response); |
258 CHECK_GT(response_length, 0); | 265 CHECK_GT(response_length, 0); |
259 DCHECK(valid_sessions_.find(session_id) != valid_sessions_.end()); | 266 DCHECK(valid_sessions_.find(session_id) != valid_sessions_.end()); |
260 | 267 |
261 std::string key_string(reinterpret_cast<const char*>(response), | 268 std::string key_string(reinterpret_cast<const char*>(response), |
262 response_length); | 269 response_length); |
263 KeyIdAndKeyPairs keys; | 270 KeyIdAndKeyPairs keys; |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 bool AesDecryptor::DecryptionKey::Init() { | 473 bool AesDecryptor::DecryptionKey::Init() { |
467 CHECK(!secret_.empty()); | 474 CHECK(!secret_.empty()); |
468 decryption_key_.reset(crypto::SymmetricKey::Import( | 475 decryption_key_.reset(crypto::SymmetricKey::Import( |
469 crypto::SymmetricKey::AES, secret_)); | 476 crypto::SymmetricKey::AES, secret_)); |
470 if (!decryption_key_) | 477 if (!decryption_key_) |
471 return false; | 478 return false; |
472 return true; | 479 return true; |
473 } | 480 } |
474 | 481 |
475 } // namespace media | 482 } // namespace media |
OLD | NEW |