Chromium Code Reviews| 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_REMOTING_RENDERER_CONTROLLER_H_ | 5 #ifndef MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_ |
| 6 #define MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_ | 6 #define MEDIA_REMOTING_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/metrics.h" | |
| 12 #include "media/remoting/remoting_interstitial_ui.h" | 13 #include "media/remoting/remoting_interstitial_ui.h" |
| 13 #include "media/remoting/remoting_source_impl.h" | 14 #include "media/remoting/remoting_source_impl.h" |
| 14 #include "third_party/skia/include/core/SkBitmap.h" | 15 #include "third_party/skia/include/core/SkBitmap.h" |
| 15 | 16 |
| 16 namespace media { | 17 namespace media { |
| 17 | 18 |
| 18 namespace remoting { | 19 namespace remoting { |
| 19 class RpcBroker; | 20 class RpcBroker; |
| 20 } | 21 } |
| 21 | 22 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 const RemotingSourceImpl::DataPipeStartCallback& done_callback); | 81 const RemotingSourceImpl::DataPipeStartCallback& done_callback); |
| 81 | 82 |
| 82 // Used by RemotingRendererImpl to query the session state. | 83 // Used by RemotingRendererImpl to query the session state. |
| 83 RemotingSourceImpl* remoting_source() const { | 84 RemotingSourceImpl* remoting_source() const { |
| 84 DCHECK(thread_checker_.CalledOnValidThread()); | 85 DCHECK(thread_checker_.CalledOnValidThread()); |
| 85 return remoting_source_.get(); | 86 return remoting_source_.get(); |
| 86 } | 87 } |
| 87 | 88 |
| 88 base::WeakPtr<remoting::RpcBroker> GetRpcBroker() const; | 89 base::WeakPtr<remoting::RpcBroker> GetRpcBroker() const; |
| 89 | 90 |
| 90 // Called by RemoteRendererImpl when irregular playback is detected, which | 91 // Called by RemotingRendererImpl when it encountered a fatal error. This will |
|
xjz
2017/01/17 05:36:25
s/RemotingRendererImpl/RemoteRendererImpl
miu
2017/01/17 21:09:18
Done.
| |
| 91 // indicates either insufficient network bandwidth or the receiver cannot | 92 // cause remoting to shut down and never start back up for the lifetime of |
| 92 // handle the data volume of the content (e.g., too high resolution and/or | 93 // this controller. |
| 93 // frame rate). | 94 void OnRendererFatalError(remoting::StopTrigger stop_trigger); |
| 94 void OnIrregularPlaybackDetected(); | |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 bool has_audio() const { | 97 bool has_audio() const { |
| 98 return pipeline_metadata_.has_audio && | 98 return pipeline_metadata_.has_audio && |
| 99 pipeline_metadata_.audio_decoder_config.IsValidConfig(); | 99 pipeline_metadata_.audio_decoder_config.IsValidConfig(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool has_video() const { | 102 bool has_video() const { |
| 103 return pipeline_metadata_.has_video && | 103 return pipeline_metadata_.has_video && |
| 104 pipeline_metadata_.video_decoder_config.IsValidConfig(); | 104 pipeline_metadata_.video_decoder_config.IsValidConfig(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 bool IsVideoCodecSupported(); | 107 bool IsVideoCodecSupported(); |
| 108 bool IsAudioCodecSupported(); | 108 bool IsAudioCodecSupported(); |
| 109 bool IsRemoteSinkAvailable(); | 109 bool IsRemoteSinkAvailable(); |
| 110 | 110 |
| 111 // Helper to decide whether to enter or leave Remoting mode. | 111 // Helper to decide whether to enter or leave Remoting mode. |
| 112 bool ShouldBeRemoting(); | 112 bool ShouldBeRemoting(); |
| 113 | 113 |
| 114 // Determines whether to enter or leave Remoting mode and switches if | 114 // Determines whether to enter or leave Remoting mode and switches if |
| 115 // necessary. | 115 // necessary. Each call to this method could cause a remoting session to be |
| 116 void UpdateAndMaybeSwitch(); | 116 // started or stopped; and if that happens, the |start_trigger| or |
| 117 // |stop_trigger| must be the reason. | |
| 118 void UpdateAndMaybeSwitch(remoting::StartTrigger start_trigger, | |
| 119 remoting::StopTrigger stop_trigger); | |
| 117 | 120 |
| 118 // Called to download the poster image. Called when: | 121 // Called to download the poster image. Called when: |
| 119 // 1. Poster URL changes. | 122 // 1. Poster URL changes. |
| 120 // 2. ShowInterstitialCallback is set. | 123 // 2. ShowInterstitialCallback is set. |
| 121 // 3. DownloadPosterCallback is set. | 124 // 3. DownloadPosterCallback is set. |
| 122 void DownloadPosterImage(); | 125 void DownloadPosterImage(); |
| 123 | 126 |
| 124 // Called when poster image is downloaded. | 127 // Called when poster image is downloaded. |
| 125 void OnPosterImageDownloaded(const GURL& download_url, const SkBitmap& image); | 128 void OnPosterImageDownloaded(const GURL& download_url, |
| 129 base::TimeTicks download_start_time, | |
| 130 const SkBitmap& image); | |
| 126 | 131 |
| 127 // Update remoting interstitial with |image|. When |image| is not set, | 132 // Update remoting interstitial with |image|. When |image| is not set, |
| 128 // interstitial will be drawn on previously downloaded poster image (in | 133 // interstitial will be drawn on previously downloaded poster image (in |
| 129 // RemoteRendererImpl) or black background if none was downloaded before. | 134 // RemoteRendererImpl) or black background if none was downloaded before. |
| 130 // Call this when: | 135 // Call this when: |
| 131 // 1. SetShowInterstitialCallback() is called (RemoteRendererImpl is created). | 136 // 1. SetShowInterstitialCallback() is called (RemoteRendererImpl is created). |
| 132 // 2. The remoting session is shut down (to update the status message in the | 137 // 2. The remoting session is shut down (to update the status message in the |
| 133 // interstitial). | 138 // interstitial). |
| 134 // 3. The size of the canvas is changed (to update the background image and | 139 // 3. The size of the canvas is changed (to update the background image and |
| 135 // the position of the status message). | 140 // the position of the status message). |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 153 // Remote Playback API spec for more details: | 158 // Remote Playback API spec for more details: |
| 154 // https://w3c.github.io/remote-playback | 159 // https://w3c.github.io/remote-playback |
| 155 bool is_remote_playback_disabled_ = true; | 160 bool is_remote_playback_disabled_ = true; |
| 156 | 161 |
| 157 // Indicates whether video is the dominant visible content in the tab. | 162 // Indicates whether video is the dominant visible content in the tab. |
| 158 bool is_dominant_content_ = false; | 163 bool is_dominant_content_ = false; |
| 159 | 164 |
| 160 // Indicates whether video is paused. | 165 // Indicates whether video is paused. |
| 161 bool is_paused_ = true; | 166 bool is_paused_ = true; |
| 162 | 167 |
| 163 // Indicates whether OnIrregularPlaybackDetected() has been called. | 168 // Indicates whether OnRendererFatalError() has been called. This indicates |
| 164 bool irregular_playback_detected_ = false; | 169 // one of several possible problems: 1) An environmental problem such as |
| 170 // out-of-memory, insufficient network bandwidth, etc. 2) The receiver may | |
| 171 // have been unable to play-out the content correctly (e.g., not capable of a | |
| 172 // high frame rate at a high resolution). 3) An implementation bug. In any | |
| 173 // case, once a renderer encounters a fatal error, remoting will be shut down | |
| 174 // and never start again for the lifetime of this controller. | |
| 175 bool encountered_renderer_fatal_error_ = false; | |
| 165 | 176 |
| 166 // The callback to switch the media renderer. | 177 // The callback to switch the media renderer. |
| 167 base::Closure switch_renderer_cb_; | 178 base::Closure switch_renderer_cb_; |
| 168 | 179 |
| 169 // Called when remoting sink availability is changed. | 180 // Called when remoting sink availability is changed. |
| 170 base::Callback<void(bool)> sink_available_changed_cb_; | 181 base::Callback<void(bool)> sink_available_changed_cb_; |
| 171 | 182 |
| 172 // This is initially the RemotingSourceImpl passed to the ctor, and might be | 183 // This is initially the RemotingSourceImpl passed to the ctor, and might be |
| 173 // replaced with a different instance later if OnSetCdm() is called. | 184 // replaced with a different instance later if OnSetCdm() is called. |
| 174 scoped_refptr<RemotingSourceImpl> remoting_source_; | 185 scoped_refptr<RemotingSourceImpl> remoting_source_; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 186 ShowInterstitialCallback show_interstitial_cb_; | 197 ShowInterstitialCallback show_interstitial_cb_; |
| 187 | 198 |
| 188 // Current poster URL, whose image will feed into the local UI. | 199 // Current poster URL, whose image will feed into the local UI. |
| 189 GURL poster_url_; | 200 GURL poster_url_; |
| 190 | 201 |
| 191 // The callback to download the poster image. Called when |poster_url_| | 202 // The callback to download the poster image. Called when |poster_url_| |
| 192 // changes during a remoting session or the show interstial callback is set. | 203 // changes during a remoting session or the show interstial callback is set. |
| 193 // OnPosterImageDownloaded() will be called when download completes. | 204 // OnPosterImageDownloaded() will be called when download completes. |
| 194 DownloadPosterCallback download_poster_cb_; | 205 DownloadPosterCallback download_poster_cb_; |
| 195 | 206 |
| 207 // Records session events of interest. | |
| 208 remoting::SessionMetricsRecorder metrics_recorder_; | |
| 209 | |
| 196 base::WeakPtrFactory<RemotingRendererController> weak_factory_; | 210 base::WeakPtrFactory<RemotingRendererController> weak_factory_; |
| 197 | 211 |
| 198 DISALLOW_COPY_AND_ASSIGN(RemotingRendererController); | 212 DISALLOW_COPY_AND_ASSIGN(RemotingRendererController); |
| 199 }; | 213 }; |
| 200 | 214 |
| 201 } // namespace media | 215 } // namespace media |
| 202 | 216 |
| 203 #endif // MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_ | 217 #endif // MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_ |
| OLD | NEW |