Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(845)

Side by Side Diff: media/crypto/aes_decryptor.h

Issue 10447035: Introducing DecoderBuffer and general Buffer cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Buffer Bonanza! Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_CRYPTO_AES_DECRYPTOR_H_ 5 #ifndef MEDIA_CRYPTO_AES_DECRYPTOR_H_
6 #define MEDIA_CRYPTO_AES_DECRYPTOR_H_ 6 #define MEDIA_CRYPTO_AES_DECRYPTOR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/hash_tables.h" 11 #include "base/hash_tables.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "media/base/decoder_buffer.h"
scherkus (not reviewing) 2012/05/26 01:36:32 fwd declare instead? (i.e., replace Buffer fwd dec
DaleCurtis 2012/05/29 21:17:01 Done.
14 #include "media/base/media_export.h" 15 #include "media/base/media_export.h"
15 16
16 namespace crypto { 17 namespace crypto {
17 class SymmetricKey; 18 class SymmetricKey;
18 } 19 }
19 20
20 namespace media { 21 namespace media {
21 22
22 class Buffer; 23 class Buffer;
23 24
24 // Decrypts AES encrypted buffer into unencrypted buffer. 25 // Decrypts AES encrypted buffer into unencrypted buffer.
25 class MEDIA_EXPORT AesDecryptor { 26 class MEDIA_EXPORT AesDecryptor {
26 public: 27 public:
27 AesDecryptor(); 28 AesDecryptor();
28 ~AesDecryptor(); 29 ~AesDecryptor();
29 30
30 // Add a |key_id| and |key| pair to the key system. The key is not limited to 31 // Add a |key_id| and |key| pair to the key system. The key is not limited to
31 // a decryption key. It can be any data that the key system accepts, such as 32 // a decryption key. It can be any data that the key system accepts, such as
32 // a license. If multiple calls of this function set different keys for the 33 // a license. If multiple calls of this function set different keys for the
33 // same |key_id|, the older key will be replaced by the newer key. 34 // same |key_id|, the older key will be replaced by the newer key.
34 void AddKey(const uint8* key_id, int key_id_size, 35 void AddKey(const uint8* key_id, int key_id_size,
35 const uint8* key, int key_size); 36 const uint8* key, int key_size);
36 37
37 // Decrypt |input| buffer. The |input| should not be NULL. 38 // Decrypt |input| buffer. The |input| should not be NULL.
38 // Return a Buffer that contains decrypted data if decryption succeeded. 39 // Return a Buffer that contains decrypted data if decryption succeeded.
39 // Return NULL if decryption failed. 40 // Return NULL if decryption failed.
40 scoped_refptr<Buffer> Decrypt(const scoped_refptr<Buffer>& input); 41 scoped_refptr<DecoderBuffer> Decrypt(
42 const scoped_refptr<DecoderBuffer>& input);
41 43
42 private: 44 private:
43 // KeyMap owns the crypto::SymmetricKey* and must delete them when they are 45 // KeyMap owns the crypto::SymmetricKey* and must delete them when they are
44 // not needed any more. 46 // not needed any more.
45 typedef base::hash_map<std::string, crypto::SymmetricKey*> KeyMap; 47 typedef base::hash_map<std::string, crypto::SymmetricKey*> KeyMap;
46 KeyMap key_map_; 48 KeyMap key_map_;
47 base::Lock lock_; 49 base::Lock lock_;
48 50
49 DISALLOW_COPY_AND_ASSIGN(AesDecryptor); 51 DISALLOW_COPY_AND_ASSIGN(AesDecryptor);
50 }; 52 };
51 53
52 } // namespace media 54 } // namespace media
53 55
54 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_ 56 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698