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_ANDROID_MEDIA_SESSION_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_SESSION_H_ |
6 #define CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_SESSION_H_ | 6 #define CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_SESSION_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
12 #include "base/id_map.h" | 12 #include "base/id_map.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "content/browser/media/android/media_session_uma_helper.h" | 14 #include "content/browser/media/android/media_session_uma_helper.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "content/public/browser/web_contents_observer.h" | 16 #include "content/public/browser/web_contents_observer.h" |
17 #include "content/public/browser/web_contents_user_data.h" | 17 #include "content/public/browser/web_contents_user_data.h" |
| 18 #include "content/public/common/media_metadata.h" |
18 | 19 |
19 class MediaSessionBrowserTest; | 20 class MediaSessionBrowserTest; |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
23 class MediaSessionObserver; | 24 class MediaSessionObserver; |
24 | 25 |
25 // MediaSession manages the Android AudioFocus for a given WebContents. It is | 26 // MediaSession manages the Android AudioFocus for a given WebContents. It is |
26 // requesting the audio focus, pausing when requested by the system and dropping | 27 // requesting the audio focus, pausing when requested by the system and dropping |
27 // it on demand. | 28 // it on demand. |
(...skipping 14 matching lines...) Expand all Loading... |
42 }; | 43 }; |
43 | 44 |
44 static bool RegisterMediaSession(JNIEnv* env); | 45 static bool RegisterMediaSession(JNIEnv* env); |
45 | 46 |
46 // Returns the MediaSession associated to this WebContents. Creates one if | 47 // Returns the MediaSession associated to this WebContents. Creates one if |
47 // none is currently available. | 48 // none is currently available. |
48 static MediaSession* Get(WebContents* web_contents); | 49 static MediaSession* Get(WebContents* web_contents); |
49 | 50 |
50 ~MediaSession() override; | 51 ~MediaSession() override; |
51 | 52 |
| 53 void setMetadata(const MediaMetadata& metadata) { |
| 54 metadata_ = metadata; |
| 55 } |
| 56 const MediaMetadata& metadata() const { return metadata_; } |
| 57 |
52 // Adds the given player to the current media session. Returns whether the | 58 // Adds the given player to the current media session. Returns whether the |
53 // player was successfully added. If it returns false, AddPlayer() should be | 59 // player was successfully added. If it returns false, AddPlayer() should be |
54 // called again later. | 60 // called again later. |
55 bool AddPlayer(MediaSessionObserver* observer, int player_id, Type type); | 61 bool AddPlayer(MediaSessionObserver* observer, int player_id, Type type); |
56 | 62 |
57 // Removes the given player from the current media session. Abandons audio | 63 // Removes the given player from the current media session. Abandons audio |
58 // focus if that was the last player in the session. | 64 // focus if that was the last player in the session. |
59 void RemovePlayer(MediaSessionObserver* observer, int player_id); | 65 void RemovePlayer(MediaSessionObserver* observer, int player_id); |
60 | 66 |
61 // Removes all the players associated with |observer|. Abandons audio focus if | 67 // Removes all the players associated with |observer|. Abandons audio focus if |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 State audio_focus_state_; | 187 State audio_focus_state_; |
182 SuspendType suspend_type_; | 188 SuspendType suspend_type_; |
183 Type audio_focus_type_; | 189 Type audio_focus_type_; |
184 | 190 |
185 MediaSessionUmaHelper uma_helper_; | 191 MediaSessionUmaHelper uma_helper_; |
186 | 192 |
187 // The volume multiplier of this session. All players in this session should | 193 // The volume multiplier of this session. All players in this session should |
188 // multiply their volume with this multiplier to get the effective volume. | 194 // multiply their volume with this multiplier to get the effective volume. |
189 double volume_multiplier_; | 195 double volume_multiplier_; |
190 | 196 |
| 197 MediaMetadata metadata_; |
| 198 |
191 DISALLOW_COPY_AND_ASSIGN(MediaSession); | 199 DISALLOW_COPY_AND_ASSIGN(MediaSession); |
192 }; | 200 }; |
193 | 201 |
194 } // namespace content | 202 } // namespace content |
195 | 203 |
196 #endif // CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_SESSION_H_ | 204 #endif // CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_SESSION_H_ |
OLD | NEW |