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/android/media_players_observer.h" | 10 #include "content/browser/media/android/browser_demuxer_android.h" |
Ted C
2015/08/27 23:58:44
indented too much
| |
11 #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/media/android/media_session.h" | 12 #include "content/browser/media/android/media_session.h" |
14 #include "content/browser/media/media_web_contents_observer.h" | 13 #include "content/browser/media/media_web_contents_observer.h" |
15 #include "content/browser/renderer_host/render_view_host_impl.h" | 14 #include "content/browser/renderer_host/render_view_host_impl.h" |
16 #include "content/browser/web_contents/web_contents_view_android.h" | 15 #include "content/browser/web_contents/web_contents_view_android.h" |
17 #include "content/common/media/media_player_messages_android.h" | 16 #include "content/common/media/media_player_messages_android.h" |
18 #include "content/public/browser/android/content_view_core.h" | 17 #include "content/public/browser/android/content_view_core.h" |
19 #include "content/public/browser/android/external_video_surface_container.h" | 18 #include "content/public/browser/android/external_video_surface_container.h" |
20 #include "content/public/browser/browser_context.h" | 19 #include "content/public/browser/browser_context.h" |
21 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 } | 113 } |
115 | 114 |
116 if (player != player_manager->GetFullscreenPlayer()) { | 115 if (player != player_manager->GetFullscreenPlayer()) { |
117 gfx::ScopedJavaSurface scoped_surface(surface_texture.get()); | 116 gfx::ScopedJavaSurface scoped_surface(surface_texture.get()); |
118 player->SetVideoSurface(scoped_surface.Pass()); | 117 player->SetVideoSurface(scoped_surface.Pass()); |
119 } | 118 } |
120 } | 119 } |
121 | 120 |
122 // static | 121 // static |
123 BrowserMediaPlayerManager* BrowserMediaPlayerManager::Create( | 122 BrowserMediaPlayerManager* BrowserMediaPlayerManager::Create( |
124 RenderFrameHost* rfh, | 123 RenderFrameHost* rfh) { |
125 MediaPlayersObserver* audio_monitor) { | |
126 if (g_factory) | 124 if (g_factory) |
127 return g_factory(rfh, audio_monitor); | 125 return g_factory(rfh); |
128 return new BrowserMediaPlayerManager(rfh, audio_monitor); | 126 return new BrowserMediaPlayerManager(rfh); |
129 } | 127 } |
130 | 128 |
131 ContentViewCore* BrowserMediaPlayerManager::GetContentViewCore() const { | 129 ContentViewCore* BrowserMediaPlayerManager::GetContentViewCore() const { |
132 return ContentViewCoreImpl::FromWebContents(web_contents()); | 130 return ContentViewCoreImpl::FromWebContents(web_contents()); |
133 } | 131 } |
134 | 132 |
135 MediaPlayerAndroid* BrowserMediaPlayerManager::CreateMediaPlayer( | 133 MediaPlayerAndroid* BrowserMediaPlayerManager::CreateMediaPlayer( |
136 const MediaPlayerHostMsg_Initialize_Params& media_player_params, | 134 const MediaPlayerHostMsg_Initialize_Params& media_player_params, |
137 bool hide_url_log, | 135 bool hide_url_log, |
138 BrowserDemuxerAndroid* demuxer) { | 136 BrowserDemuxerAndroid* demuxer) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 media_player_params.frame_url); | 185 media_player_params.frame_url); |
188 } | 186 } |
189 } | 187 } |
190 } | 188 } |
191 | 189 |
192 NOTREACHED(); | 190 NOTREACHED(); |
193 return NULL; | 191 return NULL; |
194 } | 192 } |
195 | 193 |
196 BrowserMediaPlayerManager::BrowserMediaPlayerManager( | 194 BrowserMediaPlayerManager::BrowserMediaPlayerManager( |
197 RenderFrameHost* render_frame_host, | 195 RenderFrameHost* render_frame_host) |
198 MediaPlayersObserver* audio_monitor) | |
199 : render_frame_host_(render_frame_host), | 196 : render_frame_host_(render_frame_host), |
200 audio_monitor_(audio_monitor), | |
201 fullscreen_player_id_(kInvalidMediaPlayerId), | 197 fullscreen_player_id_(kInvalidMediaPlayerId), |
202 fullscreen_player_is_released_(false), | 198 fullscreen_player_is_released_(false), |
203 web_contents_(WebContents::FromRenderFrameHost(render_frame_host)), | 199 web_contents_(WebContents::FromRenderFrameHost(render_frame_host)), |
204 weak_ptr_factory_(this) { | 200 weak_ptr_factory_(this) { |
205 } | 201 } |
206 | 202 |
207 BrowserMediaPlayerManager::~BrowserMediaPlayerManager() { | 203 BrowserMediaPlayerManager::~BrowserMediaPlayerManager() { |
208 // During the tear down process, OnDestroyPlayer() may or may not be called | 204 // During the tear down process, OnDestroyPlayer() may or may not be called |
209 // (e.g. the WebContents may be destroyed before the render process). So | 205 // (e.g. the WebContents may be destroyed before the render process). So |
210 // we cannot DCHECK(players_.empty()) here. Instead, all media players in | 206 // we cannot DCHECK(players_.empty()) here. Instead, all media players in |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 } | 326 } |
331 | 327 |
332 void BrowserMediaPlayerManager::OnVideoSizeChanged( | 328 void BrowserMediaPlayerManager::OnVideoSizeChanged( |
333 int player_id, int width, int height) { | 329 int player_id, int width, int height) { |
334 Send(new MediaPlayerMsg_MediaVideoSizeChanged(RoutingID(), player_id, | 330 Send(new MediaPlayerMsg_MediaVideoSizeChanged(RoutingID(), player_id, |
335 width, height)); | 331 width, height)); |
336 if (fullscreen_player_id_ == player_id) | 332 if (fullscreen_player_id_ == player_id) |
337 video_view_->OnVideoSizeChanged(width, height); | 333 video_view_->OnVideoSizeChanged(width, height); |
338 } | 334 } |
339 | 335 |
340 void BrowserMediaPlayerManager::OnAudibleStateChanged( | |
341 int player_id, bool is_audible) { | |
342 audio_monitor_->OnAudibleStateChanged( | |
343 render_frame_host_, player_id, is_audible); | |
344 } | |
345 | |
346 void BrowserMediaPlayerManager::OnWaitingForDecryptionKey(int player_id) { | 336 void BrowserMediaPlayerManager::OnWaitingForDecryptionKey(int player_id) { |
347 Send(new MediaPlayerMsg_WaitingForDecryptionKey(RoutingID(), player_id)); | 337 Send(new MediaPlayerMsg_WaitingForDecryptionKey(RoutingID(), player_id)); |
348 } | 338 } |
349 | 339 |
350 media::MediaResourceGetter* | 340 media::MediaResourceGetter* |
351 BrowserMediaPlayerManager::GetMediaResourceGetter() { | 341 BrowserMediaPlayerManager::GetMediaResourceGetter() { |
352 if (!media_resource_getter_.get()) { | 342 if (!media_resource_getter_.get()) { |
353 RenderProcessHost* host = web_contents()->GetRenderProcessHost(); | 343 RenderProcessHost* host = web_contents()->GetRenderProcessHost(); |
354 BrowserContext* context = host->GetBrowserContext(); | 344 BrowserContext* context = host->GetBrowserContext(); |
355 StoragePartition* partition = host->GetStoragePartition(); | 345 StoragePartition* partition = host->GetStoragePartition(); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
616 players_.push_back(player); | 606 players_.push_back(player); |
617 } | 607 } |
618 | 608 |
619 void BrowserMediaPlayerManager::RemovePlayer(int player_id) { | 609 void BrowserMediaPlayerManager::RemovePlayer(int player_id) { |
620 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin(); | 610 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin(); |
621 it != players_.end(); ++it) { | 611 it != players_.end(); ++it) { |
622 if ((*it)->player_id() == player_id) { | 612 if ((*it)->player_id() == player_id) { |
623 ReleaseMediaResources(player_id); | 613 ReleaseMediaResources(player_id); |
624 (*it)->DeleteOnCorrectThread(); | 614 (*it)->DeleteOnCorrectThread(); |
625 players_.weak_erase(it); | 615 players_.weak_erase(it); |
626 audio_monitor_->RemovePlayer(render_frame_host_, player_id); | |
627 MediaSession::Get(web_contents())->RemovePlayer(this, player_id); | 616 MediaSession::Get(web_contents())->RemovePlayer(this, player_id); |
628 break; | 617 break; |
629 } | 618 } |
630 } | 619 } |
631 } | 620 } |
632 | 621 |
633 scoped_ptr<media::MediaPlayerAndroid> BrowserMediaPlayerManager::SwapPlayer( | 622 scoped_ptr<media::MediaPlayerAndroid> BrowserMediaPlayerManager::SwapPlayer( |
634 int player_id, media::MediaPlayerAndroid* player) { | 623 int player_id, media::MediaPlayerAndroid* player) { |
635 media::MediaPlayerAndroid* previous_player = NULL; | 624 media::MediaPlayerAndroid* previous_player = NULL; |
636 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin(); | 625 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
693 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); | 682 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); |
694 #endif // defined(VIDEO_HOLE) | 683 #endif // defined(VIDEO_HOLE) |
695 } | 684 } |
696 | 685 |
697 void BrowserMediaPlayerManager::ReleasePlayer(MediaPlayerAndroid* player) { | 686 void BrowserMediaPlayerManager::ReleasePlayer(MediaPlayerAndroid* player) { |
698 player->Release(); | 687 player->Release(); |
699 ReleaseMediaResources(player->player_id()); | 688 ReleaseMediaResources(player->player_id()); |
700 } | 689 } |
701 | 690 |
702 } // namespace content | 691 } // namespace content |
OLD | NEW |