| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_CONTROLLER_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_CONTROLLER_H_ |
| 6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_CONTROLLER_H_ | 6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "content/browser/media/session/media_session_observer.h" | 10 #include "content/browser/media/session/media_session_observer.h" |
| 11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
| 13 | 13 |
| 14 namespace media { |
| 15 enum class MediaContentType; |
| 16 } // namespace media |
| 17 |
| 14 namespace content { | 18 namespace content { |
| 15 | 19 |
| 16 class MediaSession; | 20 class MediaSession; |
| 17 class MediaWebContentsObserver; | 21 class MediaWebContentsObserver; |
| 18 | 22 |
| 19 // Helper class for controlling a single player's MediaSession instance. Sends | 23 // Helper class for controlling a single player's MediaSession instance. Sends |
| 20 // browser side MediaSession commands back to a player hosted in the renderer | 24 // browser side MediaSession commands back to a player hosted in the renderer |
| 21 // process. | 25 // process. |
| 22 class CONTENT_EXPORT MediaSessionController : | 26 class CONTENT_EXPORT MediaSessionController : |
| 23 NON_EXPORTED_BASE(public MediaSessionObserver) { | 27 NON_EXPORTED_BASE(public MediaSessionObserver) { |
| 24 public: | 28 public: |
| 25 MediaSessionController(const WebContentsObserver::MediaPlayerId& id, | 29 MediaSessionController(const WebContentsObserver::MediaPlayerId& id, |
| 26 MediaWebContentsObserver* media_web_contents_observer); | 30 MediaWebContentsObserver* media_web_contents_observer); |
| 27 ~MediaSessionController() override; | 31 ~MediaSessionController() override; |
| 28 | 32 |
| 29 // Minimum duration of content for a MediaSession instance to be created. | 33 // Minimum duration of content for a MediaSession instance to be created. |
| 30 enum { kMinimumDurationForContentSecs = 5 }; | 34 enum { kMinimumDurationForContentSecs = 5 }; |
| 31 | 35 |
| 32 // Clients must call this after construction and destroy the controller if it | 36 // Clients must call this after construction and destroy the controller if it |
| 33 // returns false. May be called more than once; does nothing if none of the | 37 // returns false. May be called more than once; does nothing if none of the |
| 34 // input parameters have changed since the last call. | 38 // input parameters have changed since the last call. |
| 35 // | 39 // |
| 36 // Note: Once a session has been initialized with |has_audio| as true, all | 40 // Note: Once a session has been initialized with |has_audio| as true, all |
| 37 // future calls to Initialize() will retain this flag. | 41 // future calls to Initialize() will retain this flag. |
| 38 // TODO(dalecurtis): Delete sticky audio once we're no longer using WMPA and | 42 // TODO(dalecurtis): Delete sticky audio once we're no longer using WMPA and |
| 39 // the BrowserMediaPlayerManagers. Tracked by http://crbug.com/580626 | 43 // the BrowserMediaPlayerManagers. Tracked by http://crbug.com/580626 |
| 40 bool Initialize(bool has_audio, bool is_remote, base::TimeDelta duration); | 44 bool Initialize(bool has_audio, |
| 45 bool is_remote, |
| 46 media::MediaContentType media_content_type); |
| 41 | 47 |
| 42 // Must be called when a pause occurs on the renderer side media player; keeps | 48 // Must be called when a pause occurs on the renderer side media player; keeps |
| 43 // the MediaSession instance in sync with renderer side behavior. | 49 // the MediaSession instance in sync with renderer side behavior. |
| 44 void OnPlaybackPaused(); | 50 void OnPlaybackPaused(); |
| 45 | 51 |
| 46 // MediaSessionObserver implementation. | 52 // MediaSessionObserver implementation. |
| 47 void OnSuspend(int player_id) override; | 53 void OnSuspend(int player_id) override; |
| 48 void OnResume(int player_id) override; | 54 void OnResume(int player_id) override; |
| 49 void OnSetVolumeMultiplier(int player_id, double volume_multiplier) override; | 55 void OnSetVolumeMultiplier(int player_id, double volume_multiplier) override; |
| 50 | 56 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 62 | 68 |
| 63 int player_id_ = 0; | 69 int player_id_ = 0; |
| 64 bool has_session_ = false; | 70 bool has_session_ = false; |
| 65 | 71 |
| 66 DISALLOW_COPY_AND_ASSIGN(MediaSessionController); | 72 DISALLOW_COPY_AND_ASSIGN(MediaSessionController); |
| 67 }; | 73 }; |
| 68 | 74 |
| 69 } // namespace content | 75 } // namespace content |
| 70 | 76 |
| 71 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_CONTROLLER_H_ | 77 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_CONTROLLER_H_ |
| OLD | NEW |