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

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

Issue 2507463004: Fix broken SurfaceView usage on < M devices. (Closed)
Patch Set: Created 4 years, 1 month 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 <array> 8 #include <array>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 // If we have a surface request callback we should call it and complete 317 // If we have a surface request callback we should call it and complete
318 // initialization with the returned surface. 318 // initialization with the returned surface.
319 request_surface_cb_.Run( 319 request_surface_cb_.Run(
320 requires_restart_for_external_output_surface, 320 requires_restart_for_external_output_surface,
321 BindToCurrentLoop(base::Bind(&GpuVideoDecoder::OnSurfaceAvailable, 321 BindToCurrentLoop(base::Bind(&GpuVideoDecoder::OnSurfaceAvailable,
322 weak_factory_.GetWeakPtr()))); 322 weak_factory_.GetWeakPtr())));
323 return; 323 return;
324 } 324 }
325 325
326 // If external surfaces are not supported we can complete initialization now. 326 // If external surfaces are not supported we can complete initialization now.
327 CompleteInitialization(); 327 CompleteInitialization(SurfaceManager::kNoSurfaceID);
328 } 328 }
329 329
330 void GpuVideoDecoder::OnSurfaceAvailable(int surface_id) { 330 void GpuVideoDecoder::OnSurfaceAvailable(int surface_id) {
331 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 331 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
332 332
333 // It's possible for the vda to become null if NotifyError is called. 333 // It's possible for the vda to become null if NotifyError is called.
334 if (!vda_) { 334 if (!vda_) {
335 if (!init_cb_.is_null()) 335 if (!init_cb_.is_null())
336 base::ResetAndReturn(&init_cb_).Run(false); 336 base::ResetAndReturn(&init_cb_).Run(false);
337 return; 337 return;
338 } 338 }
339 339
340 vda_->SetSurface(surface_id); 340 // If initialization has already completed, there's nothing to do but try to
341 341 // set the surface. If we're still initializing, we must pass the surface via
342 // If initialization has already completed, there's nothing left to do. 342 // the config since the remote VDA has not yet been created.
343 if (init_cb_.is_null()) 343 if (init_cb_.is_null()) {
344 vda_->SetSurface(surface_id);
344 return; 345 return;
346 }
345 347
346 // Otherwise initialization was waiting for the surface, so complete it now. 348 // Otherwise initialization was waiting for the surface, so complete it now.
347 CompleteInitialization(); 349 CompleteInitialization(surface_id);
348 } 350 }
349 351
350 void GpuVideoDecoder::CompleteInitialization() { 352 void GpuVideoDecoder::CompleteInitialization(int surface_id) {
351 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 353 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
352 DCHECK(vda_); 354 DCHECK(vda_);
353 DCHECK(!init_cb_.is_null()); 355 DCHECK(!init_cb_.is_null());
354 356
355 VideoDecodeAccelerator::Config vda_config; 357 VideoDecodeAccelerator::Config vda_config;
356 vda_config.profile = config_.profile(); 358 vda_config.profile = config_.profile();
357 vda_config.cdm_id = cdm_id_; 359 vda_config.cdm_id = cdm_id_;
358 vda_config.is_encrypted = config_.is_encrypted(); 360 vda_config.is_encrypted = config_.is_encrypted();
361 vda_config.surface_id = surface_id;
359 vda_config.is_deferred_initialization_allowed = true; 362 vda_config.is_deferred_initialization_allowed = true;
360 vda_config.initial_expected_coded_size = config_.coded_size(); 363 vda_config.initial_expected_coded_size = config_.coded_size();
361 364
362 #if defined(OS_ANDROID) && defined(USE_PROPRIETARY_CODECS) 365 #if defined(OS_ANDROID) && defined(USE_PROPRIETARY_CODECS)
363 // We pass the SPS and PPS on Android because it lets us initialize 366 // We pass the SPS and PPS on Android because it lets us initialize
364 // MediaCodec more reliably (http://crbug.com/649185). 367 // MediaCodec more reliably (http://crbug.com/649185).
365 if (config_.codec() == kCodecH264) 368 if (config_.codec() == kCodecH264)
366 ExtractSpsAndPps(config_.extra_data(), &vda_config.sps, &vda_config.pps); 369 ExtractSpsAndPps(config_.extra_data(), &vda_config.sps, &vda_config.pps);
367 #endif 370 #endif
368 371
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 } 895 }
893 return false; 896 return false;
894 } 897 }
895 898
896 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() 899 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent()
897 const { 900 const {
898 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); 901 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread());
899 } 902 }
900 903
901 } // namespace media 904 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698