Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(723)

Side by Side Diff: content/renderer/media/android/renderer_media_player_manager.h

Issue 1567123002: Support CAST+WMPI on android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dcheck removed Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_RENDERER_MEDIA_ANDROID_RENDERER_MEDIA_PLAYER_MANAGER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_ANDROID_RENDERER_MEDIA_PLAYER_MANAGER_H_
6 #define CONTENT_RENDERER_MEDIA_ANDROID_RENDERER_MEDIA_PLAYER_MANAGER_H_ 6 #define CONTENT_RENDERER_MEDIA_ANDROID_RENDERER_MEDIA_PLAYER_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "content/common/media/media_player_messages_enums_android.h"
14 #include "content/public/renderer/render_frame_observer.h" 13 #include "content/public/renderer/render_frame_observer.h"
15 #include "media/base/android/media_player_android.h" 14 #include "media/base/android/media_player_android.h"
15 #include "media/blink/renderer_media_player_interface.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 namespace blink { 18 namespace blink {
19 class WebFrame; 19 class WebFrame;
20 } 20 }
21 21
22 namespace gfx { 22 namespace gfx {
23 class RectF; 23 class RectF;
24 } 24 }
25 25
26 struct MediaPlayerHostMsg_Initialize_Params; 26 struct MediaPlayerHostMsg_Initialize_Params;
27 27
28 namespace content { 28 namespace content {
29 class WebMediaPlayerAndroid; 29 class WebMediaPlayerAndroid;
30 using media::RendererMediaPlayerInterface;
DaleCurtis 2016/01/14 02:01:41 Either keep as class or convert the rest to using
hubbe 2016/01/14 18:05:00 Done.
30 31
31 // Class for managing all the WebMediaPlayerAndroid objects in the same 32 // Class for managing all the WebMediaPlayerAndroid objects in the same
32 // RenderFrame. 33 // RenderFrame.
33 class RendererMediaPlayerManager : public RenderFrameObserver { 34 class RendererMediaPlayerManager :
35 public RenderFrameObserver,
36 public media::RendererMediaPlayerManagerInterface {
34 public: 37 public:
35 // Constructs a RendererMediaPlayerManager object for the |render_frame|. 38 // Constructs a RendererMediaPlayerManager object for the |render_frame|.
36 explicit RendererMediaPlayerManager(RenderFrame* render_frame); 39 explicit RendererMediaPlayerManager(RenderFrame* render_frame);
37 ~RendererMediaPlayerManager() override; 40 ~RendererMediaPlayerManager() override;
38 41
39 // RenderFrameObserver overrides. 42 // RenderFrameObserver overrides.
40 bool OnMessageReceived(const IPC::Message& msg) override; 43 bool OnMessageReceived(const IPC::Message& msg) override;
41 void WasHidden() override; 44 void WasHidden() override;
42 45
43 // Initializes a MediaPlayerAndroid object in browser process. 46 // Initializes a MediaPlayerAndroid object in browser process.
44 void Initialize(MediaPlayerHostMsg_Initialize_Type type, 47 void Initialize(MediaPlayerHostMsg_Initialize_Type type,
45 int player_id, 48 int player_id,
46 const GURL& url, 49 const GURL& url,
47 const GURL& first_party_for_cookies, 50 const GURL& first_party_for_cookies,
48 int demuxer_client_id, 51 int demuxer_client_id,
49 const GURL& frame_url, 52 const GURL& frame_url,
50 bool allow_credentials); 53 bool allow_credentials) override;
51 54
52 // Starts the player. 55 // Starts the player.
53 void Start(int player_id); 56 void Start(int player_id) override;
54 57
55 // Pauses the player. 58 // Pauses the player.
56 // is_media_related_action should be true if this pause is coming from an 59 // is_media_related_action should be true if this pause is coming from an
57 // an action that explicitly pauses the video (user pressing pause, JS, etc.) 60 // an action that explicitly pauses the video (user pressing pause, JS, etc.)
58 // Otherwise it should be false if Pause is being called due to other reasons 61 // Otherwise it should be false if Pause is being called due to other reasons
59 // (cleanup, freeing resources, etc.) 62 // (cleanup, freeing resources, etc.)
60 void Pause(int player_id, bool is_media_related_action); 63 void Pause(int player_id, bool is_media_related_action) override;
61 64
62 // Performs seek on the player. 65 // Performs seek on the player.
63 void Seek(int player_id, const base::TimeDelta& time); 66 void Seek(int player_id, const base::TimeDelta& time) override;
64 67
65 // Sets the player volume. 68 // Sets the player volume.
66 void SetVolume(int player_id, double volume); 69 void SetVolume(int player_id, double volume) override;
67 70
68 // Sets the poster image. 71 // Sets the poster image.
69 void SetPoster(int player_id, const GURL& poster); 72 void SetPoster(int player_id, const GURL& poster) override;
70 73
71 // Releases resources for the player after being suspended. 74 // Releases resources for the player after being suspended.
72 void SuspendAndReleaseResources(int player_id); 75 void SuspendAndReleaseResources(int player_id);
73 76
74 // Destroys the player in the browser process 77 // Destroys the player in the browser process
75 void DestroyPlayer(int player_id); 78 void DestroyPlayer(int player_id) override;
76 79
77 // Requests remote playback if possible 80 // Requests remote playback if possible
78 void RequestRemotePlayback(int player_id); 81 void RequestRemotePlayback(int player_id) override;
79 82
80 // Requests control of remote playback 83 // Requests control of remote playback
81 void RequestRemotePlaybackControl(int player_id); 84 void RequestRemotePlaybackControl(int player_id) override;
82 85
83 // Requests the player to enter fullscreen. 86 // Requests the player to enter fullscreen.
84 void EnterFullscreen(int player_id); 87 void EnterFullscreen(int player_id);
85 88
86 // Requests the player with |player_id| to use the CDM with |cdm_id|. 89 // Requests the player with |player_id| to use the CDM with |cdm_id|.
87 // Does nothing if |cdm_id| is kInvalidCdmId. 90 // Does nothing if |cdm_id| is kInvalidCdmId.
88 // TODO(xhwang): Update this when we implement setCdm(0). 91 // TODO(xhwang): Update this when we implement setCdm(0).
89 void SetCdm(int player_id, int cdm_id); 92 void SetCdm(int player_id, int cdm_id);
90 93
91 #if defined(VIDEO_HOLE) 94 #if defined(VIDEO_HOLE)
92 // Requests an external surface for out-of-band compositing. 95 // Requests an external surface for out-of-band compositing.
93 void RequestExternalSurface(int player_id, const gfx::RectF& geometry); 96 void RequestExternalSurface(int player_id, const gfx::RectF& geometry);
94 97
95 // RenderFrameObserver overrides. 98 // RenderFrameObserver overrides.
96 void DidCommitCompositorFrame() override; 99 void DidCommitCompositorFrame() override;
97 100
98 // Returns true if a media player should use video-overlay for the embedded 101 // Returns true if a media player should use video-overlay for the embedded
99 // encrypted video. 102 // encrypted video.
100 bool ShouldUseVideoOverlayForEmbeddedEncryptedVideo(); 103 bool ShouldUseVideoOverlayForEmbeddedEncryptedVideo();
101 #endif // defined(VIDEO_HOLE) 104 #endif // defined(VIDEO_HOLE)
102 105
103 // Registers and unregisters a WebMediaPlayerAndroid object. 106 // Registers and unregisters a WebMediaPlayerAndroid object.
104 int RegisterMediaPlayer(WebMediaPlayerAndroid* player); 107 int RegisterMediaPlayer(RendererMediaPlayerInterface* player) override;
105 void UnregisterMediaPlayer(int player_id); 108 void UnregisterMediaPlayer(int player_id) override;
106 109
107 // Gets the pointer to WebMediaPlayerAndroid given the |player_id|. 110 // Gets the pointer to WebMediaPlayerAndroid given the |player_id|.
108 WebMediaPlayerAndroid* GetMediaPlayer(int player_id); 111 RendererMediaPlayerInterface* GetMediaPlayer(int player_id);
109 112
110 #if defined(VIDEO_HOLE) 113 #if defined(VIDEO_HOLE)
111 // Gets the list of media players with video geometry changes. 114 // Gets the list of media players with video geometry changes.
112 void RetrieveGeometryChanges(std::map<int, gfx::RectF>* changes); 115 void RetrieveGeometryChanges(std::map<int, gfx::RectF>* changes);
113 #endif // defined(VIDEO_HOLE) 116 #endif // defined(VIDEO_HOLE)
114 117
115 private: 118 private:
116 // Message handlers. 119 // Message handlers.
117 void OnMediaMetadataChanged(int player_id, 120 void OnMediaMetadataChanged(int player_id,
118 base::TimeDelta duration, 121 base::TimeDelta duration,
(...skipping 14 matching lines...) Expand all
133 void OnMediaPlayerReleased(int player_id); 136 void OnMediaPlayerReleased(int player_id);
134 void OnConnectedToRemoteDevice(int player_id, 137 void OnConnectedToRemoteDevice(int player_id,
135 const std::string& remote_playback_message); 138 const std::string& remote_playback_message);
136 void OnDisconnectedFromRemoteDevice(int player_id); 139 void OnDisconnectedFromRemoteDevice(int player_id);
137 void OnDidExitFullscreen(int player_id); 140 void OnDidExitFullscreen(int player_id);
138 void OnDidEnterFullscreen(int player_id); 141 void OnDidEnterFullscreen(int player_id);
139 void OnPlayerPlay(int player_id); 142 void OnPlayerPlay(int player_id);
140 void OnPlayerPause(int player_id); 143 void OnPlayerPause(int player_id);
141 void OnRemoteRouteAvailabilityChanged(int player_id, bool routes_available); 144 void OnRemoteRouteAvailabilityChanged(int player_id, bool routes_available);
142 145
143 // Release all video player resources.
144 // If something is in progress the resource will not be freed. It will
145 // only be freed once the tab is destroyed or if the user navigates away
146 // via WebMediaPlayerAndroid::Destroy.
147 void ReleaseVideoResources();
148
149 // Info for all available WebMediaPlayerAndroid on a page; kept so that 146 // Info for all available WebMediaPlayerAndroid on a page; kept so that
150 // we can enumerate them to send updates about tab focus and visibility. 147 // we can enumerate them to send updates about tab focus and visibility.
151 std::map<int, WebMediaPlayerAndroid*> media_players_; 148 std::map<int, RendererMediaPlayerInterface*> media_players_;
152 149
153 int next_media_player_id_; 150 int next_media_player_id_;
154 151
155 DISALLOW_COPY_AND_ASSIGN(RendererMediaPlayerManager); 152 DISALLOW_COPY_AND_ASSIGN(RendererMediaPlayerManager);
156 }; 153 };
157 154
158 } // namespace content 155 } // namespace content
159 156
160 #endif // CONTENT_RENDERER_MEDIA_ANDROID_RENDERER_MEDIA_PLAYER_MANAGER_H_ 157 #endif // CONTENT_RENDERER_MEDIA_ANDROID_RENDERER_MEDIA_PLAYER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698