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

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

Issue 11091005: Update PluginInstance for decrypt-and-decode video. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: a lot of change, need to be reviewed again 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/ppapi_decryptor.cc
diff --git a/webkit/media/crypto/ppapi_decryptor.cc b/webkit/media/crypto/ppapi_decryptor.cc
index b4fa1595b3ba62dc46dbcf72e95d76bc555fc149..3ce504e750ec20eacd2c36f1eccd0bd718b6da51 100644
--- a/webkit/media/crypto/ppapi_decryptor.cc
+++ b/webkit/media/crypto/ppapi_decryptor.cc
@@ -7,6 +7,7 @@
#include <string>
#include "base/bind.h"
+#include "base/callback_helpers.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/message_loop.h"
@@ -37,7 +38,7 @@ PpapiDecryptor::~PpapiDecryptor() {
bool PpapiDecryptor::GenerateKeyRequest(const std::string& key_system,
const uint8* init_data,
int init_data_length) {
- DVLOG(1) << "GenerateKeyRequest()";
+ DVLOG(2) << "GenerateKeyRequest()";
ddorwin 2012/10/13 01:40:28 Do we have level 1 logs in Proxydecryptor or somet
xhwang 2012/10/15 19:53:01 We have a level 1 log in ReportFailureToCallPlugin
DCHECK(render_loop_proxy_->BelongsToCurrentThread());
DCHECK(cdm_plugin_);
@@ -60,7 +61,7 @@ void PpapiDecryptor::AddKey(const std::string& key_system,
const uint8* init_data,
int init_data_length,
const std::string& session_id) {
- DVLOG(1) << "AddKey()";
+ DVLOG(2) << "AddKey()";
DCHECK(render_loop_proxy_->BelongsToCurrentThread());
DCHECK(cdm_plugin_);
@@ -78,7 +79,7 @@ void PpapiDecryptor::AddKey(const std::string& key_system,
void PpapiDecryptor::CancelKeyRequest(const std::string& key_system,
const std::string& session_id) {
- DVLOG(1) << "CancelKeyRequest()";
+ DVLOG(2) << "CancelKeyRequest()";
DCHECK(render_loop_proxy_->BelongsToCurrentThread());
DCHECK(cdm_plugin_);
@@ -99,7 +100,7 @@ void PpapiDecryptor::Decrypt(
return;
}
- DVLOG(1) << "Decrypt()";
+ DVLOG(3) << "Decrypt()";
if (!cdm_plugin_->Decrypt(encrypted, decrypt_cb))
decrypt_cb.Run(kError, NULL);
}
@@ -121,16 +122,21 @@ void PpapiDecryptor::InitializeVideoDecoder(
return;
}
- DVLOG(1) << "InitializeVideoDecoder()";
+ DVLOG(2) << "InitializeVideoDecoder()";
DCHECK(config->is_encrypted());
DCHECK(config->IsValidConfig());
+ video_decoder_init_cb_ = init_cb;
key_added_cb_ = key_added_cb;
- // TODO(xhwang): Enable this once PluginInstance is updated.
- // if (!cdm_plugin_->InitializeVideoDecoder(video_config.Pass(), init_cb))
- // init_cb.Run(false);
- init_cb.Run(false);
+ if (!cdm_plugin_->InitializeVideoDecoder(
+ *config,
+ base::Bind(&PpapiDecryptor::OnVideoDecoderInitialized,
+ base::Unretained(this)))) {
+ key_added_cb_.Reset();
+ base::ResetAndReturn(&video_decoder_init_cb_).Run(false);
+ return;
+ }
}
void PpapiDecryptor::DecryptAndDecodeVideo(
@@ -144,26 +150,34 @@ void PpapiDecryptor::DecryptAndDecodeVideo(
return;
}
- DVLOG(1) << "DecryptAndDecodeVideo()";
- // TODO(xhwang): Enable this once PluginInstance is updated.
- // if (!cdm_plugin_->DecryptAndDecodeVideo(encrypted, video_decode_cb))
- // video_decode_cb.Run(kError, NULL);
- NOTIMPLEMENTED();
- video_decode_cb.Run(kError, NULL);
+ DVLOG(3) << "DecryptAndDecodeVideo()";
+ if (!cdm_plugin_->DecryptAndDecode(encrypted, video_decode_cb))
+ video_decode_cb.Run(kError, NULL);
}
void PpapiDecryptor::CancelDecryptAndDecodeVideo() {
ddorwin 2012/10/13 01:40:28 Should this be CancelVideoDecode() or eventually C
xhwang 2012/10/15 19:53:01 Yes, I plan to rename it to ResetDecoder(type) whe
- DVLOG(1) << "CancelDecryptAndDecodeVideo()";
- // TODO(xhwang): Implement CancelDecryptAndDecodeVideo() in PluginInstance
- // and call it here.
- NOTIMPLEMENTED();
+ if (!render_loop_proxy_->BelongsToCurrentThread()) {
+ render_loop_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&PpapiDecryptor::CancelDecryptAndDecodeVideo,
+ base::Unretained(this)));
+ return;
+ }
+
+ DVLOG(2) << "CancelDecryptAndDecodeVideo()";
+ cdm_plugin_->ResetDecoder();
ddorwin 2012/10/13 01:40:28 When we have audio, this will reset both. Is that
xhwang 2012/10/15 19:53:01 ResetDecoder will take a StreamType param later.
}
void PpapiDecryptor::StopVideoDecoder() {
ddorwin 2012/10/13 01:40:28 same here for both of the above.
xhwang 2012/10/15 19:53:01 ditto
- DVLOG(1) << "StopVideoDecoder()";
- // TODO(xhwang): Implement StopVideoDecoder() in PluginInstance
- // and call it here.
- NOTIMPLEMENTED();
+ if (!render_loop_proxy_->BelongsToCurrentThread()) {
+ render_loop_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&PpapiDecryptor::StopVideoDecoder, base::Unretained(this)));
+ return;
+ }
+
+ DVLOG(2) << "StopVideoDecoder()";
+ cdm_plugin_->DeinitializeDecoder();
}
void PpapiDecryptor::ReportFailureToCallPlugin(const std::string& key_system,
@@ -172,4 +186,14 @@ void PpapiDecryptor::ReportFailureToCallPlugin(const std::string& key_system,
client_->KeyError(key_system, session_id, kUnknownError, 0);
}
+void PpapiDecryptor::OnVideoDecoderInitialized(bool success) {
+ DCHECK(!key_added_cb_.is_null());
+ DCHECK(!video_decoder_init_cb_.is_null());
+
+ if (!success)
+ key_added_cb_.Reset();
+
+ base::ResetAndReturn(&video_decoder_init_cb_).Run(success);
+}
+
} // namespace webkit_media

Powered by Google App Engine
This is Rietveld 408576698