| 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/browser/android/content_video_view.h" | |
| 15 #include "content/public/browser/render_view_host_observer.h" | |
| 16 #include "googleurl/src/gurl.h" | |
| 17 #include "media/base/android/media_player_bridge.h" | |
| 18 #include "media/base/android/media_player_bridge_manager.h" | |
| 19 #include "ui/gfx/rect_f.h" | |
| 20 | |
| 21 namespace content { | |
| 22 | |
| 23 class WebContents; | |
| 24 | |
| 25 // This class manages all the MediaPlayerBridge objects. It receives | |
| 26 // control operations from the the render process, and forwards | |
| 27 // them to corresponding MediaPlayerBridge object. Callbacks from | |
| 28 // MediaPlayerBridge objects are converted to IPCs and then sent to the | |
| 29 // render process. | |
| 30 class MediaPlayerManagerAndroid | |
| 31 : public RenderViewHostObserver, | |
| 32 public media::MediaPlayerBridgeManager { | |
| 33 public: | |
| 34 // Create a MediaPlayerManagerAndroid object for the |render_view_host|. | |
| 35 explicit MediaPlayerManagerAndroid(RenderViewHost* render_view_host); | |
| 36 virtual ~MediaPlayerManagerAndroid(); | |
| 37 | |
| 38 // RenderViewHostObserver overrides. | |
| 39 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 40 | |
| 41 // Fullscreen video playback controls. | |
| 42 void FullscreenPlayerPlay(); | |
| 43 void FullscreenPlayerPause(); | |
| 44 void FullscreenPlayerSeek(int msec); | |
| 45 void ExitFullscreen(bool release_media_player); | |
| 46 void SetVideoSurface(jobject surface); | |
| 47 | |
| 48 // An internal method that checks for current time routinely and generates | |
| 49 // time update events. | |
| 50 void OnTimeUpdate(int player_id, base::TimeDelta current_time); | |
| 51 | |
| 52 // Callbacks needed by media::MediaPlayerBridge. | |
| 53 void OnMediaMetadataChanged(int player_id, base::TimeDelta duration, | |
| 54 int width, int height, bool success); | |
| 55 void OnPlaybackComplete(int player_id); | |
| 56 void OnMediaInterrupted(int player_id); | |
| 57 void OnBufferingUpdate(int player_id, int percentage); | |
| 58 void OnSeekComplete(int player_id, base::TimeDelta current_time); | |
| 59 void OnError(int player_id, int error); | |
| 60 void OnVideoSizeChanged(int player_id, int width, int height); | |
| 61 | |
| 62 // media::MediaPlayerBridgeManager overrides. | |
| 63 virtual void RequestMediaResources(media::MediaPlayerBridge* player) OVERRIDE; | |
| 64 virtual void ReleaseMediaResources(media::MediaPlayerBridge* player) OVERRIDE; | |
| 65 | |
| 66 // Release all the players managed by this object. | |
| 67 void DestroyAllMediaPlayers(); | |
| 68 | |
| 69 #if defined(GOOGLE_TV) | |
| 70 void AttachExternalVideoSurface(int player_id, jobject surface); | |
| 71 void DetachExternalVideoSurface(int player_id); | |
| 72 #endif | |
| 73 | |
| 74 media::MediaPlayerBridge* GetFullscreenPlayer(); | |
| 75 media::MediaPlayerBridge* GetPlayer(int player_id); | |
| 76 | |
| 77 private: | |
| 78 // Message handlers. | |
| 79 void OnEnterFullscreen(int player_id); | |
| 80 void OnExitFullscreen(int player_id); | |
| 81 void OnInitialize(int player_id, const GURL& url, | |
| 82 const GURL& first_party_for_cookies); | |
| 83 void OnStart(int player_id); | |
| 84 void OnSeek(int player_id, base::TimeDelta time); | |
| 85 void OnPause(int player_id); | |
| 86 void OnReleaseResources(int player_id); | |
| 87 void OnDestroyPlayer(int player_id); | |
| 88 #if defined(GOOGLE_TV) | |
| 89 void OnRequestExternalSurface(int player_id); | |
| 90 void OnNotifyGeometryChange(int player_id, const gfx::RectF& rect); | |
| 91 #endif | |
| 92 | |
| 93 // An array of managed players. | |
| 94 ScopedVector<media::MediaPlayerBridge> players_; | |
| 95 | |
| 96 // The fullscreen video view object. | |
| 97 ContentVideoView video_view_; | |
| 98 | |
| 99 // Player ID of the fullscreen media player. | |
| 100 int fullscreen_player_id_; | |
| 101 | |
| 102 WebContents* web_contents_; | |
| 103 | |
| 104 DISALLOW_COPY_AND_ASSIGN(MediaPlayerManagerAndroid); | |
| 105 }; | |
| 106 | |
| 107 } // namespace content | |
| 108 | |
| 109 #endif // CONTENT_BROWSER_ANDROID_MEDIA_PLAYER_MANAGER_ANDROID_H_ | |
| OLD | NEW |