Chromium Code Reviews| Index: media/cdm/cenc_utils.cc |
| diff --git a/media/cdm/cenc_utils.cc b/media/cdm/cenc_utils.cc |
| index 1e33cca361337898f0371281632af05e8b7d0759..9eda4aee7e07654148ce841daaeab3e29eb4403d 100644 |
| --- a/media/cdm/cenc_utils.cc |
| +++ b/media/cdm/cenc_utils.cc |
| @@ -15,13 +15,10 @@ namespace media { |
| // system specific header ('pssh') boxes. |
| // ref: https://w3c.github.io/encrypted-media/cenc-format.html |
| -// SystemID for the Common System. |
| -// https://w3c.github.io/encrypted-media/cenc-format.html#common-system |
| -const uint8_t kCommonSystemId[] = { 0x10, 0x77, 0xef, 0xec, |
| - 0xc0, 0xb2, 0x4d, 0x02, |
| - 0xac, 0xe3, 0x3c, 0x1e, |
| - 0x52, 0xe2, 0xfb, 0x4b }; |
| - |
| +// Returns true if |input| contains only 1 or more valid 'pssh' boxes, false |
| +// otherwise. |pssh_boxes| is updated as the set of parsed 'pssh' boxes. |
| +// Note: All boxes in |input| must be 'pssh' boxes. However, if they can't be |
| +// properly parsed (e.g. unsupported version), then they will be skipped. |
| static bool ReadAllPsshBoxes( |
| const std::vector<uint8_t>& input, |
| std::vector<mp4::FullProtectionSystemSpecificHeader>* pssh_boxes) { |
| @@ -70,27 +67,29 @@ bool ValidatePsshInput(const std::vector<uint8_t>& input) { |
| return ReadAllPsshBoxes(input, &children); |
| } |
| -bool GetKeyIdsForCommonSystemId(const std::vector<uint8_t>& input, |
| - KeyIdList* key_ids) { |
| +bool GetKeyIdsFromPsshBoxes(const std::vector<uint8_t>& pssh_boxes, |
| + const std::vector<uint8_t>& system_id, |
| + KeyIdList* key_ids) { |
| + // If there are no 'pssh' boxes then no key IDs found. |
| + if (pssh_boxes.empty()) |
| + return false; |
| + |
| + std::vector<mp4::FullProtectionSystemSpecificHeader> children; |
| + if (!ReadAllPsshBoxes(pssh_boxes, &children)) |
|
ddorwin
2015/06/25 22:49:23
We now have |pssh_boxes| passed to |input| AND |ps
jrummell
2015/06/30 00:49:12
Acknowledged.
|
| + return false; |
| + |
| + // Check all children for an appropriate 'pssh' box, returning the |
| + // key IDs found. |
| KeyIdList result; |
| - std::vector<uint8_t> common_system_id( |
| - kCommonSystemId, kCommonSystemId + arraysize(kCommonSystemId)); |
| - |
| - if (!input.empty()) { |
| - std::vector<mp4::FullProtectionSystemSpecificHeader> children; |
| - if (!ReadAllPsshBoxes(input, &children)) |
| - return false; |
| - |
| - // Check all children for an appropriate 'pssh' box, concatenating any |
| - // key IDs found. |
| - for (const auto& child : children) { |
| - if (child.system_id == common_system_id && child.key_ids.size() > 0) |
| - result.insert(result.end(), child.key_ids.begin(), child.key_ids.end()); |
| + for (const auto& child : children) { |
| + if (child.system_id == system_id) { |
| + key_ids->assign(child.key_ids.begin(), child.key_ids.end()); |
| + return key_ids->size() > 0; |
| } |
| } |
| - key_ids->swap(result); |
| - return key_ids->size() > 0; |
| + // No matching 'pssh' box found. |
| + return false; |
| } |
| bool GetPsshData(const std::vector<uint8_t>& input, |