Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: content/browser/media/session/media_session_controllers_manager.cc

Issue 1996043002: Split MediaContentType and AudioFocusType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed desktop build & tests Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/session/media_session_controllers_manager.h" 5 #include "content/browser/media/session/media_session_controllers_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/browser/media/session/media_session.h" 8 #include "content/browser/media/session/media_session.h"
9 #include "content/browser/media/session/media_session_controller.h" 9 #include "content/browser/media/session/media_session_controller.h"
10 #include "content/browser/media/session/media_session_observer.h" 10 #include "content/browser/media/session/media_session_observer.h"
(...skipping 27 matching lines...) Expand all
38 return; 38 return;
39 39
40 for (auto it = controllers_map_.begin(); it != controllers_map_.end();) { 40 for (auto it = controllers_map_.begin(); it != controllers_map_.end();) {
41 if (it->first.first == render_frame_host) 41 if (it->first.first == render_frame_host)
42 it = controllers_map_.erase(it); 42 it = controllers_map_.erase(it);
43 else 43 else
44 ++it; 44 ++it;
45 } 45 }
46 } 46 }
47 47
48 bool MediaSessionControllersManager::RequestPlay(const MediaPlayerId& id, 48 bool MediaSessionControllersManager::RequestPlay(
49 bool has_audio, bool is_remote, base::TimeDelta duration) { 49 const MediaPlayerId& id, bool has_audio, bool is_remote,
50 media::MediaContentType media_content_type) {
50 if (!IsDefaultMediaSessionEnabled()) 51 if (!IsDefaultMediaSessionEnabled())
51 return true; 52 return true;
52 53
53 // Since we don't remove session instances on pause, there may be an existing 54 // Since we don't remove session instances on pause, there may be an existing
54 // instance for this playback attempt. 55 // instance for this playback attempt.
55 // 56 //
56 // In this case, try to reinitialize it with the new settings. If they are 57 // In this case, try to reinitialize it with the new settings. If they are
57 // the same, this is a no-op. If the reinitialize fails, destroy the 58 // the same, this is a no-op. If the reinitialize fails, destroy the
58 // controller. A later playback attempt will create a new controller. 59 // controller. A later playback attempt will create a new controller.
59 auto it = controllers_map_.find(id); 60 auto it = controllers_map_.find(id);
60 if (it != controllers_map_.end()) { 61 if (it != controllers_map_.end()) {
61 if (it->second->Initialize(has_audio, is_remote, duration)) 62 if (it->second->Initialize(has_audio, is_remote, media_content_type))
62 return true; 63 return true;
63 controllers_map_.erase(it); 64 controllers_map_.erase(it);
64 return false; 65 return false;
65 } 66 }
66 67
67 std::unique_ptr<MediaSessionController> controller( 68 std::unique_ptr<MediaSessionController> controller(
68 new MediaSessionController(id, media_web_contents_observer_)); 69 new MediaSessionController(id, media_web_contents_observer_));
69 70
70 if (!controller->Initialize(has_audio, is_remote, duration)) 71 if (!controller->Initialize(has_audio, is_remote, media_content_type))
71 return false; 72 return false;
72 73
73 controllers_map_[id] = std::move(controller); 74 controllers_map_[id] = std::move(controller);
74 return true; 75 return true;
75 } 76 }
76 77
77 void MediaSessionControllersManager::OnPause(const MediaPlayerId& id) { 78 void MediaSessionControllersManager::OnPause(const MediaPlayerId& id) {
78 if (!IsDefaultMediaSessionEnabled()) 79 if (!IsDefaultMediaSessionEnabled())
79 return; 80 return;
80 81
81 auto it = controllers_map_.find(id); 82 auto it = controllers_map_.find(id);
82 if (it == controllers_map_.end()) 83 if (it == controllers_map_.end())
83 return; 84 return;
84 85
85 it->second->OnPlaybackPaused(); 86 it->second->OnPlaybackPaused();
86 } 87 }
87 88
88 void MediaSessionControllersManager::OnEnd(const MediaPlayerId& id) { 89 void MediaSessionControllersManager::OnEnd(const MediaPlayerId& id) {
89 if (!IsDefaultMediaSessionEnabled()) 90 if (!IsDefaultMediaSessionEnabled())
90 return; 91 return;
91 controllers_map_.erase(id); 92 controllers_map_.erase(id);
92 } 93 }
93 94
94 } // namespace content 95 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698