Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(964)

Unified Diff: content/browser/media/android/media_session_controller.h

Issue 1570043002: Implement MediaSession on top of the WebMediaPlayerDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@media_session
Patch Set: Rebase yet again. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/media/android/media_session_controller.h
diff --git a/content/browser/media/android/media_session_controller.h b/content/browser/media/android/media_session_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..ec8607d98a60b2b1eeb07fbacfabffa654c0ed94
--- /dev/null
+++ b/content/browser/media/android/media_session_controller.h
@@ -0,0 +1,58 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_SESSION_CONTROLLER_H_
+#define CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_SESSION_CONTROLLER_H_
+
+#include "base/time/time.h"
+#include "content/browser/media/android/media_session_observer.h"
+#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
+#include "content/common/content_export.h"
+
+namespace content {
+
+// Helper class for controlling a single player's MediaSession instance. Sends
+// browser side MediaSession commands back to a player hosted in the renderer
+// process.
+class CONTENT_EXPORT MediaSessionController : public MediaSessionObserver {
+ public:
+ MediaSessionController(const WebContentsObserver::MediaPlayerId& id,
+ MediaWebContentsObserver* media_web_contents_observer);
+ ~MediaSessionController() override;
+
+ // Minimum duration of content for a MediaSession instance to be created.
+ enum { kMinimumDurationForContentSecs = 5 };
+
+ // Clients must call this after construction and destroy the controller if it
+ // returns false.
+ bool Initialize(bool has_audio, bool is_remote, base::TimeDelta duration);
+
+ // Must be called when a pause occurs on the renderer side media player; keeps
+ // the MediaSession instance in sync with renderer side behavior.
+ 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
+
+ // MediaSessionObserver implementation.
+ void OnSuspend(int player_id) override;
+ void OnResume(int player_id) override;
+ void OnSetVolumeMultiplier(int player_id, double volume_multiplier) override;
+
+ // TODO(dalecurtis): Remove once WMPA is removed and there are no inaccurate
+ // setting reports.
+ 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.
+
+ 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.
+
+ private:
+ const WebContentsObserver::MediaPlayerId id_;
+ 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.
+ int player_id_ = 0;
+ bool initialized_ = false;
+ bool has_audio_ = false;
+
+ DISALLOW_COPY_AND_ASSIGN(MediaSessionController);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_SESSION_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698