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

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

Issue 2461073002: Use MediaCodec.setOutputSurface() for fullscreen transitions on M. (Closed)
Patch Set: Simplify APIs. 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 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 ScheduleRestart(); 329 ScheduleRestart();
330 } 330 }
331 331
332 void WebMediaPlayerImpl::DisableOverlay() { 332 void WebMediaPlayerImpl::DisableOverlay() {
333 overlay_enabled_ = false; 333 overlay_enabled_ = false;
334 surface_created_cb_.Cancel(); 334 surface_created_cb_.Cancel();
335 overlay_surface_id_ = SurfaceManager::kNoSurfaceID; 335 overlay_surface_id_ = SurfaceManager::kNoSurfaceID;
336 336
337 if (decoder_requires_restart_for_overlay_) 337 if (decoder_requires_restart_for_overlay_)
338 ScheduleRestart(); 338 ScheduleRestart();
339 else if (!pending_surface_request_cb_.is_null())
340 pending_surface_request_cb_.Run(overlay_surface_id_);
339 } 341 }
340 342
341 void WebMediaPlayerImpl::enteredFullscreen() { 343 void WebMediaPlayerImpl::enteredFullscreen() {
342 if (!force_video_overlays_ && !disable_fullscreen_video_overlays_) 344 if (!force_video_overlays_ && !disable_fullscreen_video_overlays_)
343 EnableOverlay(); 345 EnableOverlay();
344 if (observer_) 346 if (observer_)
345 observer_->OnEnteredFullscreen(); 347 observer_->OnEnteredFullscreen();
346 } 348 }
347 349
348 void WebMediaPlayerImpl::exitedFullscreen() { 350 void WebMediaPlayerImpl::exitedFullscreen() {
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 media_log_->CreateBooleanEvent( 1454 media_log_->CreateBooleanEvent(
1453 MediaLogEvent::NETWORK_ACTIVITY_SET, 1455 MediaLogEvent::NETWORK_ACTIVITY_SET,
1454 "is_downloading_data", is_downloading)); 1456 "is_downloading_data", is_downloading));
1455 } 1457 }
1456 1458
1457 void WebMediaPlayerImpl::OnSurfaceCreated(int surface_id) { 1459 void WebMediaPlayerImpl::OnSurfaceCreated(int surface_id) {
1458 if (force_video_overlays_ && surface_id == SurfaceManager::kNoSurfaceID) 1460 if (force_video_overlays_ && surface_id == SurfaceManager::kNoSurfaceID)
1459 LOG(ERROR) << "Create surface failed."; 1461 LOG(ERROR) << "Create surface failed.";
1460 1462
1461 overlay_surface_id_ = surface_id; 1463 overlay_surface_id_ = surface_id;
1462 if (!pending_surface_request_cb_.is_null()) 1464 if (!pending_surface_request_cb_.is_null()) {
1463 base::ResetAndReturn(&pending_surface_request_cb_).Run(surface_id); 1465 if (decoder_requires_restart_for_overlay_)
1466 base::ResetAndReturn(&pending_surface_request_cb_).Run(surface_id);
1467 else
1468 pending_surface_request_cb_.Run(surface_id);
1469 }
1464 } 1470 }
1465 1471
1466 // TODO(watk): Move this state management out of WMPI. 1472 // TODO(watk): Move this state management out of WMPI.
1467 void WebMediaPlayerImpl::OnSurfaceRequested( 1473 void WebMediaPlayerImpl::OnSurfaceRequested(
watk 2016/11/03 20:26:34 Naming suggestion for when the time comes. This fe
DaleCurtis 2016/11/04 01:07:22 Agreed I don't like the name, but since the mechan
1474 bool decoder_requires_restart_for_overlay,
1468 const SurfaceCreatedCB& surface_created_cb) { 1475 const SurfaceCreatedCB& surface_created_cb) {
1469 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1476 DCHECK(main_task_runner_->BelongsToCurrentThread());
1470 DCHECK(surface_manager_); 1477 DCHECK(surface_manager_);
1471 DCHECK(!use_fallback_path_); 1478 DCHECK(!use_fallback_path_);
1472 1479
1473 // A null callback indicates that the decoder is going away. 1480 // A null callback indicates that the decoder is going away.
1474 if (surface_created_cb.is_null()) { 1481 if (surface_created_cb.is_null()) {
1482 DCHECK(!decoder_requires_restart_for_overlay);
1475 decoder_requires_restart_for_overlay_ = false; 1483 decoder_requires_restart_for_overlay_ = false;
1476 pending_surface_request_cb_.Reset(); 1484 pending_surface_request_cb_.Reset();
1477 return; 1485 return;
1478 } 1486 }
1479 1487
1480 // If we're getting a surface request it means GVD is initializing, so until 1488 // If we're getting a surface request it means GVD is initializing, so until
1481 // we get a null surface request, GVD is the active decoder. While that's the 1489 // we get a null surface request, GVD is the active decoder. While that's the
1482 // case we should restart the pipeline on fullscreen transitions so that when 1490 // case we should restart the pipeline on fullscreen transitions so that when
1483 // we create a new GVD it will request a surface again and get the right kind 1491 // we create a new GVD it will request a surface again and get the right kind
1484 // of surface for the fullscreen state. 1492 // of surface for the fullscreen state.
1485 // TODO(watk): Don't require a pipeline restart to switch surfaces for 1493 // TODO(watk): Don't require a pipeline restart to switch surfaces for
1486 // cases where it isn't necessary. 1494 // cases where it isn't necessary.
1487 decoder_requires_restart_for_overlay_ = true; 1495 decoder_requires_restart_for_overlay_ = decoder_requires_restart_for_overlay;
1496 if (!decoder_requires_restart_for_overlay_)
1497 pending_surface_request_cb_ = surface_created_cb;
1488 if (overlay_enabled_) { 1498 if (overlay_enabled_) {
1489 if (overlay_surface_id_ != SurfaceManager::kNoSurfaceID) 1499 if (overlay_surface_id_ != SurfaceManager::kNoSurfaceID)
1490 surface_created_cb.Run(overlay_surface_id_); 1500 surface_created_cb.Run(overlay_surface_id_);
1491 else 1501 else
1492 pending_surface_request_cb_ = surface_created_cb; 1502 pending_surface_request_cb_ = surface_created_cb;
1493 } else { 1503 } else {
1494 // Tell the decoder to create its own surface. 1504 // Tell the decoder to create its own surface.
1495 surface_created_cb.Run(SurfaceManager::kNoSurfaceID); 1505 surface_created_cb.Run(SurfaceManager::kNoSurfaceID);
1496 } 1506 }
1497 } 1507 }
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 pipeline_metadata_.natural_size, 1903 pipeline_metadata_.natural_size,
1894 base::Bind(&GetCurrentTimeInternal, this))); 1904 base::Bind(&GetCurrentTimeInternal, this)));
1895 watch_time_reporter_->OnVolumeChange(volume_); 1905 watch_time_reporter_->OnVolumeChange(volume_);
1896 if (delegate_ && delegate_->IsHidden()) 1906 if (delegate_ && delegate_->IsHidden())
1897 watch_time_reporter_->OnHidden(); 1907 watch_time_reporter_->OnHidden();
1898 else 1908 else
1899 watch_time_reporter_->OnShown(); 1909 watch_time_reporter_->OnShown();
1900 } 1910 }
1901 1911
1902 } // namespace media 1912 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698