OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 MEDIA_REMOTING_RENDERER_CONTROLLER_H_ | 5 #ifndef MEDIA_REMOTING_RENDERER_CONTROLLER_H_ |
6 #define MEDIA_REMOTING_RENDERER_CONTROLLER_H_ | 6 #define MEDIA_REMOTING_RENDERER_CONTROLLER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/optional.h" | 10 #include "base/optional.h" |
11 #include "media/base/media_observer.h" | 11 #include "media/base/media_observer.h" |
12 #include "media/remoting/interstitial.h" | |
13 #include "media/remoting/metrics.h" | 12 #include "media/remoting/metrics.h" |
14 #include "media/remoting/shared_session.h" | 13 #include "media/remoting/shared_session.h" |
15 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
miu
2017/04/13 02:15:10
Can we remove the SkBitmap #include?
xjz
2017/04/13 23:48:36
Yes. Done.
| |
16 | 15 |
17 namespace media { | 16 namespace media { |
18 namespace remoting { | 17 namespace remoting { |
19 | 18 |
20 class RpcBroker; | 19 class RpcBroker; |
21 | 20 |
22 // This class: | 21 // This class: |
23 // 1) Implements the SharedSession::Client; | 22 // 1) Implements the SharedSession::Client; |
24 // 2) Monitors player events as a MediaObserver; | 23 // 2) Monitors player events as a MediaObserver; |
25 // 3) May trigger the switch of the media renderer between local playback | 24 // 3) May trigger the switch of the media renderer between local playback |
(...skipping 10 matching lines...) Expand all Loading... | |
36 | 35 |
37 // MediaObserver implementation. | 36 // MediaObserver implementation. |
38 void OnEnteredFullscreen() override; | 37 void OnEnteredFullscreen() override; |
39 void OnExitedFullscreen() override; | 38 void OnExitedFullscreen() override; |
40 void OnBecameDominantVisibleContent(bool is_dominant) override; | 39 void OnBecameDominantVisibleContent(bool is_dominant) override; |
41 void OnSetCdm(CdmContext* cdm_context) override; | 40 void OnSetCdm(CdmContext* cdm_context) override; |
42 void OnMetadataChanged(const PipelineMetadata& metadata) override; | 41 void OnMetadataChanged(const PipelineMetadata& metadata) override; |
43 void OnRemotePlaybackDisabled(bool disabled) override; | 42 void OnRemotePlaybackDisabled(bool disabled) override; |
44 void OnPlaying() override; | 43 void OnPlaying() override; |
45 void OnPaused() override; | 44 void OnPaused() override; |
46 void OnSetPoster(const GURL& poster) override; | 45 void OnSetPoster(const GURL& poster) override {} |
miu
2017/04/13 02:15:10
We should remove OnSetPoster() from the interface,
xjz
2017/04/13 23:48:36
Done.
| |
47 void SetClient(MediaObserverClient* client) override; | 46 void SetClient(MediaObserverClient* client) override; |
48 | 47 |
49 using ShowInterstitialCallback = base::Callback< | |
50 void(const SkBitmap&, const gfx::Size&, InterstitialType type)>; | |
51 // Called by the CourierRenderer constructor to set the callback to draw and | |
52 // show remoting interstial. | |
53 void SetShowInterstitialCallback(const ShowInterstitialCallback& cb); | |
54 using DownloadPosterCallback = | |
55 base::Callback<void(const GURL&, | |
56 const base::Callback<void(const SkBitmap&)>&)>; | |
57 // Set the callback to download poster image. | |
58 void SetDownloadPosterCallback(const DownloadPosterCallback& cb); | |
59 | |
60 base::WeakPtr<RendererController> GetWeakPtr() { | 48 base::WeakPtr<RendererController> GetWeakPtr() { |
61 return weak_factory_.GetWeakPtr(); | 49 return weak_factory_.GetWeakPtr(); |
62 } | 50 } |
63 | 51 |
64 // Used by AdaptiveRendererFactory to query whether to create a Media | 52 // Used by AdaptiveRendererFactory to query whether to create a Media |
65 // Remoting Renderer. | 53 // Remoting Renderer. |
66 bool remote_rendering_started() const { | 54 bool remote_rendering_started() const { |
67 DCHECK(thread_checker_.CalledOnValidThread()); | 55 DCHECK(thread_checker_.CalledOnValidThread()); |
68 return remote_rendering_started_; | 56 return remote_rendering_started_; |
69 } | 57 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 // Helper to decide whether to enter or leave Remoting mode. | 94 // Helper to decide whether to enter or leave Remoting mode. |
107 bool ShouldBeRemoting(); | 95 bool ShouldBeRemoting(); |
108 | 96 |
109 // Determines whether to enter or leave Remoting mode and switches if | 97 // Determines whether to enter or leave Remoting mode and switches if |
110 // necessary. Each call to this method could cause a remoting session to be | 98 // necessary. Each call to this method could cause a remoting session to be |
111 // started or stopped; and if that happens, the |start_trigger| or | 99 // started or stopped; and if that happens, the |start_trigger| or |
112 // |stop_trigger| must be the reason. | 100 // |stop_trigger| must be the reason. |
113 void UpdateAndMaybeSwitch(StartTrigger start_trigger, | 101 void UpdateAndMaybeSwitch(StartTrigger start_trigger, |
114 StopTrigger stop_trigger); | 102 StopTrigger stop_trigger); |
115 | 103 |
116 // Called to download the poster image. Called when: | |
117 // 1. Poster URL changes. | |
118 // 2. ShowInterstitialCallback is set. | |
119 // 3. DownloadPosterCallback is set. | |
120 void DownloadPosterImage(); | |
121 | |
122 // Called when poster image is downloaded. | |
123 void OnPosterImageDownloaded(const GURL& download_url, | |
124 base::TimeTicks download_start_time, | |
125 const SkBitmap& image); | |
126 | |
127 // Update remoting interstitial with |image|. When |image| is not set, | |
128 // interstitial will be drawn on previously downloaded poster image (in | |
129 // CourierRenderer) or black background if none was downloaded before. | |
130 // Call this when: | |
131 // 1. SetShowInterstitialCallback() is called (CourierRenderer is created). | |
132 // 2. The remoting session is shut down (to update the status message in the | |
133 // interstitial). | |
134 // 3. The size of the canvas is changed (to update the background image and | |
135 // the position of the status message). | |
136 // 4. Poster image is downloaded (to update the background image). | |
137 void UpdateInterstitial(const base::Optional<SkBitmap>& image); | |
138 | |
139 // Indicates whether this media element is in full screen. | 104 // Indicates whether this media element is in full screen. |
140 bool is_fullscreen_ = false; | 105 bool is_fullscreen_ = false; |
141 | 106 |
142 // Indicates whether remoting is started. | 107 // Indicates whether remoting is started. |
143 bool remote_rendering_started_ = false; | 108 bool remote_rendering_started_ = false; |
144 | 109 |
145 // Indicates whether audio or video is encrypted. | 110 // Indicates whether audio or video is encrypted. |
146 bool is_encrypted_ = false; | 111 bool is_encrypted_ = false; |
147 | 112 |
148 // Indicates whether remote playback is currently disabled. This starts out as | 113 // Indicates whether remote playback is currently disabled. This starts out as |
(...skipping 24 matching lines...) Expand all Loading... | |
173 // replaced with a different instance later if OnSetCdm() is called. | 138 // replaced with a different instance later if OnSetCdm() is called. |
174 scoped_refptr<SharedSession> session_; | 139 scoped_refptr<SharedSession> session_; |
175 | 140 |
176 // This is used to check all the methods are called on the current thread in | 141 // This is used to check all the methods are called on the current thread in |
177 // debug builds. | 142 // debug builds. |
178 base::ThreadChecker thread_checker_; | 143 base::ThreadChecker thread_checker_; |
179 | 144 |
180 // Current pipeline metadata. | 145 // Current pipeline metadata. |
181 PipelineMetadata pipeline_metadata_; | 146 PipelineMetadata pipeline_metadata_; |
182 | 147 |
183 // The callback to show the remoting interstitial. It is set shortly after | |
184 // remoting is started (when CourierRenderer is constructed, it calls | |
185 // SetShowInterstitialCallback()), and is reset shortly after remoting has | |
186 // ended. | |
187 ShowInterstitialCallback show_interstitial_cb_; | |
188 | |
189 // The arguments passed in the last call to the interstitial callback. On each | |
190 // call to UpdateInterstitial(), one or more of these may be changed. If any | |
191 // change, the callback will be run. | |
192 SkBitmap interstitial_background_; | |
193 gfx::Size interstitial_natural_size_; | |
194 InterstitialType interstitial_type_ = InterstitialType::BETWEEN_SESSIONS; | |
195 | |
196 // Current poster URL, whose image will feed into the local UI. | |
197 GURL poster_url_; | |
198 | |
199 // The callback to download the poster image. Called when |poster_url_| | |
200 // changes during a remoting session or the show interstial callback is set. | |
201 // OnPosterImageDownloaded() will be called when download completes. | |
202 DownloadPosterCallback download_poster_cb_; | |
203 | |
204 // Records session events of interest. | 148 // Records session events of interest. |
205 SessionMetricsRecorder metrics_recorder_; | 149 SessionMetricsRecorder metrics_recorder_; |
206 | 150 |
207 // Not own by this class. Can only be set once by calling SetClient(). | 151 // Not own by this class. Can only be set once by calling SetClient(). |
208 MediaObserverClient* client_ = nullptr; | 152 MediaObserverClient* client_ = nullptr; |
209 | 153 |
210 base::WeakPtrFactory<RendererController> weak_factory_; | 154 base::WeakPtrFactory<RendererController> weak_factory_; |
211 | 155 |
212 DISALLOW_COPY_AND_ASSIGN(RendererController); | 156 DISALLOW_COPY_AND_ASSIGN(RendererController); |
213 }; | 157 }; |
214 | 158 |
215 } // namespace remoting | 159 } // namespace remoting |
216 } // namespace media | 160 } // namespace media |
217 | 161 |
218 #endif // MEDIA_REMOTING_RENDERER_CONTROLLER_H_ | 162 #endif // MEDIA_REMOTING_RENDERER_CONTROLLER_H_ |
OLD | NEW |