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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 | 202 |
203 // Requests audio focus to the AudioFocusDelegate. | 203 // Requests audio focus to the AudioFocusDelegate. |
204 // Returns whether the request was granted. | 204 // Returns whether the request was granted. |
205 CONTENT_EXPORT bool RequestSystemAudioFocus( | 205 CONTENT_EXPORT bool RequestSystemAudioFocus( |
206 AudioFocusManager::AudioFocusType audio_focus_type); | 206 AudioFocusManager::AudioFocusType audio_focus_type); |
207 | 207 |
208 // To be called after a call to AbandonAudioFocus() in order request the | 208 // To be called after a call to AbandonAudioFocus() in order request the |
209 // delegate to abandon the audio focus. | 209 // delegate to abandon the audio focus. |
210 CONTENT_EXPORT void AbandonSystemAudioFocusIfNeeded(); | 210 CONTENT_EXPORT void AbandonSystemAudioFocusIfNeeded(); |
211 | 211 |
212 // Notifies WebContents about the state change of the media session. | 212 // Notifies observers about the state change of the media session. |
213 void UpdateWebContents(); | 213 void DispatchStateChange(); |
whywhat
2016/11/03 14:32:17
nit: you could call it NotifyObserversAboutStateCh
Zhiqiang Zhang (Slow)
2016/11/04 14:10:54
Done.
| |
214 | 214 |
215 // Internal method that should be used instead of setting audio_focus_state_. | 215 // Internal method that should be used instead of setting audio_focus_state_. |
216 // It sets audio_focus_state_ and notifies observers about the state change. | 216 // It sets audio_focus_state_ and notifies observers about the state change. |
217 void SetAudioFocusState(State audio_focus_state); | 217 void SetAudioFocusState(State audio_focus_state); |
218 | 218 |
219 // Update the volume multiplier when ducking state changes. | 219 // Update the volume multiplier when ducking state changes. |
220 void UpdateVolumeMultiplier(); | 220 void UpdateVolumeMultiplier(); |
221 | 221 |
222 // Get the volume multiplier, which depends on whether the media session is | 222 // Get the volume multiplier, which depends on whether the media session is |
223 // ducking. | 223 // ducking. |
224 double GetVolumeMultiplier() const; | 224 double GetVolumeMultiplier() const; |
225 | 225 |
226 // Registers a MediaSessionImpl state change callback. | 226 // Registers a MediaSessionImpl state change callback. |
227 CONTENT_EXPORT std::unique_ptr<base::CallbackList<void(State)>::Subscription> | 227 CONTENT_EXPORT std::unique_ptr<base::CallbackList<void(State)>::Subscription> |
228 RegisterMediaSessionStateChangedCallbackForTest( | 228 RegisterMediaSessionStateChangedCallbackForTest( |
229 const StateChangedCallback& cb); | 229 const StateChangedCallback& cb); |
230 | 230 |
231 CONTENT_EXPORT bool AddPepperPlayer(MediaSessionPlayerObserver* observer, | 231 CONTENT_EXPORT bool AddPepperPlayer(MediaSessionPlayerObserver* observer, |
232 int player_id); | 232 int player_id); |
233 | 233 |
234 CONTENT_EXPORT bool AddOneShotPlayer(MediaSessionPlayerObserver* observer, | |
235 int player_id); | |
236 | |
234 std::unique_ptr<AudioFocusDelegate> delegate_; | 237 std::unique_ptr<AudioFocusDelegate> delegate_; |
235 PlayersMap players_; | 238 PlayersMap players_; |
whywhat
2016/11/03 14:32:17
nit: perhaps we should rename players_ into normal
Zhiqiang Zhang (Slow)
2016/11/04 14:10:54
Done.
| |
236 PlayersMap pepper_players_; | 239 PlayersMap pepper_players_; |
240 PlayersMap one_shot_players_; | |
237 | 241 |
238 State audio_focus_state_; | 242 State audio_focus_state_; |
239 MediaSession::SuspendType suspend_type_; | 243 MediaSession::SuspendType suspend_type_; |
240 AudioFocusManager::AudioFocusType audio_focus_type_; | 244 AudioFocusManager::AudioFocusType audio_focus_type_; |
241 | 245 |
242 MediaSessionUmaHelper uma_helper_; | 246 MediaSessionUmaHelper uma_helper_; |
243 | 247 |
244 // The ducking state of this media session. The initial value is |false|, and | 248 // The ducking state of this media session. The initial value is |false|, and |
245 // is set to |true| after StartDucking(), and will be set to |false| after | 249 // is set to |true| after StartDucking(), and will be set to |false| after |
246 // StopDucking(). | 250 // StopDucking(). |
247 bool is_ducking_; | 251 bool is_ducking_; |
248 | 252 |
249 base::Optional<MediaMetadata> metadata_; | 253 base::Optional<MediaMetadata> metadata_; |
250 base::CallbackList<void(State)> media_session_state_listeners_; | 254 base::CallbackList<void(State)> media_session_state_listeners_; |
251 | 255 |
252 base::ObserverList<MediaSessionObserver> observers_; | 256 base::ObserverList<MediaSessionObserver> observers_; |
253 | 257 |
254 #if defined(OS_ANDROID) | 258 #if defined(OS_ANDROID) |
255 std::unique_ptr<MediaSessionAndroid> session_android_; | 259 std::unique_ptr<MediaSessionAndroid> session_android_; |
256 #endif // defined(OS_ANDROID) | 260 #endif // defined(OS_ANDROID) |
257 | 261 |
258 DISALLOW_COPY_AND_ASSIGN(MediaSessionImpl); | 262 DISALLOW_COPY_AND_ASSIGN(MediaSessionImpl); |
259 }; | 263 }; |
260 | 264 |
261 } // namespace content | 265 } // namespace content |
262 | 266 |
263 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_ | 267 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_ |
OLD | NEW |