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

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: Fix trybot detected error. 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, const std::string& casting_message);
49 void SwitchToLocalPlayer(int player_id);
50
49 protected: 51 protected:
50 void OnSetPoster(int player_id, const GURL& url) override; 52 void OnSetPoster(int player_id, const GURL& url) override;
51 53
52 private: 54 private:
53 // Returns a MediaPlayerAndroid implementation for playing the media remotely. 55 // Returns a MediaPlayerAndroid implementation for playing the media remotely.
54 RemoteMediaPlayerBridge* CreateRemoteMediaPlayer( 56 RemoteMediaPlayerBridge* CreateRemoteMediaPlayer(
55 media::MediaPlayerAndroid* local_player); 57 media::MediaPlayerAndroid* local_player);
56 58
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. 59 // Replaces the remote player with the local player this class is holding.
62 // Does nothing if there is no remote player. 60 // Does nothing if there is no remote player.
63 void ReplaceRemotePlayerWithLocal(); 61 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 62
70 // content::BrowserMediaPlayerManager overrides. 63 // content::BrowserMediaPlayerManager overrides.
71 void OnStart(int player_id) override; 64 void OnStart(int player_id) override;
72 void OnInitialize( 65 void OnInitialize(
73 const MediaPlayerHostMsg_Initialize_Params& media_player_params) override; 66 const MediaPlayerHostMsg_Initialize_Params& media_player_params) override;
74 void OnDestroyPlayer(int player_id) override; 67 void OnDestroyPlayer(int player_id) override;
75 void OnReleaseResources(int player_id) override; 68 void OnReleaseResources(int player_id) override;
69 void OnSuspend(int player_id) override;
70 void OnResume(int player_id) override;
76 void OnRequestRemotePlayback(int player_id) override; 71 void OnRequestRemotePlayback(int player_id) override;
77 void OnRequestRemotePlaybackControl(int player_id) override; 72 void OnRequestRemotePlaybackControl(int player_id) override;
78 73
79 void ReleaseFullscreenPlayer(media::MediaPlayerAndroid* player) override; 74 void ReleaseFullscreenPlayer(media::MediaPlayerAndroid* player) override;
80 75
81 // Callback for when the download of poster image is done. 76 // Callback for when the download of poster image is done.
82 void DidDownloadPoster( 77 void DidDownloadPoster(
83 int player_id, 78 int player_id,
84 int id, 79 int id,
85 int http_status_code, 80 int http_status_code,
86 const GURL& image_url, 81 const GURL& image_url,
87 const std::vector<SkBitmap>& bitmaps, 82 const std::vector<SkBitmap>& bitmaps,
88 const std::vector<gfx::Size>& original_bitmap_sizes); 83 const std::vector<gfx::Size>& original_bitmap_sizes);
89 84
90 // Return the ID of the tab that's associated with this controller. Returns 85 // Return the ID of the tab that's associated with this controller. Returns
91 // -1 in case something goes wrong. 86 // -1 in case something goes wrong.
92 int GetTabId(); 87 int GetTabId();
93 88
94 // Get the player id of current remote player, if any, or -1 if none. 89 // Get the player that is not currently selected
95 int RemotePlayerId(); 90 ScopedVector<media::MediaPlayerAndroid>::iterator GetAlternativePlayer(
91 int player_id);
96 92
97 // Get the remote player for a given player id, whether or not it is currently 93 // Get the remote player for a given player id, whether or not it is currently
98 // playing remotely. 94 // playing remotely.
99 RemoteMediaPlayerBridge* GetRemotePlayer(int player_id); 95 RemoteMediaPlayerBridge* GetRemotePlayer(int player_id);
100 96
101 // The local player that we have replaced with a remote player. This is NULL 97 // 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. 98 // playing locally.
103 scoped_ptr<media::MediaPlayerAndroid> replaced_local_player_; 99 media::MediaPlayerAndroid* GetLocalPlayer(int player_id);
104 100
105 ScopedVector<RemoteMediaPlayerBridge> remote_players_; 101 void SwapCurrentPlayer(int player_id);
102
103 // Contains the alternative players that are not currently in use, i.e. the
104 // remote players for videos that are playing locally, and the local players
105 // for videos that are playing remotely.
106 ScopedVector<media::MediaPlayerAndroid> alternative_players_;
107
108 bool IsPlayingRemotely(int player_id);
109
110 std::set<int> players_playing_remotely_;
106 111
107 base::WeakPtrFactory<RemoteMediaPlayerManager> weak_ptr_factory_; 112 base::WeakPtrFactory<RemoteMediaPlayerManager> weak_ptr_factory_;
108 113
109 DISALLOW_COPY_AND_ASSIGN(RemoteMediaPlayerManager); 114 DISALLOW_COPY_AND_ASSIGN(RemoteMediaPlayerManager);
110 }; 115 };
111 116
112 } // namespace remote_media 117 } // namespace remote_media
113 118
114 #endif // CHROME_BROWSER_MEDIA_ANDROID_REMOTE_REMOTE_MEDIA_PLAYER_MANAGER_H_ 119 #endif // CHROME_BROWSER_MEDIA_ANDROID_REMOTE_REMOTE_MEDIA_PLAYER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698