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

Side by Side Diff: content/browser/media/android/browser_media_player_manager.cc

Issue 896673003: Propagate audible state from player to the containing tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing copyright notice Created 5 years, 9 months 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 "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/android/media_players_observer.h"
10 #include "content/browser/media/android/browser_demuxer_android.h" 11 #include "content/browser/media/android/browser_demuxer_android.h"
11 #include "content/browser/media/android/media_resource_getter_impl.h" 12 #include "content/browser/media/android/media_resource_getter_impl.h"
12 #include "content/browser/renderer_host/render_view_host_impl.h" 13 #include "content/browser/renderer_host/render_view_host_impl.h"
13 #include "content/browser/web_contents/web_contents_view_android.h" 14 #include "content/browser/web_contents/web_contents_view_android.h"
14 #include "content/common/media/media_player_messages_android.h" 15 #include "content/common/media/media_player_messages_android.h"
15 #include "content/public/browser/android/content_view_core.h" 16 #include "content/public/browser/android/content_view_core.h"
16 #include "content/public/browser/android/external_video_surface_container.h" 17 #include "content/public/browser/android/external_video_surface_container.h"
17 #include "content/public/browser/browser_context.h" 18 #include "content/public/browser/browser_context.h"
18 #include "content/public/browser/content_browser_client.h" 19 #include "content/public/browser/content_browser_client.h"
19 #include "content/public/browser/render_frame_host.h" 20 #include "content/public/browser/render_frame_host.h"
(...skipping 30 matching lines...) Expand all
50 } 51 }
51 52
52 // static 53 // static
53 void BrowserMediaPlayerManager::RegisterMediaUrlInterceptor( 54 void BrowserMediaPlayerManager::RegisterMediaUrlInterceptor(
54 media::MediaUrlInterceptor* media_url_interceptor) { 55 media::MediaUrlInterceptor* media_url_interceptor) {
55 media_url_interceptor_ = media_url_interceptor; 56 media_url_interceptor_ = media_url_interceptor;
56 } 57 }
57 58
58 // static 59 // static
59 BrowserMediaPlayerManager* BrowserMediaPlayerManager::Create( 60 BrowserMediaPlayerManager* BrowserMediaPlayerManager::Create(
60 RenderFrameHost* rfh) { 61 RenderFrameHost* rfh,
62 MediaPlayersObserver* audio_monitor) {
61 if (g_factory) 63 if (g_factory)
62 return g_factory(rfh); 64 return g_factory(rfh, audio_monitor);
63 return new BrowserMediaPlayerManager(rfh); 65 return new BrowserMediaPlayerManager(rfh, audio_monitor);
64 } 66 }
65 67
66 ContentViewCoreImpl* BrowserMediaPlayerManager::GetContentViewCore() const { 68 ContentViewCoreImpl* BrowserMediaPlayerManager::GetContentViewCore() const {
67 return ContentViewCoreImpl::FromWebContents(web_contents()); 69 return ContentViewCoreImpl::FromWebContents(web_contents());
68 } 70 }
69 71
70 MediaPlayerAndroid* BrowserMediaPlayerManager::CreateMediaPlayer( 72 MediaPlayerAndroid* BrowserMediaPlayerManager::CreateMediaPlayer(
71 const MediaPlayerHostMsg_Initialize_Params& media_player_params, 73 const MediaPlayerHostMsg_Initialize_Params& media_player_params,
72 bool hide_url_log, 74 bool hide_url_log,
73 MediaPlayerManager* manager, 75 MediaPlayerManager* manager,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 demuxer->CreateDemuxer(media_player_params.demuxer_client_id), 116 demuxer->CreateDemuxer(media_player_params.demuxer_client_id),
115 media_player_params.frame_url); 117 media_player_params.frame_url);
116 } 118 }
117 } 119 }
118 120
119 NOTREACHED(); 121 NOTREACHED();
120 return NULL; 122 return NULL;
121 } 123 }
122 124
123 BrowserMediaPlayerManager::BrowserMediaPlayerManager( 125 BrowserMediaPlayerManager::BrowserMediaPlayerManager(
124 RenderFrameHost* render_frame_host) 126 RenderFrameHost* render_frame_host,
127 MediaPlayersObserver* audio_monitor)
125 : render_frame_host_(render_frame_host), 128 : render_frame_host_(render_frame_host),
129 audio_monitor_(audio_monitor),
126 fullscreen_player_id_(kInvalidMediaPlayerId), 130 fullscreen_player_id_(kInvalidMediaPlayerId),
127 fullscreen_player_is_released_(false), 131 fullscreen_player_is_released_(false),
128 web_contents_(WebContents::FromRenderFrameHost(render_frame_host)), 132 web_contents_(WebContents::FromRenderFrameHost(render_frame_host)),
129 weak_ptr_factory_(this) { 133 weak_ptr_factory_(this) {
130 } 134 }
131 135
132 BrowserMediaPlayerManager::~BrowserMediaPlayerManager() { 136 BrowserMediaPlayerManager::~BrowserMediaPlayerManager() {
133 // During the tear down process, OnDestroyPlayer() may or may not be called 137 // During the tear down process, OnDestroyPlayer() may or may not be called
134 // (e.g. the WebContents may be destroyed before the render process). So 138 // (e.g. the WebContents may be destroyed before the render process). So
135 // we cannot DCHECK(players_.empty()) here. Instead, all media players in 139 // we cannot DCHECK(players_.empty()) here. Instead, all media players in
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 251 }
248 252
249 void BrowserMediaPlayerManager::OnVideoSizeChanged( 253 void BrowserMediaPlayerManager::OnVideoSizeChanged(
250 int player_id, int width, int height) { 254 int player_id, int width, int height) {
251 Send(new MediaPlayerMsg_MediaVideoSizeChanged(RoutingID(), player_id, 255 Send(new MediaPlayerMsg_MediaVideoSizeChanged(RoutingID(), player_id,
252 width, height)); 256 width, height));
253 if (fullscreen_player_id_ == player_id) 257 if (fullscreen_player_id_ == player_id)
254 video_view_->OnVideoSizeChanged(width, height); 258 video_view_->OnVideoSizeChanged(width, height);
255 } 259 }
256 260
261 void BrowserMediaPlayerManager::OnAudibleStateChanged(
262 int player_id, bool is_audible) {
263 audio_monitor_->OnAudibleStateChanged(
264 render_frame_host_, player_id, is_audible);
265 }
266
257 media::MediaResourceGetter* 267 media::MediaResourceGetter*
258 BrowserMediaPlayerManager::GetMediaResourceGetter() { 268 BrowserMediaPlayerManager::GetMediaResourceGetter() {
259 if (!media_resource_getter_.get()) { 269 if (!media_resource_getter_.get()) {
260 RenderProcessHost* host = web_contents()->GetRenderProcessHost(); 270 RenderProcessHost* host = web_contents()->GetRenderProcessHost();
261 BrowserContext* context = host->GetBrowserContext(); 271 BrowserContext* context = host->GetBrowserContext();
262 StoragePartition* partition = host->GetStoragePartition(); 272 StoragePartition* partition = host->GetStoragePartition();
263 storage::FileSystemContext* file_system_context = 273 storage::FileSystemContext* file_system_context =
264 partition ? partition->GetFileSystemContext() : NULL; 274 partition ? partition->GetFileSystemContext() : NULL;
265 // Eventually this needs to be fixed to pass the correct frame rather 275 // Eventually this needs to be fixed to pass the correct frame rather
266 // than just using the main frame. 276 // than just using the main frame.
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 DCHECK(!GetPlayer(player->player_id())); 521 DCHECK(!GetPlayer(player->player_id()));
512 players_.push_back(player); 522 players_.push_back(player);
513 } 523 }
514 524
515 void BrowserMediaPlayerManager::RemovePlayer(int player_id) { 525 void BrowserMediaPlayerManager::RemovePlayer(int player_id) {
516 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin(); 526 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin();
517 it != players_.end(); ++it) { 527 it != players_.end(); ++it) {
518 if ((*it)->player_id() == player_id) { 528 if ((*it)->player_id() == player_id) {
519 ReleaseMediaResources(player_id); 529 ReleaseMediaResources(player_id);
520 players_.erase(it); 530 players_.erase(it);
531 audio_monitor_->RemovePlayer(render_frame_host_, player_id);
521 break; 532 break;
522 } 533 }
523 } 534 }
524 } 535 }
525 536
526 scoped_ptr<media::MediaPlayerAndroid> BrowserMediaPlayerManager::SwapPlayer( 537 scoped_ptr<media::MediaPlayerAndroid> BrowserMediaPlayerManager::SwapPlayer(
527 int player_id, media::MediaPlayerAndroid* player) { 538 int player_id, media::MediaPlayerAndroid* player) {
528 media::MediaPlayerAndroid* previous_player = NULL; 539 media::MediaPlayerAndroid* previous_player = NULL;
529 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin(); 540 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin();
530 it != players_.end(); ++it) { 541 it != players_.end(); ++it) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); 597 external_video_surface_container_->ReleaseExternalVideoSurface(player_id);
587 #endif // defined(VIDEO_HOLE) 598 #endif // defined(VIDEO_HOLE)
588 } 599 }
589 600
590 void BrowserMediaPlayerManager::ReleasePlayer(MediaPlayerAndroid* player) { 601 void BrowserMediaPlayerManager::ReleasePlayer(MediaPlayerAndroid* player) {
591 player->Release(); 602 player->Release();
592 ReleaseMediaResources(player->player_id()); 603 ReleaseMediaResources(player->player_id());
593 } 604 }
594 605
595 } // namespace content 606 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/android/browser_media_player_manager.h ('k') | content/browser/media/audio_state_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698