| Index: media/blink/webmediaplayer_impl.cc
|
| diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc
|
| index 7c67743e982b430e3c7794a1e1d2a3310806ee3c..e5f56a3984aa243c5a556de23f7937ffad551cbe 100644
|
| --- a/media/blink/webmediaplayer_impl.cc
|
| +++ b/media/blink/webmediaplayer_impl.cc
|
| @@ -37,6 +37,7 @@
|
| #include "media/base/text_renderer.h"
|
| #include "media/base/timestamp_constants.h"
|
| #include "media/base/video_frame.h"
|
| +#include "media/blink/cdm_session_adapter.h"
|
| #include "media/blink/texttrack_impl.h"
|
| #include "media/blink/watch_time_reporter.h"
|
| #include "media/blink/webaudiosourceprovider_impl.h"
|
| @@ -245,9 +246,8 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
|
| media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED));
|
|
|
| if (params.initial_cdm()) {
|
| - SetCdm(base::Bind(&IgnoreCdmAttached),
|
| - ToWebContentDecryptionModuleImpl(params.initial_cdm())
|
| - ->GetCdmContext());
|
| + SetCdm(ToWebContentDecryptionModuleImpl(params.initial_cdm()),
|
| + base::Bind(&IgnoreCdmAttached));
|
| }
|
|
|
| // TODO(xhwang): When we use an external Renderer, many methods won't work,
|
| @@ -895,8 +895,8 @@ void WebMediaPlayerImpl::setContentDecryptionModule(
|
| if (!was_encrypted && watch_time_reporter_)
|
| CreateWatchTimeReporter();
|
|
|
| - SetCdm(BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnCdmAttached),
|
| - ToWebContentDecryptionModuleImpl(cdm)->GetCdmContext());
|
| + SetCdm(ToWebContentDecryptionModuleImpl(cdm),
|
| + BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnCdmAttached));
|
| }
|
|
|
| void WebMediaPlayerImpl::OnEncryptedMediaInitData(
|
| @@ -946,13 +946,23 @@ void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated(
|
| }
|
| }
|
|
|
| -void WebMediaPlayerImpl::SetCdm(const CdmAttachedCB& cdm_attached_cb,
|
| - CdmContext* cdm_context) {
|
| +void WebMediaPlayerImpl::SetCdm(WebContentDecryptionModuleImpl* cdm,
|
| + const CdmAttachedCB& cdm_attached_cb) {
|
| + if (!cdm) {
|
| + cdm_attached_cb.Run(false);
|
| + return;
|
| + }
|
| +
|
| + CdmContext* cdm_context = cdm->GetCdmContext();
|
| if (!cdm_context) {
|
| cdm_attached_cb.Run(false);
|
| return;
|
| }
|
|
|
| + // Keep a reference to the CDM, as it shouldn't be destroyed until after the
|
| + // pipeline is done with it.
|
| + cdm_adapter_ = cdm->GetCdmAdapterReference();
|
| +
|
| // If CDM initialization succeeded, tell the pipeline about it.
|
| pipeline_.SetCdm(cdm_context, cdm_attached_cb);
|
| }
|
| @@ -969,6 +979,7 @@ void WebMediaPlayerImpl::OnCdmAttached(bool success) {
|
| blink::WebContentDecryptionModuleExceptionNotSupportedError, 0,
|
| "Unable to set MediaKeys object");
|
| set_cdm_result_.reset();
|
| + cdm_adapter_ = nullptr;
|
| }
|
|
|
| void WebMediaPlayerImpl::OnPipelineSeeked(bool time_updated) {
|
|
|