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

Unified Diff: media/blink/webmediaplayer_impl.cc

Issue 759933003: Move OnNeedKey() to WebMediaPlayerImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/webmediaplayer_impl.cc
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc
index 74db5fe1ac8a614127e34d424bdc756159445085..b862928973928fa7679a6dd4dbde28a5e1a2eca3 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -60,6 +60,7 @@
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURL.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
+#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
#include "third_party/WebKit/public/web/WebSecurityOrigin.h"
#include "third_party/WebKit/public/web/WebView.h"
@@ -699,6 +700,26 @@ void WebMediaPlayerImpl::setContentDecryptionModule(
BIND_TO_RENDER_LOOP1(&WebMediaPlayerImpl::OnCdmAttached, result));
}
+void WebMediaPlayerImpl::OnNeedKey(const std::string& init_data_type,
+ const std::vector<uint8>& init_data) {
+ DCHECK(!init_data_type.empty());
+
+ // Do not fire NeedKey event if encrypted media is not enabled.
+ // TODO(xhwang): Handle this in |client_|.
+ if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() &&
+ !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) {
+ return;
+ }
+
+ UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1);
+
+ encrypted_media_support_.SetInitDataType(init_data_type);
+
+ const uint8* init_data_ptr = init_data.empty() ? nullptr : &init_data[0];
+ client_->encrypted(WebString::fromUTF8(init_data_type), init_data_ptr,
+ base::saturated_cast<unsigned int>(init_data.size()));
+}
+
void WebMediaPlayerImpl::SetCdm(CdmContext* cdm_context,
const CdmAttachedCB& cdm_attached_cb) {
pipeline_.SetCdm(cdm_context, cdm_attached_cb);
@@ -910,7 +931,7 @@ void WebMediaPlayerImpl::StartPipeline() {
LogCB mse_log_cb;
Demuxer::NeedKeyCB need_key_cb =
- encrypted_media_support_.CreateNeedKeyCB();
+ BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNeedKey);
// Figure out which demuxer to use.
if (load_type_ != LoadTypeMediaSource) {
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698