OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROMECAST_PUBLIC_MEDIA_CAST_DECRYPT_CONFIG_H_ | 5 #ifndef MEDIA_BASE_SUBSAMPLE_ENTRY_H_ |
6 #define CHROMECAST_PUBLIC_MEDIA_CAST_DECRYPT_CONFIG_H_ | 6 #define MEDIA_BASE_SUBSAMPLE_ENTRY_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | |
10 #include <vector> | |
11 | 9 |
12 namespace chromecast { | |
13 namespace media { | 10 namespace media { |
14 | 11 |
15 // The Common Encryption spec provides for subsample encryption, where portions | 12 // The Common Encryption spec provides for subsample encryption, where portions |
16 // of a sample are set in cleartext. A SubsampleEntry specifies the number of | 13 // 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 | 14 // 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, | 15 // 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 | 16 // 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 | 17 // should not be considered as part of decryption. This is logically equivalent |
21 // to concatenating all 'cypher_bytes' portions of subsamples, decrypting that | 18 // to concatenating all 'cypher_bytes' portions of subsamples, decrypting that |
22 // result, and then copying each byte from the decrypted block over the | 19 // result, and then copying each byte from the decrypted block over the |
23 // position of the corresponding encrypted byte. | 20 // position of the corresponding encrypted byte. |
24 struct SubsampleEntry { | 21 struct SubsampleEntry { |
25 SubsampleEntry() : clear_bytes(0), cypher_bytes(0) {} | 22 SubsampleEntry() : clear_bytes(0), cypher_bytes(0) {} |
26 SubsampleEntry(uint32_t clear_bytes, uint32_t cypher_bytes) | 23 SubsampleEntry(uint32_t clear_bytes, uint32_t cypher_bytes) |
27 : clear_bytes(clear_bytes), cypher_bytes(cypher_bytes) {} | 24 : clear_bytes(clear_bytes), cypher_bytes(cypher_bytes) {} |
28 uint32_t clear_bytes; | 25 uint32_t clear_bytes; |
29 uint32_t cypher_bytes; | 26 uint32_t cypher_bytes; |
30 }; | 27 }; |
31 | 28 |
32 // Contains all metadata needed to decrypt a media sample. | 29 } // namespace media |
33 class CastDecryptConfig { | |
34 public: | |
35 virtual ~CastDecryptConfig() {} | |
36 | 30 |
37 // Returns the ID for this sample's decryption key. | 31 #endif // MEDIA_BASE_SUBSAMPLE_ENTRY_H_ |
38 virtual const std::string& key_id() const = 0; | |
39 | |
40 // Returns the initialization vector as defined by the encryption format. | |
41 virtual const std::string& iv() const = 0; | |
42 | |
43 // Returns the clear and encrypted portions of the sample as described above. | |
44 virtual const std::vector<SubsampleEntry>& subsamples() const = 0; | |
45 }; | |
46 | |
47 } // namespace media | |
48 } // namespace chromecast | |
49 | |
50 #endif // CHROMECAST_PUBLIC_MEDIA_CAST_DECRYPT_CONFIG_H_ | |
OLD | NEW |