Chromium Code Reviews| 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 "base/metrics/histogram.h" | |
| 9 #include "content/browser/android/content_view_core_impl.h" | 10 #include "content/browser/android/content_view_core_impl.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" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 33 using media::MediaPlayerBridge; | 34 using media::MediaPlayerBridge; |
| 34 using media::MediaPlayerManager; | 35 using media::MediaPlayerManager; |
| 35 using media::MediaSourcePlayer; | 36 using media::MediaSourcePlayer; |
| 36 | 37 |
| 37 namespace content { | 38 namespace content { |
| 38 | 39 |
| 39 // Threshold on the number of media players per renderer before we start | 40 // Threshold on the number of media players per renderer before we start |
| 40 // attempting to release inactive media players. | 41 // attempting to release inactive media players. |
| 41 const int kMediaPlayerThreshold = 1; | 42 const int kMediaPlayerThreshold = 1; |
| 42 | 43 |
| 44 // Number of media types to be recorded. | |
| 45 const int kMaxMediaTypes = 2; | |
|
Ilya Sherman
2014/08/27 22:14:37
nit: This is now unused.
qinmin
2014/08/28 00:30:09
changed to 3 as we combine the 3 types.
On 2014/08
| |
| 46 | |
| 43 static BrowserMediaPlayerManager::Factory g_factory = NULL; | 47 static BrowserMediaPlayerManager::Factory g_factory = NULL; |
| 44 static media::MediaUrlInterceptor* media_url_interceptor_ = NULL; | 48 static media::MediaUrlInterceptor* media_url_interceptor_ = NULL; |
| 45 | 49 |
| 50 void RecordMobileMediaType(bool is_media_url) { | |
|
xhwang
2014/08/27 23:02:21
nit: Won't it be easier if you just report MediaPl
qinmin
2014/08/28 00:30:09
Done.
| |
| 51 UMA_HISTOGRAM_BOOLEAN("Media.Mobile.MediaType", is_media_url); | |
|
xhwang
2014/08/27 23:02:21
nit: Since this only applies to Chrome for Android
qinmin
2014/08/28 00:30:09
Done.
| |
| 52 } | |
| 53 | |
| 46 // static | 54 // static |
| 47 void BrowserMediaPlayerManager::RegisterFactory(Factory factory) { | 55 void BrowserMediaPlayerManager::RegisterFactory(Factory factory) { |
| 48 g_factory = factory; | 56 g_factory = factory; |
| 49 } | 57 } |
| 50 | 58 |
| 51 // static | 59 // static |
| 52 void BrowserMediaPlayerManager::RegisterMediaUrlInterceptor( | 60 void BrowserMediaPlayerManager::RegisterMediaUrlInterceptor( |
| 53 media::MediaUrlInterceptor* media_url_interceptor) { | 61 media::MediaUrlInterceptor* media_url_interceptor) { |
| 54 media_url_interceptor_ = media_url_interceptor; | 62 media_url_interceptor_ = media_url_interceptor; |
| 55 } | 63 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 // May reach here due to prerendering. Don't extract the metadata | 104 // May reach here due to prerendering. Don't extract the metadata |
| 97 // since it is expensive. | 105 // since it is expensive. |
| 98 // TODO(qinmin): extract the metadata once the user decided to load | 106 // TODO(qinmin): extract the metadata once the user decided to load |
| 99 // the page. | 107 // the page. |
| 100 browser_media_player_manager->OnMediaMetadataChanged( | 108 browser_media_player_manager->OnMediaMetadataChanged( |
| 101 media_player_params.player_id, base::TimeDelta(), 0, 0, false); | 109 media_player_params.player_id, base::TimeDelta(), 0, 0, false); |
| 102 } else if (!content_view_core_impl->ShouldBlockMediaRequest( | 110 } else if (!content_view_core_impl->ShouldBlockMediaRequest( |
| 103 media_player_params.url)) { | 111 media_player_params.url)) { |
| 104 media_player_bridge->Initialize(); | 112 media_player_bridge->Initialize(); |
| 105 } | 113 } |
| 114 std::string path = media_player_params.url.path(); | |
| 115 bool is_hls_media = EndsWith(path, ".m3u8", true) || | |
| 116 EndsWith(path, ".m3u", true); | |
| 117 UMA_HISTOGRAM_BOOLEAN("Media.Mobile.IsHttpLiveStreamingMedia", | |
| 118 is_hls_media); | |
|
xhwang
2014/08/27 23:02:21
nit:
Since both UMAs are pretty small (having onl
qinmin
2014/08/28 00:30:09
Done.
ddorwin
2014/08/28 00:59:14
drive-by:
Would it make more sense to have a "cont
| |
| 119 RecordMobileMediaType(true); | |
| 106 return media_player_bridge; | 120 return media_player_bridge; |
| 107 } | 121 } |
| 108 | 122 |
| 109 case MEDIA_PLAYER_TYPE_MEDIA_SOURCE: { | 123 case MEDIA_PLAYER_TYPE_MEDIA_SOURCE: { |
| 124 RecordMobileMediaType(false); | |
| 110 return new MediaSourcePlayer( | 125 return new MediaSourcePlayer( |
| 111 media_player_params.player_id, | 126 media_player_params.player_id, |
| 112 manager, | 127 manager, |
| 113 base::Bind(&BrowserMediaPlayerManager::OnMediaResourcesRequested, | 128 base::Bind(&BrowserMediaPlayerManager::OnMediaResourcesRequested, |
| 114 weak_ptr_factory_.GetWeakPtr()), | 129 weak_ptr_factory_.GetWeakPtr()), |
| 115 base::Bind(&BrowserMediaPlayerManager::OnMediaResourcesReleased, | 130 base::Bind(&BrowserMediaPlayerManager::OnMediaResourcesReleased, |
| 116 weak_ptr_factory_.GetWeakPtr()), | 131 weak_ptr_factory_.GetWeakPtr()), |
| 117 demuxer->CreateDemuxer(media_player_params.demuxer_client_id), | 132 demuxer->CreateDemuxer(media_player_params.demuxer_client_id), |
| 118 media_player_params.frame_url); | 133 media_player_params.frame_url); |
| 119 } | 134 } |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 586 #if defined(VIDEO_HOLE) | 601 #if defined(VIDEO_HOLE) |
| 587 MediaPlayerAndroid* player = GetPlayer(player_id); | 602 MediaPlayerAndroid* player = GetPlayer(player_id); |
| 588 if (player && player->IsSurfaceInUse()) | 603 if (player && player->IsSurfaceInUse()) |
| 589 return; | 604 return; |
| 590 if (external_video_surface_container_) | 605 if (external_video_surface_container_) |
| 591 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); | 606 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); |
| 592 #endif // defined(VIDEO_HOLE) | 607 #endif // defined(VIDEO_HOLE) |
| 593 } | 608 } |
| 594 | 609 |
| 595 } // namespace content | 610 } // namespace content |
| OLD | NEW |