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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
341 jobject surface) { | 341 jobject surface) { |
342 MediaPlayerAndroid* player = GetPlayer(player_id); | 342 MediaPlayerAndroid* player = GetPlayer(player_id); |
343 if (player) { | 343 if (player) { |
344 player->SetVideoSurface( | 344 player->SetVideoSurface( |
345 gfx::ScopedJavaSurface::AcquireExternalSurface(surface)); | 345 gfx::ScopedJavaSurface::AcquireExternalSurface(surface)); |
346 } | 346 } |
347 } | 347 } |
348 | 348 |
349 void BrowserMediaPlayerManager::DetachExternalVideoSurface(int player_id) { | 349 void BrowserMediaPlayerManager::DetachExternalVideoSurface(int player_id) { |
350 MediaPlayerAndroid* player = GetPlayer(player_id); | 350 MediaPlayerAndroid* player = GetPlayer(player_id); |
351 if (player) | 351 if (player) { |
352 // If a player looses its external surface because | |
353 // it enters fullscreen, the video should not be paused. | |
354 if (player_id != fullscreen_player_id_) { | |
355 player->Release(); | |
356 Send(new MediaPlayerMsg_DidMediaPlayerPause(RoutingID(), player_id)); | |
357 } | |
352 player->SetVideoSurface(gfx::ScopedJavaSurface()); | 358 player->SetVideoSurface(gfx::ScopedJavaSurface()); |
359 } | |
353 } | 360 } |
354 | 361 |
355 void BrowserMediaPlayerManager::OnFrameInfoUpdated() { | 362 void BrowserMediaPlayerManager::OnFrameInfoUpdated() { |
356 if (external_video_surface_container_) | 363 if (external_video_surface_container_) |
357 external_video_surface_container_->OnFrameInfoUpdated(); | 364 external_video_surface_container_->OnFrameInfoUpdated(); |
358 } | 365 } |
359 | 366 |
360 void BrowserMediaPlayerManager::OnNotifyExternalSurface( | 367 void BrowserMediaPlayerManager::OnNotifyExternalSurface( |
361 int player_id, bool is_request, const gfx::RectF& rect) { | 368 int player_id, bool is_request, const gfx::RectF& rect) { |
362 if (!web_contents_) | 369 if (!web_contents_) |
(...skipping 24 matching lines...) Expand all Loading... | |
387 base::Unretained(this)), | 394 base::Unretained(this)), |
388 base::Bind(&BrowserMediaPlayerManager::DetachExternalVideoSurface, | 395 base::Bind(&BrowserMediaPlayerManager::DetachExternalVideoSurface, |
389 base::Unretained(this))); | 396 base::Unretained(this))); |
390 } | 397 } |
391 } | 398 } |
392 #endif // defined(VIDEO_HOLE) | 399 #endif // defined(VIDEO_HOLE) |
393 | 400 |
394 void BrowserMediaPlayerManager::OnEnterFullscreen(int player_id) { | 401 void BrowserMediaPlayerManager::OnEnterFullscreen(int player_id) { |
395 DCHECK_EQ(fullscreen_player_id_, -1); | 402 DCHECK_EQ(fullscreen_player_id_, -1); |
396 #if defined(VIDEO_HOLE) | 403 #if defined(VIDEO_HOLE) |
404 fullscreen_player_id_ = player_id; | |
qinmin
2014/11/21 00:23:50
As I mentioned earlier, using fullscreen_player_id
| |
405 // Avoid Z-fight: when any player goes | |
406 // fullscreen release any external surface. | |
397 if (external_video_surface_container_) | 407 if (external_video_surface_container_) |
398 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); | 408 external_video_surface_container_->ReleaseExternalVideoSurface( |
409 ExternalVideoSurfaceContainer::kAnyPlayer); | |
410 fullscreen_player_id_ = -1; | |
399 #endif // defined(VIDEO_HOLE) | 411 #endif // defined(VIDEO_HOLE) |
400 if (video_view_.get()) { | 412 if (video_view_.get()) { |
401 fullscreen_player_id_ = player_id; | 413 fullscreen_player_id_ = player_id; |
402 video_view_->OpenVideo(); | 414 video_view_->OpenVideo(); |
403 return; | 415 return; |
404 } else if (!ContentVideoView::GetInstance()) { | 416 } else if (!ContentVideoView::GetInstance()) { |
405 // In Android WebView, two ContentViewCores could both try to enter | 417 // In Android WebView, two ContentViewCores could both try to enter |
406 // fullscreen video, we just ignore the second one. | 418 // fullscreen video, we just ignore the second one. |
407 video_view_.reset(new ContentVideoView(this)); | 419 video_view_.reset(new ContentVideoView(this)); |
408 base::android::ScopedJavaLocalRef<jobject> j_content_video_view = | 420 base::android::ScopedJavaLocalRef<jobject> j_content_video_view = |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
590 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); | 602 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); |
591 #endif // defined(VIDEO_HOLE) | 603 #endif // defined(VIDEO_HOLE) |
592 } | 604 } |
593 | 605 |
594 void BrowserMediaPlayerManager::ReleasePlayer(MediaPlayerAndroid* player) { | 606 void BrowserMediaPlayerManager::ReleasePlayer(MediaPlayerAndroid* player) { |
595 player->Release(); | 607 player->Release(); |
596 ReleaseMediaResources(player->player_id()); | 608 ReleaseMediaResources(player->player_id()); |
597 } | 609 } |
598 | 610 |
599 } // namespace content | 611 } // namespace content |
OLD | NEW |