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_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_ |
6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_ | 6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 219 |
220 // Requests audio focus to the AudioFocusDelegate. | 220 // Requests audio focus to the AudioFocusDelegate. |
221 // Returns whether the request was granted. | 221 // Returns whether the request was granted. |
222 CONTENT_EXPORT bool RequestSystemAudioFocus( | 222 CONTENT_EXPORT bool RequestSystemAudioFocus( |
223 AudioFocusManager::AudioFocusType audio_focus_type); | 223 AudioFocusManager::AudioFocusType audio_focus_type); |
224 | 224 |
225 // To be called after a call to AbandonAudioFocus() in order request the | 225 // To be called after a call to AbandonAudioFocus() in order request the |
226 // delegate to abandon the audio focus. | 226 // delegate to abandon the audio focus. |
227 CONTENT_EXPORT void AbandonSystemAudioFocusIfNeeded(); | 227 CONTENT_EXPORT void AbandonSystemAudioFocusIfNeeded(); |
228 | 228 |
229 // Notifies WebContents about the state change of the media session. | 229 // Notifies observers about the state change of the media session. |
230 void UpdateWebContents(); | 230 void NotifyAboutStateChange(); |
231 | 231 |
232 // Internal method that should be used instead of setting audio_focus_state_. | 232 // Internal method that should be used instead of setting audio_focus_state_. |
233 // It sets audio_focus_state_ and notifies observers about the state change. | 233 // It sets audio_focus_state_ and notifies observers about the state change. |
234 void SetAudioFocusState(State audio_focus_state); | 234 void SetAudioFocusState(State audio_focus_state); |
235 | 235 |
236 // Update the volume multiplier when ducking state changes. | 236 // Update the volume multiplier when ducking state changes. |
237 void UpdateVolumeMultiplier(); | 237 void UpdateVolumeMultiplier(); |
238 | 238 |
239 // Get the volume multiplier, which depends on whether the media session is | 239 // Get the volume multiplier, which depends on whether the media session is |
240 // ducking. | 240 // ducking. |
241 double GetVolumeMultiplier() const; | 241 double GetVolumeMultiplier() const; |
242 | 242 |
243 // Registers a MediaSessionImpl state change callback. | 243 // Registers a MediaSessionImpl state change callback. |
244 CONTENT_EXPORT std::unique_ptr<base::CallbackList<void(State)>::Subscription> | 244 CONTENT_EXPORT std::unique_ptr<base::CallbackList<void(State)>::Subscription> |
245 RegisterMediaSessionStateChangedCallbackForTest( | 245 RegisterMediaSessionStateChangedCallbackForTest( |
246 const StateChangedCallback& cb); | 246 const StateChangedCallback& cb); |
247 | 247 |
248 CONTENT_EXPORT bool AddPepperPlayer(MediaSessionPlayerObserver* observer, | 248 CONTENT_EXPORT bool AddPepperPlayer(MediaSessionPlayerObserver* observer, |
249 int player_id); | 249 int player_id); |
250 | 250 |
| 251 CONTENT_EXPORT bool AddOneShotPlayer(MediaSessionPlayerObserver* observer, |
| 252 int player_id); |
| 253 |
251 std::unique_ptr<AudioFocusDelegate> delegate_; | 254 std::unique_ptr<AudioFocusDelegate> delegate_; |
252 PlayersMap players_; | 255 PlayersMap normal_players_; |
253 PlayersMap pepper_players_; | 256 PlayersMap pepper_players_; |
| 257 PlayersMap one_shot_players_; |
254 | 258 |
255 State audio_focus_state_; | 259 State audio_focus_state_; |
256 MediaSession::SuspendType suspend_type_; | 260 MediaSession::SuspendType suspend_type_; |
257 AudioFocusManager::AudioFocusType audio_focus_type_; | 261 AudioFocusManager::AudioFocusType audio_focus_type_; |
258 | 262 |
259 MediaSessionUmaHelper uma_helper_; | 263 MediaSessionUmaHelper uma_helper_; |
260 | 264 |
261 // The ducking state of this media session. The initial value is |false|, and | 265 // The ducking state of this media session. The initial value is |false|, and |
262 // is set to |true| after StartDucking(), and will be set to |false| after | 266 // is set to |true| after StartDucking(), and will be set to |false| after |
263 // StopDucking(). | 267 // StopDucking(). |
(...skipping 11 matching lines...) Expand all Loading... |
275 // The MediaSessionService this session is associated with (the service of the | 279 // The MediaSessionService this session is associated with (the service of the |
276 // top-level frame). | 280 // top-level frame). |
277 MediaSessionServiceImpl* service_; | 281 MediaSessionServiceImpl* service_; |
278 | 282 |
279 DISALLOW_COPY_AND_ASSIGN(MediaSessionImpl); | 283 DISALLOW_COPY_AND_ASSIGN(MediaSessionImpl); |
280 }; | 284 }; |
281 | 285 |
282 } // namespace content | 286 } // namespace content |
283 | 287 |
284 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_ | 288 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_ |
OLD | NEW |