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

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: rebase and fix compile errors 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
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | media/filters/opus_audio_decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/callback_helpers.h" 11 #include "base/callback_helpers.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/cpu.h" 13 #include "base/cpu.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/task_runner_util.h" 17 #include "base/task_runner_util.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "gpu/command_buffer/common/mailbox_holder.h" 19 #include "gpu/command_buffer/common/mailbox_holder.h"
20 #include "media/base/bind_to_current_loop.h" 20 #include "media/base/bind_to_current_loop.h"
21 #include "media/base/cdm_context.h"
21 #include "media/base/decoder_buffer.h" 22 #include "media/base/decoder_buffer.h"
22 #include "media/base/media_switches.h" 23 #include "media/base/media_switches.h"
23 #include "media/base/pipeline.h" 24 #include "media/base/pipeline.h"
24 #include "media/base/video_decoder_config.h" 25 #include "media/base/video_decoder_config.h"
25 #include "media/renderers/gpu_video_accelerator_factories.h" 26 #include "media/renderers/gpu_video_accelerator_factories.h"
26 #include "third_party/skia/include/core/SkBitmap.h" 27 #include "third_party/skia/include/core/SkBitmap.h"
27 28
28 namespace media { 29 namespace media {
29 30
30 const char GpuVideoDecoder::kDecoderName[] = "GpuVideoDecoder"; 31 const char GpuVideoDecoder::kDecoderName[] = "GpuVideoDecoder";
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1); 122 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1);
122 cb.Run(success); 123 cb.Run(success);
123 } 124 }
124 125
125 std::string GpuVideoDecoder::GetDisplayName() const { 126 std::string GpuVideoDecoder::GetDisplayName() const {
126 return kDecoderName; 127 return kDecoderName;
127 } 128 }
128 129
129 void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, 130 void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config,
130 bool /* low_delay */, 131 bool /* low_delay */,
131 const SetCdmReadyCB& set_cdm_ready_cb, 132 CdmContext* cdm_context,
132 const InitCB& init_cb, 133 const InitCB& init_cb,
133 const OutputCB& output_cb) { 134 const OutputCB& output_cb) {
134 DVLOG(3) << "Initialize()"; 135 DVLOG(3) << "Initialize()";
135 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 136 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
136 DCHECK(config.IsValidConfig()); 137 DCHECK(config.IsValidConfig());
137 138
138 InitCB bound_init_cb = 139 InitCB bound_init_cb =
139 base::Bind(&ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB, 140 base::Bind(&ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB,
140 BindToCurrentLoop(init_cb)); 141 BindToCurrentLoop(init_cb));
141 142
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 191
191 VideoDecodeAccelerator::Config vda_config(config); 192 VideoDecodeAccelerator::Config vda_config(config);
192 193
193 if (!vda_ || !vda_->Initialize(vda_config, this)) { 194 if (!vda_ || !vda_->Initialize(vda_config, this)) {
194 DVLOG(1) << "VDA initialization failed."; 195 DVLOG(1) << "VDA initialization failed.";
195 bound_init_cb.Run(false); 196 bound_init_cb.Run(false);
196 return; 197 return;
197 } 198 }
198 199
199 if (config.is_encrypted()) { 200 if (config.is_encrypted()) {
201 DCHECK(cdm_context);
202 // No need to store |cdm_context| since it's not needed in reinitialization.
203 if (cdm_context->GetCdmId() == CdmContext::kInvalidCdmId) {
204 DVLOG(1) << "CDM ID not available.";
205 bound_init_cb.Run(false);
206 return;
207 }
208
209 // |init_cb_| will be fired when CDM is attached.
200 init_cb_ = bound_init_cb; 210 init_cb_ = bound_init_cb;
201 set_cdm_ready_cb_ = set_cdm_ready_cb; 211 vda_->SetCdm(cdm_context->GetCdmId());
202 set_cdm_ready_cb_.Run(BindToCurrentLoop(
203 base::Bind(&GpuVideoDecoder::SetCdm, weak_factory_.GetWeakPtr())));
204 return; 212 return;
205 } 213 }
206 214
207 DVLOG(3) << "GpuVideoDecoder::Initialize() succeeded."; 215 DVLOG(3) << "GpuVideoDecoder::Initialize() succeeded.";
208 bound_init_cb.Run(true); 216 bound_init_cb.Run(true);
209 } 217 }
210 218
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) { 219 void GpuVideoDecoder::NotifyCdmAttached(bool success) {
232 DVLOG_IF(2, !success) << __FUNCTION__ << ": CDM not attached."; 220 DVLOG_IF(2, !success) << __FUNCTION__ << ": CDM not attached.";
233 DCHECK(!init_cb_.is_null()); 221 DCHECK(!init_cb_.is_null());
234 DCHECK(!cdm_attached_cb_.is_null());
235 222
236 base::ResetAndReturn(&cdm_attached_cb_).Run(success);
237 base::ResetAndReturn(&init_cb_).Run(success); 223 base::ResetAndReturn(&init_cb_).Run(success);
238 } 224 }
239 225
240 void GpuVideoDecoder::DestroyPictureBuffers(PictureBufferMap* buffers) { 226 void GpuVideoDecoder::DestroyPictureBuffers(PictureBufferMap* buffers) {
241 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 227 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
242 for (PictureBufferMap::iterator it = buffers->begin(); it != buffers->end(); 228 for (PictureBufferMap::iterator it = buffers->begin(); it != buffers->end();
243 ++it) { 229 ++it) {
244 factories_->DeleteTexture(it->second.texture_id()); 230 factories_->DeleteTexture(it->second.texture_id());
245 } 231 }
246 232
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 } 585 }
600 586
601 GpuVideoDecoder::~GpuVideoDecoder() { 587 GpuVideoDecoder::~GpuVideoDecoder() {
602 DVLOG(3) << __FUNCTION__; 588 DVLOG(3) << __FUNCTION__;
603 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 589 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
604 590
605 if (vda_) 591 if (vda_)
606 DestroyVDA(); 592 DestroyVDA();
607 DCHECK(assigned_picture_buffers_.empty()); 593 DCHECK(assigned_picture_buffers_.empty());
608 594
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()) 595 if (!init_cb_.is_null())
614 base::ResetAndReturn(&init_cb_).Run(false); 596 base::ResetAndReturn(&init_cb_).Run(false);
615 597
616 for (size_t i = 0; i < available_shm_segments_.size(); ++i) { 598 for (size_t i = 0; i < available_shm_segments_.size(); ++i) {
617 delete available_shm_segments_[i]; 599 delete available_shm_segments_[i];
618 } 600 }
619 available_shm_segments_.clear(); 601 available_shm_segments_.clear();
620 602
621 for (std::map<int32_t, PendingDecoderBuffer>::iterator it = 603 for (std::map<int32_t, PendingDecoderBuffer>::iterator it =
622 bitstream_buffers_in_decoder_.begin(); 604 bitstream_buffers_in_decoder_.begin();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 } 668 }
687 return false; 669 return false;
688 } 670 }
689 671
690 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() 672 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent()
691 const { 673 const {
692 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); 674 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread());
693 } 675 }
694 676
695 } // namespace media 677 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | media/filters/opus_audio_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698