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" |
11 #include "content/browser/media/android/media_resource_getter_impl.h" | 11 #include "content/browser/media/android/media_resource_getter_impl.h" |
12 #include "content/browser/renderer_host/render_view_host_impl.h" | 12 #include "content/browser/renderer_host/render_view_host_impl.h" |
13 #include "content/browser/web_contents/web_contents_view_android.h" | 13 #include "content/browser/web_contents/web_contents_view_android.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/content_browser_client.h" |
19 #include "content/public/browser/render_frame_host.h" | 19 #include "content/public/browser/render_frame_host.h" |
20 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
21 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
22 #include "content/public/browser/storage_partition.h" | 22 #include "content/public/browser/storage_partition.h" |
23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
24 #include "content/public/browser/web_contents_delegate.h" | 24 #include "content/public/browser/web_contents_delegate.h" |
25 #include "content/public/common/content_client.h" | 25 #include "content/public/common/content_client.h" |
26 #include "content/public/common/content_switches.h" | 26 #include "content/public/common/content_switches.h" |
27 #include "media/base/android/media_player_bridge.h" | 27 #include "media/base/android/media_player_bridge.h" |
28 #include "media/base/android/media_source_player.h" | 28 #include "media/base/android/media_source_player.h" |
| 29 #include "media/base/android/media_url_interceptor.h" |
29 #include "media/base/media_switches.h" | 30 #include "media/base/media_switches.h" |
30 | 31 |
31 using media::MediaPlayerAndroid; | 32 using media::MediaPlayerAndroid; |
32 using media::MediaPlayerBridge; | 33 using media::MediaPlayerBridge; |
33 using media::MediaPlayerManager; | 34 using media::MediaPlayerManager; |
34 using media::MediaSourcePlayer; | 35 using media::MediaSourcePlayer; |
35 | 36 |
36 namespace content { | 37 namespace content { |
37 | 38 |
38 // Threshold on the number of media players per renderer before we start | 39 // Threshold on the number of media players per renderer before we start |
39 // attempting to release inactive media players. | 40 // attempting to release inactive media players. |
40 const int kMediaPlayerThreshold = 1; | 41 const int kMediaPlayerThreshold = 1; |
41 | 42 |
42 static BrowserMediaPlayerManager::Factory g_factory = NULL; | 43 static BrowserMediaPlayerManager::Factory g_factory = NULL; |
| 44 static media::MediaUrlInterceptor* media_url_interceptor_ = NULL; |
43 | 45 |
44 // static | 46 // static |
45 void BrowserMediaPlayerManager::RegisterFactory(Factory factory) { | 47 void BrowserMediaPlayerManager::RegisterFactory(Factory factory) { |
46 g_factory = factory; | 48 g_factory = factory; |
47 } | 49 } |
48 | 50 |
49 // static | 51 // static |
| 52 void BrowserMediaPlayerManager::RegisterMediaUrlInterceptor( |
| 53 media::MediaUrlInterceptor* media_url_interceptor) { |
| 54 media_url_interceptor_ = media_url_interceptor; |
| 55 } |
| 56 |
| 57 // static |
50 BrowserMediaPlayerManager* BrowserMediaPlayerManager::Create( | 58 BrowserMediaPlayerManager* BrowserMediaPlayerManager::Create( |
51 RenderFrameHost* rfh) { | 59 RenderFrameHost* rfh) { |
52 if (g_factory) | 60 if (g_factory) |
53 return g_factory(rfh); | 61 return g_factory(rfh); |
54 return new BrowserMediaPlayerManager(rfh); | 62 return new BrowserMediaPlayerManager(rfh); |
55 } | 63 } |
56 | 64 |
57 ContentViewCoreImpl* BrowserMediaPlayerManager::GetContentViewCore() const { | 65 ContentViewCoreImpl* BrowserMediaPlayerManager::GetContentViewCore() const { |
58 return ContentViewCoreImpl::FromWebContents(web_contents()); | 66 return ContentViewCoreImpl::FromWebContents(web_contents()); |
59 } | 67 } |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 // than just using the main frame. | 296 // than just using the main frame. |
289 media_resource_getter_.reset(new MediaResourceGetterImpl( | 297 media_resource_getter_.reset(new MediaResourceGetterImpl( |
290 context, | 298 context, |
291 file_system_context, | 299 file_system_context, |
292 host->GetID(), | 300 host->GetID(), |
293 web_contents()->GetMainFrame()->GetRoutingID())); | 301 web_contents()->GetMainFrame()->GetRoutingID())); |
294 } | 302 } |
295 return media_resource_getter_.get(); | 303 return media_resource_getter_.get(); |
296 } | 304 } |
297 | 305 |
| 306 media::MediaUrlInterceptor* |
| 307 BrowserMediaPlayerManager::GetMediaUrlInterceptor() { |
| 308 return media_url_interceptor_; |
| 309 } |
| 310 |
298 MediaPlayerAndroid* BrowserMediaPlayerManager::GetFullscreenPlayer() { | 311 MediaPlayerAndroid* BrowserMediaPlayerManager::GetFullscreenPlayer() { |
299 return GetPlayer(fullscreen_player_id_); | 312 return GetPlayer(fullscreen_player_id_); |
300 } | 313 } |
301 | 314 |
302 MediaPlayerAndroid* BrowserMediaPlayerManager::GetPlayer(int player_id) { | 315 MediaPlayerAndroid* BrowserMediaPlayerManager::GetPlayer(int player_id) { |
303 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin(); | 316 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin(); |
304 it != players_.end(); ++it) { | 317 it != players_.end(); ++it) { |
305 if ((*it)->player_id() == player_id) | 318 if ((*it)->player_id() == player_id) |
306 return *it; | 319 return *it; |
307 } | 320 } |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 #if defined(VIDEO_HOLE) | 585 #if defined(VIDEO_HOLE) |
573 MediaPlayerAndroid* player = GetPlayer(player_id); | 586 MediaPlayerAndroid* player = GetPlayer(player_id); |
574 if (player && player->IsSurfaceInUse()) | 587 if (player && player->IsSurfaceInUse()) |
575 return; | 588 return; |
576 if (external_video_surface_container_) | 589 if (external_video_surface_container_) |
577 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); | 590 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); |
578 #endif // defined(VIDEO_HOLE) | 591 #endif // defined(VIDEO_HOLE) |
579 } | 592 } |
580 | 593 |
581 } // namespace content | 594 } // namespace content |
OLD | NEW |