Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chromecast / public / media / cast_decrypt_config.h
blob582bce9b0297af6df7bcbf6a06f4bca97b9da252
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
3 // found in the LICENSE file.
5 #ifndef CHROMECAST_PUBLIC_MEDIA_CAST_DECRYPT_CONFIG_H_
6 #define CHROMECAST_PUBLIC_MEDIA_CAST_DECRYPT_CONFIG_H_
8 #include <stdint.h>
9 #include <string>
10 #include <vector>
12 namespace chromecast {
13 namespace media {
15 // The Common Encryption spec provides for subsample encryption, where portions
16 // of a sample are set in cleartext. A SubsampleEntry specifies the number of
17 // clear and encrypted bytes in each subsample. For decryption, all of the
18 // encrypted bytes in a sample should be considered a single logical stream,
19 // regardless of how they are divided into subsamples, and the clear bytes
20 // should not be considered as part of decryption. This is logically equivalent
21 // to concatenating all 'cypher_bytes' portions of subsamples, decrypting that
22 // result, and then copying each byte from the decrypted block over the
23 // position of the corresponding encrypted byte.
24 struct SubsampleEntry {
25 SubsampleEntry() : clear_bytes(0), cypher_bytes(0) {}
26 SubsampleEntry(uint32_t clear_bytes, uint32_t cypher_bytes)
27 : clear_bytes(clear_bytes), cypher_bytes(cypher_bytes) {}
28 uint32_t clear_bytes;
29 uint32_t cypher_bytes;
32 // Contains all metadata needed to decrypt a media sample.
33 class CastDecryptConfig {
34 public:
35 virtual ~CastDecryptConfig() {}
37 // Returns the ID for this sample's decryption key.
38 virtual const std::string& key_id() const = 0;
40 // Returns the initialization vector as defined by the encryption format.
41 virtual const std::string& iv() const = 0;
43 // Returns the clear and encrypted portions of the sample as described above.
44 virtual const std::vector<SubsampleEntry>& subsamples() const = 0;
47 } // namespace media
48 } // namespace chromecast
50 #endif // CHROMECAST_PUBLIC_MEDIA_CAST_DECRYPT_CONFIG_H_