| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/cenc_utils.h" | 5 #include "media/cdm/cenc_utils.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "media/formats/mp4/box_definitions.h" | 8 #include "media/formats/mp4/box_definitions.h" |
| 9 #include "media/formats/mp4/box_reader.h" | 9 #include "media/formats/mp4/box_reader.h" |
| 10 | 10 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 return false; | 82 return false; |
| 83 | 83 |
| 84 // Check all children for an appropriate 'pssh' box, concatenating any | 84 // Check all children for an appropriate 'pssh' box, concatenating any |
| 85 // key IDs found. | 85 // key IDs found. |
| 86 for (const auto& child : children) { | 86 for (const auto& child : children) { |
| 87 if (child.system_id == common_system_id && child.key_ids.size() > 0) | 87 if (child.system_id == common_system_id && child.key_ids.size() > 0) |
| 88 result.insert(result.end(), child.key_ids.begin(), child.key_ids.end()); | 88 result.insert(result.end(), child.key_ids.begin(), child.key_ids.end()); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 // No matching 'pssh' box found. | |
| 93 // TODO(jrummell): This should return true only if there was at least one | |
| 94 // key ID present. However, numerous test files don't contain the 'pssh' box | |
| 95 // for Common Format, so no keys are found. http://crbug.com/460308 | |
| 96 key_ids->swap(result); | 92 key_ids->swap(result); |
| 97 return true; | 93 return key_ids->size() > 0; |
| 98 } | 94 } |
| 99 | 95 |
| 100 bool GetPsshData(const std::vector<uint8_t>& input, | 96 bool GetPsshData(const std::vector<uint8_t>& input, |
| 101 const std::vector<uint8_t>& system_id, | 97 const std::vector<uint8_t>& system_id, |
| 102 std::vector<uint8_t>* pssh_data) { | 98 std::vector<uint8_t>* pssh_data) { |
| 103 if (input.empty()) | 99 if (input.empty()) |
| 104 return false; | 100 return false; |
| 105 | 101 |
| 106 std::vector<mp4::FullProtectionSystemSpecificHeader> children; | 102 std::vector<mp4::FullProtectionSystemSpecificHeader> children; |
| 107 if (!ReadAllPsshBoxes(input, &children)) | 103 if (!ReadAllPsshBoxes(input, &children)) |
| 108 return false; | 104 return false; |
| 109 | 105 |
| 110 // Check all children for an appropriate 'pssh' box, returning |data| from | 106 // Check all children for an appropriate 'pssh' box, returning |data| from |
| 111 // the first one found. | 107 // the first one found. |
| 112 for (const auto& child : children) { | 108 for (const auto& child : children) { |
| 113 if (child.system_id == system_id) { | 109 if (child.system_id == system_id) { |
| 114 pssh_data->assign(child.data.begin(), child.data.end()); | 110 pssh_data->assign(child.data.begin(), child.data.end()); |
| 115 return true; | 111 return true; |
| 116 } | 112 } |
| 117 } | 113 } |
| 118 | 114 |
| 119 // No matching 'pssh' box found. | 115 // No matching 'pssh' box found. |
| 120 return false; | 116 return false; |
| 121 } | 117 } |
| 122 | 118 |
| 123 } // namespace media | 119 } // namespace media |
| OLD | NEW |