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/browser/android/content_video_view.h" |
15 #include "content/public/browser/render_view_host_observer.h" | 15 #include "content/public/browser/render_view_host_observer.h" |
16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
17 #include "media/base/android/media_player_bridge.h" | 17 #include "media/base/android/media_player_bridge.h" |
18 #include "media/base/android/media_player_bridge_manager.h" | 18 #include "media/base/android/media_player_bridge_manager.h" |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
| 22 class WebContents; |
| 23 |
22 // This class manages all the MediaPlayerBridge objects. It receives | 24 // This class manages all the MediaPlayerBridge objects. It receives |
23 // control operations from the the render process, and forwards | 25 // control operations from the the render process, and forwards |
24 // them to corresponding MediaPlayerBridge object. Callbacks from | 26 // them to corresponding MediaPlayerBridge object. Callbacks from |
25 // MediaPlayerBridge objects are converted to IPCs and then sent to the | 27 // MediaPlayerBridge objects are converted to IPCs and then sent to the |
26 // render process. | 28 // render process. |
27 class MediaPlayerManagerAndroid | 29 class MediaPlayerManagerAndroid |
28 : public RenderViewHostObserver, | 30 : public RenderViewHostObserver, |
29 public media::MediaPlayerBridgeManager { | 31 public media::MediaPlayerBridgeManager { |
30 public: | 32 public: |
31 // Create a MediaPlayerManagerAndroid object for the |render_view_host|. | 33 // Create a MediaPlayerManagerAndroid object for the |render_view_host|. |
(...skipping 23 matching lines...) Expand all Loading... |
55 void OnError(int player_id, int error); | 57 void OnError(int player_id, int error); |
56 void OnVideoSizeChanged(int player_id, int width, int height); | 58 void OnVideoSizeChanged(int player_id, int width, int height); |
57 | 59 |
58 // media::MediaPlayerBridgeManager overrides. | 60 // media::MediaPlayerBridgeManager overrides. |
59 virtual void RequestMediaResources(media::MediaPlayerBridge* player) OVERRIDE; | 61 virtual void RequestMediaResources(media::MediaPlayerBridge* player) OVERRIDE; |
60 virtual void ReleaseMediaResources(media::MediaPlayerBridge* player) OVERRIDE; | 62 virtual void ReleaseMediaResources(media::MediaPlayerBridge* player) OVERRIDE; |
61 | 63 |
62 // Release all the players managed by this object. | 64 // Release all the players managed by this object. |
63 void DestroyAllMediaPlayers(); | 65 void DestroyAllMediaPlayers(); |
64 | 66 |
| 67 void AttachExternalVideoSurface(int player_id, jobject surface); |
| 68 void DetachExternalVideoSurface(int player_id); |
| 69 |
65 media::MediaPlayerBridge* GetFullscreenPlayer(); | 70 media::MediaPlayerBridge* GetFullscreenPlayer(); |
66 media::MediaPlayerBridge* GetPlayer(int player_id); | 71 media::MediaPlayerBridge* GetPlayer(int player_id); |
67 | 72 |
68 private: | 73 private: |
69 // Message handlers. | 74 // Message handlers. |
70 void OnEnterFullscreen(int player_id); | 75 void OnEnterFullscreen(int player_id); |
71 void OnExitFullscreen(int player_id); | 76 void OnExitFullscreen(int player_id); |
72 void OnInitialize(int player_id, const GURL& url, | 77 void OnInitialize(int player_id, const GURL& url, |
73 const GURL& first_party_for_cookies); | 78 const GURL& first_party_for_cookies); |
74 void OnStart(int player_id); | 79 void OnStart(int player_id); |
75 void OnSeek(int player_id, base::TimeDelta time); | 80 void OnSeek(int player_id, base::TimeDelta time); |
76 void OnPause(int player_id); | 81 void OnPause(int player_id); |
77 void OnReleaseResources(int player_id); | 82 void OnReleaseResources(int player_id); |
78 void OnDestroyPlayer(int player_id); | 83 void OnDestroyPlayer(int player_id); |
| 84 void OnRequestExternalSurface(int player_id); |
79 | 85 |
80 // An array of managed players. | 86 // An array of managed players. |
81 ScopedVector<media::MediaPlayerBridge> players_; | 87 ScopedVector<media::MediaPlayerBridge> players_; |
82 | 88 |
83 // The fullscreen video view object. | 89 // The fullscreen video view object. |
84 ContentVideoView video_view_; | 90 ContentVideoView video_view_; |
85 | 91 |
86 // Player ID of the fullscreen media player. | 92 // Player ID of the fullscreen media player. |
87 int fullscreen_player_id_; | 93 int fullscreen_player_id_; |
88 | 94 |
| 95 WebContents* web_contents_; |
| 96 |
89 DISALLOW_COPY_AND_ASSIGN(MediaPlayerManagerAndroid); | 97 DISALLOW_COPY_AND_ASSIGN(MediaPlayerManagerAndroid); |
90 }; | 98 }; |
91 | 99 |
92 } // namespace content | 100 } // namespace content |
93 | 101 |
94 #endif // CONTENT_BROWSER_ANDROID_MEDIA_PLAYER_MANAGER_ANDROID_H_ | 102 #endif // CONTENT_BROWSER_ANDROID_MEDIA_PLAYER_MANAGER_ANDROID_H_ |
OLD | NEW |