| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_ANDROID_MEDIA_PLAYER_MANAGER_ANDROID_H_ |
| 6 #define CONTENT_BROWSER_ANDROID_MEDIA_PLAYER_MANAGER_ANDROID_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/scoped_vector.h" |
| 13 #include "base/time.h" |
| 14 #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_manager.h" |
| 17 |
| 18 namespace content { |
| 19 |
| 20 // This class manages all the android mediaplayer objects. It receives the |
| 21 // control operations from the the renderer process, and forward |
| 22 // them to corresponding mediaplayers. Media notification messages are sent |
| 23 // this class first, before it forwards them to the renderer process. |
| 24 class MediaPlayerManagerAndroid : public content::RenderViewHostObserver, |
| 25 public media::MediaPlayerBridgeManager { |
| 26 public: |
| 27 explicit MediaPlayerManagerAndroid(RenderViewHost* render_view_host); |
| 28 virtual ~MediaPlayerManagerAndroid(); |
| 29 |
| 30 // RenderViewHostObserver overrides. |
| 31 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 32 |
| 33 // An internal method that checks for current time routinely and generates |
| 34 // time update events. |
| 35 void OnTimeUpdate(int player_id, base::TimeDelta current_time); |
| 36 |
| 37 // Callbacks needed by media::MediaPlayerBridge. |
| 38 void OnPrepared(int player_id, base::TimeDelta duration); |
| 39 void OnPlaybackComplete(int player_id); |
| 40 void OnBufferingUpdate(int player_id, int percentage); |
| 41 void OnSeekComplete(int player_id, base::TimeDelta current_time); |
| 42 void OnError(int player_id, int error); |
| 43 void OnVideoSizeChanged(int player_id, int width, int height); |
| 44 |
| 45 // media::MediaPlayerBridgeManager overrides. |
| 46 virtual void RequestMediaResources(media::MediaPlayerBridge* player) OVERRIDE; |
| 47 virtual void ReleaseMediaResources(media::MediaPlayerBridge* player) OVERRIDE; |
| 48 |
| 49 // Release all the players managed by this object. |
| 50 void CleanUpAllPlayers(); |
| 51 |
| 52 media::MediaPlayerBridge* GetPlayer(int player_id); |
| 53 |
| 54 private: |
| 55 // Message handlers. |
| 56 void OnInitialize(int player_id, const std::string& url); |
| 57 void OnStart(int player_id); |
| 58 void OnSeek(int player_id, base::TimeDelta time); |
| 59 void OnPause(int player_id); |
| 60 void OnReleaseResources(int player_id); |
| 61 void OnDestroyPlayer(int player_id); |
| 62 |
| 63 // An array of managed players. |
| 64 ScopedVector<media::MediaPlayerBridge> players_; |
| 65 |
| 66 DISALLOW_COPY_AND_ASSIGN(MediaPlayerManagerAndroid); |
| 67 }; |
| 68 |
| 69 } // namespace content |
| 70 |
| 71 #endif // CONTENT_BROWSER_ANDROID_MEDIA_PLAYER_MANAGER_ANDROID_H_ |
| OLD | NEW |