| 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" |
| 11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "content/browser/android/content_video_view.h" | 13 #include "content/browser/android/content_video_view.h" |
| 14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 #include "content/common/media/media_player_messages_enums_android.h" | 15 #include "content/common/media/media_player_messages_enums_android.h" |
| 16 #include "ipc/ipc_message.h" | 16 #include "ipc/ipc_message.h" |
| 17 #include "media/base/android/media_player_android.h" | 17 #include "media/base/android/media_player_android.h" |
| 18 #include "media/base/android/media_player_manager.h" | 18 #include "media/base/android/media_player_manager.h" |
| 19 #include "media/base/android/media_url_interceptor.h" | 19 #include "media/base/android/media_url_interceptor.h" |
| 20 #include "ui/gfx/geometry/rect_f.h" | 20 #include "ui/gfx/geometry/rect_f.h" |
| 21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 22 | 22 |
| 23 namespace media { | 23 namespace media { |
| 24 class DemuxerAndroid; | 24 class DemuxerAndroid; |
| 25 } | 25 } |
| 26 | 26 |
| 27 struct MediaPlayerHostMsg_Initialize_Params; | 27 struct MediaPlayerHostMsg_Initialize_Params; |
| 28 | 28 |
| 29 namespace content { | 29 namespace content { |
| 30 class AudioMonitorAndroid; |
| 30 class BrowserDemuxerAndroid; | 31 class BrowserDemuxerAndroid; |
| 31 class ContentViewCoreImpl; | 32 class ContentViewCoreImpl; |
| 32 class ExternalVideoSurfaceContainer; | 33 class ExternalVideoSurfaceContainer; |
| 33 class RenderFrameHost; | 34 class RenderFrameHost; |
| 34 class WebContents; | 35 class WebContents; |
| 35 | 36 |
| 36 // This class manages all the MediaPlayerAndroid objects. | 37 // This class manages all the MediaPlayerAndroid objects. |
| 37 // It receives control operations from the the render process, and forwards | 38 // It receives control operations from the the render process, and forwards |
| 38 // them to corresponding MediaPlayerAndroid object. Callbacks from | 39 // them to corresponding MediaPlayerAndroid object. Callbacks from |
| 39 // MediaPlayerAndroid objects are converted to IPCs and then sent to the render | 40 // MediaPlayerAndroid objects are converted to IPCs and then sent to the render |
| 40 // process. | 41 // process. |
| 41 class CONTENT_EXPORT BrowserMediaPlayerManager | 42 class CONTENT_EXPORT BrowserMediaPlayerManager |
| 42 : public media::MediaPlayerManager { | 43 : public media::MediaPlayerManager { |
| 43 public: | 44 public: |
| 44 // Permits embedders to provide an extended version of the class. | 45 // Permits embedders to provide an extended version of the class. |
| 45 typedef BrowserMediaPlayerManager* (*Factory)(RenderFrameHost*); | 46 typedef BrowserMediaPlayerManager* (*Factory)(RenderFrameHost*, |
| 47 AudioMonitorAndroid*); |
| 46 static void RegisterFactory(Factory factory); | 48 static void RegisterFactory(Factory factory); |
| 47 | 49 |
| 48 // Permits embedders to handle custom urls. | 50 // Permits embedders to handle custom urls. |
| 49 static void RegisterMediaUrlInterceptor( | 51 static void RegisterMediaUrlInterceptor( |
| 50 media::MediaUrlInterceptor* media_url_interceptor); | 52 media::MediaUrlInterceptor* media_url_interceptor); |
| 51 | 53 |
| 52 // Returns a new instance using the registered factory if available. | 54 // Returns a new instance using the registered factory if available. |
| 53 static BrowserMediaPlayerManager* Create(RenderFrameHost* rfh); | 55 static BrowserMediaPlayerManager* Create( |
| 56 RenderFrameHost* rfh, |
| 57 AudioMonitorAndroid* audio_monitor); |
| 54 | 58 |
| 55 ContentViewCoreImpl* GetContentViewCore() const; | 59 ContentViewCoreImpl* GetContentViewCore() const; |
| 56 | 60 |
| 57 virtual ~BrowserMediaPlayerManager(); | 61 virtual ~BrowserMediaPlayerManager(); |
| 58 | 62 |
| 59 // Fullscreen video playback controls. | 63 // Fullscreen video playback controls. |
| 60 virtual void ExitFullscreen(bool release_media_player); | 64 virtual void ExitFullscreen(bool release_media_player); |
| 61 virtual void SetVideoSurface(gfx::ScopedJavaSurface surface); | 65 virtual void SetVideoSurface(gfx::ScopedJavaSurface surface); |
| 62 | 66 |
| 63 // Called when browser player wants the renderer media element to seek. | 67 // Called when browser player wants the renderer media element to seek. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 80 bool success) override; | 84 bool success) override; |
| 81 virtual void OnPlaybackComplete(int player_id) override; | 85 virtual void OnPlaybackComplete(int player_id) override; |
| 82 virtual void OnMediaInterrupted(int player_id) override; | 86 virtual void OnMediaInterrupted(int player_id) override; |
| 83 virtual void OnBufferingUpdate(int player_id, int percentage) override; | 87 virtual void OnBufferingUpdate(int player_id, int percentage) override; |
| 84 virtual void OnSeekComplete( | 88 virtual void OnSeekComplete( |
| 85 int player_id, | 89 int player_id, |
| 86 const base::TimeDelta& current_time) override; | 90 const base::TimeDelta& current_time) override; |
| 87 virtual void OnError(int player_id, int error) override; | 91 virtual void OnError(int player_id, int error) override; |
| 88 virtual void OnVideoSizeChanged( | 92 virtual void OnVideoSizeChanged( |
| 89 int player_id, int width, int height) override; | 93 int player_id, int width, int height) override; |
| 94 virtual void OnAudibleStateChanged( |
| 95 int player_id, bool is_audible_now) override; |
| 96 |
| 90 virtual media::MediaResourceGetter* GetMediaResourceGetter() override; | 97 virtual media::MediaResourceGetter* GetMediaResourceGetter() override; |
| 91 virtual media::MediaUrlInterceptor* GetMediaUrlInterceptor() override; | 98 virtual media::MediaUrlInterceptor* GetMediaUrlInterceptor() override; |
| 92 virtual media::MediaPlayerAndroid* GetFullscreenPlayer() override; | 99 virtual media::MediaPlayerAndroid* GetFullscreenPlayer() override; |
| 93 virtual media::MediaPlayerAndroid* GetPlayer(int player_id) override; | 100 virtual media::MediaPlayerAndroid* GetPlayer(int player_id) override; |
| 94 virtual void RequestFullScreen(int player_id) override; | 101 virtual void RequestFullScreen(int player_id) override; |
| 95 #if defined(VIDEO_HOLE) | 102 #if defined(VIDEO_HOLE) |
| 96 virtual bool ShouldUseVideoOverlayForEmbeddedEncryptedVideo() override; | 103 virtual bool ShouldUseVideoOverlayForEmbeddedEncryptedVideo() override; |
| 97 | 104 |
| 98 void AttachExternalVideoSurface(int player_id, jobject surface); | 105 void AttachExternalVideoSurface(int player_id, jobject surface); |
| 99 void DetachExternalVideoSurface(int player_id); | 106 void DetachExternalVideoSurface(int player_id); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 115 virtual void OnRequestRemotePlayback(int player_id); | 122 virtual void OnRequestRemotePlayback(int player_id); |
| 116 virtual void OnRequestRemotePlaybackControl(int player_id); | 123 virtual void OnRequestRemotePlaybackControl(int player_id); |
| 117 virtual void ReleaseFullscreenPlayer(media::MediaPlayerAndroid* player); | 124 virtual void ReleaseFullscreenPlayer(media::MediaPlayerAndroid* player); |
| 118 #if defined(VIDEO_HOLE) | 125 #if defined(VIDEO_HOLE) |
| 119 void OnNotifyExternalSurface( | 126 void OnNotifyExternalSurface( |
| 120 int player_id, bool is_request, const gfx::RectF& rect); | 127 int player_id, bool is_request, const gfx::RectF& rect); |
| 121 #endif // defined(VIDEO_HOLE) | 128 #endif // defined(VIDEO_HOLE) |
| 122 | 129 |
| 123 protected: | 130 protected: |
| 124 // Clients must use Create() or subclass constructor. | 131 // Clients must use Create() or subclass constructor. |
| 125 explicit BrowserMediaPlayerManager(RenderFrameHost* render_frame_host); | 132 BrowserMediaPlayerManager(RenderFrameHost* render_frame_host, |
| 133 AudioMonitorAndroid* audio_monitor); |
| 126 | 134 |
| 127 WebContents* web_contents() const { return web_contents_; } | 135 WebContents* web_contents() const { return web_contents_; } |
| 128 | 136 |
| 129 // Adds a given player to the list. | 137 // Adds a given player to the list. |
| 130 void AddPlayer(media::MediaPlayerAndroid* player); | 138 void AddPlayer(media::MediaPlayerAndroid* player); |
| 131 | 139 |
| 132 // Removes the player with the specified id. | 140 // Removes the player with the specified id. |
| 133 void RemovePlayer(int player_id); | 141 void RemovePlayer(int player_id); |
| 134 | 142 |
| 135 // Replaces a player with the specified id with a given MediaPlayerAndroid | 143 // Replaces a player with the specified id with a given MediaPlayerAndroid |
| (...skipping 29 matching lines...) Expand all Loading... |
| 165 // Releases the player. However, don't remove it from |players_|. | 173 // Releases the player. However, don't remove it from |players_|. |
| 166 void ReleasePlayer(media::MediaPlayerAndroid* player); | 174 void ReleasePlayer(media::MediaPlayerAndroid* player); |
| 167 | 175 |
| 168 #if defined(VIDEO_HOLE) | 176 #if defined(VIDEO_HOLE) |
| 169 void ReleasePlayerOfExternalVideoSurfaceIfNeeded(int future_player); | 177 void ReleasePlayerOfExternalVideoSurfaceIfNeeded(int future_player); |
| 170 void OnRequestExternalSurface(int player_id, const gfx::RectF& rect); | 178 void OnRequestExternalSurface(int player_id, const gfx::RectF& rect); |
| 171 #endif // defined(VIDEO_HOLE) | 179 #endif // defined(VIDEO_HOLE) |
| 172 | 180 |
| 173 RenderFrameHost* const render_frame_host_; | 181 RenderFrameHost* const render_frame_host_; |
| 174 | 182 |
| 183 AudioMonitorAndroid* audio_monitor_; |
| 184 |
| 175 // An array of managed players. | 185 // An array of managed players. |
| 176 ScopedVector<media::MediaPlayerAndroid> players_; | 186 ScopedVector<media::MediaPlayerAndroid> players_; |
| 177 | 187 |
| 178 // The fullscreen video view object or NULL if video is not played in | 188 // The fullscreen video view object or NULL if video is not played in |
| 179 // fullscreen. | 189 // fullscreen. |
| 180 scoped_ptr<ContentVideoView> video_view_; | 190 scoped_ptr<ContentVideoView> video_view_; |
| 181 | 191 |
| 182 #if defined(VIDEO_HOLE) | 192 #if defined(VIDEO_HOLE) |
| 183 scoped_ptr<ExternalVideoSurfaceContainer> external_video_surface_container_; | 193 scoped_ptr<ExternalVideoSurfaceContainer> external_video_surface_container_; |
| 184 #endif | 194 #endif |
| (...skipping 11 matching lines...) Expand all Loading... |
| 196 | 206 |
| 197 // NOTE: Weak pointers must be invalidated before all other member variables. | 207 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 198 base::WeakPtrFactory<BrowserMediaPlayerManager> weak_ptr_factory_; | 208 base::WeakPtrFactory<BrowserMediaPlayerManager> weak_ptr_factory_; |
| 199 | 209 |
| 200 DISALLOW_COPY_AND_ASSIGN(BrowserMediaPlayerManager); | 210 DISALLOW_COPY_AND_ASSIGN(BrowserMediaPlayerManager); |
| 201 }; | 211 }; |
| 202 | 212 |
| 203 } // namespace content | 213 } // namespace content |
| 204 | 214 |
| 205 #endif // CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_ | 215 #endif // CONTENT_BROWSER_MEDIA_ANDROID_BROWSER_MEDIA_PLAYER_MANAGER_H_ |
| OLD | NEW |