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

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

Issue 2849043002: Send AndroidOverlay routing token from WMPI to AVDA. (Closed)
Patch Set: rebased Created 3 years, 7 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/gpu/android_video_decode_accelerator.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 <array> 8 #include <array>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 base::TimeDelta ts, 104 base::TimeDelta ts,
105 const gfx::Rect& vr, 105 const gfx::Rect& vr,
106 const gfx::Size& ns) 106 const gfx::Size& ns)
107 : bitstream_buffer_id(bbid), 107 : bitstream_buffer_id(bbid),
108 timestamp(ts), 108 timestamp(ts),
109 visible_rect(vr), 109 visible_rect(vr),
110 natural_size(ns) {} 110 natural_size(ns) {}
111 111
112 GpuVideoDecoder::BufferData::~BufferData() {} 112 GpuVideoDecoder::BufferData::~BufferData() {}
113 113
114 GpuVideoDecoder::GpuVideoDecoder(GpuVideoAcceleratorFactories* factories, 114 GpuVideoDecoder::GpuVideoDecoder(
115 const RequestSurfaceCB& request_surface_cb, 115 GpuVideoAcceleratorFactories* factories,
116 MediaLog* media_log) 116 const RequestOverlayInfoCB& request_overlay_info_cb,
117 MediaLog* media_log)
117 : needs_bitstream_conversion_(false), 118 : needs_bitstream_conversion_(false),
118 factories_(factories), 119 factories_(factories),
119 request_surface_cb_(request_surface_cb), 120 request_overlay_info_cb_(request_overlay_info_cb),
120 media_log_(media_log), 121 media_log_(media_log),
121 vda_initialized_(false), 122 vda_initialized_(false),
122 state_(kNormal), 123 state_(kNormal),
123 decoder_texture_target_(0), 124 decoder_texture_target_(0),
124 pixel_format_(PIXEL_FORMAT_UNKNOWN), 125 pixel_format_(PIXEL_FORMAT_UNKNOWN),
125 next_picture_buffer_id_(0), 126 next_picture_buffer_id_(0),
126 next_bitstream_buffer_id_(0), 127 next_bitstream_buffer_id_(0),
127 available_pictures_(0), 128 available_pictures_(0),
128 needs_all_picture_buffers_to_decode_(false), 129 needs_all_picture_buffers_to_decode_(false),
129 supports_deferred_initialization_(false), 130 supports_deferred_initialization_(false),
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 bound_init_cb.Run(false); 287 bound_init_cb.Run(false);
287 return; 288 return;
288 } 289 }
289 } 290 }
290 291
291 init_cb_ = bound_init_cb; 292 init_cb_ = bound_init_cb;
292 293
293 const bool supports_external_output_surface = !!( 294 const bool supports_external_output_surface = !!(
294 capabilities.flags & 295 capabilities.flags &
295 VideoDecodeAccelerator::Capabilities::SUPPORTS_EXTERNAL_OUTPUT_SURFACE); 296 VideoDecodeAccelerator::Capabilities::SUPPORTS_EXTERNAL_OUTPUT_SURFACE);
296 if (supports_external_output_surface && !request_surface_cb_.is_null()) { 297 if (supports_external_output_surface && !request_overlay_info_cb_.is_null()) {
297 const bool requires_restart_for_external_output_surface = 298 const bool requires_restart_for_external_output_surface =
298 !(capabilities.flags & VideoDecodeAccelerator::Capabilities:: 299 !(capabilities.flags & VideoDecodeAccelerator::Capabilities::
299 SUPPORTS_SET_EXTERNAL_OUTPUT_SURFACE); 300 SUPPORTS_SET_EXTERNAL_OUTPUT_SURFACE);
300 301
301 // If we have a surface request callback we should call it and complete 302 // If we have a surface request callback we should call it and complete
302 // initialization with the returned surface. 303 // initialization with the returned surface.
303 request_surface_cb_.Run( 304 request_overlay_info_cb_.Run(
304 requires_restart_for_external_output_surface, 305 requires_restart_for_external_output_surface,
305 BindToCurrentLoop(base::Bind(&GpuVideoDecoder::OnSurfaceAvailable, 306 BindToCurrentLoop(base::Bind(&GpuVideoDecoder::OnOverlayInfoAvailable,
306 weak_factory_.GetWeakPtr()))); 307 weak_factory_.GetWeakPtr())));
307 return; 308 return;
308 } 309 }
309 310
310 // If external surfaces are not supported we can complete initialization now. 311 // If external surfaces are not supported we can complete initialization now.
311 CompleteInitialization(SurfaceManager::kNoSurfaceID); 312 CompleteInitialization(SurfaceManager::kNoSurfaceID,
313 base::UnguessableToken());
312 } 314 }
313 315
314 // OnSurfaceAvailable() might be called at any time between Initialize() and 316 // OnOverlayInfoAvailable() might be called at any time between Initialize() and
315 // ~GpuVideoDecoder() so we have to be careful to not make assumptions about 317 // ~GpuVideoDecoder() so we have to be careful to not make assumptions about
316 // the current state. 318 // the current state.
317 void GpuVideoDecoder::OnSurfaceAvailable(int surface_id) { 319 // At most one of |surface_id| and |token| should be provided. The other will
320 // be kNoSurfaceID or an empty token, respectively.
321 void GpuVideoDecoder::OnOverlayInfoAvailable(
322 int surface_id,
323 const base::Optional<base::UnguessableToken>& token) {
318 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 324 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
319 325
320 if (!vda_) 326 if (!vda_)
321 return; 327 return;
322 328
323 // If the VDA has not been initialized, we were waiting for the first surface 329 // If the VDA has not been initialized, we were waiting for the first surface
324 // so it can be passed to Initialize() via the config. We can't call 330 // so it can be passed to Initialize() via the config. We can't call
325 // SetSurface() before initializing because there is no remote VDA to handle 331 // SetSurface() before initializing because there is no remote VDA to handle
326 // the call yet. 332 // the call yet.
327 if (!vda_initialized_) { 333 if (!vda_initialized_) {
328 CompleteInitialization(surface_id); 334 CompleteInitialization(surface_id, token);
329 return; 335 return;
330 } 336 }
331 337
332 // The VDA must be already initialized (or async initialization is in 338 // The VDA must be already initialized (or async initialization is in
333 // progress) so we can call SetSurface(). 339 // progress) so we can call SetSurface().
334 vda_->SetSurface(surface_id); 340 vda_->SetSurface(surface_id, token);
335 } 341 }
336 342
337 void GpuVideoDecoder::CompleteInitialization(int surface_id) { 343 void GpuVideoDecoder::CompleteInitialization(
344 int surface_id,
345 const base::Optional<base::UnguessableToken>& token) {
338 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 346 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
339 DCHECK(vda_); 347 DCHECK(vda_);
340 DCHECK(!init_cb_.is_null()); 348 DCHECK(!init_cb_.is_null());
341 DCHECK(!vda_initialized_); 349 DCHECK(!vda_initialized_);
342 350
343 VideoDecodeAccelerator::Config vda_config; 351 VideoDecodeAccelerator::Config vda_config;
344 vda_config.profile = config_.profile(); 352 vda_config.profile = config_.profile();
345 vda_config.cdm_id = cdm_id_; 353 vda_config.cdm_id = cdm_id_;
346 vda_config.surface_id = surface_id; 354 vda_config.surface_id = surface_id;
355 vda_config.overlay_routing_token = token;
347 vda_config.encryption_scheme = config_.encryption_scheme(); 356 vda_config.encryption_scheme = config_.encryption_scheme();
348 vda_config.is_deferred_initialization_allowed = true; 357 vda_config.is_deferred_initialization_allowed = true;
349 vda_config.initial_expected_coded_size = config_.coded_size(); 358 vda_config.initial_expected_coded_size = config_.coded_size();
350 vda_config.color_space = config_.color_space_info(); 359 vda_config.color_space = config_.color_space_info();
351 360
352 #if defined(OS_ANDROID) && BUILDFLAG(USE_PROPRIETARY_CODECS) 361 #if defined(OS_ANDROID) && BUILDFLAG(USE_PROPRIETARY_CODECS)
353 // We pass the SPS and PPS on Android because it lets us initialize 362 // We pass the SPS and PPS on Android because it lets us initialize
354 // MediaCodec more reliably (http://crbug.com/649185). 363 // MediaCodec more reliably (http://crbug.com/649185).
355 if (config_.codec() == kCodecH264) 364 if (config_.codec() == kCodecH264)
356 ExtractSpsAndPps(config_.extra_data(), &vda_config.sps, &vda_config.pps); 365 ExtractSpsAndPps(config_.extra_data(), &vda_config.sps, &vda_config.pps);
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 GpuVideoDecoder::~GpuVideoDecoder() { 805 GpuVideoDecoder::~GpuVideoDecoder() {
797 DVLOG(3) << __func__; 806 DVLOG(3) << __func__;
798 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); 807 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent();
799 808
800 if (vda_) 809 if (vda_)
801 DestroyVDA(); 810 DestroyVDA();
802 DCHECK(assigned_picture_buffers_.empty()); 811 DCHECK(assigned_picture_buffers_.empty());
803 812
804 if (!init_cb_.is_null()) 813 if (!init_cb_.is_null())
805 base::ResetAndReturn(&init_cb_).Run(false); 814 base::ResetAndReturn(&init_cb_).Run(false);
806 if (!request_surface_cb_.is_null()) 815 if (!request_overlay_info_cb_.is_null())
807 base::ResetAndReturn(&request_surface_cb_).Run(false, SurfaceCreatedCB()); 816 base::ResetAndReturn(&request_overlay_info_cb_)
817 .Run(false, ProvideOverlayInfoCB());
808 818
809 for (size_t i = 0; i < available_shm_segments_.size(); ++i) { 819 for (size_t i = 0; i < available_shm_segments_.size(); ++i) {
810 delete available_shm_segments_[i]; 820 delete available_shm_segments_[i];
811 } 821 }
812 available_shm_segments_.clear(); 822 available_shm_segments_.clear();
813 823
814 for (std::map<int32_t, PendingDecoderBuffer>::iterator it = 824 for (std::map<int32_t, PendingDecoderBuffer>::iterator it =
815 bitstream_buffers_in_decoder_.begin(); 825 bitstream_buffers_in_decoder_.begin();
816 it != bitstream_buffers_in_decoder_.end(); ++it) { 826 it != bitstream_buffers_in_decoder_.end(); ++it) {
817 delete it->second.shm_buffer; 827 delete it->second.shm_buffer;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 } 900 }
891 return false; 901 return false;
892 } 902 }
893 903
894 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() 904 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent()
895 const { 905 const {
896 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); 906 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread());
897 } 907 }
898 908
899 } // namespace media 909 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/gpu_video_decoder.h ('k') | media/gpu/android_video_decode_accelerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698