| 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 "webcontentdecryptionmodulesession_impl.h" | 5 #include "webcontentdecryptionmodulesession_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 NOTREACHED(); | 98 NOTREACHED(); |
| 99 return MediaKeys::TEMPORARY_SESSION; | 99 return MediaKeys::TEMPORARY_SESSION; |
| 100 } | 100 } |
| 101 | 101 |
| 102 static bool SanitizeInitData(EmeInitDataType init_data_type, | 102 static bool SanitizeInitData(EmeInitDataType init_data_type, |
| 103 const unsigned char* init_data, | 103 const unsigned char* init_data, |
| 104 size_t init_data_length, | 104 size_t init_data_length, |
| 105 std::vector<uint8_t>* sanitized_init_data, | 105 std::vector<uint8_t>* sanitized_init_data, |
| 106 std::string* error_message) { | 106 std::string* error_message) { |
| 107 DCHECK_GT(init_data_length, 0u); |
| 107 if (init_data_length > limits::kMaxInitDataLength) { | 108 if (init_data_length > limits::kMaxInitDataLength) { |
| 108 error_message->assign("Initialization data too long."); | 109 error_message->assign("Initialization data too long."); |
| 109 return false; | 110 return false; |
| 110 } | 111 } |
| 111 | 112 |
| 112 switch (init_data_type) { | 113 switch (init_data_type) { |
| 113 case EmeInitDataType::WEBM: | 114 case EmeInitDataType::WEBM: |
| 115 // |init_data| for WebM is a single key. |
| 116 if (init_data_length > limits::kMaxKeyIdLength) { |
| 117 error_message->assign("Initialization data for WebM is too long."); |
| 118 return false; |
| 119 } |
| 114 sanitized_init_data->assign(init_data, init_data + init_data_length); | 120 sanitized_init_data->assign(init_data, init_data + init_data_length); |
| 115 return true; | 121 return true; |
| 116 | 122 |
| 117 case EmeInitDataType::CENC: | 123 case EmeInitDataType::CENC: |
| 118 #if defined(USE_PROPRIETARY_CODECS) | 124 #if defined(USE_PROPRIETARY_CODECS) |
| 119 sanitized_init_data->assign(init_data, init_data + init_data_length); | 125 sanitized_init_data->assign(init_data, init_data + init_data_length); |
| 120 if (!ValidatePsshInput(*sanitized_init_data)) { | 126 if (!ValidatePsshInput(*sanitized_init_data)) { |
| 121 error_message->assign("Initialization data for CENC is incorrect."); | 127 error_message->assign("Initialization data for CENC is incorrect."); |
| 122 return false; | 128 return false; |
| 123 } | 129 } |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 | 437 |
| 432 DCHECK(session_id_.empty()) << "Session ID may not be changed once set."; | 438 DCHECK(session_id_.empty()) << "Session ID may not be changed once set."; |
| 433 session_id_ = session_id; | 439 session_id_ = session_id; |
| 434 *status = | 440 *status = |
| 435 adapter_->RegisterSession(session_id_, weak_ptr_factory_.GetWeakPtr()) | 441 adapter_->RegisterSession(session_id_, weak_ptr_factory_.GetWeakPtr()) |
| 436 ? SessionInitStatus::NEW_SESSION | 442 ? SessionInitStatus::NEW_SESSION |
| 437 : SessionInitStatus::SESSION_ALREADY_EXISTS; | 443 : SessionInitStatus::SESSION_ALREADY_EXISTS; |
| 438 } | 444 } |
| 439 | 445 |
| 440 } // namespace media | 446 } // namespace media |
| OLD | NEW |