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

Unified Diff: content/renderer/media/webmediaplayer_impl.cc

Issue 416333011: Allow setContentDecryptionModule() to get called when setting is done. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: const & Created 6 years, 5 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: content/renderer/media/webmediaplayer_impl.cc
diff --git a/content/renderer/media/webmediaplayer_impl.cc b/content/renderer/media/webmediaplayer_impl.cc
index 1a61233b71ad0fb0002ba1257674d03742893df7..ee7325b61b1eef082b7d5e179046f998c575b15a 100644
--- a/content/renderer/media/webmediaplayer_impl.cc
+++ b/content/renderer/media/webmediaplayer_impl.cc
@@ -61,6 +61,7 @@
#include "media/filters/video_renderer_impl.h"
#include "media/filters/vpx_video_decoder.h"
#include "third_party/WebKit/public/platform/WebContentDecryptionModule.h"
+#include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
#include "third_party/WebKit/public/platform/WebMediaSource.h"
#include "third_party/WebKit/public/platform/WebRect.h"
#include "third_party/WebKit/public/platform/WebSize.h"
@@ -783,7 +784,7 @@ WebMediaPlayerImpl::GenerateKeyRequestInternal(const std::string& key_system,
if (proxy_decryptor_ && !decryptor_ready_cb_.is_null()) {
base::ResetAndReturn(&decryptor_ready_cb_)
- .Run(proxy_decryptor_->GetDecryptor());
+ .Run(proxy_decryptor_->GetDecryptor(), base::Bind(&base::DoNothing));
}
current_key_system_ = key_system;
@@ -888,6 +889,8 @@ WebMediaPlayer::MediaKeyException WebMediaPlayerImpl::CancelKeyRequestInternal(
void WebMediaPlayerImpl::setContentDecryptionModule(
blink::WebContentDecryptionModule* cdm) {
DCHECK(main_loop_->BelongsToCurrentThread());
+ // TODO(jrummell): Remove this method once blink starts calling with 2
ddorwin 2014/07/30 22:35:45 Better in the header?
jrummell 2014/08/01 22:09:42 Based in comments for the blink review, we may kee
+ // parameters.
// TODO(xhwang): Support setMediaKeys(0) if necessary: http://crbug.com/330324
if (!cdm)
@@ -896,7 +899,40 @@ void WebMediaPlayerImpl::setContentDecryptionModule(
web_cdm_ = ToWebContentDecryptionModuleImpl(cdm);
if (web_cdm_ && !decryptor_ready_cb_.is_null())
- base::ResetAndReturn(&decryptor_ready_cb_).Run(web_cdm_->GetDecryptor());
+ base::ResetAndReturn(&decryptor_ready_cb_)
+ .Run(web_cdm_->GetDecryptor(), base::Bind(&base::DoNothing));
+}
+
+void WebMediaPlayerImpl::setContentDecryptionModule(
+ blink::WebContentDecryptionModule* cdm,
+ blink::WebContentDecryptionModuleResult result) {
+ DCHECK(main_loop_->BelongsToCurrentThread());
+
+ // TODO(xhwang): Support setMediaKeys(0) if necessary: http://crbug.com/330324
+ if (!cdm) {
+ result.completeWithError(
+ blink::WebContentDecryptionModuleExceptionNotSupportedError,
+ 0,
+ "Setting a null MediaKeys object not supported.");
ddorwin 2014/07/30 22:35:45 nit: s/not/is not/. Or, to be more concise, just d
jrummell 2014/08/01 22:09:42 Done.
+ return;
+ }
+
+ web_cdm_ = ToWebContentDecryptionModuleImpl(cdm);
+
+ if (web_cdm_ && !decryptor_ready_cb_.is_null()) {
+ base::ResetAndReturn(&decryptor_ready_cb_)
+ .Run(web_cdm_->GetDecryptor(),
+ BIND_TO_RENDER_LOOP1(
+ &WebMediaPlayerImpl::ContentDecryptionModuleSet, result));
+ } else {
+ // No player, so setting CDM is complete.
ddorwin 2014/07/30 22:35:45 I don't think this comment is correct. WMPI is the
jrummell 2014/08/01 22:09:42 Comment updated. decryptor_ready_cb_ is null if .s
+ ContentDecryptionModuleSet(result);
+ }
+}
+
+void WebMediaPlayerImpl::ContentDecryptionModuleSet(
+ blink::WebContentDecryptionModuleResult result) {
+ result.complete();
}
void WebMediaPlayerImpl::InvalidateOnMainThread() {
@@ -1315,7 +1351,8 @@ void WebMediaPlayerImpl::SetDecryptorReadyCB(
// Cancels the previous decryptor request.
if (decryptor_ready_cb.is_null()) {
if (!decryptor_ready_cb_.is_null())
- base::ResetAndReturn(&decryptor_ready_cb_).Run(NULL);
+ base::ResetAndReturn(&decryptor_ready_cb_)
+ .Run(NULL, base::Bind(&base::DoNothing));
ddorwin 2014/07/30 22:35:45 Don't we need to satisfy the promise in some way?
jrummell 2014/08/01 22:09:42 Here we are cancelling the previous request. There
return;
}
@@ -1330,12 +1367,14 @@ void WebMediaPlayerImpl::SetDecryptorReadyCB(
DCHECK(!proxy_decryptor_ || !web_cdm_);
if (proxy_decryptor_) {
- decryptor_ready_cb.Run(proxy_decryptor_->GetDecryptor());
+ decryptor_ready_cb.Run(proxy_decryptor_->GetDecryptor(),
+ base::Bind(&base::DoNothing));
ddorwin 2014/07/30 22:35:45 prefixed only - so this is fine.
jrummell 2014/08/01 22:09:42 Acknowledged.
return;
}
if (web_cdm_) {
- decryptor_ready_cb.Run(web_cdm_->GetDecryptor());
+ decryptor_ready_cb.Run(web_cdm_->GetDecryptor(),
ddorwin 2014/07/30 22:35:45 Maybe comment that there can be no outstanding set
jrummell 2014/08/01 22:09:42 Not sure what to comment here. setContentDecryptio
+ base::Bind(&base::DoNothing));
return;
}

Powered by Google App Engine
This is Rietveld 408576698