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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Change the volume multiplier of the session to |volume_multiplier|. |
107 CONTENT_EXPORT void SetVolumeMultiplier(double volume_multiplier); | 107 CONTENT_EXPORT void SetVolumeMultiplier(double volume_multiplier); |
108 | 108 |
| 109 CONTENT_EXPORT void SetPepperVolumeMultiplier(double volume_multiplier); |
| 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 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 using StateChangedCallback = base::Callback<void(State)>; | 166 using StateChangedCallback = base::Callback<void(State)>; |
165 | 167 |
166 CONTENT_EXPORT explicit MediaSession(WebContents* web_contents); | 168 CONTENT_EXPORT explicit MediaSession(WebContents* web_contents); |
167 | 169 |
168 void Initialize(); | 170 void Initialize(); |
169 | 171 |
170 CONTENT_EXPORT void OnSuspendInternal(SuspendType suspend_type, | 172 CONTENT_EXPORT void OnSuspendInternal(SuspendType suspend_type, |
171 State new_state); | 173 State new_state); |
172 CONTENT_EXPORT void OnResumeInternal(SuspendType suspend_type); | 174 CONTENT_EXPORT void OnResumeInternal(SuspendType suspend_type); |
173 | 175 |
| 176 bool AddPepperPlayer(MediaSessionObserver* observer, int player_id); |
| 177 |
174 // Requests audio focus to the MediaSessionDelegate. | 178 // Requests audio focus to the MediaSessionDelegate. |
175 // Returns whether the request was granted. | 179 // Returns whether the request was granted. |
176 bool RequestSystemAudioFocus( | 180 bool RequestSystemAudioFocus( |
177 AudioFocusManager::AudioFocusType audio_focus_type); | 181 AudioFocusManager::AudioFocusType audio_focus_type); |
178 | 182 |
179 // To be called after a call to AbandonAudioFocus() in order request the | 183 // To be called after a call to AbandonAudioFocus() in order request the |
180 // delegate to abandon the audio focus. | 184 // delegate to abandon the audio focus. |
181 void AbandonSystemAudioFocusIfNeeded(); | 185 void AbandonSystemAudioFocusIfNeeded(); |
182 | 186 |
183 // Notifies WebContents about the state change of the media session. | 187 // Notifies WebContents about the state change of the media session. |
184 void UpdateWebContents(); | 188 void UpdateWebContents(); |
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 |
195 std::unique_ptr<MediaSessionDelegate> delegate_; | 199 std::unique_ptr<MediaSessionDelegate> delegate_; |
196 PlayersMap players_; | 200 PlayersMap players_; |
| 201 PlayersMap pepper_players_; |
197 | 202 |
198 State audio_focus_state_; | 203 State audio_focus_state_; |
199 SuspendType suspend_type_; | 204 SuspendType suspend_type_; |
200 AudioFocusManager::AudioFocusType audio_focus_type_; | 205 AudioFocusManager::AudioFocusType audio_focus_type_; |
201 | 206 |
202 MediaSessionUmaHelper uma_helper_; | 207 MediaSessionUmaHelper uma_helper_; |
203 | 208 |
204 // The volume multiplier of this session. All players in this session should | 209 // The volume multiplier of this session. All players in this session should |
205 // multiply their volume with this multiplier to get the effective volume. | 210 // multiply their volume with this multiplier to get the effective volume. |
206 double volume_multiplier_; | 211 double volume_multiplier_; |
207 | 212 |
208 MediaMetadata metadata_; | 213 MediaMetadata metadata_; |
209 base::CallbackList<void(State)> media_session_state_listeners_; | 214 base::CallbackList<void(State)> media_session_state_listeners_; |
210 | 215 |
211 DISALLOW_COPY_AND_ASSIGN(MediaSession); | 216 DISALLOW_COPY_AND_ASSIGN(MediaSession); |
212 }; | 217 }; |
213 | 218 |
214 } // namespace content | 219 } // namespace content |
215 | 220 |
216 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_H_ | 221 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_H_ |
OLD | NEW |