OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 MEDIA_BASE_DECRYPT_CONFIG_H_ | 5 #ifndef MEDIA_BASE_DECRYPT_CONFIG_H_ |
6 #define MEDIA_BASE_DECRYPT_CONFIG_H_ | 6 #define MEDIA_BASE_DECRYPT_CONFIG_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 // Contains all information that a decryptor needs to decrypt a media sample. | 31 // Contains all information that a decryptor needs to decrypt a media sample. |
32 class MEDIA_EXPORT DecryptConfig { | 32 class MEDIA_EXPORT DecryptConfig { |
33 public: | 33 public: |
34 // Keys are always 128 bits. | 34 // Keys are always 128 bits. |
35 static const int kDecryptionKeySize = 16; | 35 static const int kDecryptionKeySize = 16; |
36 | 36 |
37 // |key_id| is the ID that references the decryption key for this sample. | 37 // |key_id| is the ID that references the decryption key for this sample. |
38 // |iv| is the initialization vector defined by the encrypted format. | 38 // |iv| is the initialization vector defined by the encrypted format. |
39 // Currently |iv| must be 16 bytes as defined by WebM and ISO. Or must be | 39 // Currently |iv| must be 16 bytes as defined by WebM and ISO. Or must be |
40 // empty which signals to perform the integrity check on an unencrypted | 40 // empty which signals an unencrypted frame. |
41 // frame as defined WebM. | |
42 // |checksum| is the hash value of the encrypted buffer. |checksum| is | |
43 // defined by the encrypted format and may be NULL. | |
44 // |data_offset| is the amount of data that should be discarded from the | 41 // |data_offset| is the amount of data that should be discarded from the |
45 // head of the sample buffer before applying subsample information. A | 42 // head of the sample buffer before applying subsample information. A |
46 // decrypted buffer will be shorter than an encrypted buffer by this amount. | 43 // decrypted buffer will be shorter than an encrypted buffer by this amount. |
47 // |subsamples| defines the clear and encrypted portions of the sample as | 44 // |subsamples| defines the clear and encrypted portions of the sample as |
48 // described above. A decrypted buffer will be equal in size to the sum | 45 // described above. A decrypted buffer will be equal in size to the sum |
49 // of the subsample sizes. | 46 // of the subsample sizes. |
50 // | 47 // |
51 // |data_offset| is applied after |checksum|, but before |subsamples|. | 48 // |data_offset| is applied before |subsamples|. |
52 DecryptConfig(const std::string& key_id, | 49 DecryptConfig(const std::string& key_id, |
53 const std::string& iv, | 50 const std::string& iv, |
54 const std::string& checksum, | |
55 const int data_offset, | 51 const int data_offset, |
56 const std::vector<SubsampleEntry>& subsamples); | 52 const std::vector<SubsampleEntry>& subsamples); |
57 ~DecryptConfig(); | 53 ~DecryptConfig(); |
58 | 54 |
59 const std::string& key_id() const { return key_id_; } | 55 const std::string& key_id() const { return key_id_; } |
60 const std::string& iv() const { return iv_; } | 56 const std::string& iv() const { return iv_; } |
61 const std::string& checksum() const { return checksum_; } | |
62 int data_offset() const { return data_offset_; } | 57 int data_offset() const { return data_offset_; } |
63 const std::vector<SubsampleEntry>& subsamples() const { return subsamples_; } | 58 const std::vector<SubsampleEntry>& subsamples() const { return subsamples_; } |
64 | 59 |
65 private: | 60 private: |
66 const std::string key_id_; | 61 const std::string key_id_; |
67 | 62 |
68 // Initialization vector. | 63 // Initialization vector. |
69 const std::string iv_; | 64 const std::string iv_; |
70 | 65 |
71 // Checksum of the data to be verified before decrypting the data. This may | 66 // TODO(fgalligan): Remove |data_offset_| if there is no plan to use it in |
72 // be empty for some formats. | 67 // the future. |
73 const std::string checksum_; | |
74 | |
75 // Amount of data to be discarded before applying subsample information. | 68 // Amount of data to be discarded before applying subsample information. |
76 const int data_offset_; | 69 const int data_offset_; |
77 | 70 |
78 // Subsample information. May be empty for some formats, meaning entire frame | 71 // Subsample information. May be empty for some formats, meaning entire frame |
79 // (less data ignored by data_offset_) is encrypted. | 72 // (less data ignored by data_offset_) is encrypted. |
80 const std::vector<SubsampleEntry> subsamples_; | 73 const std::vector<SubsampleEntry> subsamples_; |
81 | 74 |
82 DISALLOW_COPY_AND_ASSIGN(DecryptConfig); | 75 DISALLOW_COPY_AND_ASSIGN(DecryptConfig); |
83 }; | 76 }; |
84 | 77 |
85 } // namespace media | 78 } // namespace media |
86 | 79 |
87 #endif // MEDIA_BASE_DECRYPT_CONFIG_H_ | 80 #endif // MEDIA_BASE_DECRYPT_CONFIG_H_ |
OLD | NEW |