Chromium Code Reviews| Index: media/filters/gpu_video_decoder.cc |
| diff --git a/media/filters/gpu_video_decoder.cc b/media/filters/gpu_video_decoder.cc |
| index 7e7144f4ffa3acc832a9715bf10d78c5ba0faf67..60efc8d3b07b7bd3d424761324a2a8c33940d0ab 100644 |
| --- a/media/filters/gpu_video_decoder.cc |
| +++ b/media/filters/gpu_video_decoder.cc |
| @@ -36,6 +36,10 @@ |
| #include "media/formats/mp4/box_definitions.h" |
| #endif |
| +#if defined(OS_ANDROID) |
| +#include "base/android/build_info.h" |
| +#endif |
| + |
| namespace media { |
| namespace { |
| @@ -212,12 +216,16 @@ void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, |
| base::Bind(&ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB, |
| BindToCurrentLoop(init_cb), media_log_); |
| + bool requires_restart_for_external_output_surface = false; |
| #if !defined(OS_ANDROID) |
| if (config.is_encrypted()) { |
| DVLOG(1) << "Encrypted stream not supported."; |
| bound_init_cb.Run(false); |
| return; |
| } |
| +#else |
| + requires_restart_for_external_output_surface = |
| + base::android::BuildInfo::GetInstance()->sdk_int() < 23; |
| #endif |
| bool previously_initialized = config_.IsValidConfig(); |
| @@ -309,6 +317,7 @@ void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, |
| // If we have a surface request callback we should call it and complete |
| // initialization with the returned surface. |
| request_surface_cb_.Run( |
| + requires_restart_for_external_output_surface, |
| BindToCurrentLoop(base::Bind(&GpuVideoDecoder::CompleteInitialization, |
| weak_factory_.GetWeakPtr(), cdm_id))); |
| return; |
| @@ -321,7 +330,6 @@ void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, |
| void GpuVideoDecoder::CompleteInitialization(int cdm_id, int surface_id) { |
| DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| - DCHECK(!init_cb_.is_null()); |
| // It's possible for the vda to become null if NotifyError is called. |
| if (!vda_) { |
| @@ -329,6 +337,12 @@ void GpuVideoDecoder::CompleteInitialization(int cdm_id, int surface_id) { |
| return; |
| } |
| + // If initialization has already completed, then send the new surface id. |
|
liberato (no reviews please)
2016/10/29 18:57:20
this is a little confusing. it might be clearer i
|
| + if (init_cb_.is_null()) { |
| + vda_->SetSurface(surface_id); |
| + return; |
| + } |
| + |
| VideoDecodeAccelerator::Config vda_config; |
| vda_config.profile = config_.profile(); |
| vda_config.cdm_id = cdm_id; |
| @@ -785,7 +799,7 @@ GpuVideoDecoder::~GpuVideoDecoder() { |
| if (!init_cb_.is_null()) |
| base::ResetAndReturn(&init_cb_).Run(false); |
| if (!request_surface_cb_.is_null()) |
| - base::ResetAndReturn(&request_surface_cb_).Run(SurfaceCreatedCB()); |
| + base::ResetAndReturn(&request_surface_cb_).Run(false, SurfaceCreatedCB()); |
| for (size_t i = 0; i < available_shm_segments_.size(); ++i) { |
| delete available_shm_segments_[i]; |