| OLD | NEW |
| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 256 |
| 257 // If we don't have to wait for a surface complete initialization with a null | 257 // If we don't have to wait for a surface complete initialization with a null |
| 258 // surface. | 258 // surface. |
| 259 CompleteInitialization(cdm_id, SurfaceManager::kNoSurfaceID); | 259 CompleteInitialization(cdm_id, SurfaceManager::kNoSurfaceID); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void GpuVideoDecoder::CompleteInitialization(int cdm_id, int surface_id) { | 262 void GpuVideoDecoder::CompleteInitialization(int cdm_id, int surface_id) { |
| 263 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 263 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| 264 DCHECK(!init_cb_.is_null()); | 264 DCHECK(!init_cb_.is_null()); |
| 265 | 265 |
| 266 VideoDecodeAccelerator::Config vda_config(config_); | 266 VideoDecodeAccelerator::Config vda_config; |
| 267 vda_config.profile = config_.profile(); |
| 268 vda_config.cdm_id = cdm_id; |
| 269 vda_config.is_encrypted = config_.is_encrypted(); |
| 267 vda_config.surface_id = surface_id; | 270 vda_config.surface_id = surface_id; |
| 268 vda_config.is_deferred_initialization_allowed = true; | 271 vda_config.is_deferred_initialization_allowed = true; |
| 269 vda_config.initial_expected_coded_size = config_.coded_size(); | 272 vda_config.initial_expected_coded_size = config_.coded_size(); |
| 270 if (!vda_->Initialize(vda_config, this)) { | 273 if (!vda_->Initialize(vda_config, this)) { |
| 271 DVLOG(1) << "VDA::Initialize failed."; | 274 DVLOG(1) << "VDA::Initialize failed."; |
| 272 base::ResetAndReturn(&init_cb_).Run(false); | 275 base::ResetAndReturn(&init_cb_).Run(false); |
| 273 return; | 276 return; |
| 274 } | 277 } |
| 275 | 278 |
| 276 // The VDA is now initialized, but if the stream is encrypted we need to | 279 // If deferred initialization is not supported, initialization is complete. |
| 277 // attach the CDM before completing GVD's initialization. | 280 // Otherwise, a call to NotifyInitializationComplete will follow with the |
| 278 if (config_.is_encrypted()) { | 281 // result of deferred initialization. |
| 279 // TODO(watk,timav): Pass this in the VDA::Config. | 282 if (!supports_deferred_initialization_) |
| 280 vda_->SetCdm(cdm_id); | |
| 281 DCHECK(supports_deferred_initialization_); | |
| 282 } | |
| 283 | |
| 284 // We enable deferred initialization in the config, so if the VDA supports it, | |
| 285 // then it will be in use. Otherwise, initialization is already complete. | |
| 286 if (!supports_deferred_initialization_) { | |
| 287 base::ResetAndReturn(&init_cb_).Run(true); | 283 base::ResetAndReturn(&init_cb_).Run(true); |
| 288 } | |
| 289 | |
| 290 // A call to NotifyInitializationComplete will follow with the status. | |
| 291 } | 284 } |
| 292 | 285 |
| 293 void GpuVideoDecoder::NotifyInitializationComplete(bool success) { | 286 void GpuVideoDecoder::NotifyInitializationComplete(bool success) { |
| 294 DVLOG_IF(2, !success) << __FUNCTION__ << ": CDM not attached."; | 287 DVLOG_IF(1, !success) << __FUNCTION__ << " Deferred initialization failed."; |
| 295 DCHECK(!init_cb_.is_null()); | 288 DCHECK(!init_cb_.is_null()); |
| 296 | 289 |
| 297 base::ResetAndReturn(&init_cb_).Run(success); | 290 base::ResetAndReturn(&init_cb_).Run(success); |
| 298 } | 291 } |
| 299 | 292 |
| 300 void GpuVideoDecoder::DestroyPictureBuffers(PictureBufferMap* buffers) { | 293 void GpuVideoDecoder::DestroyPictureBuffers(PictureBufferMap* buffers) { |
| 301 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 294 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| 302 for (PictureBufferMap::iterator it = buffers->begin(); it != buffers->end(); | 295 for (PictureBufferMap::iterator it = buffers->begin(); it != buffers->end(); |
| 303 ++it) { | 296 ++it) { |
| 304 for (uint32_t id : it->second.texture_ids()) | 297 for (uint32_t id : it->second.texture_ids()) |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 } | 776 } |
| 784 return false; | 777 return false; |
| 785 } | 778 } |
| 786 | 779 |
| 787 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() | 780 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
| 788 const { | 781 const { |
| 789 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); | 782 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |
| 790 } | 783 } |
| 791 | 784 |
| 792 } // namespace media | 785 } // namespace media |
| OLD | NEW |