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

Side by Side Diff: chrome/browser/media/android/remote/remote_media_player_manager.h

Issue 1403703005: Refactor Clank cast connect logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 CHROME_BROWSER_MEDIA_ANDROID_REMOTE_REMOTE_MEDIA_PLAYER_MANAGER_H_ 5 #ifndef CHROME_BROWSER_MEDIA_ANDROID_REMOTE_REMOTE_MEDIA_PLAYER_MANAGER_H_
6 #define CHROME_BROWSER_MEDIA_ANDROID_REMOTE_REMOTE_MEDIA_PLAYER_MANAGER_H_ 6 #define CHROME_BROWSER_MEDIA_ANDROID_REMOTE_REMOTE_MEDIA_PLAYER_MANAGER_H_
7 7
8 #include <set>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
12 #include "chrome/browser/media/android/remote/remote_media_player_bridge.h" 13 #include "chrome/browser/media/android/remote/remote_media_player_bridge.h"
13 #include "content/browser/media/android/browser_media_player_manager.h" 14 #include "content/browser/media/android/browser_media_player_manager.h"
14 #include "media/base/android/media_player_android.h" 15 #include "media/base/android/media_player_android.h"
15 16
16 struct MediaPlayerHostMsg_Initialize_Params; 17 struct MediaPlayerHostMsg_Initialize_Params;
17 18
18 namespace remote_media { 19 namespace remote_media {
19 20
20 // media::MediaPlayerManager implementation that allows the user to play media 21 // media::MediaPlayerManager implementation that allows the user to play media
21 // remotely. 22 // remotely.
22 class RemoteMediaPlayerManager : public content::BrowserMediaPlayerManager { 23 class RemoteMediaPlayerManager : public content::BrowserMediaPlayerManager {
23 public: 24 public:
24 explicit RemoteMediaPlayerManager( 25 explicit RemoteMediaPlayerManager(
25 content::RenderFrameHost* render_frame_host); 26 content::RenderFrameHost* render_frame_host);
26 ~RemoteMediaPlayerManager() override; 27 ~RemoteMediaPlayerManager() override;
27 28
28 void OnPlaying(int player_id); 29 void OnPlaying(int player_id);
29 void OnPaused(int player_id); 30 void OnPaused(int player_id);
30 31
31 // Callback to trigger when a remote device has been selected.
32 void OnRemoteDeviceSelected(int player_id);
33
34 // Callback to trigger when a remote device has been unselected. 32 // Callback to trigger when a remote device has been unselected.
35 void OnRemoteDeviceUnselected(int player_id); 33 void OnRemoteDeviceUnselected(int player_id);
36 34
37 // Callback to trigger when the video on a remote device finishes playing. 35 // Callback to trigger when the video on a remote device finishes playing.
38 void OnRemotePlaybackFinished(int player_id); 36 void OnRemotePlaybackFinished(int player_id);
39 37
40 // Callback to trigger when the availability of remote routes changes. 38 // Callback to trigger when the availability of remote routes changes.
41 void OnRouteAvailabilityChanged(int tab_id, bool routes_available); 39 void OnRouteAvailabilityChanged(int tab_id, bool routes_available);
42 40
43 void OnMediaMetadataChanged(int player_id, 41 void OnMediaMetadataChanged(int player_id,
44 base::TimeDelta duration, 42 base::TimeDelta duration,
45 int width, 43 int width,
46 int height, 44 int height,
47 bool success) override; 45 bool success) override;
48 46
47 // Swap which player is currently in use (local or remote).
48 void SwitchToRemotePlayer(int player_id);
49 void SwitchToLocalPlayer(int player_id);
50 void OnPlayingRemotely(int player_id, const std::string& casting_message);
51
49 protected: 52 protected:
50 void OnSetPoster(int player_id, const GURL& url) override; 53 void OnSetPoster(int player_id, const GURL& url) override;
51 54
52 private: 55 private:
53 // Returns a MediaPlayerAndroid implementation for playing the media remotely. 56 // Returns a MediaPlayerAndroid implementation for playing the media remotely.
54 RemoteMediaPlayerBridge* CreateRemoteMediaPlayer( 57 RemoteMediaPlayerBridge* CreateRemoteMediaPlayer(
55 media::MediaPlayerAndroid* local_player); 58 media::MediaPlayerAndroid* local_player);
56 59
57 // Replaces the given local player with the remote one. Does nothing if the
58 // player is remote already.
59 void ReplaceLocalPlayerWithRemote(media::MediaPlayerAndroid* player);
60
61 // Replaces the remote player with the local player this class is holding. 60 // Replaces the remote player with the local player this class is holding.
62 // Does nothing if there is no remote player. 61 // Does nothing if there is no remote player.
63 void ReplaceRemotePlayerWithLocal(); 62 void ReplaceRemotePlayerWithLocal(int player_id);
64
65 // Checks if the URL managed by the player should be played remotely.
66 // Returns true if the manager should do nothing, false if it needs to
67 // proceed.
68 bool MaybeStartPlayingRemotely(int player_id);
69 63
70 // content::BrowserMediaPlayerManager overrides. 64 // content::BrowserMediaPlayerManager overrides.
71 void OnStart(int player_id) override; 65 void OnStart(int player_id) override;
72 void OnInitialize( 66 void OnInitialize(
73 const MediaPlayerHostMsg_Initialize_Params& media_player_params) override; 67 const MediaPlayerHostMsg_Initialize_Params& media_player_params) override;
74 void OnDestroyPlayer(int player_id) override; 68 void OnDestroyPlayer(int player_id) override;
75 void OnReleaseResources(int player_id) override; 69 void OnReleaseResources(int player_id) override;
70 void OnSuspend(int player_id) override;
71 void OnResume(int player_id) override;
76 void OnRequestRemotePlayback(int player_id) override; 72 void OnRequestRemotePlayback(int player_id) override;
77 void OnRequestRemotePlaybackControl(int player_id) override; 73 void OnRequestRemotePlaybackControl(int player_id) override;
78 74
79 void ReleaseFullscreenPlayer(media::MediaPlayerAndroid* player) override; 75 void ReleaseFullscreenPlayer(media::MediaPlayerAndroid* player) override;
80 76
81 // Callback for when the download of poster image is done. 77 // Callback for when the download of poster image is done.
82 void DidDownloadPoster( 78 void DidDownloadPoster(
83 int player_id, 79 int player_id,
84 int id, 80 int id,
85 int http_status_code, 81 int http_status_code,
86 const GURL& image_url, 82 const GURL& image_url,
87 const std::vector<SkBitmap>& bitmaps, 83 const std::vector<SkBitmap>& bitmaps,
88 const std::vector<gfx::Size>& original_bitmap_sizes); 84 const std::vector<gfx::Size>& original_bitmap_sizes);
89 85
90 // Return the ID of the tab that's associated with this controller. Returns 86 // Return the ID of the tab that's associated with this controller. Returns
91 // -1 in case something goes wrong. 87 // -1 in case something goes wrong.
92 int GetTabId(); 88 int GetTabId();
93 89
94 // Get the player id of current remote player, if any, or -1 if none. 90 // Get the player that is not currently selected
95 int RemotePlayerId(); 91 ScopedVector<media::MediaPlayerAndroid>::iterator GetAlternativePlayer(
dgn 2015/10/14 16:05:49 Return media::MediaPlayerAndroid* instead, and nul
aberent 2015/10/15 10:31:38 No, I need the iterator in SwapCurrentPlayer, If I
dgn 2015/10/15 11:07:31 OK I missed that. nit: How about having 2 methods
aberent 2015/10/15 12:57:54 Seems unnecessary. Not done.
92 int player_id);
96 93
97 // Get the remote player for a given player id, whether or not it is currently 94 // Get the remote player for a given player id, whether or not it is currently
98 // playing remotely. 95 // playing remotely.
99 RemoteMediaPlayerBridge* GetRemotePlayer(int player_id); 96 RemoteMediaPlayerBridge* GetRemotePlayer(int player_id);
100 97
101 // The local player that we have replaced with a remote player. This is NULL 98 // Get the local player for a given player id, whether or not it is currently
102 // if we do not have a remote player currently running. 99 // playing locally.
103 scoped_ptr<media::MediaPlayerAndroid> replaced_local_player_; 100 media::MediaPlayerAndroid* GetLocalPlayer(int player_id);
104 101
105 ScopedVector<RemoteMediaPlayerBridge> remote_players_; 102 void SwapCurrentPlayer(int player_id);
103
104 // Contains the alternative players that are not currently in use, i.e. the
105 // remote players for videos that are playing locally, and the local players
106 // for videos that are playing remotely.
107 ScopedVector<media::MediaPlayerAndroid> alternative_players_;
108
109 std::set<int> players_playing_remotely_;
106 110
107 base::WeakPtrFactory<RemoteMediaPlayerManager> weak_ptr_factory_; 111 base::WeakPtrFactory<RemoteMediaPlayerManager> weak_ptr_factory_;
108 112
109 DISALLOW_COPY_AND_ASSIGN(RemoteMediaPlayerManager); 113 DISALLOW_COPY_AND_ASSIGN(RemoteMediaPlayerManager);
110 }; 114 };
111 115
112 } // namespace remote_media 116 } // namespace remote_media
113 117
114 #endif // CHROME_BROWSER_MEDIA_ANDROID_REMOTE_REMOTE_MEDIA_PLAYER_MANAGER_H_ 118 #endif // CHROME_BROWSER_MEDIA_ANDROID_REMOTE_REMOTE_MEDIA_PLAYER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698