| 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 "media/base/decrypt_config.h" | 5 #include "media/base/decrypt_config.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace media { | 9 namespace media { |
| 10 | 10 |
| 11 DecryptConfig::DecryptConfig(const std::string& key_id, | 11 DecryptConfig::DecryptConfig(const std::string& key_id, |
| 12 const std::string& iv, | 12 const std::string& iv, |
| 13 const std::vector<SubsampleEntry>& subsamples) | 13 const std::vector<SubsampleEntry>& subsamples) |
| 14 : key_id_(key_id), | 14 : key_id_(key_id), |
| 15 iv_(iv), | 15 iv_(iv), |
| 16 subsamples_(subsamples) { | 16 subsamples_(subsamples) { |
| 17 CHECK_GT(key_id.size(), 0u); | 17 CHECK_GT(key_id.size(), 0u); |
| 18 CHECK(iv.size() == static_cast<size_t>(DecryptConfig::kDecryptionKeySize) || | 18 CHECK(iv.size() == static_cast<size_t>(DecryptConfig::kDecryptionKeySize) || |
| 19 iv.empty()); | 19 iv.empty()); |
| 20 } | 20 } |
| 21 | 21 |
| 22 DecryptConfig::~DecryptConfig() {} | 22 DecryptConfig::~DecryptConfig() {} |
| 23 | 23 |
| 24 bool DecryptConfig::Matches(const DecryptConfig& config) const { |
| 25 if (key_id() != config.key_id() || iv() != config.iv() || |
| 26 subsamples().size() != config.subsamples().size()) { |
| 27 return false; |
| 28 } |
| 29 |
| 30 for (size_t i = 0; i < subsamples().size(); ++i) { |
| 31 if ((subsamples()[i].clear_bytes != config.subsamples()[i].clear_bytes) || |
| 32 (subsamples()[i].cypher_bytes != config.subsamples()[i].cypher_bytes)) { |
| 33 return false; |
| 34 } |
| 35 } |
| 36 |
| 37 return true; |
| 38 } |
| 39 |
| 24 } // namespace media | 40 } // namespace media |
| OLD | NEW |