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

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: build fixes + comments addressed 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 30
31 // Class for managing all the WebMediaPlayerAndroid objects in the same 31 // Class for managing all the WebMediaPlayerAndroid objects in the same
32 // RenderFrame. 32 // RenderFrame.
33 class RendererMediaPlayerManager : public RenderFrameObserver { 33 class RendererMediaPlayerManager :
34 public RenderFrameObserver,
35 public media::RendererMediaPlayerManagerInterface {
34 public: 36 public:
35 // Constructs a RendererMediaPlayerManager object for the |render_frame|. 37 // Constructs a RendererMediaPlayerManager object for the |render_frame|.
36 explicit RendererMediaPlayerManager(RenderFrame* render_frame); 38 explicit RendererMediaPlayerManager(RenderFrame* render_frame);
37 ~RendererMediaPlayerManager() override; 39 ~RendererMediaPlayerManager() override;
38 40
39 // RenderFrameObserver overrides. 41 // RenderFrameObserver overrides.
40 bool OnMessageReceived(const IPC::Message& msg) override; 42 bool OnMessageReceived(const IPC::Message& msg) override;
41 void WasHidden() override; 43 void WasHidden() override;
42 44
43 // Initializes a MediaPlayerAndroid object in browser process. 45 // Initializes a MediaPlayerAndroid object in browser process.
44 void Initialize(MediaPlayerHostMsg_Initialize_Type type, 46 void Initialize(MediaPlayerHostMsg_Initialize_Type type,
45 int player_id, 47 int player_id,
46 const GURL& url, 48 const GURL& url,
47 const GURL& first_party_for_cookies, 49 const GURL& first_party_for_cookies,
48 int demuxer_client_id, 50 int demuxer_client_id,
49 const GURL& frame_url, 51 const GURL& frame_url,
50 bool allow_credentials); 52 bool allow_credentials) override;
51 53
52 // Starts the player. 54 // Starts the player.
53 void Start(int player_id); 55 void Start(int player_id) override;
54 56
55 // Pauses the player. 57 // Pauses the player.
56 // is_media_related_action should be true if this pause is coming from an 58 // 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.) 59 // 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 60 // Otherwise it should be false if Pause is being called due to other reasons
59 // (cleanup, freeing resources, etc.) 61 // (cleanup, freeing resources, etc.)
60 void Pause(int player_id, bool is_media_related_action); 62 void Pause(int player_id, bool is_media_related_action) override;
61 63
62 // Performs seek on the player. 64 // Performs seek on the player.
63 void Seek(int player_id, const base::TimeDelta& time); 65 void Seek(int player_id, const base::TimeDelta& time) override;
64 66
65 // Sets the player volume. 67 // Sets the player volume.
66 void SetVolume(int player_id, double volume); 68 void SetVolume(int player_id, double volume) override;
67 69
68 // Sets the poster image. 70 // Sets the poster image.
69 void SetPoster(int player_id, const GURL& poster); 71 void SetPoster(int player_id, const GURL& poster) override;
70 72
71 // Releases resources for the player after being suspended. 73 // Releases resources for the player after being suspended.
72 void SuspendAndReleaseResources(int player_id); 74 void SuspendAndReleaseResources(int player_id) override;
73 75
74 // Destroys the player in the browser process 76 // Destroys the player in the browser process
75 void DestroyPlayer(int player_id); 77 void DestroyPlayer(int player_id) override;
76 78
77 // Requests remote playback if possible 79 // Requests remote playback if possible
78 void RequestRemotePlayback(int player_id); 80 void RequestRemotePlayback(int player_id) override;
79 81
80 // Requests control of remote playback 82 // Requests control of remote playback
81 void RequestRemotePlaybackControl(int player_id); 83 void RequestRemotePlaybackControl(int player_id) override;
82 84
83 // Requests the player to enter fullscreen. 85 // Requests the player to enter fullscreen.
84 void EnterFullscreen(int player_id); 86 void EnterFullscreen(int player_id);
85 87
86 // Requests the player with |player_id| to use the CDM with |cdm_id|. 88 // Requests the player with |player_id| to use the CDM with |cdm_id|.
87 // Does nothing if |cdm_id| is kInvalidCdmId. 89 // Does nothing if |cdm_id| is kInvalidCdmId.
88 // TODO(xhwang): Update this when we implement setCdm(0). 90 // TODO(xhwang): Update this when we implement setCdm(0).
89 void SetCdm(int player_id, int cdm_id); 91 void SetCdm(int player_id, int cdm_id);
90 92
91 #if defined(VIDEO_HOLE) 93 #if defined(VIDEO_HOLE)
92 // Requests an external surface for out-of-band compositing. 94 // Requests an external surface for out-of-band compositing.
93 void RequestExternalSurface(int player_id, const gfx::RectF& geometry); 95 void RequestExternalSurface(int player_id, const gfx::RectF& geometry);
94 96
95 // RenderFrameObserver overrides. 97 // RenderFrameObserver overrides.
96 void DidCommitCompositorFrame() override; 98 void DidCommitCompositorFrame() override;
97 99
98 // Returns true if a media player should use video-overlay for the embedded 100 // Returns true if a media player should use video-overlay for the embedded
99 // encrypted video. 101 // encrypted video.
100 bool ShouldUseVideoOverlayForEmbeddedEncryptedVideo(); 102 bool ShouldUseVideoOverlayForEmbeddedEncryptedVideo();
101 #endif // defined(VIDEO_HOLE) 103 #endif // defined(VIDEO_HOLE)
102 104
103 // Registers and unregisters a WebMediaPlayerAndroid object. 105 // Registers and unregisters a WebMediaPlayerAndroid object.
104 int RegisterMediaPlayer(WebMediaPlayerAndroid* player); 106 int RegisterMediaPlayer(media::RendererMediaPlayerInterface* player) override;
105 void UnregisterMediaPlayer(int player_id); 107 void UnregisterMediaPlayer(int player_id) override;
106 108
107 // Gets the pointer to WebMediaPlayerAndroid given the |player_id|. 109 // Gets the pointer to WebMediaPlayerAndroid given the |player_id|.
108 WebMediaPlayerAndroid* GetMediaPlayer(int player_id); 110 media::RendererMediaPlayerInterface* GetMediaPlayer(int player_id);
109 111
110 #if defined(VIDEO_HOLE) 112 #if defined(VIDEO_HOLE)
111 // Gets the list of media players with video geometry changes. 113 // Gets the list of media players with video geometry changes.
112 void RetrieveGeometryChanges(std::map<int, gfx::RectF>* changes); 114 void RetrieveGeometryChanges(std::map<int, gfx::RectF>* changes);
113 #endif // defined(VIDEO_HOLE) 115 #endif // defined(VIDEO_HOLE)
114 116
115 private: 117 private:
116 // Message handlers. 118 // Message handlers.
117 void OnMediaMetadataChanged(int player_id, 119 void OnMediaMetadataChanged(int player_id,
118 base::TimeDelta duration, 120 base::TimeDelta duration,
(...skipping 14 matching lines...) Expand all
133 void OnMediaPlayerReleased(int player_id); 135 void OnMediaPlayerReleased(int player_id);
134 void OnConnectedToRemoteDevice(int player_id, 136 void OnConnectedToRemoteDevice(int player_id,
135 const std::string& remote_playback_message); 137 const std::string& remote_playback_message);
136 void OnDisconnectedFromRemoteDevice(int player_id); 138 void OnDisconnectedFromRemoteDevice(int player_id);
137 void OnDidExitFullscreen(int player_id); 139 void OnDidExitFullscreen(int player_id);
138 void OnDidEnterFullscreen(int player_id); 140 void OnDidEnterFullscreen(int player_id);
139 void OnPlayerPlay(int player_id); 141 void OnPlayerPlay(int player_id);
140 void OnPlayerPause(int player_id); 142 void OnPlayerPause(int player_id);
141 void OnRemoteRouteAvailabilityChanged(int player_id, bool routes_available); 143 void OnRemoteRouteAvailabilityChanged(int player_id, bool routes_available);
142 144
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 145 // Info for all available WebMediaPlayerAndroid on a page; kept so that
150 // we can enumerate them to send updates about tab focus and visibility. 146 // we can enumerate them to send updates about tab focus and visibility.
151 std::map<int, WebMediaPlayerAndroid*> media_players_; 147 std::map<int, media::RendererMediaPlayerInterface*> media_players_;
152 148
153 int next_media_player_id_; 149 int next_media_player_id_;
154 150
155 DISALLOW_COPY_AND_ASSIGN(RendererMediaPlayerManager); 151 DISALLOW_COPY_AND_ASSIGN(RendererMediaPlayerManager);
156 }; 152 };
157 153
158 } // namespace content 154 } // namespace content
159 155
160 #endif // CONTENT_RENDERER_MEDIA_ANDROID_RENDERER_MEDIA_PLAYER_MANAGER_H_ 156 #endif // CONTENT_RENDERER_MEDIA_ANDROID_RENDERER_MEDIA_PLAYER_MANAGER_H_
OLDNEW
« no previous file with comments | « content/content_common.gypi ('k') | content/renderer/media/android/renderer_media_player_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698