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

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

Issue 555223004: Update MediaKeys interface for EME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: base::Time Created 6 years, 2 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 10 matching lines...) Expand all
21 class SymmetricKey; 21 class SymmetricKey;
22 } 22 }
23 23
24 namespace media { 24 namespace media {
25 25
26 // Decrypts an AES encrypted buffer into an unencrypted buffer. The AES 26 // Decrypts an AES encrypted buffer into an unencrypted buffer. The AES
27 // encryption must be CTR with a key size of 128bits. 27 // encryption must be CTR with a key size of 128bits.
28 class MEDIA_EXPORT AesDecryptor : public MediaKeys, public Decryptor { 28 class MEDIA_EXPORT AesDecryptor : public MediaKeys, public Decryptor {
29 public: 29 public:
30 AesDecryptor(const SessionMessageCB& session_message_cb, 30 AesDecryptor(const SessionMessageCB& session_message_cb,
31 const SessionClosedCB& session_closed_cb); 31 const SessionClosedCB& session_closed_cb,
32 const SessionKeysChangeCB& session_keys_change_cb);
32 virtual ~AesDecryptor(); 33 virtual ~AesDecryptor();
33 34
34 // MediaKeys implementation. 35 // MediaKeys implementation.
36 virtual void SetServerCertificate(
37 const uint8* certificate_data,
38 int certificate_data_length,
39 scoped_ptr<SimpleCdmPromise> promise) OVERRIDE;
35 virtual void CreateSession(const std::string& init_data_type, 40 virtual void CreateSession(const std::string& init_data_type,
36 const uint8* init_data, 41 const uint8* init_data,
37 int init_data_length, 42 int init_data_length,
38 SessionType session_type, 43 SessionType session_type,
39 scoped_ptr<NewSessionCdmPromise> promise) OVERRIDE; 44 scoped_ptr<NewSessionCdmPromise> promise) OVERRIDE;
40 virtual void LoadSession(const std::string& web_session_id, 45 virtual void LoadSession(const std::string& web_session_id,
41 scoped_ptr<NewSessionCdmPromise> promise) OVERRIDE; 46 scoped_ptr<NewSessionCdmPromise> promise) OVERRIDE;
42 virtual void UpdateSession(const std::string& web_session_id, 47 virtual void UpdateSession(const std::string& web_session_id,
43 const uint8* response, 48 const uint8* response,
44 int response_length, 49 int response_length,
45 scoped_ptr<SimpleCdmPromise> promise) OVERRIDE; 50 scoped_ptr<SimpleCdmPromise> promise) OVERRIDE;
46 virtual void ReleaseSession(const std::string& web_session_id, 51 virtual void CloseSession(const std::string& web_session_id,
47 scoped_ptr<SimpleCdmPromise> promise) OVERRIDE; 52 scoped_ptr<SimpleCdmPromise> promise) OVERRIDE;
53 virtual void RemoveSession(const std::string& web_session_id,
54 scoped_ptr<SimpleCdmPromise> promise) OVERRIDE;
55 virtual void GetUsableKeyIds(const std::string& web_session_id,
56 scoped_ptr<KeyIdsPromise> promise) OVERRIDE;
48 virtual Decryptor* GetDecryptor() OVERRIDE; 57 virtual Decryptor* GetDecryptor() OVERRIDE;
49 58
50 // Decryptor implementation. 59 // Decryptor implementation.
51 virtual void RegisterNewKeyCB(StreamType stream_type, 60 virtual void RegisterNewKeyCB(StreamType stream_type,
52 const NewKeyCB& key_added_cb) OVERRIDE; 61 const NewKeyCB& key_added_cb) OVERRIDE;
53 virtual void Decrypt(StreamType stream_type, 62 virtual void Decrypt(StreamType stream_type,
54 const scoped_refptr<DecoderBuffer>& encrypted, 63 const scoped_refptr<DecoderBuffer>& encrypted,
55 const DecryptCB& decrypt_cb) OVERRIDE; 64 const DecryptCB& decrypt_cb) OVERRIDE;
56 virtual void CancelDecrypt(StreamType stream_type) OVERRIDE; 65 virtual void CancelDecrypt(StreamType stream_type) OVERRIDE;
57 virtual void InitializeAudioDecoder(const AudioDecoderConfig& config, 66 virtual void InitializeAudioDecoder(const AudioDecoderConfig& config,
58 const DecoderInitCB& init_cb) OVERRIDE; 67 const DecoderInitCB& init_cb) OVERRIDE;
59 virtual void InitializeVideoDecoder(const VideoDecoderConfig& config, 68 virtual void InitializeVideoDecoder(const VideoDecoderConfig& config,
60 const DecoderInitCB& init_cb) OVERRIDE; 69 const DecoderInitCB& init_cb) OVERRIDE;
61 virtual void DecryptAndDecodeAudio( 70 virtual void DecryptAndDecodeAudio(
62 const scoped_refptr<DecoderBuffer>& encrypted, 71 const scoped_refptr<DecoderBuffer>& encrypted,
63 const AudioDecodeCB& audio_decode_cb) OVERRIDE; 72 const AudioDecodeCB& audio_decode_cb) OVERRIDE;
64 virtual void DecryptAndDecodeVideo( 73 virtual void DecryptAndDecodeVideo(
65 const scoped_refptr<DecoderBuffer>& encrypted, 74 const scoped_refptr<DecoderBuffer>& encrypted,
66 const VideoDecodeCB& video_decode_cb) OVERRIDE; 75 const VideoDecodeCB& video_decode_cb) OVERRIDE;
67 virtual void ResetDecoder(StreamType stream_type) OVERRIDE; 76 virtual void ResetDecoder(StreamType stream_type) OVERRIDE;
68 virtual void DeinitializeDecoder(StreamType stream_type) OVERRIDE; 77 virtual void DeinitializeDecoder(StreamType stream_type) OVERRIDE;
69 78
70 void GetUsableKeyIds(const std::string& web_session_id,
71 scoped_ptr<KeyIdsPromise> promise);
72
73 private: 79 private:
74 // TODO(fgalligan): Remove this and change KeyMap to use crypto::SymmetricKey 80 // TODO(fgalligan): Remove this and change KeyMap to use crypto::SymmetricKey
75 // as there are no decryptors that are performing an integrity check. 81 // as there are no decryptors that are performing an integrity check.
76 // Helper class that manages the decryption key. 82 // Helper class that manages the decryption key.
77 class DecryptionKey { 83 class DecryptionKey {
78 public: 84 public:
79 explicit DecryptionKey(const std::string& secret); 85 explicit DecryptionKey(const std::string& secret);
80 ~DecryptionKey(); 86 ~DecryptionKey();
81 87
82 // Creates the encryption key. 88 // Creates the encryption key.
(...skipping 30 matching lines...) Expand all
113 // Gets a DecryptionKey associated with |key_id|. The AesDecryptor still owns 119 // Gets a DecryptionKey associated with |key_id|. The AesDecryptor still owns
114 // the key. Returns NULL if no key is associated with |key_id|. 120 // the key. Returns NULL if no key is associated with |key_id|.
115 DecryptionKey* GetKey(const std::string& key_id) const; 121 DecryptionKey* GetKey(const std::string& key_id) const;
116 122
117 // Deletes all keys associated with |web_session_id|. 123 // Deletes all keys associated with |web_session_id|.
118 void DeleteKeysForSession(const std::string& web_session_id); 124 void DeleteKeysForSession(const std::string& web_session_id);
119 125
120 // Callbacks for firing session events. 126 // Callbacks for firing session events.
121 SessionMessageCB session_message_cb_; 127 SessionMessageCB session_message_cb_;
122 SessionClosedCB session_closed_cb_; 128 SessionClosedCB session_closed_cb_;
129 SessionKeysChangeCB session_keys_change_cb_;
123 130
124 // Since only Decrypt() is called off the renderer thread, we only need to 131 // Since only Decrypt() is called off the renderer thread, we only need to
125 // protect |key_map_|, the only member variable that is shared between 132 // protect |key_map_|, the only member variable that is shared between
126 // Decrypt() and other methods. 133 // Decrypt() and other methods.
127 KeyIdToSessionKeysMap key_map_; // Protected by |key_map_lock_|. 134 KeyIdToSessionKeysMap key_map_; // Protected by |key_map_lock_|.
128 mutable base::Lock key_map_lock_; // Protects the |key_map_|. 135 mutable base::Lock key_map_lock_; // Protects the |key_map_|.
129 136
130 // Keeps track of current valid sessions. 137 // Keeps track of current valid sessions.
131 std::set<std::string> valid_sessions_; 138 std::set<std::string> valid_sessions_;
132 139
133 // Make web session ID unique per renderer by making it static. Web session 140 // Make web session ID unique per renderer by making it static. Web session
134 // IDs seen by the app will be "1", "2", etc. 141 // IDs seen by the app will be "1", "2", etc.
135 static uint32 next_web_session_id_; 142 static uint32 next_web_session_id_;
136 143
137 NewKeyCB new_audio_key_cb_; 144 NewKeyCB new_audio_key_cb_;
138 NewKeyCB new_video_key_cb_; 145 NewKeyCB new_video_key_cb_;
139 146
140 // Protect |new_audio_key_cb_| and |new_video_key_cb_| as they are set on the 147 // Protect |new_audio_key_cb_| and |new_video_key_cb_| as they are set on the
141 // main thread but called on the media thread. 148 // main thread but called on the media thread.
142 mutable base::Lock new_key_cb_lock_; 149 mutable base::Lock new_key_cb_lock_;
143 150
144 DISALLOW_COPY_AND_ASSIGN(AesDecryptor); 151 DISALLOW_COPY_AND_ASSIGN(AesDecryptor);
145 }; 152 };
146 153
147 } // namespace media 154 } // namespace media
148 155
149 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_ 156 #endif // MEDIA_CRYPTO_AES_DECRYPTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698