blob: f4117f61c5a7111d14e1244ae200bd892c5755f8 [file] [log] [blame]
liberato7014d6d2016-08-10 17:45:471// 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 Pazc306689d2018-05-29 17:48:458#include <stddef.h>
liberato7014d6d2016-08-10 17:45:479#include <stdint.h>
10
John Rummelldeb337b2018-05-09 09:02:1511#include <vector>
12
13#include "media/base/media_export.h"
14
liberato7014d6d2016-08-10 17:45:4715namespace 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.
26struct 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 Rummelldeb337b2018-05-09 09:02:1534// 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|.
37MEDIA_EXPORT bool VerifySubsamplesMatchSize(
38 const std::vector<SubsampleEntry>& subsamples,
39 size_t input_size);
40
liberato7014d6d2016-08-10 17:45:4741} // namespace media
42
43#endif // MEDIA_BASE_SUBSAMPLE_ENTRY_H_