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

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 2856643002: Explicitly represent "no surface ID yet" in WMPI. (Closed)
Patch Set: removed redundant check 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/blink/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/blink/webmediaplayer_impl.h" 5 #include "media/blink/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 #if defined(OS_ANDROID) 334 #if defined(OS_ANDROID)
335 return true; 335 return true;
336 #else 336 #else
337 return false; 337 return false;
338 #endif 338 #endif
339 } 339 }
340 340
341 void WebMediaPlayerImpl::EnableOverlay() { 341 void WebMediaPlayerImpl::EnableOverlay() {
342 overlay_enabled_ = true; 342 overlay_enabled_ = true;
343 if (surface_manager_) { 343 if (surface_manager_) {
344 overlay_surface_id_.reset();
344 surface_created_cb_.Reset( 345 surface_created_cb_.Reset(
345 base::Bind(&WebMediaPlayerImpl::OnSurfaceCreated, AsWeakPtr())); 346 base::Bind(&WebMediaPlayerImpl::OnSurfaceCreated, AsWeakPtr()));
346 surface_manager_->CreateFullscreenSurface(pipeline_metadata_.natural_size, 347 surface_manager_->CreateFullscreenSurface(pipeline_metadata_.natural_size,
347 surface_created_cb_.callback()); 348 surface_created_cb_.callback());
348 } 349 }
349 350
350 if (decoder_requires_restart_for_overlay_) 351 if (decoder_requires_restart_for_overlay_)
351 ScheduleRestart(); 352 ScheduleRestart();
352 } 353 }
353 354
354 void WebMediaPlayerImpl::DisableOverlay() { 355 void WebMediaPlayerImpl::DisableOverlay() {
355 overlay_enabled_ = false; 356 overlay_enabled_ = false;
356 surface_created_cb_.Cancel(); 357 surface_created_cb_.Cancel();
357 overlay_surface_id_ = SurfaceManager::kNoSurfaceID; 358 overlay_surface_id_ = SurfaceManager::kNoSurfaceID;
358 359
359 if (decoder_requires_restart_for_overlay_) 360 if (decoder_requires_restart_for_overlay_)
360 ScheduleRestart(); 361 ScheduleRestart();
361 else if (!set_surface_cb_.is_null()) 362 else if (!set_surface_cb_.is_null())
362 set_surface_cb_.Run(overlay_surface_id_); 363 set_surface_cb_.Run(*overlay_surface_id_);
363 } 364 }
364 365
365 void WebMediaPlayerImpl::EnteredFullscreen() { 366 void WebMediaPlayerImpl::EnteredFullscreen() {
366 // |force_video_overlays_| implies that we're already in overlay mode, so take 367 // |force_video_overlays_| implies that we're already in overlay mode, so take
367 // no action here. Otherwise, switch to an overlay if it's allowed and if 368 // no action here. Otherwise, switch to an overlay if it's allowed and if
368 // it will display properly. 369 // it will display properly.
369 if (!force_video_overlays_ && enable_fullscreen_video_overlays_ && 370 if (!force_video_overlays_ && enable_fullscreen_video_overlays_ &&
370 DoesOverlaySupportMetadata()) { 371 DoesOverlaySupportMetadata()) {
371 EnableOverlay(); 372 EnableOverlay();
372 } 373 }
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 // 1702 //
1702 // If |decoder_requires_restart_for_overlay| is true, we must restart the 1703 // If |decoder_requires_restart_for_overlay| is true, we must restart the
1703 // pipeline for fullscreen transitions. The decoder is unable to switch 1704 // pipeline for fullscreen transitions. The decoder is unable to switch
1704 // surfaces otherwise. If false, we simply need to tell the decoder about the 1705 // surfaces otherwise. If false, we simply need to tell the decoder about the
1705 // new surface and it will handle things seamlessly. 1706 // new surface and it will handle things seamlessly.
1706 decoder_requires_restart_for_overlay_ = decoder_requires_restart_for_overlay; 1707 decoder_requires_restart_for_overlay_ = decoder_requires_restart_for_overlay;
1707 set_surface_cb_ = set_surface_cb; 1708 set_surface_cb_ = set_surface_cb;
1708 1709
1709 // If we're waiting for the surface to arrive, OnSurfaceCreated() will be 1710 // If we're waiting for the surface to arrive, OnSurfaceCreated() will be
1710 // called later when it arrives; so do nothing for now. 1711 // called later when it arrives; so do nothing for now.
1711 if (overlay_enabled_ && overlay_surface_id_ == SurfaceManager::kNoSurfaceID) 1712 if (!overlay_surface_id_)
1712 return; 1713 return;
1713 1714
1714 OnSurfaceCreated(overlay_surface_id_); 1715 OnSurfaceCreated(*overlay_surface_id_);
1715 } 1716 }
1716 1717
1717 std::unique_ptr<Renderer> WebMediaPlayerImpl::CreateRenderer() { 1718 std::unique_ptr<Renderer> WebMediaPlayerImpl::CreateRenderer() {
1718 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1719 DCHECK(main_task_runner_->BelongsToCurrentThread());
1719 1720
1720 if (force_video_overlays_) 1721 if (force_video_overlays_)
1721 EnableOverlay(); 1722 EnableOverlay();
1722 1723
1723 RequestSurfaceCB request_surface_cb; 1724 RequestSurfaceCB request_surface_cb;
1724 #if defined(OS_ANDROID) 1725 #if defined(OS_ANDROID)
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 2396
2396 if (is_encrypted_) 2397 if (is_encrypted_)
2397 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.EME", height); 2398 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.EME", height);
2398 2399
2399 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.All", height); 2400 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.All", height);
2400 } 2401 }
2401 2402
2402 #undef UMA_HISTOGRAM_VIDEO_HEIGHT 2403 #undef UMA_HISTOGRAM_VIDEO_HEIGHT
2403 2404
2404 } // namespace media 2405 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698