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

Side by Side Diff: content/browser/media/android/browser_media_player_manager.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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_BROWSER_MEDIA_PLAYER_MANAGER_H_ 5 #ifndef CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_
6 #define CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_ 6 #define CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "content/browser/android/content_video_view.h" 15 #include "content/browser/android/content_video_view.h"
16 #include "content/browser/media/android/media_session_observer.h"
17 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
18 #include "ipc/ipc_message.h" 17 #include "ipc/ipc_message.h"
19 #include "media/base/android/media_player_android.h" 18 #include "media/base/android/media_player_android.h"
20 #include "media/base/android/media_player_manager.h" 19 #include "media/base/android/media_player_manager.h"
21 #include "media/base/android/media_url_interceptor.h" 20 #include "media/base/android/media_url_interceptor.h"
22 #include "ui/gfx/geometry/rect_f.h" 21 #include "ui/gfx/geometry/rect_f.h"
23 #include "ui/gl/android/scoped_java_surface.h" 22 #include "ui/gl/android/scoped_java_surface.h"
24 #include "url/gurl.h" 23 #include "url/gurl.h"
25 24
26 namespace media { 25 namespace media {
(...skipping 11 matching lines...) Expand all
38 class RenderFrameHost; 37 class RenderFrameHost;
39 class WebContents; 38 class WebContents;
40 39
41 // This class manages all the MediaPlayerAndroid objects. 40 // This class manages all the MediaPlayerAndroid objects.
42 // It receives control operations from the the render process, and forwards 41 // It receives control operations from the the render process, and forwards
43 // them to corresponding MediaPlayerAndroid object. Callbacks from 42 // them to corresponding MediaPlayerAndroid object. Callbacks from
44 // MediaPlayerAndroid objects are converted to IPCs and then sent to the render 43 // MediaPlayerAndroid objects are converted to IPCs and then sent to the render
45 // process. 44 // process.
46 class CONTENT_EXPORT BrowserMediaPlayerManager 45 class CONTENT_EXPORT BrowserMediaPlayerManager
47 : public media::MediaPlayerManager, 46 : public media::MediaPlayerManager,
48 public MediaSessionObserver,
49 public ContentVideoView::Client { 47 public ContentVideoView::Client {
50 public: 48 public:
51 // Permits embedders to provide an extended version of the class. 49 // Permits embedders to provide an extended version of the class.
52 typedef BrowserMediaPlayerManager* (*Factory)(RenderFrameHost*); 50 typedef BrowserMediaPlayerManager* (*Factory)(RenderFrameHost*);
53 static void RegisterFactory(Factory factory); 51 static void RegisterFactory(Factory factory);
54 52
55 // Permits embedders to handle custom urls. 53 // Permits embedders to handle custom urls.
56 static void RegisterMediaUrlInterceptor( 54 static void RegisterMediaUrlInterceptor(
57 media::MediaUrlInterceptor* media_url_interceptor); 55 media::MediaUrlInterceptor* media_url_interceptor);
58 56
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 media::MediaPlayerAndroid* GetFullscreenPlayer() override; 104 media::MediaPlayerAndroid* GetFullscreenPlayer() override;
107 media::MediaPlayerAndroid* GetPlayer(int player_id) override; 105 media::MediaPlayerAndroid* GetPlayer(int player_id) override;
108 bool RequestPlay(int player_id, base::TimeDelta duration, 106 bool RequestPlay(int player_id, base::TimeDelta duration,
109 bool has_audio) override; 107 bool has_audio) override;
110 #if defined(VIDEO_HOLE) 108 #if defined(VIDEO_HOLE)
111 void AttachExternalVideoSurface(int player_id, jobject surface); 109 void AttachExternalVideoSurface(int player_id, jobject surface);
112 void DetachExternalVideoSurface(int player_id); 110 void DetachExternalVideoSurface(int player_id);
113 void OnFrameInfoUpdated(); 111 void OnFrameInfoUpdated();
114 #endif // defined(VIDEO_HOLE) 112 #endif // defined(VIDEO_HOLE)
115 113
116 // MediaSessionObserver overrides.
117 void OnSuspend(int player_id) override;
118 void OnResume(int player_id) override;
119 void OnSetVolumeMultiplier(int player_id, double volume_multiplier) override;
120
121 // Message handlers. 114 // Message handlers.
122 virtual void OnEnterFullscreen(int player_id); 115 virtual void OnEnterFullscreen(int player_id);
123 virtual void OnInitialize( 116 virtual void OnInitialize(
124 const MediaPlayerHostMsg_Initialize_Params& media_player_params); 117 const MediaPlayerHostMsg_Initialize_Params& media_player_params);
125 virtual void OnStart(int player_id); 118 virtual void OnStart(int player_id);
126 virtual void OnSeek(int player_id, const base::TimeDelta& time); 119 virtual void OnSeek(int player_id, const base::TimeDelta& time);
127 virtual void OnPause(int player_id, bool is_media_related_action); 120 virtual void OnPause(int player_id, bool is_media_related_action);
128 virtual void OnSetVolume(int player_id, double volume); 121 virtual void OnSetVolume(int player_id, double volume);
129 virtual void OnSetPoster(int player_id, const GURL& poster); 122 virtual void OnSetPoster(int player_id, const GURL& poster);
130 virtual void OnSuspendAndReleaseResources(int player_id); 123 virtual void OnSuspendAndReleaseResources(int player_id);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // On the contrary, requests with false |temporary| value are subject to 160 // On the contrary, requests with false |temporary| value are subject to
168 // clean up if their players are idle. 161 // clean up if their players are idle.
169 virtual bool RequestDecoderResources(int player_id, bool temporary); 162 virtual bool RequestDecoderResources(int player_id, bool temporary);
170 163
171 // MediaPlayerAndroid must call this to inform the manager that it has 164 // MediaPlayerAndroid must call this to inform the manager that it has
172 // released the decoder resources. This can be triggered by the 165 // released the decoder resources. This can be triggered by the
173 // ReleasePlayer() call below, or when meta data is extracted, or when player 166 // ReleasePlayer() call below, or when meta data is extracted, or when player
174 // is stuck in an error. 167 // is stuck in an error.
175 virtual void OnDecoderResourcesReleased(int player_id); 168 virtual void OnDecoderResourcesReleased(int player_id);
176 169
170 virtual bool IsPlayingRemotely(int player_id);
mlamouri (slow - plz ping) 2016/01/22 16:58:31 You are going to hate us but you will have to reba
DaleCurtis 2016/01/23 02:10:59 Done, but you guys are killing me! :) You might co
171
177 int RoutingID(); 172 int RoutingID();
178 173
179 // Helper function to send messages to RenderFrameObserver. 174 // Helper function to send messages to RenderFrameObserver.
180 bool Send(IPC::Message* msg); 175 bool Send(IPC::Message* msg);
181 176
182 private: 177 private:
183 // Constructs a MediaPlayerAndroid object. 178 // Constructs a MediaPlayerAndroid object.
184 media::MediaPlayerAndroid* CreateMediaPlayer( 179 media::MediaPlayerAndroid* CreateMediaPlayer(
185 const MediaPlayerHostMsg_Initialize_Params& media_player_params, 180 const MediaPlayerHostMsg_Initialize_Params& media_player_params,
186 bool hide_url_log, 181 bool hide_url_log,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 int fullscreen_player_id_; 220 int fullscreen_player_id_;
226 221
227 // Whether the fullscreen player has been Release()-d. 222 // Whether the fullscreen player has been Release()-d.
228 bool fullscreen_player_is_released_; 223 bool fullscreen_player_is_released_;
229 224
230 WebContents* const web_contents_; 225 WebContents* const web_contents_;
231 226
232 // Object for retrieving resources media players. 227 // Object for retrieving resources media players.
233 scoped_ptr<media::MediaResourceGetter> media_resource_getter_; 228 scoped_ptr<media::MediaResourceGetter> media_resource_getter_;
234 229
230 // Map of player IDs to delegate IDs for use with
231 // MediaWebContentsObserverAndroid.
232 std::map<int, int64_t> player_id_to_delegate_id_map_;
233
235 // NOTE: Weak pointers must be invalidated before all other member variables. 234 // NOTE: Weak pointers must be invalidated before all other member variables.
236 base::WeakPtrFactory<BrowserMediaPlayerManager> weak_ptr_factory_; 235 base::WeakPtrFactory<BrowserMediaPlayerManager> weak_ptr_factory_;
237 236
238 DISALLOW_COPY_AND_ASSIGN(BrowserMediaPlayerManager); 237 DISALLOW_COPY_AND_ASSIGN(BrowserMediaPlayerManager);
239 }; 238 };
240 239
241 } // namespace content 240 } // namespace content
242 241
243 #endif // CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_ 242 #endif // CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698