Chromium Code Reviews| 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) { |