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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "content/browser/android/content_view_core_impl.h" | 8 #include "content/browser/android/content_view_core_impl.h" |
9 #include "content/browser/media/android/browser_demuxer_android.h" | 9 #include "content/browser/media/android/browser_demuxer_android.h" |
10 #include "content/browser/media/android/media_resource_getter_impl.h" | 10 #include "content/browser/media/android/media_resource_getter_impl.h" |
11 #include "content/browser/renderer_host/render_view_host_impl.h" | 11 #include "content/browser/renderer_host/render_view_host_impl.h" |
12 #include "content/browser/web_contents/web_contents_view_android.h" | 12 #include "content/browser/web_contents/web_contents_view_android.h" |
13 #include "content/common/media/cdm_messages.h" | 13 #include "content/common/media/cdm_messages.h" |
14 #include "content/common/media/media_player_messages_android.h" | 14 #include "content/common/media/media_player_messages_android.h" |
15 #include "content/public/browser/android/content_view_core.h" | 15 #include "content/public/browser/android/content_view_core.h" |
16 #include "content/public/browser/android/external_video_surface_container.h" | 16 #include "content/public/browser/android/external_video_surface_container.h" |
17 #include "content/public/browser/browser_context.h" | 17 #include "content/public/browser/browser_context.h" |
18 #include "content/public/browser/content_browser_client.h" | |
18 #include "content/public/browser/render_process_host.h" | 19 #include "content/public/browser/render_process_host.h" |
19 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
20 #include "content/public/browser/storage_partition.h" | 21 #include "content/public/browser/storage_partition.h" |
21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
22 #include "content/public/browser/web_contents_delegate.h" | 23 #include "content/public/browser/web_contents_delegate.h" |
23 #include "content/public/common/content_client.h" | 24 #include "content/public/common/content_client.h" |
24 #include "content/public/common/content_switches.h" | 25 #include "content/public/common/content_switches.h" |
25 #include "media/base/android/media_drm_bridge.h" | 26 #include "media/base/android/media_drm_bridge.h" |
26 #include "media/base/android/media_player_bridge.h" | 27 #include "media/base/android/media_player_bridge.h" |
27 #include "media/base/android/media_source_player.h" | 28 #include "media/base/android/media_source_player.h" |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
430 gfx::ScopedJavaSurface::AcquireExternalSurface(surface)); | 431 gfx::ScopedJavaSurface::AcquireExternalSurface(surface)); |
431 } | 432 } |
432 } | 433 } |
433 | 434 |
434 void BrowserMediaPlayerManager::DetachExternalVideoSurface(int player_id) { | 435 void BrowserMediaPlayerManager::DetachExternalVideoSurface(int player_id) { |
435 MediaPlayerAndroid* player = GetPlayer(player_id); | 436 MediaPlayerAndroid* player = GetPlayer(player_id); |
436 if (player) | 437 if (player) |
437 player->SetVideoSurface(gfx::ScopedJavaSurface()); | 438 player->SetVideoSurface(gfx::ScopedJavaSurface()); |
438 } | 439 } |
439 | 440 |
441 void BrowserMediaPlayerManager::OnFrameInfoUpdated() { | |
boliu
2014/04/11 01:52:10
How much of the new code in this file need to be b
ycheo (away)
2014/04/11 05:05:46
The remained parts are to control to enable or dis
| |
442 if (external_video_surface_container_) { | |
443 external_video_surface_container_->OnFrameInfoUpdated(); | |
444 } | |
445 } | |
446 | |
440 void BrowserMediaPlayerManager::OnNotifyExternalSurface( | 447 void BrowserMediaPlayerManager::OnNotifyExternalSurface( |
441 int player_id, bool is_request, const gfx::RectF& rect) { | 448 int player_id, bool is_request, const gfx::RectF& rect) { |
442 if (!web_contents_) | 449 if (!web_contents_) |
443 return; | 450 return; |
444 | 451 |
445 ExternalVideoSurfaceContainer::CreateForWebContents(web_contents_); | |
446 ExternalVideoSurfaceContainer* surface_container = | |
447 ExternalVideoSurfaceContainer::FromWebContents(web_contents_); | |
448 if (!surface_container) | |
449 return; | |
450 | |
451 if (is_request) { | 452 if (is_request) { |
453 if (!external_video_surface_container_) { | |
454 external_video_surface_container_.reset( | |
455 GetContentClient()->browser()->CreateExternalVideoSurfaceContainer( | |
456 web_contents_)); | |
457 } | |
452 // It's safe to use base::Unretained(this), because the callbacks will not | 458 // It's safe to use base::Unretained(this), because the callbacks will not |
453 // be called after running ReleaseExternalVideoSurface(). | 459 // be called after running ReleaseExternalVideoSurface(). |
454 surface_container->RequestExternalVideoSurface( | 460 external_video_surface_container_->RequestExternalVideoSurface( |
boliu
2014/04/11 01:52:10
Need to handle the case when CreateExternalVideoS
ycheo (away)
2014/04/11 05:05:46
Done.
| |
455 player_id, | 461 player_id, |
456 base::Bind(&BrowserMediaPlayerManager::AttachExternalVideoSurface, | 462 base::Bind(&BrowserMediaPlayerManager::AttachExternalVideoSurface, |
457 base::Unretained(this)), | 463 base::Unretained(this)), |
458 base::Bind(&BrowserMediaPlayerManager::DetachExternalVideoSurface, | 464 base::Bind(&BrowserMediaPlayerManager::DetachExternalVideoSurface, |
459 base::Unretained(this))); | 465 base::Unretained(this))); |
460 } | 466 } |
461 surface_container->OnExternalVideoSurfacePositionChanged(player_id, rect); | 467 if (external_video_surface_container_) { |
468 external_video_surface_container_->OnExternalVideoSurfacePositionChanged( | |
469 player_id, rect); | |
470 } | |
462 } | 471 } |
463 #endif // defined(VIDEO_HOLE) | 472 #endif // defined(VIDEO_HOLE) |
464 | 473 |
465 void BrowserMediaPlayerManager::DisableFullscreenEncryptedMediaPlayback() { | 474 void BrowserMediaPlayerManager::DisableFullscreenEncryptedMediaPlayback() { |
466 if (fullscreen_player_id_ == -1) | 475 if (fullscreen_player_id_ == -1) |
467 return; | 476 return; |
468 | 477 |
469 // If the fullscreen player is not playing back encrypted video, do nothing. | 478 // If the fullscreen player is not playing back encrypted video, do nothing. |
470 MediaDrmBridge* drm_bridge = GetDrmBridge(fullscreen_player_id_); | 479 MediaDrmBridge* drm_bridge = GetDrmBridge(fullscreen_player_id_); |
471 if (!drm_bridge) | 480 if (!drm_bridge) |
472 return; | 481 return; |
473 | 482 |
474 // Exit fullscreen. | 483 // Exit fullscreen. |
475 pending_fullscreen_player_id_ = fullscreen_player_id_; | 484 pending_fullscreen_player_id_ = fullscreen_player_id_; |
476 OnExitFullscreen(fullscreen_player_id_); | 485 OnExitFullscreen(fullscreen_player_id_); |
477 } | 486 } |
478 | 487 |
479 void BrowserMediaPlayerManager::OnEnterFullscreen(int player_id) { | 488 void BrowserMediaPlayerManager::OnEnterFullscreen(int player_id) { |
480 DCHECK_EQ(fullscreen_player_id_, -1); | 489 DCHECK_EQ(fullscreen_player_id_, -1); |
481 if (cdm_ids_pending_approval_.find(player_id) != | 490 if (cdm_ids_pending_approval_.find(player_id) != |
482 cdm_ids_pending_approval_.end()) { | 491 cdm_ids_pending_approval_.end()) { |
483 return; | 492 return; |
484 } | 493 } |
485 | 494 |
486 #if defined(VIDEO_HOLE) | 495 #if defined(VIDEO_HOLE) |
487 ExternalVideoSurfaceContainer* surface_container = | 496 if (external_video_surface_container_) |
488 ExternalVideoSurfaceContainer::FromWebContents(web_contents_); | 497 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); |
489 if (surface_container) | |
490 surface_container->ReleaseExternalVideoSurface(player_id); | |
491 #endif // defined(VIDEO_HOLE) | 498 #endif // defined(VIDEO_HOLE) |
492 if (video_view_.get()) { | 499 if (video_view_.get()) { |
493 fullscreen_player_id_ = player_id; | 500 fullscreen_player_id_ = player_id; |
494 video_view_->OpenVideo(); | 501 video_view_->OpenVideo(); |
495 } else if (!ContentVideoView::GetInstance()) { | 502 } else if (!ContentVideoView::GetInstance()) { |
496 // In Android WebView, two ContentViewCores could both try to enter | 503 // In Android WebView, two ContentViewCores could both try to enter |
497 // fullscreen video, we just ignore the second one. | 504 // fullscreen video, we just ignore the second one. |
498 fullscreen_player_id_ = player_id; | 505 fullscreen_player_id_ = player_id; |
499 video_view_.reset(new ContentVideoView(this)); | 506 video_view_.reset(new ContentVideoView(this)); |
500 } | 507 } |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
866 routing_id(), (*it)->player_id())); | 873 routing_id(), (*it)->player_id())); |
867 } | 874 } |
868 } | 875 } |
869 } | 876 } |
870 | 877 |
871 void BrowserMediaPlayerManager::OnMediaResourcesReleased(int player_id) { | 878 void BrowserMediaPlayerManager::OnMediaResourcesReleased(int player_id) { |
872 #if defined(VIDEO_HOLE) | 879 #if defined(VIDEO_HOLE) |
873 MediaPlayerAndroid* player = GetPlayer(player_id); | 880 MediaPlayerAndroid* player = GetPlayer(player_id); |
874 if (player && player->IsSurfaceInUse()) | 881 if (player && player->IsSurfaceInUse()) |
875 return; | 882 return; |
876 ExternalVideoSurfaceContainer* surface_container = | 883 if (external_video_surface_container_) |
877 ExternalVideoSurfaceContainer::FromWebContents(web_contents_); | 884 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); |
878 if (surface_container) | |
879 surface_container->ReleaseExternalVideoSurface(player_id); | |
880 #endif // defined(VIDEO_HOLE) | 885 #endif // defined(VIDEO_HOLE) |
881 } | 886 } |
882 | 887 |
883 } // namespace content | 888 } // namespace content |
OLD | NEW |