liberato | 7014d6d | 2016-08-10 17:45:47 | [diff] [blame] | 1 | // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef MEDIA_BASE_SUBSAMPLE_ENTRY_H_ |
| 6 | #define MEDIA_BASE_SUBSAMPLE_ENTRY_H_ |
| 7 | |
Jose Dapena Paz | c306689d | 2018-05-29 17:48:45 | [diff] [blame] | 8 | #include <stddef.h> |
liberato | 7014d6d | 2016-08-10 17:45:47 | [diff] [blame] | 9 | #include <stdint.h> |
| 10 | |
John Rummell | deb337b | 2018-05-09 09:02:15 | [diff] [blame] | 11 | #include <vector> |
| 12 | |
| 13 | #include "media/base/media_export.h" |
| 14 | |
liberato | 7014d6d | 2016-08-10 17:45:47 | [diff] [blame] | 15 | namespace media { |
| 16 | |
| 17 | // The Common Encryption spec provides for subsample encryption, where portions |
| 18 | // of a sample are set in cleartext. A SubsampleEntry specifies the number of |
| 19 | // clear and encrypted bytes in each subsample. For decryption, all of the |
| 20 | // encrypted bytes in a sample should be considered a single logical stream, |
| 21 | // regardless of how they are divided into subsamples, and the clear bytes |
| 22 | // should not be considered as part of decryption. This is logically equivalent |
| 23 | // to concatenating all 'cypher_bytes' portions of subsamples, decrypting that |
| 24 | // result, and then copying each byte from the decrypted block over the |
| 25 | // position of the corresponding encrypted byte. |
| 26 | struct SubsampleEntry { |
| 27 | SubsampleEntry() : clear_bytes(0), cypher_bytes(0) {} |
| 28 | SubsampleEntry(uint32_t clear_bytes, uint32_t cypher_bytes) |
| 29 | : clear_bytes(clear_bytes), cypher_bytes(cypher_bytes) {} |
| 30 | uint32_t clear_bytes; |
| 31 | uint32_t cypher_bytes; |
| 32 | }; |
| 33 | |
John Rummell | deb337b | 2018-05-09 09:02:15 | [diff] [blame] | 34 | // Verifies that |subsamples| correctly specifies a buffer of length |
| 35 | // |input_size|. Returns false if the total of bytes specified in |subsamples| |
| 36 | // does not match |input_size|. |
| 37 | MEDIA_EXPORT bool VerifySubsamplesMatchSize( |
| 38 | const std::vector<SubsampleEntry>& subsamples, |
| 39 | size_t input_size); |
| 40 | |
liberato | 7014d6d | 2016-08-10 17:45:47 | [diff] [blame] | 41 | } // namespace media |
| 42 | |
| 43 | #endif // MEDIA_BASE_SUBSAMPLE_ENTRY_H_ |