| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_ANDROID_MEDIA_PLAYER_MANAGER_ANDROID_H_ | 5 #ifndef CONTENT_BROWSER_ANDROID_MEDIA_PLAYER_MANAGER_ANDROID_H_ |
| 6 #define CONTENT_BROWSER_ANDROID_MEDIA_PLAYER_MANAGER_ANDROID_H_ | 6 #define CONTENT_BROWSER_ANDROID_MEDIA_PLAYER_MANAGER_ANDROID_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "content/browser/android/content_video_view.h" |
| 14 #include "content/public/browser/render_view_host_observer.h" | 15 #include "content/public/browser/render_view_host_observer.h" |
| 15 #include "media/base/android/media_player_bridge.h" | 16 #include "media/base/android/media_player_bridge.h" |
| 16 #include "media/base/android/media_player_bridge_manager.h" | 17 #include "media/base/android/media_player_bridge_manager.h" |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 | 20 |
| 20 // This class manages all the MediaPlayerBridge objects. It receives | 21 // This class manages all the MediaPlayerBridge objects. It receives |
| 21 // control operations from the the render process, and forwards | 22 // control operations from the the render process, and forwards |
| 22 // them to corresponding MediaPlayerBridge object. Callbacks from | 23 // them to corresponding MediaPlayerBridge object. Callbacks from |
| 23 // MediaPlayerBridge objects are converted to IPCs and then sent to the | 24 // MediaPlayerBridge objects are converted to IPCs and then sent to the |
| 24 // render process. | 25 // render process. |
| 25 class MediaPlayerManagerAndroid | 26 class MediaPlayerManagerAndroid |
| 26 : public RenderViewHostObserver, | 27 : public RenderViewHostObserver, |
| 27 public media::MediaPlayerBridgeManager { | 28 public media::MediaPlayerBridgeManager { |
| 28 public: | 29 public: |
| 29 // Create a MediaPlayerManagerAndroid object for the |render_view_host|. | 30 // Create a MediaPlayerManagerAndroid object for the |render_view_host|. |
| 30 explicit MediaPlayerManagerAndroid(RenderViewHost* render_view_host); | 31 explicit MediaPlayerManagerAndroid(RenderViewHost* render_view_host); |
| 31 virtual ~MediaPlayerManagerAndroid(); | 32 virtual ~MediaPlayerManagerAndroid(); |
| 32 | 33 |
| 33 // RenderViewHostObserver overrides. | 34 // RenderViewHostObserver overrides. |
| 34 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 35 | 36 |
| 37 // Fullscreen video playback controls. |
| 38 void FullscreenPlayerPlay(); |
| 39 void FullscreenPlayerPause(); |
| 40 void FullscreenPlayerSeek(int msec); |
| 41 void ExitFullscreen(bool release_media_player); |
| 42 void SetVideoSurface(jobject surface); |
| 43 |
| 36 // An internal method that checks for current time routinely and generates | 44 // An internal method that checks for current time routinely and generates |
| 37 // time update events. | 45 // time update events. |
| 38 void OnTimeUpdate(int player_id, base::TimeDelta current_time); | 46 void OnTimeUpdate(int player_id, base::TimeDelta current_time); |
| 39 | 47 |
| 40 // Callbacks needed by media::MediaPlayerBridge. | 48 // Callbacks needed by media::MediaPlayerBridge. |
| 41 void OnPrepared(int player_id, base::TimeDelta duration); | 49 void OnPrepared(int player_id, base::TimeDelta duration); |
| 42 void OnPlaybackComplete(int player_id); | 50 void OnPlaybackComplete(int player_id); |
| 43 void OnBufferingUpdate(int player_id, int percentage); | 51 void OnBufferingUpdate(int player_id, int percentage); |
| 44 void OnSeekComplete(int player_id, base::TimeDelta current_time); | 52 void OnSeekComplete(int player_id, base::TimeDelta current_time); |
| 45 void OnError(int player_id, int error); | 53 void OnError(int player_id, int error); |
| 46 void OnVideoSizeChanged(int player_id, int width, int height); | 54 void OnVideoSizeChanged(int player_id, int width, int height); |
| 47 | 55 |
| 48 // media::MediaPlayerBridgeManager overrides. | 56 // media::MediaPlayerBridgeManager overrides. |
| 49 virtual void RequestMediaResources(media::MediaPlayerBridge* player) OVERRIDE; | 57 virtual void RequestMediaResources(media::MediaPlayerBridge* player) OVERRIDE; |
| 50 virtual void ReleaseMediaResources(media::MediaPlayerBridge* player) OVERRIDE; | 58 virtual void ReleaseMediaResources(media::MediaPlayerBridge* player) OVERRIDE; |
| 51 | 59 |
| 52 // Release all the players managed by this object. | 60 // Release all the players managed by this object. |
| 53 void DestroyAllMediaPlayers(); | 61 void DestroyAllMediaPlayers(); |
| 54 | 62 |
| 63 media::MediaPlayerBridge* GetFullscreenPlayer(); |
| 55 media::MediaPlayerBridge* GetPlayer(int player_id); | 64 media::MediaPlayerBridge* GetPlayer(int player_id); |
| 56 | 65 |
| 57 private: | 66 private: |
| 58 // Message handlers. | 67 // Message handlers. |
| 68 void OnEnterFullscreen(int player_id); |
| 69 void OnExitFullscreen(int player_id); |
| 59 void OnInitialize(int player_id, const std::string& url, | 70 void OnInitialize(int player_id, const std::string& url, |
| 60 const std::string& first_party_for_cookies); | 71 const std::string& first_party_for_cookies); |
| 61 void OnStart(int player_id); | 72 void OnStart(int player_id); |
| 62 void OnSeek(int player_id, base::TimeDelta time); | 73 void OnSeek(int player_id, base::TimeDelta time); |
| 63 void OnPause(int player_id); | 74 void OnPause(int player_id); |
| 64 void OnReleaseResources(int player_id); | 75 void OnReleaseResources(int player_id); |
| 65 void OnDestroyPlayer(int player_id); | 76 void OnDestroyPlayer(int player_id); |
| 66 | 77 |
| 67 // An array of managed players. | 78 // An array of managed players. |
| 68 ScopedVector<media::MediaPlayerBridge> players_; | 79 ScopedVector<media::MediaPlayerBridge> players_; |
| 69 | 80 |
| 81 // The fullscreen video view object. |
| 82 ContentVideoView video_view_; |
| 83 |
| 84 // Player ID of the fullscreen media player. |
| 85 int fullscreen_player_id_; |
| 86 |
| 70 DISALLOW_COPY_AND_ASSIGN(MediaPlayerManagerAndroid); | 87 DISALLOW_COPY_AND_ASSIGN(MediaPlayerManagerAndroid); |
| 71 }; | 88 }; |
| 72 | 89 |
| 73 } // namespace content | 90 } // namespace content |
| 74 | 91 |
| 75 #endif // CONTENT_BROWSER_ANDROID_MEDIA_PLAYER_MANAGER_ANDROID_H_ | 92 #endif // CONTENT_BROWSER_ANDROID_MEDIA_PLAYER_MANAGER_ANDROID_H_ |
| OLD | NEW |