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" |
11 #include "base/id_map.h" | 11 #include "base/id_map.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/optional.h" |
13 #include "content/browser/media/session/audio_focus_manager.h" | 14 #include "content/browser/media/session/audio_focus_manager.h" |
14 #include "content/browser/media/session/media_session_uma_helper.h" | 15 #include "content/browser/media/session/media_session_uma_helper.h" |
15 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
16 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
17 #include "content/public/browser/web_contents_user_data.h" | 18 #include "content/public/browser/web_contents_user_data.h" |
18 #include "content/public/common/media_metadata.h" | 19 #include "content/public/common/media_metadata.h" |
19 | 20 |
20 class MediaSessionBrowserTest; | 21 class MediaSessionBrowserTest; |
21 | 22 |
22 namespace media { | 23 namespace media { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // Suspended by the page via script or user interaction. | 57 // Suspended by the page via script or user interaction. |
57 CONTENT, | 58 CONTENT, |
58 }; | 59 }; |
59 | 60 |
60 // Returns the MediaSession associated to this WebContents. Creates one if | 61 // Returns the MediaSession associated to this WebContents. Creates one if |
61 // none is currently available. | 62 // none is currently available. |
62 CONTENT_EXPORT static MediaSession* Get(WebContents* web_contents); | 63 CONTENT_EXPORT static MediaSession* Get(WebContents* web_contents); |
63 | 64 |
64 ~MediaSession() override; | 65 ~MediaSession() override; |
65 | 66 |
66 void SetMetadata(const MediaMetadata& metadata); | 67 void SetMetadata(const base::Optional<MediaMetadata>& metadata); |
67 const MediaMetadata& metadata() const { return metadata_; } | 68 const base::Optional<MediaMetadata>& metadata() const { return metadata_; } |
68 | 69 |
69 // Adds the given player to the current media session. Returns whether the | 70 // Adds the given player to the current media session. Returns whether the |
70 // player was successfully added. If it returns false, AddPlayer() should be | 71 // player was successfully added. If it returns false, AddPlayer() should be |
71 // called again later. | 72 // called again later. |
72 CONTENT_EXPORT bool AddPlayer(MediaSessionObserver* observer, | 73 CONTENT_EXPORT bool AddPlayer(MediaSessionObserver* observer, |
73 int player_id, | 74 int player_id, |
74 media::MediaContentType media_content_type); | 75 media::MediaContentType media_content_type); |
75 | 76 |
76 // Removes the given player from the current media session. Abandons audio | 77 // Removes the given player from the current media session. Abandons audio |
77 // focus if that was the last player in the session. | 78 // focus if that was the last player in the session. |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 SuspendType suspend_type_; | 212 SuspendType suspend_type_; |
212 AudioFocusManager::AudioFocusType audio_focus_type_; | 213 AudioFocusManager::AudioFocusType audio_focus_type_; |
213 | 214 |
214 MediaSessionUmaHelper uma_helper_; | 215 MediaSessionUmaHelper uma_helper_; |
215 | 216 |
216 // The ducking state of this media session. The initial value is |false|, and | 217 // The ducking state of this media session. The initial value is |false|, and |
217 // is set to |true| after StartDucking(), and will be set to |false| after | 218 // is set to |true| after StartDucking(), and will be set to |false| after |
218 // StopDucking(). | 219 // StopDucking(). |
219 bool is_ducking_; | 220 bool is_ducking_; |
220 | 221 |
221 MediaMetadata metadata_; | 222 base::Optional<MediaMetadata> metadata_; |
222 base::CallbackList<void(State)> media_session_state_listeners_; | 223 base::CallbackList<void(State)> media_session_state_listeners_; |
223 | 224 |
224 DISALLOW_COPY_AND_ASSIGN(MediaSession); | 225 DISALLOW_COPY_AND_ASSIGN(MediaSession); |
225 }; | 226 }; |
226 | 227 |
227 } // namespace content | 228 } // namespace content |
228 | 229 |
229 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_H_ | 230 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_H_ |
OLD | NEW |