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

Unified Diff: webkit/media/crypto/proxy_decryptor.cc

Issue 11226019: Encrypted Media: Replace DecryptorClient with key event callbacks. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: webkit/media/crypto/proxy_decryptor.cc
diff --git a/webkit/media/crypto/proxy_decryptor.cc b/webkit/media/crypto/proxy_decryptor.cc
index 6ef4a5efee5a048ace670041f0378d9cb856ef6d..1d027093d7950b405b2e1e520b04a526e163bfb3 100644
--- a/webkit/media/crypto/proxy_decryptor.cc
+++ b/webkit/media/crypto/proxy_decryptor.cc
@@ -63,11 +63,17 @@ static void FireNeedKey(media::DecryptorClient* client,
ProxyDecryptor::ProxyDecryptor(
const scoped_refptr<base::MessageLoopProxy>& message_loop,
- media::DecryptorClient* decryptor_client,
+ const KeyAddedCB& key_added_cb,
+ const KeyErrorCB& key_error_cb,
+ const KeyMessageCB& key_message_cb,
+ const NeedKeyCB& need_key_cb,
WebKit::WebMediaPlayerClient* web_media_player_client,
WebKit::WebFrame* web_frame)
: decryption_message_loop_(message_loop),
- client_(decryptor_client),
+ key_added_cb_(key_added_cb),
+ key_error_cb_(key_error_cb),
+ key_message_cb_(key_message_cb),
+ need_key_cb_(need_key_cb),
web_media_player_client_(web_media_player_client),
web_frame_(web_frame),
is_waiting_for_decryptor_(false),
@@ -112,7 +118,7 @@ bool ProxyDecryptor::GenerateKeyRequest(const std::string& key_system,
if (!decryptor_) {
decryptor_ = CreateDecryptor(key_system);
if (!decryptor_) {
- client_->KeyError(key_system, "", media::Decryptor::kUnknownError, 0);
+ KeyError(key_system, "", media::Decryptor::kUnknownError, 0);
return false;
}
}
@@ -179,7 +185,7 @@ void ProxyDecryptor::Decrypt(
// TODO(xhwang): The same NeedKey may be fired here and multiple times in
// OnBufferDecrypted(). While the spec says only one NeedKey should be
// fired. Leave them as is since the spec about this may change.
- FireNeedKey(client_, encrypted);
+ FireNeedKey(this, encrypted);
return;
}
@@ -242,9 +248,36 @@ void ProxyDecryptor::DeinitializeDecoder(StreamType stream_type) {
NOTREACHED() << "ProxyDecryptor does not support audio/video decoding";
}
+void ProxyDecryptor::KeyAdded(const std::string& key_system,
+ const std::string& session_id) {
+ key_added_cb_.Run(key_system, session_id);
+}
+
+void ProxyDecryptor::KeyError(const std::string& key_system,
+ const std::string& session_id,
+ Decryptor::KeyError error_code,
+ int system_code) {
+ key_error_cb_.Run(key_system, session_id, error_code, system_code);
+}
+
+void ProxyDecryptor::KeyMessage(const std::string& key_system,
+ const std::string& session_id,
+ scoped_array<uint8> message,
+ int message_length,
+ const std::string& default_url) {
+ key_message_cb_.Run(
+ key_system, session_id, message.Pass(), message_length, default_url);
+}
+
+void ProxyDecryptor::NeedKey(const std::string& key_system,
+ const std::string& session_id,
+ scoped_array<uint8> init_data,
+ int init_data_length) {
+ need_key_cb_.Run(key_system, session_id, init_data.Pass(), init_data_length);
+}
Ami GONE FROM CHROMIUM 2012/10/23 06:52:22 This collection of functions is a pretty strong sm
xhwang 2012/10/23 07:32:13 If we remove DecryptorClient and use callbacks exc
Ami GONE FROM CHROMIUM 2012/10/23 07:42:54 I /think/ so... But it's late and I'm not as famil
+
scoped_ptr<media::Decryptor> ProxyDecryptor::CreatePpapiDecryptor(
const std::string& key_system) {
- DCHECK(client_);
DCHECK(web_media_player_client_);
DCHECK(web_frame_);
@@ -257,16 +290,14 @@ scoped_ptr<media::Decryptor> ProxyDecryptor::CreatePpapiDecryptor(
return scoped_ptr<media::Decryptor>();
}
- return scoped_ptr<media::Decryptor>(new PpapiDecryptor(client_,
+ return scoped_ptr<media::Decryptor>(new PpapiDecryptor(this,
plugin_instance));
}
scoped_ptr<media::Decryptor> ProxyDecryptor::CreateDecryptor(
const std::string& key_system) {
- DCHECK(client_);
-
if (CanUseAesDecryptor(key_system))
- return scoped_ptr<media::Decryptor>(new media::AesDecryptor(client_));
+ return scoped_ptr<media::Decryptor>(new media::AesDecryptor(this));
// We only support AesDecryptor and PpapiDecryptor. So if we cannot
// use the AesDecryptor, then we'll try to create a PpapiDecryptor for given
@@ -355,7 +386,7 @@ void ProxyDecryptor::OnBufferDecrypted(
// TODO(xhwang): The same NeedKey may be fired multiple times here and also
// in Decrypt(). While the spec says only one NeedKey should be fired. Leave
// them as is since the spec about this may change.
- FireNeedKey(client_, pending_buffer_to_decrypt_);
+ FireNeedKey(this, pending_buffer_to_decrypt_);
}
} // namespace webkit_media

Powered by Google App Engine
This is Rietveld 408576698