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

Unified Diff: media/blink/webmediaplayer_impl.cc

Issue 2402563002: Keep reference to CDM to avoid it's premature destruction (Closed)
Patch Set: Created 4 years, 2 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
« 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 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) {
« 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