OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_H_ |
6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_H_ | 6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/callback_list.h" | 10 #include "base/callback_list.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 CONTENT_EXPORT void Resume(SuspendType suspend_type); | 96 CONTENT_EXPORT void Resume(SuspendType suspend_type); |
97 | 97 |
98 // Suspend the media session. | 98 // Suspend the media session. |
99 // |type| represents the origin of the request. | 99 // |type| represents the origin of the request. |
100 CONTENT_EXPORT void Suspend(SuspendType suspend_type); | 100 CONTENT_EXPORT void Suspend(SuspendType suspend_type); |
101 | 101 |
102 // Stop the media session. | 102 // Stop the media session. |
103 // |type| represents the origin of the request. | 103 // |type| represents the origin of the request. |
104 CONTENT_EXPORT void Stop(SuspendType suspend_type); | 104 CONTENT_EXPORT void Stop(SuspendType suspend_type); |
105 | 105 |
106 // Change the volume multiplier of the session to |volume_multiplier|. | 106 CONTENT_EXPORT void Duck(); |
107 CONTENT_EXPORT void SetVolumeMultiplier(double volume_multiplier); | 107 CONTENT_EXPORT void Unduck(); |
| 108 |
| 109 CONTENT_EXPORT bool IsDucking() { return is_ducking_; } |
108 | 110 |
109 // Returns if the session can be controlled by Resume() and Suspend calls | 111 // Returns if the session can be controlled by Resume() and Suspend calls |
110 // above. | 112 // above. |
111 CONTENT_EXPORT bool IsControllable() const; | 113 CONTENT_EXPORT bool IsControllable() const; |
112 | 114 |
113 // Returns if the session is currently active. | 115 // Returns if the session is currently active. |
114 CONTENT_EXPORT bool IsActive() const; | 116 CONTENT_EXPORT bool IsActive() const; |
115 | 117 |
116 // Returns if the session is currently suspended. | 118 // Returns if the session is currently suspended. |
117 // TODO(mlamouri): IsSuspended() below checks if the state is not ACTIVE | 119 // TODO(mlamouri): IsSuspended() below checks if the state is not ACTIVE |
118 // instead of checking if the state is SUSPENDED. In order to not have to | 120 // instead of checking if the state is SUSPENDED. In order to not have to |
119 // change all the callers and make the current refactoring ridiculously huge, | 121 // change all the callers and make the current refactoring ridiculously huge, |
120 // this method is introduced temporarily and will be removed later. | 122 // this method is introduced temporarily and will be removed later. |
121 bool IsReallySuspended() const; | 123 bool IsReallySuspended() const; |
122 | 124 |
123 // Returns if the session is currently suspended or inactive. | 125 // Returns if the session is currently suspended or inactive. |
124 CONTENT_EXPORT bool IsSuspended() const; | 126 CONTENT_EXPORT bool IsSuspended() const; |
125 | 127 |
| 128 void SetOnTop(bool is_on_top); |
| 129 |
126 private: | 130 private: |
127 friend class content::WebContentsUserData<MediaSession>; | 131 friend class content::WebContentsUserData<MediaSession>; |
128 friend class ::MediaSessionBrowserTest; | 132 friend class ::MediaSessionBrowserTest; |
129 friend class content::MediaSessionVisibilityBrowserTest; | 133 friend class content::MediaSessionVisibilityBrowserTest; |
130 friend class content::AudioFocusManagerTest; | 134 friend class content::AudioFocusManagerTest; |
131 friend class content::MediaSessionStateObserver; | 135 friend class content::MediaSessionStateObserver; |
132 | 136 |
133 CONTENT_EXPORT void SetDelegateForTests( | 137 CONTENT_EXPORT void SetDelegateForTests( |
134 std::unique_ptr<MediaSessionDelegate> delegate); | 138 std::unique_ptr<MediaSessionDelegate> delegate); |
135 CONTENT_EXPORT bool IsActiveForTest() const; | 139 CONTENT_EXPORT bool IsActiveForTest() const; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 189 |
186 // Internal method that should be used instead of setting audio_focus_state_. | 190 // Internal method that should be used instead of setting audio_focus_state_. |
187 // It sets audio_focus_state_ and notifies observers about the state change. | 191 // It sets audio_focus_state_ and notifies observers about the state change. |
188 void SetAudioFocusState(State audio_focus_state); | 192 void SetAudioFocusState(State audio_focus_state); |
189 | 193 |
190 // Registers a MediaSession state change callback. | 194 // Registers a MediaSession state change callback. |
191 CONTENT_EXPORT std::unique_ptr<base::CallbackList<void(State)>::Subscription> | 195 CONTENT_EXPORT std::unique_ptr<base::CallbackList<void(State)>::Subscription> |
192 RegisterMediaSessionStateChangedCallbackForTest( | 196 RegisterMediaSessionStateChangedCallbackForTest( |
193 const StateChangedCallback& cb); | 197 const StateChangedCallback& cb); |
194 | 198 |
| 199 CONTENT_EXPORT bool AddPepperPlayer(MediaSessionObserver* observer, |
| 200 int player_id); |
| 201 |
| 202 double GetVolumeMultiplier() const; |
| 203 double GetPepperVolumeMultiplier() const; |
| 204 |
195 std::unique_ptr<MediaSessionDelegate> delegate_; | 205 std::unique_ptr<MediaSessionDelegate> delegate_; |
196 PlayersMap players_; | 206 PlayersMap players_; |
| 207 PlayersMap pepper_players_; |
197 | 208 |
198 State audio_focus_state_; | 209 State audio_focus_state_; |
199 SuspendType suspend_type_; | 210 SuspendType suspend_type_; |
200 AudioFocusManager::AudioFocusType audio_focus_type_; | 211 AudioFocusManager::AudioFocusType audio_focus_type_; |
201 | 212 |
202 MediaSessionUmaHelper uma_helper_; | 213 MediaSessionUmaHelper uma_helper_; |
203 | 214 |
204 // The volume multiplier of this session. All players in this session should | 215 // Whether this session is ducked, which is used to compute the volume |
205 // multiply their volume with this multiplier to get the effective volume. | 216 // multiplier of this session. All players in this session should multiply |
206 double volume_multiplier_; | 217 // their volume with this multiplier to get the effective volume. |
| 218 bool is_ducking_; |
| 219 |
| 220 bool is_on_top_; |
207 | 221 |
208 MediaMetadata metadata_; | 222 MediaMetadata metadata_; |
209 base::CallbackList<void(State)> media_session_state_listeners_; | 223 base::CallbackList<void(State)> media_session_state_listeners_; |
210 | 224 |
211 DISALLOW_COPY_AND_ASSIGN(MediaSession); | 225 DISALLOW_COPY_AND_ASSIGN(MediaSession); |
212 }; | 226 }; |
213 | 227 |
214 } // namespace content | 228 } // namespace content |
215 | 229 |
216 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_H_ | 230 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_H_ |
OLD | NEW |