| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/android/media_player_manager_android.h" | 5 #include "content/browser/android/media_player_manager_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "content/browser/android/media_resource_getter_impl.h" | 8 #include "content/browser/android/media_resource_getter_impl.h" |
| 9 #include "content/browser/web_contents/web_contents_view_android.h" | 9 #include "content/browser/web_contents/web_contents_view_android.h" |
| 10 #include "content/common/media/media_player_messages.h" | 10 #include "content/common/media/media_player_messages.h" |
| 11 #include "content/public/browser/browser_context.h" | 11 #include "content/public/browser/browser_context.h" |
| 12 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
| 13 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
| 14 #include "content/public/browser/storage_partition.h" | 14 #include "content/public/browser/storage_partition.h" |
| 15 | 15 |
| 16 using media::MediaPlayerBridge; | 16 using media::MediaPlayerBridge; |
| 17 | 17 |
| 18 // Threshold on the number of media players per renderer before we start | 18 // Threshold on the number of media players per renderer before we start |
| 19 // attempting to release inactive media players. | 19 // attempting to release inactive media players. |
| 20 static const int kMediaPlayerThreshold = 1; | 20 static const int kMediaPlayerThreshold = 1; |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 | 23 |
| 24 MediaPlayerManagerAndroid::MediaPlayerManagerAndroid( | 24 MediaPlayerManagerImpl::MediaPlayerManagerImpl( |
| 25 RenderViewHost* render_view_host) | 25 RenderViewHost* render_view_host) |
| 26 : RenderViewHostObserver(render_view_host), | 26 : RenderViewHostObserver(render_view_host), |
| 27 ALLOW_THIS_IN_INITIALIZER_LIST(video_view_(this)), | 27 ALLOW_THIS_IN_INITIALIZER_LIST(video_view_(this)), |
| 28 fullscreen_player_id_(-1), | 28 fullscreen_player_id_(-1), |
| 29 web_contents_(WebContents::FromRenderViewHost(render_view_host)) { | 29 web_contents_(WebContents::FromRenderViewHost(render_view_host)) { |
| 30 } | 30 } |
| 31 | 31 |
| 32 MediaPlayerManagerAndroid::~MediaPlayerManagerAndroid() {} | 32 MediaPlayerManagerImpl::~MediaPlayerManagerImpl() {} |
| 33 | 33 |
| 34 bool MediaPlayerManagerAndroid::OnMessageReceived(const IPC::Message& msg) { | 34 bool MediaPlayerManagerImpl::OnMessageReceived(const IPC::Message& msg) { |
| 35 bool handled = true; | 35 bool handled = true; |
| 36 IPC_BEGIN_MESSAGE_MAP(MediaPlayerManagerAndroid, msg) | 36 IPC_BEGIN_MESSAGE_MAP(MediaPlayerManagerImpl, msg) |
| 37 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_EnterFullscreen, OnEnterFullscreen) | 37 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_EnterFullscreen, OnEnterFullscreen) |
| 38 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_ExitFullscreen, OnExitFullscreen) | 38 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_ExitFullscreen, OnExitFullscreen) |
| 39 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_MediaPlayerInitialize, OnInitialize) | 39 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_MediaPlayerInitialize, OnInitialize) |
| 40 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_MediaPlayerStart, OnStart) | 40 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_MediaPlayerStart, OnStart) |
| 41 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_MediaPlayerSeek, OnSeek) | 41 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_MediaPlayerSeek, OnSeek) |
| 42 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_MediaPlayerPause, OnPause) | 42 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_MediaPlayerPause, OnPause) |
| 43 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_MediaPlayerRelease, | 43 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_MediaPlayerRelease, |
| 44 OnReleaseResources) | 44 OnReleaseResources) |
| 45 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DestroyMediaPlayer, OnDestroyPlayer) | 45 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DestroyMediaPlayer, OnDestroyPlayer) |
| 46 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DestroyAllMediaPlayers, | 46 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DestroyAllMediaPlayers, |
| 47 DestroyAllMediaPlayers) | 47 DestroyAllMediaPlayers) |
| 48 #if defined(GOOGLE_TV) | 48 #if defined(GOOGLE_TV) |
| 49 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_RequestExternalSurface, | 49 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_RequestExternalSurface, |
| 50 OnRequestExternalSurface) | 50 OnRequestExternalSurface) |
| 51 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_NotifyGeometryChange, | 51 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_NotifyGeometryChange, |
| 52 OnNotifyGeometryChange) | 52 OnNotifyGeometryChange) |
| 53 #endif | 53 #endif |
| 54 IPC_MESSAGE_UNHANDLED(handled = false) | 54 IPC_MESSAGE_UNHANDLED(handled = false) |
| 55 IPC_END_MESSAGE_MAP() | 55 IPC_END_MESSAGE_MAP() |
| 56 return handled; | 56 return handled; |
| 57 } | 57 } |
| 58 | 58 |
| 59 void MediaPlayerManagerAndroid::FullscreenPlayerPlay() { | 59 void MediaPlayerManagerImpl::FullscreenPlayerPlay() { |
| 60 MediaPlayerBridge* player = GetFullscreenPlayer(); | 60 MediaPlayerBridge* player = GetFullscreenPlayer(); |
| 61 if (player) { | 61 if (player) { |
| 62 player->Start(); | 62 player->Start(); |
| 63 Send(new MediaPlayerMsg_DidMediaPlayerPlay( | 63 Send(new MediaPlayerMsg_DidMediaPlayerPlay( |
| 64 routing_id(), fullscreen_player_id_)); | 64 routing_id(), fullscreen_player_id_)); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 void MediaPlayerManagerAndroid::FullscreenPlayerPause() { | 68 void MediaPlayerManagerImpl::FullscreenPlayerPause() { |
| 69 MediaPlayerBridge* player = GetFullscreenPlayer(); | 69 MediaPlayerBridge* player = GetFullscreenPlayer(); |
| 70 if (player) { | 70 if (player) { |
| 71 player->Pause(); | 71 player->Pause(); |
| 72 Send(new MediaPlayerMsg_DidMediaPlayerPause( | 72 Send(new MediaPlayerMsg_DidMediaPlayerPause( |
| 73 routing_id(), fullscreen_player_id_)); | 73 routing_id(), fullscreen_player_id_)); |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 void MediaPlayerManagerAndroid::FullscreenPlayerSeek(int msec) { | 77 void MediaPlayerManagerImpl::FullscreenPlayerSeek(int msec) { |
| 78 MediaPlayerBridge* player = GetFullscreenPlayer(); | 78 MediaPlayerBridge* player = GetFullscreenPlayer(); |
| 79 if (player) | 79 if (player) |
| 80 player->SeekTo(base::TimeDelta::FromMilliseconds(msec)); | 80 player->SeekTo(base::TimeDelta::FromMilliseconds(msec)); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void MediaPlayerManagerAndroid::ExitFullscreen(bool release_media_player) { | 83 void MediaPlayerManagerImpl::ExitFullscreen(bool release_media_player) { |
| 84 Send(new MediaPlayerMsg_DidExitFullscreen( | 84 Send(new MediaPlayerMsg_DidExitFullscreen( |
| 85 routing_id(), fullscreen_player_id_)); | 85 routing_id(), fullscreen_player_id_)); |
| 86 MediaPlayerBridge* player = GetFullscreenPlayer(); | 86 MediaPlayerBridge* player = GetFullscreenPlayer(); |
| 87 fullscreen_player_id_ = -1; | 87 fullscreen_player_id_ = -1; |
| 88 if (!player) | 88 if (!player) |
| 89 return; | 89 return; |
| 90 if (release_media_player) | 90 if (release_media_player) |
| 91 player->Release(); | 91 player->Release(); |
| 92 else | 92 else |
| 93 player->SetVideoSurface(NULL); | 93 player->SetVideoSurface(NULL); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void MediaPlayerManagerAndroid::SetVideoSurface(jobject surface) { | 96 void MediaPlayerManagerImpl::SetVideoSurface(jobject surface) { |
| 97 MediaPlayerBridge* player = GetFullscreenPlayer(); | 97 MediaPlayerBridge* player = GetFullscreenPlayer(); |
| 98 if (player) { | 98 if (player) { |
| 99 player->SetVideoSurface(surface); | 99 player->SetVideoSurface(surface); |
| 100 Send(new MediaPlayerMsg_DidEnterFullscreen( | 100 Send(new MediaPlayerMsg_DidEnterFullscreen( |
| 101 routing_id(), player->player_id())); | 101 routing_id(), player->player_id())); |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 void MediaPlayerManagerAndroid::OnInitialize( | 105 void MediaPlayerManagerImpl::OnInitialize( |
| 106 int player_id, const GURL& url, const GURL& first_party_for_cookies) { | 106 int player_id, const GURL& url, const GURL& first_party_for_cookies) { |
| 107 for (ScopedVector<MediaPlayerBridge>::iterator it = players_.begin(); | 107 for (ScopedVector<MediaPlayerBridge>::iterator it = players_.begin(); |
| 108 it != players_.end(); ++it) { | 108 it != players_.end(); ++it) { |
| 109 if ((*it)->player_id() == player_id) { | 109 if ((*it)->player_id() == player_id) { |
| 110 players_.erase(it); | 110 players_.erase(it); |
| 111 break; | 111 break; |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 RenderProcessHost* host = render_view_host()->GetProcess(); | 115 RenderProcessHost* host = render_view_host()->GetProcess(); |
| 116 BrowserContext* context = host->GetBrowserContext(); | |
| 117 StoragePartition* partition = host->GetStoragePartition(); | |
| 118 fileapi::FileSystemContext* file_system_context = | |
| 119 partition ? partition->GetFileSystemContext() : NULL; | |
| 120 players_.push_back(new MediaPlayerBridge( | 116 players_.push_back(new MediaPlayerBridge( |
| 121 player_id, url, first_party_for_cookies, | 117 player_id, url, first_party_for_cookies, |
| 122 new MediaResourceGetterImpl(context, file_system_context, host->GetID(), | 118 host->GetBrowserContext()->IsOffTheRecord(), this, |
| 123 routing_id()), | 119 base::Bind(&MediaPlayerManagerImpl::OnError, base::Unretained(this)), |
| 124 context->IsOffTheRecord(), this, | 120 base::Bind(&MediaPlayerManagerImpl::OnVideoSizeChanged, |
| 125 base::Bind(&MediaPlayerManagerAndroid::OnError, base::Unretained(this)), | |
| 126 base::Bind(&MediaPlayerManagerAndroid::OnVideoSizeChanged, | |
| 127 base::Unretained(this)), | 121 base::Unretained(this)), |
| 128 base::Bind(&MediaPlayerManagerAndroid::OnBufferingUpdate, | 122 base::Bind(&MediaPlayerManagerImpl::OnBufferingUpdate, |
| 129 base::Unretained(this)), | 123 base::Unretained(this)), |
| 130 base::Bind(&MediaPlayerManagerAndroid::OnMediaMetadataChanged, | 124 base::Bind(&MediaPlayerManagerImpl::OnMediaMetadataChanged, |
| 131 base::Unretained(this)), | 125 base::Unretained(this)), |
| 132 base::Bind(&MediaPlayerManagerAndroid::OnPlaybackComplete, | 126 base::Bind(&MediaPlayerManagerImpl::OnPlaybackComplete, |
| 133 base::Unretained(this)), | 127 base::Unretained(this)), |
| 134 base::Bind(&MediaPlayerManagerAndroid::OnSeekComplete, | 128 base::Bind(&MediaPlayerManagerImpl::OnSeekComplete, |
| 135 base::Unretained(this)), | 129 base::Unretained(this)), |
| 136 base::Bind(&MediaPlayerManagerAndroid::OnTimeUpdate, | 130 base::Bind(&MediaPlayerManagerImpl::OnTimeUpdate, |
| 137 base::Unretained(this)), | 131 base::Unretained(this)), |
| 138 base::Bind(&MediaPlayerManagerAndroid::OnMediaInterrupted, | 132 base::Bind(&MediaPlayerManagerImpl::OnMediaInterrupted, |
| 139 base::Unretained(this)))); | 133 base::Unretained(this)))); |
| 140 } | 134 } |
| 141 | 135 |
| 142 void MediaPlayerManagerAndroid::OnStart(int player_id) { | 136 media::MediaResourceGetter* MediaPlayerManagerImpl::GetMediaResourceGetter() { |
| 137 if (!media_resource_getter_.get()) { |
| 138 RenderProcessHost* host = render_view_host()->GetProcess(); |
| 139 BrowserContext* context = host->GetBrowserContext(); |
| 140 StoragePartition* partition = host->GetStoragePartition(); |
| 141 fileapi::FileSystemContext* file_system_context = |
| 142 partition ? partition->GetFileSystemContext() : NULL; |
| 143 media_resource_getter_.reset(new MediaResourceGetterImpl( |
| 144 context, file_system_context, host->GetID(), routing_id())); |
| 145 } |
| 146 return media_resource_getter_.get(); |
| 147 } |
| 148 |
| 149 void MediaPlayerManagerImpl::OnStart(int player_id) { |
| 143 MediaPlayerBridge* player = GetPlayer(player_id); | 150 MediaPlayerBridge* player = GetPlayer(player_id); |
| 144 if (player) | 151 if (player) |
| 145 player->Start(); | 152 player->Start(); |
| 146 } | 153 } |
| 147 | 154 |
| 148 void MediaPlayerManagerAndroid::OnSeek(int player_id, base::TimeDelta time) { | 155 void MediaPlayerManagerImpl::OnSeek(int player_id, base::TimeDelta time) { |
| 149 MediaPlayerBridge* player = GetPlayer(player_id); | 156 MediaPlayerBridge* player = GetPlayer(player_id); |
| 150 if (player) | 157 if (player) |
| 151 player->SeekTo(time); | 158 player->SeekTo(time); |
| 152 } | 159 } |
| 153 | 160 |
| 154 void MediaPlayerManagerAndroid::OnPause(int player_id) { | 161 void MediaPlayerManagerImpl::OnPause(int player_id) { |
| 155 MediaPlayerBridge* player = GetPlayer(player_id); | 162 MediaPlayerBridge* player = GetPlayer(player_id); |
| 156 if (player) | 163 if (player) |
| 157 player->Pause(); | 164 player->Pause(); |
| 158 } | 165 } |
| 159 | 166 |
| 160 void MediaPlayerManagerAndroid::OnEnterFullscreen(int player_id) { | 167 void MediaPlayerManagerImpl::OnEnterFullscreen(int player_id) { |
| 161 DCHECK_EQ(fullscreen_player_id_, -1); | 168 DCHECK_EQ(fullscreen_player_id_, -1); |
| 162 | 169 |
| 163 fullscreen_player_id_ = player_id; | 170 fullscreen_player_id_ = player_id; |
| 164 video_view_.CreateContentVideoView(); | 171 video_view_.CreateContentVideoView(); |
| 165 } | 172 } |
| 166 | 173 |
| 167 void MediaPlayerManagerAndroid::OnExitFullscreen(int player_id) { | 174 void MediaPlayerManagerImpl::OnExitFullscreen(int player_id) { |
| 168 if (fullscreen_player_id_ == player_id) { | 175 if (fullscreen_player_id_ == player_id) { |
| 169 MediaPlayerBridge* player = GetPlayer(player_id); | 176 MediaPlayerBridge* player = GetPlayer(player_id); |
| 170 if (player) | 177 if (player) |
| 171 player->SetVideoSurface(NULL); | 178 player->SetVideoSurface(NULL); |
| 172 video_view_.DestroyContentVideoView(); | 179 video_view_.DestroyContentVideoView(); |
| 173 fullscreen_player_id_ = -1; | 180 fullscreen_player_id_ = -1; |
| 174 } | 181 } |
| 175 } | 182 } |
| 176 | 183 |
| 177 void MediaPlayerManagerAndroid::OnReleaseResources(int player_id) { | 184 void MediaPlayerManagerImpl::OnReleaseResources(int player_id) { |
| 178 MediaPlayerBridge* player = GetPlayer(player_id); | 185 MediaPlayerBridge* player = GetPlayer(player_id); |
| 179 // Don't release the fullscreen player when tab visibility changes, | 186 // Don't release the fullscreen player when tab visibility changes, |
| 180 // it will be released when user hit the back/home button or when | 187 // it will be released when user hit the back/home button or when |
| 181 // OnDestroyPlayer is called. | 188 // OnDestroyPlayer is called. |
| 182 if (player && player_id != fullscreen_player_id_) | 189 if (player && player_id != fullscreen_player_id_) |
| 183 player->Release(); | 190 player->Release(); |
| 184 } | 191 } |
| 185 | 192 |
| 186 void MediaPlayerManagerAndroid::OnDestroyPlayer(int player_id) { | 193 void MediaPlayerManagerImpl::OnDestroyPlayer(int player_id) { |
| 187 for (ScopedVector<MediaPlayerBridge>::iterator it = players_.begin(); | 194 for (ScopedVector<MediaPlayerBridge>::iterator it = players_.begin(); |
| 188 it != players_.end(); ++it) { | 195 it != players_.end(); ++it) { |
| 189 if ((*it)->player_id() == player_id) { | 196 if ((*it)->player_id() == player_id) { |
| 190 players_.erase(it); | 197 players_.erase(it); |
| 191 break; | 198 break; |
| 192 } | 199 } |
| 193 } | 200 } |
| 194 if (fullscreen_player_id_ == player_id) | 201 if (fullscreen_player_id_ == player_id) |
| 195 fullscreen_player_id_ = -1; | 202 fullscreen_player_id_ = -1; |
| 196 } | 203 } |
| 197 | 204 |
| 198 void MediaPlayerManagerAndroid::DestroyAllMediaPlayers() { | 205 void MediaPlayerManagerImpl::DestroyAllMediaPlayers() { |
| 199 players_.clear(); | 206 players_.clear(); |
| 200 if (fullscreen_player_id_ != -1) { | 207 if (fullscreen_player_id_ != -1) { |
| 201 video_view_.DestroyContentVideoView(); | 208 video_view_.DestroyContentVideoView(); |
| 202 fullscreen_player_id_ = -1; | 209 fullscreen_player_id_ = -1; |
| 203 } | 210 } |
| 204 } | 211 } |
| 205 | 212 |
| 206 #if defined(GOOGLE_TV) | 213 #if defined(GOOGLE_TV) |
| 207 void MediaPlayerManagerAndroid::AttachExternalVideoSurface(int player_id, | 214 void MediaPlayerManagerImpl::AttachExternalVideoSurface(int player_id, |
| 208 jobject surface) { | 215 jobject surface) { |
| 209 MediaPlayerBridge* player = GetPlayer(player_id); | 216 MediaPlayerBridge* player = GetPlayer(player_id); |
| 210 if (player) | 217 if (player) |
| 211 player->SetVideoSurface(surface); | 218 player->SetVideoSurface(surface); |
| 212 } | 219 } |
| 213 | 220 |
| 214 void MediaPlayerManagerAndroid::DetachExternalVideoSurface(int player_id) { | 221 void MediaPlayerManagerImpl::DetachExternalVideoSurface(int player_id) { |
| 215 MediaPlayerBridge* player = GetPlayer(player_id); | 222 MediaPlayerBridge* player = GetPlayer(player_id); |
| 216 if (player) | 223 if (player) |
| 217 player->SetVideoSurface(NULL); | 224 player->SetVideoSurface(NULL); |
| 218 } | 225 } |
| 219 | 226 |
| 220 void MediaPlayerManagerAndroid::OnRequestExternalSurface(int player_id) { | 227 void MediaPlayerManagerImpl::OnRequestExternalSurface(int player_id) { |
| 221 if (!web_contents_) | 228 if (!web_contents_) |
| 222 return; | 229 return; |
| 223 | 230 |
| 224 WebContentsViewAndroid* view = | 231 WebContentsViewAndroid* view = |
| 225 static_cast<WebContentsViewAndroid*>(web_contents_->GetView()); | 232 static_cast<WebContentsViewAndroid*>(web_contents_->GetView()); |
| 226 if (view) | 233 if (view) |
| 227 view->RequestExternalVideoSurface(player_id); | 234 view->RequestExternalVideoSurface(player_id); |
| 228 } | 235 } |
| 229 | 236 |
| 230 void MediaPlayerManagerAndroid::OnNotifyGeometryChange(int player_id, | 237 void MediaPlayerManagerImpl::OnNotifyGeometryChange(int player_id, |
| 231 const gfx::RectF& rect) { | 238 const gfx::RectF& rect) { |
| 232 if (!web_contents_) | 239 if (!web_contents_) |
| 233 return; | 240 return; |
| 234 | 241 |
| 235 WebContentsViewAndroid* view = | 242 WebContentsViewAndroid* view = |
| 236 static_cast<WebContentsViewAndroid*>(web_contents_->GetView()); | 243 static_cast<WebContentsViewAndroid*>(web_contents_->GetView()); |
| 237 if (view) | 244 if (view) |
| 238 view->NotifyGeometryChange(player_id, rect); | 245 view->NotifyGeometryChange(player_id, rect); |
| 239 } | 246 } |
| 240 #endif | 247 #endif |
| 241 | 248 |
| 242 MediaPlayerBridge* MediaPlayerManagerAndroid::GetPlayer(int player_id) { | 249 MediaPlayerBridge* MediaPlayerManagerImpl::GetPlayer(int player_id) { |
| 243 for (ScopedVector<MediaPlayerBridge>::iterator it = players_.begin(); | 250 for (ScopedVector<MediaPlayerBridge>::iterator it = players_.begin(); |
| 244 it != players_.end(); ++it) { | 251 it != players_.end(); ++it) { |
| 245 if ((*it)->player_id() == player_id) | 252 if ((*it)->player_id() == player_id) |
| 246 return *it; | 253 return *it; |
| 247 } | 254 } |
| 248 return NULL; | 255 return NULL; |
| 249 } | 256 } |
| 250 | 257 |
| 251 MediaPlayerBridge* MediaPlayerManagerAndroid::GetFullscreenPlayer() { | 258 MediaPlayerBridge* MediaPlayerManagerImpl::GetFullscreenPlayer() { |
| 252 return GetPlayer(fullscreen_player_id_); | 259 return GetPlayer(fullscreen_player_id_); |
| 253 } | 260 } |
| 254 | 261 |
| 255 void MediaPlayerManagerAndroid::OnMediaMetadataChanged( | 262 void MediaPlayerManagerImpl::OnMediaMetadataChanged( |
| 256 int player_id, base::TimeDelta duration, int width, int height, | 263 int player_id, base::TimeDelta duration, int width, int height, |
| 257 bool success) { | 264 bool success) { |
| 258 Send(new MediaPlayerMsg_MediaMetadataChanged( | 265 Send(new MediaPlayerMsg_MediaMetadataChanged( |
| 259 routing_id(), player_id, duration, width, height, success)); | 266 routing_id(), player_id, duration, width, height, success)); |
| 260 if (fullscreen_player_id_ != -1) | 267 if (fullscreen_player_id_ != -1) |
| 261 video_view_.UpdateMediaMetadata(); | 268 video_view_.UpdateMediaMetadata(); |
| 262 } | 269 } |
| 263 | 270 |
| 264 void MediaPlayerManagerAndroid::OnPlaybackComplete(int player_id) { | 271 void MediaPlayerManagerImpl::OnPlaybackComplete(int player_id) { |
| 265 Send(new MediaPlayerMsg_MediaPlaybackCompleted(routing_id(), player_id)); | 272 Send(new MediaPlayerMsg_MediaPlaybackCompleted(routing_id(), player_id)); |
| 266 if (fullscreen_player_id_ != -1) | 273 if (fullscreen_player_id_ != -1) |
| 267 video_view_.OnPlaybackComplete(); | 274 video_view_.OnPlaybackComplete(); |
| 268 } | 275 } |
| 269 | 276 |
| 270 void MediaPlayerManagerAndroid::OnMediaInterrupted(int player_id) { | 277 void MediaPlayerManagerImpl::OnMediaInterrupted(int player_id) { |
| 271 // Tell WebKit that the audio should be paused, then release all resources | 278 // Tell WebKit that the audio should be paused, then release all resources |
| 272 Send(new MediaPlayerMsg_DidMediaPlayerPause(routing_id(), player_id)); | 279 Send(new MediaPlayerMsg_DidMediaPlayerPause(routing_id(), player_id)); |
| 273 OnReleaseResources(player_id); | 280 OnReleaseResources(player_id); |
| 274 } | 281 } |
| 275 | 282 |
| 276 void MediaPlayerManagerAndroid::OnBufferingUpdate( | 283 void MediaPlayerManagerImpl::OnBufferingUpdate( |
| 277 int player_id, int percentage) { | 284 int player_id, int percentage) { |
| 278 Send(new MediaPlayerMsg_MediaBufferingUpdate( | 285 Send(new MediaPlayerMsg_MediaBufferingUpdate( |
| 279 routing_id(), player_id, percentage)); | 286 routing_id(), player_id, percentage)); |
| 280 if (fullscreen_player_id_ != -1) | 287 if (fullscreen_player_id_ != -1) |
| 281 video_view_.OnBufferingUpdate(percentage); | 288 video_view_.OnBufferingUpdate(percentage); |
| 282 } | 289 } |
| 283 | 290 |
| 284 void MediaPlayerManagerAndroid::OnSeekComplete(int player_id, | 291 void MediaPlayerManagerImpl::OnSeekComplete(int player_id, |
| 285 base::TimeDelta current_time) { | 292 base::TimeDelta current_time) { |
| 286 Send(new MediaPlayerMsg_MediaSeekCompleted( | 293 Send(new MediaPlayerMsg_MediaSeekCompleted( |
| 287 routing_id(), player_id, current_time)); | 294 routing_id(), player_id, current_time)); |
| 288 } | 295 } |
| 289 | 296 |
| 290 void MediaPlayerManagerAndroid::OnError(int player_id, int error) { | 297 void MediaPlayerManagerImpl::OnError(int player_id, int error) { |
| 291 Send(new MediaPlayerMsg_MediaError(routing_id(), player_id, error)); | 298 Send(new MediaPlayerMsg_MediaError(routing_id(), player_id, error)); |
| 292 if (fullscreen_player_id_ != -1) | 299 if (fullscreen_player_id_ != -1) |
| 293 video_view_.OnMediaPlayerError(error); | 300 video_view_.OnMediaPlayerError(error); |
| 294 } | 301 } |
| 295 | 302 |
| 296 void MediaPlayerManagerAndroid::OnVideoSizeChanged( | 303 void MediaPlayerManagerImpl::OnVideoSizeChanged( |
| 297 int player_id, int width, int height) { | 304 int player_id, int width, int height) { |
| 298 Send(new MediaPlayerMsg_MediaVideoSizeChanged(routing_id(), player_id, | 305 Send(new MediaPlayerMsg_MediaVideoSizeChanged(routing_id(), player_id, |
| 299 width, height)); | 306 width, height)); |
| 300 if (fullscreen_player_id_ != -1) | 307 if (fullscreen_player_id_ != -1) |
| 301 video_view_.OnVideoSizeChanged(width, height); | 308 video_view_.OnVideoSizeChanged(width, height); |
| 302 } | 309 } |
| 303 | 310 |
| 304 void MediaPlayerManagerAndroid::OnTimeUpdate(int player_id, | 311 void MediaPlayerManagerImpl::OnTimeUpdate(int player_id, |
| 305 base::TimeDelta current_time) { | 312 base::TimeDelta current_time) { |
| 306 Send(new MediaPlayerMsg_MediaTimeUpdate( | 313 Send(new MediaPlayerMsg_MediaTimeUpdate( |
| 307 routing_id(), player_id, current_time)); | 314 routing_id(), player_id, current_time)); |
| 308 } | 315 } |
| 309 | 316 |
| 310 void MediaPlayerManagerAndroid::RequestMediaResources( | 317 void MediaPlayerManagerImpl::RequestMediaResources( |
| 311 MediaPlayerBridge* player) { | 318 MediaPlayerBridge* player) { |
| 312 if (player == NULL) | 319 if (player == NULL) |
| 313 return; | 320 return; |
| 314 | 321 |
| 315 int num_active_player = 0; | 322 int num_active_player = 0; |
| 316 ScopedVector<MediaPlayerBridge>::iterator it; | 323 ScopedVector<MediaPlayerBridge>::iterator it; |
| 317 for (it = players_.begin(); it != players_.end(); ++it) { | 324 for (it = players_.begin(); it != players_.end(); ++it) { |
| 318 if (!(*it)->prepared()) | 325 if (!(*it)->prepared()) |
| 319 continue; | 326 continue; |
| 320 | 327 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 332 for (it = players_.begin(); it != players_.end(); ++it) { | 339 for (it = players_.begin(); it != players_.end(); ++it) { |
| 333 if ((*it)->prepared() && !(*it)->IsPlaying() && | 340 if ((*it)->prepared() && !(*it)->IsPlaying() && |
| 334 fullscreen_player_id_ != (*it)->player_id()) { | 341 fullscreen_player_id_ != (*it)->player_id()) { |
| 335 (*it)->Release(); | 342 (*it)->Release(); |
| 336 Send(new MediaPlayerMsg_MediaPlayerReleased( | 343 Send(new MediaPlayerMsg_MediaPlayerReleased( |
| 337 routing_id(), (*it)->player_id())); | 344 routing_id(), (*it)->player_id())); |
| 338 } | 345 } |
| 339 } | 346 } |
| 340 } | 347 } |
| 341 | 348 |
| 342 void MediaPlayerManagerAndroid::ReleaseMediaResources( | 349 void MediaPlayerManagerImpl::ReleaseMediaResources( |
| 343 MediaPlayerBridge* player) { | 350 MediaPlayerBridge* player) { |
| 344 // Nothing needs to be done. | 351 // Nothing needs to be done. |
| 345 } | 352 } |
| 346 | 353 |
| 347 } // namespace content | 354 } // namespace content |
| OLD | NEW |