subsample_entry.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #ifndef MEDIA_BASE_SUBSAMPLE_ENTRY_H_
  5. #define MEDIA_BASE_SUBSAMPLE_ENTRY_H_
  6. #include <stddef.h>
  7. #include <stdint.h>
  8. #include <vector>
  9. #include "media/base/media_export.h"
  10. namespace media {
  11. // The Common Encryption spec provides for subsample encryption, where portions
  12. // of a sample are set in cleartext. A SubsampleEntry specifies the number of
  13. // clear and encrypted bytes in each subsample. For decryption, all of the
  14. // encrypted bytes in a sample should be considered a single logical stream,
  15. // regardless of how they are divided into subsamples, and the clear bytes
  16. // should not be considered as part of decryption. This is logically equivalent
  17. // to concatenating all 'cypher_bytes' portions of subsamples, decrypting that
  18. // result, and then copying each byte from the decrypted block over the
  19. // position of the corresponding encrypted byte.
  20. struct SubsampleEntry {
  21. SubsampleEntry() : clear_bytes(0), cypher_bytes(0) {}
  22. SubsampleEntry(uint32_t clear_bytes, uint32_t cypher_bytes)
  23. : clear_bytes(clear_bytes), cypher_bytes(cypher_bytes) {}
  24. uint32_t clear_bytes;
  25. uint32_t cypher_bytes;
  26. };
  27. // Verifies that |subsamples| correctly specifies a buffer of length
  28. // |input_size|. Returns false if the total of bytes specified in |subsamples|
  29. // does not match |input_size|.
  30. MEDIA_EXPORT bool VerifySubsamplesMatchSize(
  31. const std::vector<SubsampleEntry>& subsamples,
  32. size_t input_size);
  33. } // namespace media
  34. #endif // MEDIA_BASE_SUBSAMPLE_ENTRY_H_