Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "content/browser/media/android/browser_media_player_manager.h" | 5 #include "content/browser/media/android/browser_media_player_manager.h" |
| 6 | 6 |
| 7 #include "base/android/scoped_java_ref.h" | 7 #include "base/android/scoped_java_ref.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "content/browser/android/content_view_core_impl.h" | 9 #include "content/browser/android/content_view_core_impl.h" |
| 10 #include "content/browser/media/android/browser_demuxer_android.h" | 10 #include "content/browser/media/android/browser_demuxer_android.h" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 jobject surface) { | 342 jobject surface) { |
| 343 MediaPlayerAndroid* player = GetPlayer(player_id); | 343 MediaPlayerAndroid* player = GetPlayer(player_id); |
| 344 if (player) { | 344 if (player) { |
| 345 player->SetVideoSurface( | 345 player->SetVideoSurface( |
| 346 gfx::ScopedJavaSurface::AcquireExternalSurface(surface)); | 346 gfx::ScopedJavaSurface::AcquireExternalSurface(surface)); |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 | 349 |
| 350 void BrowserMediaPlayerManager::DetachExternalVideoSurface(int player_id) { | 350 void BrowserMediaPlayerManager::DetachExternalVideoSurface(int player_id) { |
| 351 MediaPlayerAndroid* player = GetPlayer(player_id); | 351 MediaPlayerAndroid* player = GetPlayer(player_id); |
| 352 if (player) | 352 if (player) { |
| 353 // If a player looses its external surface because | |
| 354 // it enters fullscreen, the video should not be paused. | |
| 355 if (player_id != fullscreen_player_id_) { | |
| 356 player->Pause(true); | |
| 357 Send(new MediaPlayerMsg_DidMediaPlayerPause(RoutingID(), player_id)); | |
| 358 } | |
| 353 player->SetVideoSurface(gfx::ScopedJavaSurface()); | 359 player->SetVideoSurface(gfx::ScopedJavaSurface()); |
| 360 } | |
| 354 } | 361 } |
| 355 | 362 |
| 356 void BrowserMediaPlayerManager::OnFrameInfoUpdated() { | 363 void BrowserMediaPlayerManager::OnFrameInfoUpdated() { |
| 357 if (external_video_surface_container_) | 364 if (external_video_surface_container_) |
| 358 external_video_surface_container_->OnFrameInfoUpdated(); | 365 external_video_surface_container_->OnFrameInfoUpdated(); |
| 359 } | 366 } |
| 360 | 367 |
| 361 void BrowserMediaPlayerManager::OnNotifyExternalSurface( | 368 void BrowserMediaPlayerManager::OnNotifyExternalSurface( |
| 362 int player_id, bool is_request, const gfx::RectF& rect) { | 369 int player_id, bool is_request, const gfx::RectF& rect) { |
| 363 if (!web_contents_) | 370 if (!web_contents_) |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 388 base::Unretained(this)), | 395 base::Unretained(this)), |
| 389 base::Bind(&BrowserMediaPlayerManager::DetachExternalVideoSurface, | 396 base::Bind(&BrowserMediaPlayerManager::DetachExternalVideoSurface, |
| 390 base::Unretained(this))); | 397 base::Unretained(this))); |
| 391 } | 398 } |
| 392 } | 399 } |
| 393 #endif // defined(VIDEO_HOLE) | 400 #endif // defined(VIDEO_HOLE) |
| 394 | 401 |
| 395 void BrowserMediaPlayerManager::OnEnterFullscreen(int player_id) { | 402 void BrowserMediaPlayerManager::OnEnterFullscreen(int player_id) { |
| 396 DCHECK_EQ(fullscreen_player_id_, -1); | 403 DCHECK_EQ(fullscreen_player_id_, -1); |
| 397 #if defined(VIDEO_HOLE) | 404 #if defined(VIDEO_HOLE) |
| 405 fullscreen_player_id_ = player_id; | |
|
qinmin
2014/11/10 18:37:24
this logic is bad, we setting fullscreen_player_id
Hugo Holgersson
2014/11/10 22:22:18
You are right!
I used this logic: the external su
| |
| 406 // Avoid Z-fight: when any player goes | |
| 407 // fullscreen release any external surface. | |
| 398 if (external_video_surface_container_) | 408 if (external_video_surface_container_) |
| 399 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); | 409 external_video_surface_container_->ReleaseExternalVideoSurface( |
| 410 ExternalVideoSurfaceContainer::kAnyPlayer); | |
| 411 fullscreen_player_id_ = -1; | |
| 400 #endif // defined(VIDEO_HOLE) | 412 #endif // defined(VIDEO_HOLE) |
| 401 if (video_view_.get()) { | 413 if (video_view_.get()) { |
| 402 fullscreen_player_id_ = player_id; | 414 fullscreen_player_id_ = player_id; |
| 403 video_view_->OpenVideo(); | 415 video_view_->OpenVideo(); |
| 404 return; | 416 return; |
| 405 } else if (!ContentVideoView::GetInstance()) { | 417 } else if (!ContentVideoView::GetInstance()) { |
| 406 // In Android WebView, two ContentViewCores could both try to enter | 418 // In Android WebView, two ContentViewCores could both try to enter |
| 407 // fullscreen video, we just ignore the second one. | 419 // fullscreen video, we just ignore the second one. |
| 408 video_view_.reset(new ContentVideoView(this)); | 420 video_view_.reset(new ContentVideoView(this)); |
| 409 base::android::ScopedJavaLocalRef<jobject> j_content_video_view = | 421 base::android::ScopedJavaLocalRef<jobject> j_content_video_view = |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); | 607 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); |
| 596 #endif // defined(VIDEO_HOLE) | 608 #endif // defined(VIDEO_HOLE) |
| 597 } | 609 } |
| 598 | 610 |
| 599 void BrowserMediaPlayerManager::ReleasePlayer(MediaPlayerAndroid* player) { | 611 void BrowserMediaPlayerManager::ReleasePlayer(MediaPlayerAndroid* player) { |
| 600 player->Release(); | 612 player->Release(); |
| 601 ReleaseMediaResources(player->player_id()); | 613 ReleaseMediaResources(player->player_id()); |
| 602 } | 614 } |
| 603 | 615 |
| 604 } // namespace content | 616 } // namespace content |
| OLD | NEW |