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

Side by Side Diff: media/filters/gpu_video_decoder.cc

Issue 1666653002: media: Remove SetCdmReadyCB and CdmReadyCB (part 1). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/filters/gpu_video_decoder.h" 5 #include "media/filters/gpu_video_decoder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1); 121 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1);
122 cb.Run(success); 122 cb.Run(success);
123 } 123 }
124 124
125 std::string GpuVideoDecoder::GetDisplayName() const { 125 std::string GpuVideoDecoder::GetDisplayName() const {
126 return kDecoderName; 126 return kDecoderName;
127 } 127 }
128 128
129 void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, 129 void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config,
130 bool /* low_delay */, 130 bool /* low_delay */,
131 const SetCdmReadyCB& set_cdm_ready_cb, 131 CdmContext* cdm_context,
132 const InitCB& init_cb, 132 const InitCB& init_cb,
133 const OutputCB& output_cb) { 133 const OutputCB& output_cb) {
134 DVLOG(3) << "Initialize()"; 134 DVLOG(3) << "Initialize()";
135 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 135 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
136 DCHECK(config.IsValidConfig()); 136 DCHECK(config.IsValidConfig());
137 137
138 InitCB bound_init_cb = 138 InitCB bound_init_cb =
139 base::Bind(&ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB, 139 base::Bind(&ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB,
140 BindToCurrentLoop(init_cb)); 140 BindToCurrentLoop(init_cb));
141 141
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 VideoDecodeAccelerator::Config vda_config(config); 191 VideoDecodeAccelerator::Config vda_config(config);
192 192
193 if (!vda_ || !vda_->Initialize(vda_config, this)) { 193 if (!vda_ || !vda_->Initialize(vda_config, this)) {
194 DVLOG(1) << "VDA initialization failed."; 194 DVLOG(1) << "VDA initialization failed.";
195 bound_init_cb.Run(false); 195 bound_init_cb.Run(false);
196 return; 196 return;
197 } 197 }
198 198
199 if (config.is_encrypted()) { 199 if (config.is_encrypted()) {
200 DCHECK(cdm_context);
201 if (cdm_context->GetCdmId() == CdmContext::kInvalidCdmId) {
202 DVLOG(1) << "CDM ID not available.";
203 bound_init_cb.Run(false);
204 return;
205 }
206
207 // |init_cb_| will be fired when CDM is attached.
200 init_cb_ = bound_init_cb; 208 init_cb_ = bound_init_cb;
201 set_cdm_ready_cb_ = set_cdm_ready_cb; 209 vda_->SetCdm(cdm_context->GetCdmId());
202 set_cdm_ready_cb_.Run(BindToCurrentLoop(
203 base::Bind(&GpuVideoDecoder::SetCdm, weak_factory_.GetWeakPtr())));
204 return; 210 return;
205 } 211 }
206 212
207 DVLOG(3) << "GpuVideoDecoder::Initialize() succeeded."; 213 DVLOG(3) << "GpuVideoDecoder::Initialize() succeeded.";
208 bound_init_cb.Run(true); 214 bound_init_cb.Run(true);
209 } 215 }
210 216
211 void GpuVideoDecoder::SetCdm(CdmContext* cdm_context,
212 const CdmAttachedCB& cdm_attached_cb) {
213 DVLOG(2) << __FUNCTION__;
214 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
215
216 DCHECK(!init_cb_.is_null());
217 DCHECK(!set_cdm_ready_cb_.is_null());
218 set_cdm_ready_cb_.Reset();
219
220 if (!cdm_context || cdm_context->GetCdmId() == CdmContext::kInvalidCdmId) {
221 DVLOG(1) << "CDM ID not available.";
222 cdm_attached_cb.Run(false);
223 base::ResetAndReturn(&init_cb_).Run(false);
224 return;
225 }
226
227 cdm_attached_cb_ = cdm_attached_cb;
228 vda_->SetCdm(cdm_context->GetCdmId());
229 }
230
231 void GpuVideoDecoder::NotifyCdmAttached(bool success) { 217 void GpuVideoDecoder::NotifyCdmAttached(bool success) {
232 DVLOG_IF(2, !success) << __FUNCTION__ << ": CDM not attached."; 218 DVLOG_IF(2, !success) << __FUNCTION__ << ": CDM not attached.";
233 DCHECK(!init_cb_.is_null()); 219 DCHECK(!init_cb_.is_null());
234 DCHECK(!cdm_attached_cb_.is_null());
235 220
236 base::ResetAndReturn(&cdm_attached_cb_).Run(success);
237 base::ResetAndReturn(&init_cb_).Run(success); 221 base::ResetAndReturn(&init_cb_).Run(success);
238 } 222 }
239 223
240 void GpuVideoDecoder::DestroyPictureBuffers(PictureBufferMap* buffers) { 224 void GpuVideoDecoder::DestroyPictureBuffers(PictureBufferMap* buffers) {
241 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 225 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
242 for (PictureBufferMap::iterator it = buffers->begin(); it != buffers->end(); 226 for (PictureBufferMap::iterator it = buffers->begin(); it != buffers->end();
243 ++it) { 227 ++it) {
244 factories_->DeleteTexture(it->second.texture_id()); 228 factories_->DeleteTexture(it->second.texture_id());
245 } 229 }
246 230
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 } 583 }
600 584
601 GpuVideoDecoder::~GpuVideoDecoder() { 585 GpuVideoDecoder::~GpuVideoDecoder() {
602 DVLOG(3) << __FUNCTION__; 586 DVLOG(3) << __FUNCTION__;
603 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 587 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
604 588
605 if (vda_) 589 if (vda_)
606 DestroyVDA(); 590 DestroyVDA();
607 DCHECK(assigned_picture_buffers_.empty()); 591 DCHECK(assigned_picture_buffers_.empty());
608 592
609 if (!set_cdm_ready_cb_.is_null())
610 base::ResetAndReturn(&set_cdm_ready_cb_).Run(CdmReadyCB());
611 if (!cdm_attached_cb_.is_null())
612 base::ResetAndReturn(&cdm_attached_cb_).Run(false);
613 if (!init_cb_.is_null()) 593 if (!init_cb_.is_null())
614 base::ResetAndReturn(&init_cb_).Run(false); 594 base::ResetAndReturn(&init_cb_).Run(false);
615 595
616 for (size_t i = 0; i < available_shm_segments_.size(); ++i) { 596 for (size_t i = 0; i < available_shm_segments_.size(); ++i) {
617 delete available_shm_segments_[i]; 597 delete available_shm_segments_[i];
618 } 598 }
619 available_shm_segments_.clear(); 599 available_shm_segments_.clear();
620 600
621 for (std::map<int32_t, PendingDecoderBuffer>::iterator it = 601 for (std::map<int32_t, PendingDecoderBuffer>::iterator it =
622 bitstream_buffers_in_decoder_.begin(); 602 bitstream_buffers_in_decoder_.begin();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 } 666 }
687 return false; 667 return false;
688 } 668 }
689 669
690 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() 670 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent()
691 const { 671 const {
692 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); 672 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread());
693 } 673 }
694 674
695 } // namespace media 675 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698