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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 namespace media { | 25 namespace media { |
26 class DemuxerAndroid; | 26 class DemuxerAndroid; |
27 } | 27 } |
28 | 28 |
29 struct MediaPlayerHostMsg_Initialize_Params; | 29 struct MediaPlayerHostMsg_Initialize_Params; |
30 | 30 |
31 namespace content { | 31 namespace content { |
32 class BrowserDemuxerAndroid; | 32 class BrowserDemuxerAndroid; |
33 class ContentViewCoreImpl; | 33 class ContentViewCoreImpl; |
34 class ExternalVideoSurfaceContainer; | 34 class ExternalVideoSurfaceContainer; |
35 class MediaPlayersObserver; | |
36 class RenderFrameHost; | 35 class RenderFrameHost; |
37 class WebContents; | 36 class WebContents; |
38 | 37 |
39 // This class manages all the MediaPlayerAndroid objects. | 38 // This class manages all the MediaPlayerAndroid objects. |
40 // It receives control operations from the the render process, and forwards | 39 // It receives control operations from the the render process, and forwards |
41 // them to corresponding MediaPlayerAndroid object. Callbacks from | 40 // them to corresponding MediaPlayerAndroid object. Callbacks from |
42 // MediaPlayerAndroid objects are converted to IPCs and then sent to the render | 41 // MediaPlayerAndroid objects are converted to IPCs and then sent to the render |
43 // process. | 42 // process. |
44 class CONTENT_EXPORT BrowserMediaPlayerManager | 43 class CONTENT_EXPORT BrowserMediaPlayerManager |
45 : public media::MediaPlayerManager, | 44 : public media::MediaPlayerManager, |
46 public MediaSessionObserver { | 45 public MediaSessionObserver { |
47 public: | 46 public: |
48 // Permits embedders to provide an extended version of the class. | 47 // Permits embedders to provide an extended version of the class. |
49 typedef BrowserMediaPlayerManager* (*Factory)(RenderFrameHost*, | 48 typedef BrowserMediaPlayerManager* (*Factory)(RenderFrameHost*); |
50 MediaPlayersObserver*); | |
51 static void RegisterFactory(Factory factory); | 49 static void RegisterFactory(Factory factory); |
52 | 50 |
53 // Permits embedders to handle custom urls. | 51 // Permits embedders to handle custom urls. |
54 static void RegisterMediaUrlInterceptor( | 52 static void RegisterMediaUrlInterceptor( |
55 media::MediaUrlInterceptor* media_url_interceptor); | 53 media::MediaUrlInterceptor* media_url_interceptor); |
56 | 54 |
57 // Pass a java surface object to the MediaPlayerAndroid object | 55 // Pass a java surface object to the MediaPlayerAndroid object |
58 // identified by render process handle, render frame ID and player ID. | 56 // identified by render process handle, render frame ID and player ID. |
59 static void SetSurfacePeer(scoped_refptr<gfx::SurfaceTexture> surface_texture, | 57 static void SetSurfacePeer(scoped_refptr<gfx::SurfaceTexture> surface_texture, |
60 base::ProcessHandle render_process_handle, | 58 base::ProcessHandle render_process_handle, |
61 int render_frame_id, | 59 int render_frame_id, |
62 int player_id); | 60 int player_id); |
63 | 61 |
64 // Returns a new instance using the registered factory if available. | 62 // Returns a new instance using the registered factory if available. |
65 static BrowserMediaPlayerManager* Create( | 63 static BrowserMediaPlayerManager* Create(RenderFrameHost* rfh); |
66 RenderFrameHost* rfh, | |
67 MediaPlayersObserver* audio_monitor); | |
68 | 64 |
69 ContentViewCore* GetContentViewCore() const; | 65 ContentViewCore* GetContentViewCore() const; |
70 | 66 |
71 ~BrowserMediaPlayerManager() override; | 67 ~BrowserMediaPlayerManager() override; |
72 | 68 |
73 // Fullscreen video playback controls. | 69 // Fullscreen video playback controls. |
74 virtual void ExitFullscreen(bool release_media_player); | 70 virtual void ExitFullscreen(bool release_media_player); |
75 virtual void SetVideoSurface(gfx::ScopedJavaSurface surface); | 71 virtual void SetVideoSurface(gfx::ScopedJavaSurface surface); |
76 | 72 |
77 // Called when browser player wants the renderer media element to seek. | 73 // Called when browser player wants the renderer media element to seek. |
(...skipping 12 matching lines...) Expand all Loading... |
90 int width, | 86 int width, |
91 int height, | 87 int height, |
92 bool success) override; | 88 bool success) override; |
93 void OnPlaybackComplete(int player_id) override; | 89 void OnPlaybackComplete(int player_id) override; |
94 void OnMediaInterrupted(int player_id) override; | 90 void OnMediaInterrupted(int player_id) override; |
95 void OnBufferingUpdate(int player_id, int percentage) override; | 91 void OnBufferingUpdate(int player_id, int percentage) override; |
96 void OnSeekComplete(int player_id, | 92 void OnSeekComplete(int player_id, |
97 const base::TimeDelta& current_time) override; | 93 const base::TimeDelta& current_time) override; |
98 void OnError(int player_id, int error) override; | 94 void OnError(int player_id, int error) override; |
99 void OnVideoSizeChanged(int player_id, int width, int height) override; | 95 void OnVideoSizeChanged(int player_id, int width, int height) override; |
100 void OnAudibleStateChanged( | |
101 int player_id, bool is_audible_now) override; | |
102 void OnWaitingForDecryptionKey(int player_id) override; | 96 void OnWaitingForDecryptionKey(int player_id) override; |
103 | 97 |
104 media::MediaResourceGetter* GetMediaResourceGetter() override; | 98 media::MediaResourceGetter* GetMediaResourceGetter() override; |
105 media::MediaUrlInterceptor* GetMediaUrlInterceptor() override; | 99 media::MediaUrlInterceptor* GetMediaUrlInterceptor() override; |
106 media::MediaPlayerAndroid* GetFullscreenPlayer() override; | 100 media::MediaPlayerAndroid* GetFullscreenPlayer() override; |
107 media::MediaPlayerAndroid* GetPlayer(int player_id) override; | 101 media::MediaPlayerAndroid* GetPlayer(int player_id) override; |
108 bool RequestPlay(int player_id) override; | 102 bool RequestPlay(int player_id) override; |
109 #if defined(VIDEO_HOLE) | 103 #if defined(VIDEO_HOLE) |
110 void AttachExternalVideoSurface(int player_id, jobject surface); | 104 void AttachExternalVideoSurface(int player_id, jobject surface); |
111 void DetachExternalVideoSurface(int player_id); | 105 void DetachExternalVideoSurface(int player_id); |
(...skipping 18 matching lines...) Expand all Loading... |
130 virtual void OnRequestRemotePlayback(int player_id); | 124 virtual void OnRequestRemotePlayback(int player_id); |
131 virtual void OnRequestRemotePlaybackControl(int player_id); | 125 virtual void OnRequestRemotePlaybackControl(int player_id); |
132 virtual void ReleaseFullscreenPlayer(media::MediaPlayerAndroid* player); | 126 virtual void ReleaseFullscreenPlayer(media::MediaPlayerAndroid* player); |
133 #if defined(VIDEO_HOLE) | 127 #if defined(VIDEO_HOLE) |
134 void OnNotifyExternalSurface( | 128 void OnNotifyExternalSurface( |
135 int player_id, bool is_request, const gfx::RectF& rect); | 129 int player_id, bool is_request, const gfx::RectF& rect); |
136 #endif // defined(VIDEO_HOLE) | 130 #endif // defined(VIDEO_HOLE) |
137 | 131 |
138 protected: | 132 protected: |
139 // Clients must use Create() or subclass constructor. | 133 // Clients must use Create() or subclass constructor. |
140 BrowserMediaPlayerManager(RenderFrameHost* render_frame_host, | 134 explicit BrowserMediaPlayerManager(RenderFrameHost* render_frame_host); |
141 MediaPlayersObserver* audio_monitor); | |
142 | 135 |
143 WebContents* web_contents() const { return web_contents_; } | 136 WebContents* web_contents() const { return web_contents_; } |
144 | 137 |
145 // Adds a given player to the list. | 138 // Adds a given player to the list. |
146 void AddPlayer(media::MediaPlayerAndroid* player); | 139 void AddPlayer(media::MediaPlayerAndroid* player); |
147 | 140 |
148 // Removes the player with the specified id. | 141 // Removes the player with the specified id. |
149 void RemovePlayer(int player_id); | 142 void RemovePlayer(int player_id); |
150 | 143 |
151 // Replaces a player with the specified id with a given MediaPlayerAndroid | 144 // Replaces a player with the specified id with a given MediaPlayerAndroid |
(...skipping 28 matching lines...) Expand all Loading... |
180 // Releases the player. However, don't remove it from |players_|. | 173 // Releases the player. However, don't remove it from |players_|. |
181 void ReleasePlayer(media::MediaPlayerAndroid* player); | 174 void ReleasePlayer(media::MediaPlayerAndroid* player); |
182 | 175 |
183 #if defined(VIDEO_HOLE) | 176 #if defined(VIDEO_HOLE) |
184 void ReleasePlayerOfExternalVideoSurfaceIfNeeded(int future_player); | 177 void ReleasePlayerOfExternalVideoSurfaceIfNeeded(int future_player); |
185 void OnRequestExternalSurface(int player_id, const gfx::RectF& rect); | 178 void OnRequestExternalSurface(int player_id, const gfx::RectF& rect); |
186 #endif // defined(VIDEO_HOLE) | 179 #endif // defined(VIDEO_HOLE) |
187 | 180 |
188 RenderFrameHost* const render_frame_host_; | 181 RenderFrameHost* const render_frame_host_; |
189 | 182 |
190 MediaPlayersObserver* audio_monitor_; | |
191 | |
192 // An array of managed players. | 183 // An array of managed players. |
193 ScopedVector<media::MediaPlayerAndroid> players_; | 184 ScopedVector<media::MediaPlayerAndroid> players_; |
194 | 185 |
195 // The fullscreen video view object or NULL if video is not played in | 186 // The fullscreen video view object or NULL if video is not played in |
196 // fullscreen. | 187 // fullscreen. |
197 scoped_ptr<ContentVideoView> video_view_; | 188 scoped_ptr<ContentVideoView> video_view_; |
198 | 189 |
199 #if defined(VIDEO_HOLE) | 190 #if defined(VIDEO_HOLE) |
200 scoped_ptr<ExternalVideoSurfaceContainer> external_video_surface_container_; | 191 scoped_ptr<ExternalVideoSurfaceContainer> external_video_surface_container_; |
201 #endif | 192 #endif |
(...skipping 11 matching lines...) Expand all Loading... |
213 | 204 |
214 // NOTE: Weak pointers must be invalidated before all other member variables. | 205 // NOTE: Weak pointers must be invalidated before all other member variables. |
215 base::WeakPtrFactory<BrowserMediaPlayerManager> weak_ptr_factory_; | 206 base::WeakPtrFactory<BrowserMediaPlayerManager> weak_ptr_factory_; |
216 | 207 |
217 DISALLOW_COPY_AND_ASSIGN(BrowserMediaPlayerManager); | 208 DISALLOW_COPY_AND_ASSIGN(BrowserMediaPlayerManager); |
218 }; | 209 }; |
219 | 210 |
220 } // namespace content | 211 } // namespace content |
221 | 212 |
222 #endif // CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_ | 213 #endif // CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_ |
OLD | NEW |