summaryrefslogtreecommitdiffstats
path: root/media/base/pipeline.cc
diff options
context:
space:
mode:
Diffstat (limited to 'media/base/pipeline.cc')
-rw-r--r--media/base/pipeline.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/media/base/pipeline.cc b/media/base/pipeline.cc
index 7534688..79a50fd 100644
--- a/media/base/pipeline.cc
+++ b/media/base/pipeline.cc
@@ -44,6 +44,7 @@ Pipeline::Pipeline(
renderer_ended_(false),
text_renderer_ended_(false),
demuxer_(NULL),
+ pending_cdm_context_(nullptr),
weak_factory_(this) {
media_log_->AddEvent(media_log_->CreatePipelineStateChangedEvent(kCreated));
media_log_->AddEvent(
@@ -191,6 +192,13 @@ PipelineStatistics Pipeline::GetStatistics() const {
return statistics_;
}
+void Pipeline::SetCdm(CdmContext* cdm_context,
+ const CdmAttachedCB& cdm_attached_cb) {
+ task_runner_->PostTask(
+ FROM_HERE, base::Bind(&Pipeline::SetCdmTask, weak_factory_.GetWeakPtr(),
+ cdm_context, cdm_attached_cb));
+}
+
void Pipeline::SetErrorForTesting(PipelineStatus status) {
OnError(status);
}
@@ -496,6 +504,12 @@ void Pipeline::StartTask() {
base::Bind(&Pipeline::OnTextRendererEnded, weak_factory_.GetWeakPtr()));
}
+ // Set CDM early to avoid unnecessary delay in Renderer::Initialize().
+ if (pending_cdm_context_) {
+ renderer_->SetCdm(pending_cdm_context_, base::Bind(&IgnoreCdmAttached));
+ pending_cdm_context_ = nullptr;
+ }
+
StateTransitionTask(PIPELINE_OK);
}
@@ -602,6 +616,17 @@ void Pipeline::SeekTask(TimeDelta time, const PipelineStatusCB& seek_cb) {
base::Bind(&Pipeline::OnStateTransition, weak_factory_.GetWeakPtr()));
}
+void Pipeline::SetCdmTask(CdmContext* cdm_context,
+ const CdmAttachedCB& cdm_attached_cb) {
+ if (!renderer_) {
+ pending_cdm_context_ = cdm_context;
+ cdm_attached_cb.Run(true);
+ return;
+ }
+
+ renderer_->SetCdm(cdm_context, cdm_attached_cb);
+}
+
void Pipeline::OnRendererEnded() {
DCHECK(task_runner_->BelongsToCurrentThread());
media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::ENDED));