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> | |
9 | |
8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
9 #include "base/callback.h" | 11 #include "base/callback.h" |
10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
12 #include "base/time/time.h" | 14 #include "base/time/time.h" |
13 #include "content/browser/android/content_video_view.h" | 15 #include "content/browser/android/content_video_view.h" |
14 #include "content/browser/media/android/media_session_observer.h" | 16 #include "content/browser/media/android/media_session_observer.h" |
15 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
16 #include "content/common/media/media_player_messages_enums_android.h" | 18 #include "content/common/media/media_player_messages_enums_android.h" |
17 #include "content/public/browser/android/content_view_core.h" | 19 #include "content/public/browser/android/content_view_core.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 // Helper function to send messages to RenderFrameObserver. | 155 // Helper function to send messages to RenderFrameObserver. |
154 bool Send(IPC::Message* msg); | 156 bool Send(IPC::Message* msg); |
155 | 157 |
156 private: | 158 private: |
157 // Constructs a MediaPlayerAndroid object. | 159 // Constructs a MediaPlayerAndroid object. |
158 media::MediaPlayerAndroid* CreateMediaPlayer( | 160 media::MediaPlayerAndroid* CreateMediaPlayer( |
159 const MediaPlayerHostMsg_Initialize_Params& media_player_params, | 161 const MediaPlayerHostMsg_Initialize_Params& media_player_params, |
160 bool hide_url_log, | 162 bool hide_url_log, |
161 BrowserDemuxerAndroid* demuxer); | 163 BrowserDemuxerAndroid* demuxer); |
162 | 164 |
163 // MediaPlayerAndroid must call this before it is going to decode | 165 // Called to request decoder resources. Returns true if the request is |
164 // media streams. This helps the manager object maintain an array | 166 // permitted, or false otherwise. The manager object maintain an array |
Ted C
2015/09/28 22:42:29
maintain[s]
qinmin
2015/09/29 23:16:22
Done.
| |
165 // of active MediaPlayerAndroid objects and release the resources | 167 // of active MediaPlayerAndroid objects and release the inactive resources |
Ted C
2015/09/28 22:42:29
release[s]
qinmin
2015/09/29 23:16:22
Done.
| |
166 // when needed. Currently we only count video resources as they are | 168 // when needed. |
167 // constrained by hardware and memory limits. | 169 virtual bool RequestDecoderResources(int player_id, bool temporary); |
Ted C
2015/09/28 22:42:29
Can you describe what temporary means and why you
qinmin
2015/09/29 23:16:22
Done.
| |
168 virtual void OnMediaResourcesRequested(int player_id); | |
169 | 170 |
170 // Called when a player releases all decoding resources. | 171 // MediaPlayerAndroid must call this to inform the manager that it is about |
171 void ReleaseMediaResources(int player_id); | 172 // to release itself. |
Ted C
2015/09/28 22:42:29
What is the difference between this and ReleasePla
qinmin
2015/09/29 23:16:22
Renamed OnPlayerReleased to OnDecoderResourcesRele
| |
173 virtual void OnPlayerReleased(int player_id); | |
172 | 174 |
173 // Releases the player. However, don't remove it from |players_|. | 175 // Releases the player. However, don't remove it from |players_|. |
174 void ReleasePlayer(media::MediaPlayerAndroid* player); | 176 void ReleasePlayer(media::MediaPlayerAndroid* player); |
175 | 177 |
178 // Called when user approves media playback after being throttled. | |
179 void OnPlaybackPermissionGranted(int player_id, bool granted); | |
180 | |
181 // Helper method to start playback. | |
182 void StartInternal(int player_id); | |
183 | |
176 #if defined(VIDEO_HOLE) | 184 #if defined(VIDEO_HOLE) |
177 void ReleasePlayerOfExternalVideoSurfaceIfNeeded(int future_player); | 185 void ReleasePlayerOfExternalVideoSurfaceIfNeeded(int future_player); |
178 void OnRequestExternalSurface(int player_id, const gfx::RectF& rect); | 186 void OnRequestExternalSurface(int player_id, const gfx::RectF& rect); |
187 void ReleaseExternalSurface(int player_id); | |
179 #endif // defined(VIDEO_HOLE) | 188 #endif // defined(VIDEO_HOLE) |
180 | 189 |
181 RenderFrameHost* const render_frame_host_; | 190 RenderFrameHost* const render_frame_host_; |
182 | 191 |
183 // An array of managed players. | 192 // An array of managed players. |
184 ScopedVector<media::MediaPlayerAndroid> players_; | 193 ScopedVector<media::MediaPlayerAndroid> players_; |
185 | 194 |
195 typedef std::map<int, bool> ActivePlayerMap; | |
196 // Players that have requested decoding resources. Even though resource is | |
197 // requested, a player may be in a paused or error state and the manager | |
198 // will release its resources later. | |
199 ActivePlayerMap active_players_; | |
200 | |
186 // The fullscreen video view object or NULL if video is not played in | 201 // The fullscreen video view object or NULL if video is not played in |
187 // fullscreen. | 202 // fullscreen. |
188 scoped_ptr<ContentVideoView> video_view_; | 203 scoped_ptr<ContentVideoView> video_view_; |
189 | 204 |
190 #if defined(VIDEO_HOLE) | 205 #if defined(VIDEO_HOLE) |
191 scoped_ptr<ExternalVideoSurfaceContainer> external_video_surface_container_; | 206 scoped_ptr<ExternalVideoSurfaceContainer> external_video_surface_container_; |
192 #endif | 207 #endif |
193 | 208 |
194 // Player ID of the fullscreen media player. | 209 // Player ID of the fullscreen media player. |
195 int fullscreen_player_id_; | 210 int fullscreen_player_id_; |
196 | 211 |
197 // Whether the fullscreen player has been Release()-d. | 212 // Whether the fullscreen player has been Release()-d. |
198 bool fullscreen_player_is_released_; | 213 bool fullscreen_player_is_released_; |
199 | 214 |
200 WebContents* const web_contents_; | 215 WebContents* const web_contents_; |
201 | 216 |
202 // Object for retrieving resources media players. | 217 // Object for retrieving resources media players. |
203 scoped_ptr<media::MediaResourceGetter> media_resource_getter_; | 218 scoped_ptr<media::MediaResourceGetter> media_resource_getter_; |
204 | 219 |
205 // NOTE: Weak pointers must be invalidated before all other member variables. | 220 // NOTE: Weak pointers must be invalidated before all other member variables. |
206 base::WeakPtrFactory<BrowserMediaPlayerManager> weak_ptr_factory_; | 221 base::WeakPtrFactory<BrowserMediaPlayerManager> weak_ptr_factory_; |
207 | 222 |
208 DISALLOW_COPY_AND_ASSIGN(BrowserMediaPlayerManager); | 223 DISALLOW_COPY_AND_ASSIGN(BrowserMediaPlayerManager); |
209 }; | 224 }; |
210 | 225 |
211 } // namespace content | 226 } // namespace content |
212 | 227 |
213 #endif // CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_ | 228 #endif // CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_ |
OLD | NEW |