Chromium Code Reviews| 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 bool AesDecryptor::LoadSession(uint32 session_id, | |
| 255 const std::string& web_session_id) { | |
| 256 session_error_cb_.Run(session_id, MediaKeys::kUnknownError, 0); | |
|
ddorwin
2014/02/10 19:05:25
I don't think we need this error. For prefixed, we
xhwang
2014/02/10 22:30:55
Done.
| |
| 257 return false; | |
| 258 } | |
| 259 | |
| 254 void AesDecryptor::UpdateSession(uint32 session_id, | 260 void AesDecryptor::UpdateSession(uint32 session_id, |
| 255 const uint8* response, | 261 const uint8* response, |
| 256 int response_length) { | 262 int response_length) { |
| 257 CHECK(response); | 263 CHECK(response); |
| 258 CHECK_GT(response_length, 0); | 264 CHECK_GT(response_length, 0); |
| 259 DCHECK(valid_sessions_.find(session_id) != valid_sessions_.end()); | 265 DCHECK(valid_sessions_.find(session_id) != valid_sessions_.end()); |
| 260 | 266 |
| 261 std::string key_string(reinterpret_cast<const char*>(response), | 267 std::string key_string(reinterpret_cast<const char*>(response), |
| 262 response_length); | 268 response_length); |
| 263 KeyIdAndKeyPairs keys; | 269 KeyIdAndKeyPairs keys; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 bool AesDecryptor::DecryptionKey::Init() { | 472 bool AesDecryptor::DecryptionKey::Init() { |
| 467 CHECK(!secret_.empty()); | 473 CHECK(!secret_.empty()); |
| 468 decryption_key_.reset(crypto::SymmetricKey::Import( | 474 decryption_key_.reset(crypto::SymmetricKey::Import( |
| 469 crypto::SymmetricKey::AES, secret_)); | 475 crypto::SymmetricKey::AES, secret_)); |
| 470 if (!decryption_key_) | 476 if (!decryption_key_) |
| 471 return false; | 477 return false; |
| 472 return true; | 478 return true; |
| 473 } | 479 } |
| 474 | 480 |
| 475 } // namespace media | 481 } // namespace media |
| OLD | NEW |