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 #include "media/remoting/remoting_renderer_controller.h" | 5 #include "media/remoting/remoting_renderer_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/threading/thread_checker.h" | 9 #include "base/threading/thread_checker.h" |
| 10 #include "media/remoting/remoting_cdm_context.h" | 10 #include "media/remoting/remoting_cdm_context.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 auto* remoting_cdm_context = RemotingCdmContext::From(cdm_context); | 66 auto* remoting_cdm_context = RemotingCdmContext::From(cdm_context); |
| 67 if (!remoting_cdm_context) | 67 if (!remoting_cdm_context) |
| 68 return; | 68 return; |
| 69 | 69 |
| 70 remoting_source_->RemoveClient(this); | 70 remoting_source_->RemoveClient(this); |
| 71 remoting_source_ = remoting_cdm_context->GetRemotingSource(); | 71 remoting_source_ = remoting_cdm_context->GetRemotingSource(); |
| 72 remoting_source_->AddClient(this); // Calls OnSessionStateChanged(). | 72 remoting_source_->AddClient(this); // Calls OnSessionStateChanged(). |
| 73 UpdateAndMaybeSwitch(); | 73 UpdateAndMaybeSwitch(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void RemotingRendererController::OnSetPoster(const GURL& poster_url) { | |
| 77 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 78 | |
| 79 if (poster_url != poster_url_) { | |
| 80 poster_url_ = poster_url; | |
| 81 DownloadPosterImage(); | |
|
miu
2016/12/22 02:04:02
What if the URL is set to empty (i.e., the web pag
xjz
2016/12/22 20:13:08
This case is really an edge case as the poster ima
xjz
2016/12/22 23:21:12
Done. As chatted face to face, change UpdateInters
| |
| 82 } | |
| 83 } | |
| 84 | |
| 76 void RemotingRendererController::SetSwitchRendererCallback( | 85 void RemotingRendererController::SetSwitchRendererCallback( |
| 77 const base::Closure& cb) { | 86 const base::Closure& cb) { |
| 78 DCHECK(thread_checker_.CalledOnValidThread()); | 87 DCHECK(thread_checker_.CalledOnValidThread()); |
| 79 DCHECK(!cb.is_null()); | 88 DCHECK(!cb.is_null()); |
| 80 | 89 |
| 81 switch_renderer_cb_ = cb; | 90 switch_renderer_cb_ = cb; |
| 82 UpdateAndMaybeSwitch(); | 91 UpdateAndMaybeSwitch(); |
| 83 } | 92 } |
| 84 | 93 |
| 85 base::WeakPtr<remoting::RpcBroker> RemotingRendererController::GetRpcBroker() | 94 base::WeakPtr<remoting::RpcBroker> RemotingRendererController::GetRpcBroker() |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 // For encrypted content, it's only valid to switch to remoting renderer, | 245 // For encrypted content, it's only valid to switch to remoting renderer, |
| 237 // and never back to the local renderer. The RemotingCdmController will | 246 // and never back to the local renderer. The RemotingCdmController will |
| 238 // force-stop the session when remoting has ended; so no need to call | 247 // force-stop the session when remoting has ended; so no need to call |
| 239 // StopRemoting() from here. | 248 // StopRemoting() from here. |
| 240 DCHECK(!is_encrypted_); | 249 DCHECK(!is_encrypted_); |
| 241 switch_renderer_cb_.Run(); | 250 switch_renderer_cb_.Run(); |
| 242 remoting_source_->StopRemoting(this); | 251 remoting_source_->StopRemoting(this); |
| 243 } | 252 } |
| 244 } | 253 } |
| 245 | 254 |
| 255 void RemotingRendererController::SetDownloadPosterCallback( | |
| 256 const DownloadPosterCallback& cb) { | |
| 257 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 258 DCHECK(download_poster_cb_.is_null()); | |
| 259 download_poster_cb_ = cb; | |
| 260 DownloadPosterImage(); | |
|
miu
2016/12/22 02:04:02
Along the lines of my previous comment:
if (!po
xjz
2016/12/22 23:21:12
Done.
| |
| 261 } | |
| 262 | |
| 263 void RemotingRendererController::UpdateInterstitial(const SkBitmap& image) { | |
| 264 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 265 if (pipeline_metadata_.natural_size.IsEmpty() || !remote_rendering_started_) | |
| 266 return; | |
| 267 | |
| 268 // TODO(xjz): Update interstitial. | |
| 269 // https://codereview.chromium.org/2566223005/ | |
| 270 } | |
| 271 | |
| 272 void RemotingRendererController::DownloadPosterImage() { | |
| 273 // TODO(xjz): early return if show interstitial callback is not set. | |
| 274 if (download_poster_cb_.is_null() || poster_url_.is_empty()) | |
|
miu
2016/12/22 02:04:02
nit: Suggest taking out the "|| poster_url_.is_emp
xjz
2016/12/22 23:21:11
Done.
| |
| 275 return; | |
| 276 | |
| 277 download_poster_cb_.Run( | |
| 278 poster_url_, | |
| 279 base::Bind(&RemotingRendererController::OnPosterImageDownloaded, | |
| 280 weak_factory_.GetWeakPtr(), poster_url_)); | |
| 281 } | |
| 282 | |
| 283 void RemotingRendererController::OnPosterImageDownloaded( | |
| 284 const GURL& download_url, | |
| 285 const SkBitmap& image) { | |
| 286 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 287 | |
| 288 if (download_url != poster_url_) | |
| 289 return; // The poster image URL has changed during the download. | |
| 290 UpdateInterstitial(image); | |
| 291 } | |
| 292 | |
| 246 } // namespace media | 293 } // namespace media |
| OLD | NEW |