Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_SESSION_CONTROLLER_H_ | |
| 6 #define CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_SESSION_CONTROLLER_H_ | |
| 7 | |
| 8 #include "base/time/time.h" | |
| 9 #include "content/browser/media/android/media_session_observer.h" | |
| 10 #include "content/browser/media/media_web_contents_observer.h" | |
|
mlamouri (slow - plz ping)
2016/01/22 16:58:31
nit: I think you should be able to fwd clare this.
DaleCurtis
2016/01/23 02:10:59
Done, but requires including WebContentsObserver n
| |
| 11 #include "content/common/content_export.h" | |
| 12 | |
| 13 namespace content { | |
| 14 | |
| 15 // Helper class for controlling a single player's MediaSession instance. Sends | |
| 16 // browser side MediaSession commands back to a player hosted in the renderer | |
| 17 // process. | |
| 18 class CONTENT_EXPORT MediaSessionController : public MediaSessionObserver { | |
| 19 public: | |
| 20 MediaSessionController(const WebContentsObserver::MediaPlayerId& id, | |
| 21 MediaWebContentsObserver* media_web_contents_observer); | |
| 22 ~MediaSessionController() override; | |
| 23 | |
| 24 // Minimum duration of content for a MediaSession instance to be created. | |
| 25 enum { kMinimumDurationForContentSecs = 5 }; | |
| 26 | |
| 27 // Clients must call this after construction and destroy the controller if it | |
| 28 // returns false. | |
| 29 bool Initialize(bool has_audio, bool is_remote, base::TimeDelta duration); | |
| 30 | |
| 31 // Must be called when a pause occurs on the renderer side media player; keeps | |
| 32 // the MediaSession instance in sync with renderer side behavior. | |
| 33 void PausePlayback(); | |
|
mlamouri (slow - plz ping)
2016/01/22 16:58:31
nit: why not `OnPausePlayback()`. It sounds like t
DaleCurtis
2016/01/23 02:10:59
Went with OnPlaybackPaused() since this is reflect
| |
| 34 | |
| 35 // MediaSessionObserver implementation. | |
| 36 void OnSuspend(int player_id) override; | |
| 37 void OnResume(int player_id) override; | |
| 38 void OnSetVolumeMultiplier(int player_id, double volume_multiplier) override; | |
| 39 | |
| 40 // TODO(dalecurtis): Remove once WMPA is removed and there are no inaccurate | |
| 41 // setting reports. | |
| 42 bool has_audio() { return has_audio_; } | |
|
mlamouri (slow - plz ping)
2016/01/22 16:58:31
nit: `const`
DaleCurtis
2016/01/23 02:10:59
Done.
| |
| 43 | |
| 44 int get_player_id_for_testing() { return player_id_; } | |
|
mlamouri (slow - plz ping)
2016/01/22 16:58:31
nit: `const`
DaleCurtis
2016/01/23 02:10:59
Done.
| |
| 45 | |
| 46 private: | |
| 47 const WebContentsObserver::MediaPlayerId id_; | |
| 48 MediaWebContentsObserver* const media_web_contents_observer_; | |
|
mlamouri (slow - plz ping)
2016/01/22 16:58:31
Can you explain the ownership of this in a comment
DaleCurtis
2016/01/23 02:10:59
Done.
| |
| 49 int player_id_ = 0; | |
| 50 bool initialized_ = false; | |
| 51 bool has_audio_ = false; | |
| 52 | |
| 53 DISALLOW_COPY_AND_ASSIGN(MediaSessionController); | |
| 54 }; | |
| 55 | |
| 56 } // namespace content | |
| 57 | |
| 58 #endif // CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_SESSION_CONTROLLER_H_ | |
| OLD | NEW |