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

Unified Diff: content/browser/media/android/browser_media_player_manager.cc

Issue 714643002: Pause EME player whose external surface is stolen by another player (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove ReleaseCurrentExternalVideoSurface() Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/media/android/browser_media_player_manager.cc
diff --git a/content/browser/media/android/browser_media_player_manager.cc b/content/browser/media/android/browser_media_player_manager.cc
index 37bd64cd82b76f6bdee87b2f30860d1d6f55c871..a7ecd10a5c3d3655de9f721ce170e55bf65d93b1 100644
--- a/content/browser/media/android/browser_media_player_manager.cc
+++ b/content/browser/media/android/browser_media_player_manager.cc
@@ -338,6 +338,18 @@ void BrowserMediaPlayerManager::OnNotifyExternalSurface(
}
}
+void BrowserMediaPlayerManager::ReleasePlayerOfExternalVideoSurfaceIfNeeded(
+ int future_player) {
+ int current_player = -1;
+ if (external_video_surface_container_)
+ current_player = external_video_surface_container_->GetCurrentPlayerId();
+ if (current_player < 0)
+ return;
+
+ if (current_player != future_player)
+ OnMediaInterrupted(current_player);
+}
+
void BrowserMediaPlayerManager::OnRequestExternalSurface(
int player_id, const gfx::RectF& rect) {
if (!external_video_surface_container_) {
@@ -348,6 +360,8 @@ void BrowserMediaPlayerManager::OnRequestExternalSurface(
// It's safe to use base::Unretained(this), because the callbacks will not
// be called after running ReleaseExternalVideoSurface().
if (external_video_surface_container_) {
+ // In case we're stealing the external surface from another player.
+ ReleasePlayerOfExternalVideoSurfaceIfNeeded(player_id);
external_video_surface_container_->RequestExternalVideoSurface(
player_id,
base::Bind(&BrowserMediaPlayerManager::AttachExternalVideoSurface,
@@ -361,6 +375,9 @@ void BrowserMediaPlayerManager::OnRequestExternalSurface(
void BrowserMediaPlayerManager::OnEnterFullscreen(int player_id) {
DCHECK_EQ(fullscreen_player_id_, -1);
#if defined(VIDEO_HOLE)
+ // If this fullscreen player is started when another player
+ // uses the external surface, release that other player.
+ ReleasePlayerOfExternalVideoSurfaceIfNeeded(player_id);
if (external_video_surface_container_)
external_video_surface_container_->ReleaseExternalVideoSurface(player_id);
boliu 2014/12/08 17:51:47 Shouldn't this be the player id of the one holding
Hugo Holgersson 2014/12/09 15:35:28 Yes, you are right about when entering fullscreen
boliu 2014/12/09 18:15:18 o_o
#endif // defined(VIDEO_HOLE)

Powered by Google App Engine
This is Rietveld 408576698