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

Side by Side Diff: webkit/media/crypto/proxy_decryptor.h

Issue 11492003: Encrypted Media: Support Audio Decrypt-Only. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments mostly resolved (I believe); need to add/update tests if this looks good Created 8 years 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 WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ 5 #ifndef WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_
6 #define WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ 6 #define WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 24 matching lines...) Expand all
35 ProxyDecryptor(const scoped_refptr<base::MessageLoopProxy>& message_loop, 35 ProxyDecryptor(const scoped_refptr<base::MessageLoopProxy>& message_loop,
36 media::DecryptorClient* decryptor_client, 36 media::DecryptorClient* decryptor_client,
37 WebKit::WebMediaPlayerClient* web_media_player_client, 37 WebKit::WebMediaPlayerClient* web_media_player_client,
38 WebKit::WebFrame* web_frame); 38 WebKit::WebFrame* web_frame);
39 virtual ~ProxyDecryptor(); 39 virtual ~ProxyDecryptor();
40 40
41 void set_decryptor_for_testing(scoped_ptr<media::Decryptor> decryptor) { 41 void set_decryptor_for_testing(scoped_ptr<media::Decryptor> decryptor) {
42 decryptor_ = decryptor.Pass(); 42 decryptor_ = decryptor.Pass();
43 } 43 }
44 44
45 // Callback to notify that the decryptor has been created. 45 // Requests the ProxyDecryptor to notify the decryptor when it's ready through
46 typedef base::Callback<void(Decryptor*)> DecryptorNotificationCB; 46 // the |decryptor_ready_cb| provided.
47 47 // If |decryptor_ready_cb| is null, the ProxyDecryptor should cancel the
48 // Requests the ProxyDecryptor to notify the decryptor creation through the 48 // existing request and fire it with NULL immediately.
49 // |decryptor_notification_cb| provided. 49 void RegisterDecryptorReadyNotification(
ddorwin 2012/12/13 05:08:25 I thought we were using "Set".
50 // If |decryptor_notification_cb| is null, the ProxyDecryptor should cancel 50 const media::DecryptorReadyCB& decryptor_ready_cb);
51 // the existing request and fire it with NULL immediately.
52 void RequestDecryptorNotification(
53 const DecryptorNotificationCB& decryptor_notification_cb);
54 51
55 // media::Decryptor implementation. 52 // media::Decryptor implementation.
56 virtual bool GenerateKeyRequest(const std::string& key_system, 53 virtual bool GenerateKeyRequest(const std::string& key_system,
57 const std::string& type, 54 const std::string& type,
58 const uint8* init_data, 55 const uint8* init_data,
59 int init_data_length) OVERRIDE; 56 int init_data_length) OVERRIDE;
60 virtual void AddKey(const std::string& key_system, 57 virtual void AddKey(const std::string& key_system,
61 const uint8* key, 58 const uint8* key,
62 int key_length, 59 int key_length,
63 const uint8* init_data, 60 const uint8* init_data,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 media::DecryptorClient* client_; 107 media::DecryptorClient* client_;
111 108
112 // Needed to create the PpapiDecryptor. 109 // Needed to create the PpapiDecryptor.
113 WebKit::WebMediaPlayerClient* web_media_player_client_; 110 WebKit::WebMediaPlayerClient* web_media_player_client_;
114 WebKit::WebFrame* web_frame_; 111 WebKit::WebFrame* web_frame_;
115 112
116 // Protects the |decryptor_|. Note that |decryptor_| itself should be thread 113 // Protects the |decryptor_|. Note that |decryptor_| itself should be thread
117 // safe as per the Decryptor interface. 114 // safe as per the Decryptor interface.
118 base::Lock lock_; 115 base::Lock lock_;
119 116
120 DecryptorNotificationCB decryptor_notification_cb_; 117 media::DecryptorReadyCB decryptor_ready_cb_;
121 118
122 // The real decryptor that does decryption for the ProxyDecryptor. 119 // The real decryptor that does decryption for the ProxyDecryptor.
123 // This pointer is protected by the |lock_|. 120 // This pointer is protected by the |lock_|.
124 scoped_ptr<media::Decryptor> decryptor_; 121 scoped_ptr<media::Decryptor> decryptor_;
125 122
126 // These two variables should be set whenever the ProxyDecryptor owes a 123 // These two variables should be set whenever the ProxyDecryptor owes a
127 // pending DecryptCB to the caller (e.g. the decoder). 124 // pending DecryptCB to the caller (e.g. the decoder).
128 // TODO(xhwang): Here and below, it seems we have too many state variables 125 // TODO(xhwang): Here and below, it seems we have too many state variables
129 // to track. Use a state enum instead! 126 // to track. Use a state enum instead!
130 scoped_refptr<media::DecoderBuffer> pending_buffer_to_decrypt_; 127 scoped_refptr<media::DecoderBuffer> pending_buffer_to_decrypt_;
(...skipping 15 matching lines...) Expand all
146 // the |pending_buffer_to_decrypt_| again if kNoKey is returned because a 143 // the |pending_buffer_to_decrypt_| again if kNoKey is returned because a
147 // new key has been added. 144 // new key has been added.
148 bool has_new_key_added_; 145 bool has_new_key_added_;
149 146
150 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor); 147 DISALLOW_COPY_AND_ASSIGN(ProxyDecryptor);
151 }; 148 };
152 149
153 } // namespace webkit_media 150 } // namespace webkit_media
154 151
155 #endif // WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_ 152 #endif // WEBKIT_MEDIA_CRYPTO_PROXY_DECRYPTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698