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

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: 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
« media/blink/webmediaplayer_impl.h ('K') | « 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..a6a01d4842c2096f3bb77553d7f118d3f8ea5baa 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"
@@ -657,8 +658,11 @@ WebMediaPlayerImpl::generateKeyRequest(const WebString& key_system,
unsigned init_data_length) {
DCHECK(main_task_runner_->BelongsToCurrentThread());
+ // TODO(xhwang): We assume all streams are from the same container (thus have
ddorwin 2014/12/02 20:49:49 Note: YouTube is currently violating this assumpti
xhwang 2014/12/02 21:57:47 Acknowledged.
+ // the same "type") for now. In the future, the "type" should be passed down
ddorwin 2014/12/02 20:49:49 ditto
xhwang 2014/12/02 21:57:47 Done.
+ // from the application.
return encrypted_media_support_.GenerateKeyRequest(
- frame_, key_system, init_data, init_data_length);
+ frame_, key_system, init_data_type_, init_data, init_data_length);
}
WebMediaPlayer::MediaKeyException WebMediaPlayerImpl::addKey(
@@ -699,6 +703,25 @@ void WebMediaPlayerImpl::setContentDecryptionModule(
BIND_TO_RENDER_LOOP1(&WebMediaPlayerImpl::OnCdmAttached, result));
}
+void WebMediaPlayerImpl::OnNeedKey(const std::string& type,
ddorwin 2014/12/02 20:49:49 i_d_t
xhwang 2014/12/02 21:57:47 Done.
+ const std::vector<uint8>& init_data) {
+ // Do not fire NeedKey event if encrypted media is not enabled.
ddorwin 2014/12/02 20:49:49 I know this was copied, but should client_ be hand
xhwang 2014/12/02 21:57:47 Added TODO.
+ if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() &&
+ !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) {
+ return;
+ }
+
+ UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1);
+
+ DCHECK(init_data_type_.empty() || type.empty() || type == init_data_type_);
ddorwin 2014/12/02 20:49:49 Can type be empty? The demuxers that call this alw
ddorwin 2014/12/02 20:49:49 YouTube currently violates this without problems i
xhwang 2014/12/02 21:57:47 Good catch. Done.
xhwang 2014/12/02 21:57:47 Done.
+ if (init_data_type_.empty())
+ init_data_type_ = type;
+
+ const uint8* init_data_ptr = init_data.empty() ? nullptr : &init_data[0];
+ client_->encrypted(WebString::fromUTF8(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 +933,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) {
« media/blink/webmediaplayer_impl.h ('K') | « media/blink/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698