| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <limits> |
| 11 |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 15 |
| 14 namespace media { | 16 namespace media { |
| 15 | 17 |
| 16 const uint8_t kKey1Data[] = { | 18 const uint8_t kKey1Data[] = { |
| 17 0x7E, 0x57, 0x1D, 0x03, 0x7E, 0x57, 0x1D, 0x03, | 19 0x7E, 0x57, 0x1D, 0x03, 0x7E, 0x57, 0x1D, 0x03, |
| 18 0x7E, 0x57, 0x1D, 0x03, 0x7E, 0x57, 0x1D, 0x03 | 20 0x7E, 0x57, 0x1D, 0x03, 0x7E, 0x57, 0x1D, 0x03 |
| 19 }; | 21 }; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 47 | 49 |
| 48 protected: | 50 protected: |
| 49 // Initialize the start of the 'pssh' box (up to key_count) | 51 // Initialize the start of the 'pssh' box (up to key_count) |
| 50 void InitializePSSHBox(std::vector<uint8_t>* box, | 52 void InitializePSSHBox(std::vector<uint8_t>* box, |
| 51 uint8_t size, | 53 uint8_t size, |
| 52 uint8_t version) { | 54 uint8_t version) { |
| 53 DCHECK(box->size() == 0); | 55 DCHECK(box->size() == 0); |
| 54 | 56 |
| 55 box->reserve(size); | 57 box->reserve(size); |
| 56 // Add size. | 58 // Add size. |
| 59 DCHECK(size < std::numeric_limits<uint8_t>::max()); |
| 57 box->push_back(0); | 60 box->push_back(0); |
| 58 box->push_back(0); | 61 box->push_back(0); |
| 59 box->push_back(0); | 62 box->push_back(0); |
| 60 box->push_back(size); | 63 box->push_back(size); |
| 61 // Add 'pssh'. | 64 // Add 'pssh'. |
| 62 box->push_back('p'); | 65 box->push_back('p'); |
| 63 box->push_back('s'); | 66 box->push_back('s'); |
| 64 box->push_back('s'); | 67 box->push_back('s'); |
| 65 box->push_back('h'); | 68 box->push_back('h'); |
| 66 // Add version. | 69 // Add version. |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 EXPECT_FALSE(ValidatePsshInput(boxes)); | 550 EXPECT_FALSE(ValidatePsshInput(boxes)); |
| 548 | 551 |
| 549 // Repeat with |non_pssh_box| first. | 552 // Repeat with |non_pssh_box| first. |
| 550 boxes.clear(); | 553 boxes.clear(); |
| 551 boxes.insert(boxes.end(), non_pssh_box.begin(), non_pssh_box.end()); | 554 boxes.insert(boxes.end(), non_pssh_box.begin(), non_pssh_box.end()); |
| 552 boxes.insert(boxes.end(), pssh_box.begin(), pssh_box.end()); | 555 boxes.insert(boxes.end(), pssh_box.begin(), pssh_box.end()); |
| 553 EXPECT_FALSE(ValidatePsshInput(boxes)); | 556 EXPECT_FALSE(ValidatePsshInput(boxes)); |
| 554 } | 557 } |
| 555 | 558 |
| 556 } // namespace media | 559 } // namespace media |
| OLD | NEW |