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

Side by Side 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: Address comments. 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 unified diff | Download patch
OLDNEW
(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.h"
10 #include "content/browser/media/android/media_session_observer.h"
11 #include "content/common/content_export.h"
12 #include "content/public/browser/web_contents_observer.h"
13
14 namespace content {
15 class MediaWebContentsObserver;
16
17 // Helper class for controlling a single player's MediaSession instance. Sends
18 // browser side MediaSession commands back to a player hosted in the renderer
19 // process.
20 class CONTENT_EXPORT MediaSessionController : public MediaSessionObserver {
21 public:
22 MediaSessionController(const WebContentsObserver::MediaPlayerId& id,
23 MediaWebContentsObserver* media_web_contents_observer);
24 ~MediaSessionController() override;
25
26 // Minimum duration of content for a MediaSession instance to be created.
27 enum { kMinimumDurationForContentSecs = 5 };
28
29 // Clients must call this after construction and destroy the controller if it
30 // returns false. May be called more than once; does nothing if none of the
31 // input parameters have changed since the last call.
32 bool Initialize(bool has_audio, bool is_remote, base::TimeDelta duration);
33
34 // Must be called when a pause occurs on the renderer side media player; keeps
35 // the MediaSession instance in sync with renderer side behavior.
36 void OnPlaybackPaused();
37
38 // MediaSessionObserver implementation.
39 void OnSuspend(int player_id) override;
40 void OnResume(int player_id) override;
41 void OnSetVolumeMultiplier(int player_id, double volume_multiplier) override;
42
43 int get_player_id_for_testing() const { return player_id_; }
44
45 private:
46 const WebContentsObserver::MediaPlayerId id_;
47
48 // Non-owned pointer; |media_web_contents_observer_| is the owner of |this|.
49 MediaWebContentsObserver* const media_web_contents_observer_;
50
51 // Non-owned pointer; lifetime is the same as |media_web_contents_observer_|.
52 MediaSession* const media_session_;
53
54 int player_id_ = 0;
55 bool has_session_ = false;
56 MediaSession::Type session_type_ = MediaSession::Type::Content;
57
58 DISALLOW_COPY_AND_ASSIGN(MediaSessionController);
59 };
60
61 } // namespace content
62
63 #endif // CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_SESSION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698