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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
11 | 11 |
12 namespace media { | 12 namespace media { |
13 | 13 |
14 // Contains all information that a decryptor needs to decrypt a frame. | 14 // Contains all information that a decryptor needs to decrypt. |
15 class MEDIA_EXPORT DecryptConfig { | 15 class MEDIA_EXPORT DecryptConfig { |
16 public: | 16 public: |
17 // Keys are always 128 bits. | 17 explicit DecryptConfig(const uint8* key_id, int key_id_size); |
18 static const int kDecryptionKeySize = 16; | |
19 | |
20 // |key_id| is the ID that references the decryption key for this frame. |iv| | |
21 // is the initialization vector defined by the encrypted format. Currently | |
22 // |iv_size| must be 16 bytes as defined by WebM and ISO. |checksum| is the | |
23 // hash value of the encrypted buffer. |checksum| is defined by the | |
24 // encrypted format and may be NULL. |encrypted_frame_offset| is the offset | |
25 // into the encrypted buffer that the encrypted frame starts. The class | |
26 // will copy the data from |key_id|, |iv|, and |checksum|. | |
27 DecryptConfig(const uint8* key_id, int key_id_size, | |
28 const uint8* iv, int iv_size, | |
29 const uint8* checksum, int checksum_size, | |
30 int encrypted_frame_offset); | |
31 ~DecryptConfig(); | 18 ~DecryptConfig(); |
32 | 19 |
33 const uint8* key_id() const { return key_id_.get(); } | 20 const uint8* key_id() const { return key_id_.get(); } |
34 int key_id_size() const { return key_id_size_; } | 21 int key_id_size() const { return key_id_size_; } |
35 const uint8* iv() const { return iv_.get(); } | |
36 int iv_size() const { return iv_size_; } | |
37 const uint8* checksum() const { return checksum_.get(); } | |
38 int checksum_size() const { return checksum_size_; } | |
39 int encrypted_frame_offset() const { return encrypted_frame_offset_; } | |
40 | 22 |
41 private: | 23 private: |
42 const scoped_array<uint8> key_id_; | 24 scoped_array<uint8> key_id_; |
43 const int key_id_size_; | 25 int key_id_size_; |
44 | |
45 // Initialization vector. | |
46 const scoped_array<uint8> iv_; | |
47 const int iv_size_; | |
48 | |
49 // Checksum of the data to be verified before decrypting the data. This may | |
50 // be NULL for some formats. | |
51 const scoped_array<uint8> checksum_; | |
52 const int checksum_size_; | |
53 | |
54 // This is the offset in bytes to where the encrypted data starts within | |
55 // the input buffer. | |
56 const int encrypted_frame_offset_; | |
57 | 26 |
58 DISALLOW_COPY_AND_ASSIGN(DecryptConfig); | 27 DISALLOW_COPY_AND_ASSIGN(DecryptConfig); |
59 }; | 28 }; |
60 | 29 |
61 } // namespace media | 30 } // namespace media |
62 | 31 |
63 #endif // MEDIA_BASE_DECRYPT_CONFIG_H_ | 32 #endif // MEDIA_BASE_DECRYPT_CONFIG_H_ |
OLD | NEW |