OLD | NEW |
---|---|
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 "content/common/media/media_player_messages_enums_android.h" | 17 #include "content/common/media/media_player_messages_enums_android.h" |
19 #include "ipc/ipc_message.h" | 18 #include "ipc/ipc_message.h" |
20 #include "media/base/android/media_player_android.h" | 19 #include "media/base/android/media_player_android.h" |
21 #include "media/base/android/media_player_manager.h" | 20 #include "media/base/android/media_player_manager.h" |
22 #include "media/base/android/media_url_interceptor.h" | 21 #include "media/base/android/media_url_interceptor.h" |
23 #include "ui/gfx/geometry/rect_f.h" | 22 #include "ui/gfx/geometry/rect_f.h" |
24 #include "url/gurl.h" | 23 #include "url/gurl.h" |
25 | 24 |
26 namespace media { | 25 namespace media { |
(...skipping 10 matching lines...) Expand all Loading... | |
37 class ExternalVideoSurfaceContainer; | 36 class ExternalVideoSurfaceContainer; |
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: | 47 public: |
50 // Permits embedders to provide an extended version of the class. | 48 // Permits embedders to provide an extended version of the class. |
51 typedef BrowserMediaPlayerManager* (*Factory)(RenderFrameHost*); | 49 typedef BrowserMediaPlayerManager* (*Factory)(RenderFrameHost*); |
52 static void RegisterFactory(Factory factory); | 50 static void RegisterFactory(Factory factory); |
53 | 51 |
54 // Permits embedders to handle custom urls. | 52 // Permits embedders to handle custom urls. |
55 static void RegisterMediaUrlInterceptor( | 53 static void RegisterMediaUrlInterceptor( |
56 media::MediaUrlInterceptor* media_url_interceptor); | 54 media::MediaUrlInterceptor* media_url_interceptor); |
57 | 55 |
58 // Pass a java surface object to the MediaPlayerAndroid object | 56 // Pass a java surface object to the MediaPlayerAndroid object |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 media::MediaPlayerAndroid* GetFullscreenPlayer() override; | 103 media::MediaPlayerAndroid* GetFullscreenPlayer() override; |
106 media::MediaPlayerAndroid* GetPlayer(int player_id) override; | 104 media::MediaPlayerAndroid* GetPlayer(int player_id) override; |
107 bool RequestPlay(int player_id, base::TimeDelta duration, | 105 bool RequestPlay(int player_id, base::TimeDelta duration, |
108 bool has_audio) override; | 106 bool has_audio) override; |
109 #if defined(VIDEO_HOLE) | 107 #if defined(VIDEO_HOLE) |
110 void AttachExternalVideoSurface(int player_id, jobject surface); | 108 void AttachExternalVideoSurface(int player_id, jobject surface); |
111 void DetachExternalVideoSurface(int player_id); | 109 void DetachExternalVideoSurface(int player_id); |
112 void OnFrameInfoUpdated(); | 110 void OnFrameInfoUpdated(); |
113 #endif // defined(VIDEO_HOLE) | 111 #endif // defined(VIDEO_HOLE) |
114 | 112 |
115 // MediaSessionObserver overrides. | |
116 void OnSuspend(int player_id) override; | |
117 void OnResume(int player_id) override; | |
118 | |
119 // Message handlers. | 113 // Message handlers. |
120 virtual void OnEnterFullscreen(int player_id); | 114 virtual void OnEnterFullscreen(int player_id); |
121 virtual void OnInitialize( | 115 virtual void OnInitialize( |
122 const MediaPlayerHostMsg_Initialize_Params& media_player_params); | 116 const MediaPlayerHostMsg_Initialize_Params& media_player_params); |
123 virtual void OnStart(int player_id); | 117 virtual void OnStart(int player_id); |
124 virtual void OnSeek(int player_id, const base::TimeDelta& time); | 118 virtual void OnSeek(int player_id, const base::TimeDelta& time); |
125 virtual void OnPause(int player_id, bool is_media_related_action); | 119 virtual void OnPause(int player_id, bool is_media_related_action); |
126 virtual void OnSetVolume(int player_id, double volume); | 120 virtual void OnSetVolume(int player_id, double volume); |
127 virtual void OnSetPoster(int player_id, const GURL& poster); | 121 virtual void OnSetPoster(int player_id, const GURL& poster); |
128 virtual void OnSuspendAndReleaseResources(int player_id); | 122 virtual void OnSuspendAndReleaseResources(int player_id); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 // On the contrary, requests with false |temporary| value are subject to | 159 // On the contrary, requests with false |temporary| value are subject to |
166 // clean up if their players are idle. | 160 // clean up if their players are idle. |
167 virtual bool RequestDecoderResources(int player_id, bool temporary); | 161 virtual bool RequestDecoderResources(int player_id, bool temporary); |
168 | 162 |
169 // MediaPlayerAndroid must call this to inform the manager that it has | 163 // MediaPlayerAndroid must call this to inform the manager that it has |
170 // released the decoder resources. This can be triggered by the | 164 // released the decoder resources. This can be triggered by the |
171 // ReleasePlayer() call below, or when meta data is extracted, or when player | 165 // ReleasePlayer() call below, or when meta data is extracted, or when player |
172 // is stuck in an error. | 166 // is stuck in an error. |
173 virtual void OnDecoderResourcesReleased(int player_id); | 167 virtual void OnDecoderResourcesReleased(int player_id); |
174 | 168 |
169 virtual bool IsPlayingRemotely(int player_id); | |
mlamouri (slow - plz ping)
2016/01/19 16:59:11
FWIW, zqzhang@ has a similar change.
| |
170 | |
175 int RoutingID(); | 171 int RoutingID(); |
176 | 172 |
177 // Helper function to send messages to RenderFrameObserver. | 173 // Helper function to send messages to RenderFrameObserver. |
178 bool Send(IPC::Message* msg); | 174 bool Send(IPC::Message* msg); |
179 | 175 |
180 private: | 176 private: |
181 // Constructs a MediaPlayerAndroid object. | 177 // Constructs a MediaPlayerAndroid object. |
182 media::MediaPlayerAndroid* CreateMediaPlayer( | 178 media::MediaPlayerAndroid* CreateMediaPlayer( |
183 const MediaPlayerHostMsg_Initialize_Params& media_player_params, | 179 const MediaPlayerHostMsg_Initialize_Params& media_player_params, |
184 bool hide_url_log, | 180 bool hide_url_log, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 int fullscreen_player_id_; | 219 int fullscreen_player_id_; |
224 | 220 |
225 // Whether the fullscreen player has been Release()-d. | 221 // Whether the fullscreen player has been Release()-d. |
226 bool fullscreen_player_is_released_; | 222 bool fullscreen_player_is_released_; |
227 | 223 |
228 WebContents* const web_contents_; | 224 WebContents* const web_contents_; |
229 | 225 |
230 // Object for retrieving resources media players. | 226 // Object for retrieving resources media players. |
231 scoped_ptr<media::MediaResourceGetter> media_resource_getter_; | 227 scoped_ptr<media::MediaResourceGetter> media_resource_getter_; |
232 | 228 |
229 // Map of player IDs to delegate IDs for use with | |
230 // MediaWebContentsObserverAndroid. | |
231 std::map<int, int64_t> player_id_to_delegate_id_map_; | |
232 | |
233 // NOTE: Weak pointers must be invalidated before all other member variables. | 233 // NOTE: Weak pointers must be invalidated before all other member variables. |
234 base::WeakPtrFactory<BrowserMediaPlayerManager> weak_ptr_factory_; | 234 base::WeakPtrFactory<BrowserMediaPlayerManager> weak_ptr_factory_; |
235 | 235 |
236 DISALLOW_COPY_AND_ASSIGN(BrowserMediaPlayerManager); | 236 DISALLOW_COPY_AND_ASSIGN(BrowserMediaPlayerManager); |
237 }; | 237 }; |
238 | 238 |
239 } // namespace content | 239 } // namespace content |
240 | 240 |
241 #endif // CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_ | 241 #endif // CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_ |
OLD | NEW |