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

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

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