| OLD | NEW |
| 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" | 13 #include "content/common/media/media_player_messages_enums_android.h" |
| 14 #include "content/public/renderer/render_frame_observer.h" | 14 #include "content/public/renderer/render_frame_observer.h" |
| 15 #include "media/base/android/media_player_android.h" | 15 #include "media/base/android/media_player_android.h" |
| 16 #include "media/blink/renderer_media_player_interface.h" |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 | 18 |
| 18 namespace blink { | 19 namespace blink { |
| 19 class WebFrame; | 20 class WebFrame; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace gfx { | 23 namespace gfx { |
| 23 class RectF; | 24 class RectF; |
| 24 } | 25 } |
| 25 | 26 |
| 26 struct MediaPlayerHostMsg_Initialize_Params; | 27 struct MediaPlayerHostMsg_Initialize_Params; |
| 27 | 28 |
| 28 namespace content { | 29 namespace content { |
| 29 class WebMediaPlayerAndroid; | 30 class WebMediaPlayerAndroid; |
| 31 using media::RendererMediaPlayerInterface; |
| 30 | 32 |
| 31 // Class for managing all the WebMediaPlayerAndroid objects in the same | 33 // Class for managing all the WebMediaPlayerAndroid objects in the same |
| 32 // RenderFrame. | 34 // RenderFrame. |
| 33 class RendererMediaPlayerManager : public RenderFrameObserver { | 35 class RendererMediaPlayerManager : |
| 36 public RenderFrameObserver, |
| 37 public media::RendererMediaPlayerManagerInterface { |
| 34 public: | 38 public: |
| 35 // Constructs a RendererMediaPlayerManager object for the |render_frame|. | 39 // Constructs a RendererMediaPlayerManager object for the |render_frame|. |
| 36 explicit RendererMediaPlayerManager(RenderFrame* render_frame); | 40 explicit RendererMediaPlayerManager(RenderFrame* render_frame); |
| 37 ~RendererMediaPlayerManager() override; | 41 ~RendererMediaPlayerManager() override; |
| 38 | 42 |
| 39 // RenderFrameObserver overrides. | 43 // RenderFrameObserver overrides. |
| 40 bool OnMessageReceived(const IPC::Message& msg) override; | 44 bool OnMessageReceived(const IPC::Message& msg) override; |
| 41 void WasHidden() override; | 45 void WasHidden() override; |
| 42 | 46 |
| 43 // Initializes a MediaPlayerAndroid object in browser process. | 47 // Initializes a MediaPlayerAndroid object in browser process. |
| 44 void Initialize(MediaPlayerHostMsg_Initialize_Type type, | 48 void Initialize(media::MediaPlayerHostMsg_Initialize_Type type, |
| 45 int player_id, | 49 int player_id, |
| 46 const GURL& url, | 50 const GURL& url, |
| 47 const GURL& first_party_for_cookies, | 51 const GURL& first_party_for_cookies, |
| 48 int demuxer_client_id, | 52 int demuxer_client_id, |
| 49 const GURL& frame_url, | 53 const GURL& frame_url, |
| 50 bool allow_credentials); | 54 bool allow_credentials) override; |
| 51 | 55 |
| 52 // Starts the player. | 56 // Starts the player. |
| 53 void Start(int player_id); | 57 void Start(int player_id) override; |
| 54 | 58 |
| 55 // Pauses the player. | 59 // Pauses the player. |
| 56 // is_media_related_action should be true if this pause is coming from an | 60 // 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.) | 61 // 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 | 62 // Otherwise it should be false if Pause is being called due to other reasons |
| 59 // (cleanup, freeing resources, etc.) | 63 // (cleanup, freeing resources, etc.) |
| 60 void Pause(int player_id, bool is_media_related_action); | 64 void Pause(int player_id, bool is_media_related_action) override; |
| 61 | 65 |
| 62 // Performs seek on the player. | 66 // Performs seek on the player. |
| 63 void Seek(int player_id, const base::TimeDelta& time); | 67 void Seek(int player_id, const base::TimeDelta& time) override; |
| 64 | 68 |
| 65 // Sets the player volume. | 69 // Sets the player volume. |
| 66 void SetVolume(int player_id, double volume); | 70 void SetVolume(int player_id, double volume) override; |
| 67 | 71 |
| 68 // Sets the poster image. | 72 // Sets the poster image. |
| 69 void SetPoster(int player_id, const GURL& poster); | 73 void SetPoster(int player_id, const GURL& poster) override; |
| 70 | 74 |
| 71 // Releases resources for the player. | 75 // Releases resources for the player. |
| 72 void ReleaseResources(int player_id); | 76 void ReleaseResources(int player_id) override; |
| 73 | 77 |
| 74 // Destroys the player in the browser process | 78 // Destroys the player in the browser process |
| 75 void DestroyPlayer(int player_id); | 79 void DestroyPlayer(int player_id) override; |
| 76 | 80 |
| 77 // Requests remote playback if possible | 81 // Requests remote playback if possible |
| 78 void RequestRemotePlayback(int player_id); | 82 void RequestRemotePlayback(int player_id) override; |
| 79 | 83 |
| 80 // Requests control of remote playback | 84 // Requests control of remote playback |
| 81 void RequestRemotePlaybackControl(int player_id); | 85 void RequestRemotePlaybackControl(int player_id) override; |
| 82 | 86 |
| 83 // Requests the player to enter fullscreen. | 87 // Requests the player to enter fullscreen. |
| 84 void EnterFullscreen(int player_id); | 88 void EnterFullscreen(int player_id); |
| 85 | 89 |
| 86 // Requests the player with |player_id| to use the CDM with |cdm_id|. | 90 // Requests the player with |player_id| to use the CDM with |cdm_id|. |
| 87 // Does nothing if |cdm_id| is kInvalidCdmId. | 91 // Does nothing if |cdm_id| is kInvalidCdmId. |
| 88 // TODO(xhwang): Update this when we implement setCdm(0). | 92 // TODO(xhwang): Update this when we implement setCdm(0). |
| 89 void SetCdm(int player_id, int cdm_id); | 93 void SetCdm(int player_id, int cdm_id); |
| 90 | 94 |
| 91 #if defined(VIDEO_HOLE) | 95 #if defined(VIDEO_HOLE) |
| 92 // Requests an external surface for out-of-band compositing. | 96 // Requests an external surface for out-of-band compositing. |
| 93 void RequestExternalSurface(int player_id, const gfx::RectF& geometry); | 97 void RequestExternalSurface(int player_id, const gfx::RectF& geometry); |
| 94 | 98 |
| 95 // RenderFrameObserver overrides. | 99 // RenderFrameObserver overrides. |
| 96 void DidCommitCompositorFrame() override; | 100 void DidCommitCompositorFrame() override; |
| 97 | 101 |
| 98 // Returns true if a media player should use video-overlay for the embedded | 102 // Returns true if a media player should use video-overlay for the embedded |
| 99 // encrypted video. | 103 // encrypted video. |
| 100 bool ShouldUseVideoOverlayForEmbeddedEncryptedVideo(); | 104 bool ShouldUseVideoOverlayForEmbeddedEncryptedVideo(); |
| 101 #endif // defined(VIDEO_HOLE) | 105 #endif // defined(VIDEO_HOLE) |
| 102 | 106 |
| 103 // Registers and unregisters a WebMediaPlayerAndroid object. | 107 // Registers and unregisters a WebMediaPlayerAndroid object. |
| 104 int RegisterMediaPlayer(WebMediaPlayerAndroid* player); | 108 int RegisterMediaPlayer(RendererMediaPlayerInterface* player) override; |
| 105 void UnregisterMediaPlayer(int player_id); | 109 void UnregisterMediaPlayer(int player_id) override; |
| 106 | 110 |
| 107 // Gets the pointer to WebMediaPlayerAndroid given the |player_id|. | 111 // Gets the pointer to WebMediaPlayerAndroid given the |player_id|. |
| 108 WebMediaPlayerAndroid* GetMediaPlayer(int player_id); | 112 RendererMediaPlayerInterface* GetMediaPlayer(int player_id); |
| 109 | 113 |
| 110 #if defined(VIDEO_HOLE) | 114 #if defined(VIDEO_HOLE) |
| 111 // Gets the list of media players with video geometry changes. | 115 // Gets the list of media players with video geometry changes. |
| 112 void RetrieveGeometryChanges(std::map<int, gfx::RectF>* changes); | 116 void RetrieveGeometryChanges(std::map<int, gfx::RectF>* changes); |
| 113 #endif // defined(VIDEO_HOLE) | 117 #endif // defined(VIDEO_HOLE) |
| 114 | 118 |
| 115 private: | 119 private: |
| 116 // Message handlers. | 120 // Message handlers. |
| 117 void OnMediaMetadataChanged(int player_id, | 121 void OnMediaMetadataChanged(int player_id, |
| 118 base::TimeDelta duration, | 122 base::TimeDelta duration, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 141 void OnRemoteRouteAvailabilityChanged(int player_id, bool routes_available); | 145 void OnRemoteRouteAvailabilityChanged(int player_id, bool routes_available); |
| 142 | 146 |
| 143 // Release all video player resources. | 147 // Release all video player resources. |
| 144 // If something is in progress the resource will not be freed. It will | 148 // 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 | 149 // only be freed once the tab is destroyed or if the user navigates away |
| 146 // via WebMediaPlayerAndroid::Destroy. | 150 // via WebMediaPlayerAndroid::Destroy. |
| 147 void ReleaseVideoResources(); | 151 void ReleaseVideoResources(); |
| 148 | 152 |
| 149 // Info for all available WebMediaPlayerAndroid on a page; kept so that | 153 // Info for all available WebMediaPlayerAndroid on a page; kept so that |
| 150 // we can enumerate them to send updates about tab focus and visibility. | 154 // we can enumerate them to send updates about tab focus and visibility. |
| 151 std::map<int, WebMediaPlayerAndroid*> media_players_; | 155 std::map<int, RendererMediaPlayerInterface*> media_players_; |
| 152 | 156 |
| 153 int next_media_player_id_; | 157 int next_media_player_id_; |
| 154 | 158 |
| 155 DISALLOW_COPY_AND_ASSIGN(RendererMediaPlayerManager); | 159 DISALLOW_COPY_AND_ASSIGN(RendererMediaPlayerManager); |
| 156 }; | 160 }; |
| 157 | 161 |
| 158 } // namespace content | 162 } // namespace content |
| 159 | 163 |
| 160 #endif // CONTENT_RENDERER_MEDIA_ANDROID_RENDERER_MEDIA_PLAYER_MANAGER_H_ | 164 #endif // CONTENT_RENDERER_MEDIA_ANDROID_RENDERER_MEDIA_PLAYER_MANAGER_H_ |
| OLD | NEW |