Index: content/browser/media/android/browser_media_player_manager.cc |
diff --git a/content/browser/media/android/browser_media_player_manager.cc b/content/browser/media/android/browser_media_player_manager.cc |
index c512f3163ecf2392fedbf0d263e91cd153389f00..851fd6f2c9de5575287cc7ee21f260c212bcf42a 100644 |
--- a/content/browser/media/android/browser_media_player_manager.cc |
+++ b/content/browser/media/android/browser_media_player_manager.cc |
@@ -9,6 +9,7 @@ |
#include "base/android/scoped_java_ref.h" |
#include "content/browser/frame_host/render_frame_host_impl.h" |
#include "content/browser/media/android/browser_demuxer_android.h" |
+#include "content/browser/media/android/browser_media_session_manager.h" |
#include "content/browser/media/android/media_resource_getter_impl.h" |
#include "content/browser/media/android/media_session.h" |
#include "content/browser/media/android/media_throttler.h" |
@@ -146,16 +147,13 @@ MediaPlayerAndroid* BrowserMediaPlayerManager::CreateMediaPlayer( |
case MEDIA_PLAYER_TYPE_URL: { |
const std::string user_agent = GetContentClient()->GetUserAgent(); |
MediaPlayerBridge* media_player_bridge = new MediaPlayerBridge( |
- media_player_params.player_id, |
- media_player_params.url, |
- media_player_params.first_party_for_cookies, |
- user_agent, |
- hide_url_log, |
+ media_player_params.player_id, media_player_params.url, |
+ media_player_params.first_party_for_cookies, user_agent, hide_url_log, |
this, |
base::Bind(&BrowserMediaPlayerManager::OnDecoderResourcesReleased, |
weak_ptr_factory_.GetWeakPtr()), |
- media_player_params.frame_url, |
- media_player_params.allow_credentials); |
+ media_player_params.frame_url, media_player_params.allow_credentials, |
+ media_player_params.session_id); |
bool should_block = false; |
bool extract_metadata = |
// Initialize the player will cause MediaMetadataExtractor to decode |
@@ -188,20 +186,18 @@ MediaPlayerAndroid* BrowserMediaPlayerManager::CreateMediaPlayer( |
case MEDIA_PLAYER_TYPE_MEDIA_SOURCE: { |
if (media::UseMediaThreadForMediaPlayback()) { |
return new MediaCodecPlayer( |
- media_player_params.player_id, |
- weak_ptr_factory_.GetWeakPtr(), |
+ media_player_params.player_id, weak_ptr_factory_.GetWeakPtr(), |
base::Bind(&BrowserMediaPlayerManager::OnDecoderResourcesReleased, |
weak_ptr_factory_.GetWeakPtr()), |
demuxer->CreateDemuxer(media_player_params.demuxer_client_id), |
- media_player_params.frame_url); |
+ media_player_params.frame_url, media_player_params.session_id); |
} else { |
return new MediaSourcePlayer( |
- media_player_params.player_id, |
- this, |
+ media_player_params.player_id, this, |
base::Bind(&BrowserMediaPlayerManager::OnDecoderResourcesReleased, |
weak_ptr_factory_.GetWeakPtr()), |
demuxer->CreateDemuxer(media_player_params.demuxer_client_id), |
- media_player_params.frame_url); |
+ media_player_params.frame_url, media_player_params.session_id); |
} |
} |
} |
@@ -228,7 +224,7 @@ BrowserMediaPlayerManager::~BrowserMediaPlayerManager() { |
for (MediaPlayerAndroid* player : players_) |
player->DeleteOnCorrectThread(); |
- MediaSession::Get(web_contents())->RemovePlayers(this); |
+ GetMediaSessionManager()->RemovePlayers(this); |
players_.weak_clear(); |
} |
@@ -304,7 +300,7 @@ void BrowserMediaPlayerManager::OnMediaMetadataChanged( |
void BrowserMediaPlayerManager::OnPlaybackComplete(int player_id) { |
Send(new MediaPlayerMsg_MediaPlaybackCompleted(RoutingID(), player_id)); |
- MediaSession::Get(web_contents())->RemovePlayer(this, player_id); |
+ GetMediaSessionManager()->RemovePlayer(this, player_id); |
if (fullscreen_player_id_ == player_id) |
video_view_->OnPlaybackComplete(); |
@@ -413,8 +409,14 @@ bool BrowserMediaPlayerManager::RequestPlay(int player_id, |
? MediaSession::Type::Content |
: MediaSession::Type::Transient; |
- bool succeeded = MediaSession::Get(web_contents())->AddPlayer( |
- this, player_id, media_session_type); |
+ MediaPlayerAndroid* player = GetPlayer(player_id); |
+ DCHECK(player); |
+ |
+ MediaSession* media_session = |
+ GetMediaSessionManager()->GetSession(player->session_id()); |
+ // Implicit activation of media session unless already activated |
+ bool succeeded = |
+ media_session->AddPlayer(this, player_id, media_session_type); |
if (!succeeded) |
Send(new MediaPlayerMsg_DidMediaPlayerPause(RoutingID(), player_id)); |
return succeeded; |
@@ -603,7 +605,7 @@ void BrowserMediaPlayerManager::OnPause( |
player->Pause(is_media_related_action); |
if (is_media_related_action) |
- MediaSession::Get(web_contents())->OnPlayerPaused(this, player_id); |
+ GetMediaSessionManager()->OnPlayerPaused(this, player_id); |
} |
void BrowserMediaPlayerManager::OnSetVolume(int player_id, double volume) { |
@@ -617,7 +619,7 @@ void BrowserMediaPlayerManager::OnSetPoster(int player_id, const GURL& url) { |
} |
void BrowserMediaPlayerManager::OnSuspendAndReleaseResources(int player_id) { |
- MediaSession::Get(web_contents())->RemovePlayer(this, player_id); |
+ GetMediaSessionManager()->RemovePlayer(this, player_id); |
ReleaseResources(player_id); |
} |
@@ -650,7 +652,7 @@ void BrowserMediaPlayerManager::DestroyPlayer(int player_id) { |
#endif |
(*it)->DeleteOnCorrectThread(); |
players_.weak_erase(it); |
- MediaSession::Get(web_contents())->RemovePlayer(this, player_id); |
+ GetMediaSessionManager()->RemovePlayer(this, player_id); |
break; |
} |
} |
@@ -769,4 +771,10 @@ void BrowserMediaPlayerManager::StartInternal(int player_id) { |
} |
} |
+BrowserMediaSessionManager* |
+BrowserMediaPlayerManager::GetMediaSessionManager() { |
+ return MediaWebContentsObserverAndroid::FromWebContents(web_contents()) |
+ ->GetMediaSessionManager(render_frame_host_); |
+} |
+ |
} // namespace content |