| 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 21 matching lines...) Expand all Loading... |
| 32 } // namespace media | 32 } // namespace media |
| 33 | 33 |
| 34 namespace content { | 34 namespace content { |
| 35 | 35 |
| 36 class AudioFocusDelegate; | 36 class AudioFocusDelegate; |
| 37 class AudioFocusManagerTest; | 37 class AudioFocusManagerTest; |
| 38 class MediaSessionImplStateObserver; | 38 class MediaSessionImplStateObserver; |
| 39 class MediaSessionImplVisibilityBrowserTest; | 39 class MediaSessionImplVisibilityBrowserTest; |
| 40 class MediaSessionObserver; | 40 class MediaSessionObserver; |
| 41 class MediaSessionPlayerObserver; | 41 class MediaSessionPlayerObserver; |
| 42 class MediaSessionServiceImpl; |
| 42 | 43 |
| 43 #if defined(OS_ANDROID) | 44 #if defined(OS_ANDROID) |
| 44 class MediaSessionAndroid; | 45 class MediaSessionAndroid; |
| 45 #endif // defined(OS_ANDROID) | 46 #endif // defined(OS_ANDROID) |
| 46 | 47 |
| 47 // MediaSessionImpl is the implementation of MediaSession. It manages the media | 48 // MediaSessionImpl is the implementation of MediaSession. It manages the media |
| 48 // session and audio focus for a given WebContents. It is requesting the audio | 49 // session and audio focus for a given WebContents. It is requesting the audio |
| 49 // focus, pausing when requested by the system and dropping it on demand. The | 50 // focus, pausing when requested by the system and dropping it on demand. The |
| 50 // audio focus can be of two types: Transient or Content. A Transient audio | 51 // audio focus can be of two types: Transient or Content. A Transient audio |
| 51 // focus will allow other players to duck instead of pausing and will be | 52 // focus will allow other players to duck instead of pausing and will be |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 CONTENT_EXPORT void Resume(MediaSession::SuspendType suspend_type) override; | 117 CONTENT_EXPORT void Resume(MediaSession::SuspendType suspend_type) override; |
| 117 | 118 |
| 118 // Suspend the media session. | 119 // Suspend the media session. |
| 119 // |type| represents the origin of the request. | 120 // |type| represents the origin of the request. |
| 120 CONTENT_EXPORT void Suspend(MediaSession::SuspendType suspend_type) override; | 121 CONTENT_EXPORT void Suspend(MediaSession::SuspendType suspend_type) override; |
| 121 | 122 |
| 122 // Stop the media session. | 123 // Stop the media session. |
| 123 // |type| represents the origin of the request. | 124 // |type| represents the origin of the request. |
| 124 CONTENT_EXPORT void Stop(MediaSession::SuspendType suspend_type) override; | 125 CONTENT_EXPORT void Stop(MediaSession::SuspendType suspend_type) override; |
| 125 | 126 |
| 127 // Received a media session action and forward to blink::MediaSession. |
| 128 void DidReceiveAction(blink::mojom::MediaSessionAction action) override; |
| 129 |
| 130 // Called when an action is enabled in blink::MediaSession. This method will |
| 131 // notify the observers that the action is enabled. |
| 132 void OnMediaSessionEnabledAction(blink::mojom::MediaSessionAction action); |
| 133 |
| 134 // Called when an action is disabled in blink::MediaSession. This method will |
| 135 // notify the observers that the action is disabled. |
| 136 void OnMediaSessionDisabledAction(blink::mojom::MediaSessionAction action); |
| 137 |
| 126 // Let the media session start ducking such that the volume multiplier is | 138 // Let the media session start ducking such that the volume multiplier is |
| 127 // reduced. | 139 // reduced. |
| 128 CONTENT_EXPORT void StartDucking(); | 140 CONTENT_EXPORT void StartDucking(); |
| 129 | 141 |
| 130 // Let the media session stop ducking such that the volume multiplier is | 142 // Let the media session stop ducking such that the volume multiplier is |
| 131 // recovered. | 143 // recovered. |
| 132 CONTENT_EXPORT void StopDucking(); | 144 CONTENT_EXPORT void StopDucking(); |
| 133 | 145 |
| 134 // Returns if the session can be controlled by Resume() and Suspend calls | 146 // Returns if the session can be controlled by Resume() and Suspend calls |
| 135 // above. | 147 // above. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 153 CONTENT_EXPORT AudioFocusManager::AudioFocusType audio_focus_type() const { | 165 CONTENT_EXPORT AudioFocusManager::AudioFocusType audio_focus_type() const { |
| 154 return audio_focus_type_; | 166 return audio_focus_type_; |
| 155 } | 167 } |
| 156 | 168 |
| 157 // Returns whether the session has Pepper instances. | 169 // Returns whether the session has Pepper instances. |
| 158 bool HasPepper() const; | 170 bool HasPepper() const; |
| 159 | 171 |
| 160 // WebContentsObserver implementation | 172 // WebContentsObserver implementation |
| 161 void WebContentsDestroyed() override; | 173 void WebContentsDestroyed() override; |
| 162 | 174 |
| 175 // Sets the associated MediaSessionService for communicating with |
| 176 // blink::MediaSession. |
| 177 MediaSessionServiceImpl* GetMediaSessionService() { return service_; } |
| 178 void SetMediaSessionService(MediaSessionServiceImpl* service); |
| 179 |
| 163 private: | 180 private: |
| 164 friend class content::WebContentsUserData<MediaSessionImpl>; | 181 friend class content::WebContentsUserData<MediaSessionImpl>; |
| 165 friend class ::MediaSessionImplBrowserTest; | 182 friend class ::MediaSessionImplBrowserTest; |
| 166 friend class content::MediaSessionImplVisibilityBrowserTest; | 183 friend class content::MediaSessionImplVisibilityBrowserTest; |
| 167 friend class content::AudioFocusManagerTest; | 184 friend class content::AudioFocusManagerTest; |
| 168 friend class content::MediaSessionImplStateObserver; | 185 friend class content::MediaSessionImplStateObserver; |
| 169 | 186 |
| 170 CONTENT_EXPORT void SetDelegateForTests( | 187 CONTENT_EXPORT void SetDelegateForTests( |
| 171 std::unique_ptr<AudioFocusDelegate> delegate); | 188 std::unique_ptr<AudioFocusDelegate> delegate); |
| 172 CONTENT_EXPORT bool IsActiveForTest() const; | 189 CONTENT_EXPORT bool IsActiveForTest() const; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 265 |
| 249 base::Optional<MediaMetadata> metadata_; | 266 base::Optional<MediaMetadata> metadata_; |
| 250 base::CallbackList<void(State)> media_session_state_listeners_; | 267 base::CallbackList<void(State)> media_session_state_listeners_; |
| 251 | 268 |
| 252 base::ObserverList<MediaSessionObserver> observers_; | 269 base::ObserverList<MediaSessionObserver> observers_; |
| 253 | 270 |
| 254 #if defined(OS_ANDROID) | 271 #if defined(OS_ANDROID) |
| 255 std::unique_ptr<MediaSessionAndroid> session_android_; | 272 std::unique_ptr<MediaSessionAndroid> session_android_; |
| 256 #endif // defined(OS_ANDROID) | 273 #endif // defined(OS_ANDROID) |
| 257 | 274 |
| 275 // The MediaSessionService this session is associated with (the service of the |
| 276 // top-level frame). |
| 277 MediaSessionServiceImpl* service_; |
| 278 |
| 258 DISALLOW_COPY_AND_ASSIGN(MediaSessionImpl); | 279 DISALLOW_COPY_AND_ASSIGN(MediaSessionImpl); |
| 259 }; | 280 }; |
| 260 | 281 |
| 261 } // namespace content | 282 } // namespace content |
| 262 | 283 |
| 263 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_ | 284 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_IMPL_H_ |
| OLD | NEW |