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

Side by Side Diff: media/remoting/remoting_renderer_controller.cc

Issue 2538853002: Media Remoting: Draw remoting interstitial on poster image. (Closed)
Patch Set: Addressed xhwang's comment. Created 4 years 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 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
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 UpdateAndMaybeShowInterstitial();
miu 2016/12/20 00:48:06 Instead of calling UpdateInterstitial() here, I wo
xjz 2016/12/20 21:46:25 Done. The poster image will be downloaded here onl
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
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 }
261
262 void RemotingRendererController::UpdateAndMaybeShowInterstitial() {
miu 2016/12/20 00:48:06 naming nit: It's fine to just call this UpdateInte
xjz 2016/12/20 21:46:25 Done.
263 DCHECK(thread_checker_.CalledOnValidThread());
264 if (pipeline_metadata_.natural_size.IsEmpty())
265 return;
266
267 DCHECK(remote_rendering_started_);
268 if (poster_url_.is_empty() || download_poster_cb_.is_null()) {
269 // TODO(xjz): Draw interstitial on a black image and show it.
270 // https://codereview.chromium.org/2566223005/
271 } else {
272 download_poster_cb_.Run(
273 poster_url_,
274 base::Bind(&RemotingRendererController::PosterImageDownloaded,
275 weak_factory_.GetWeakPtr()));
miu 2016/12/20 00:48:06 Note: Recommend you pass |poster_url_| as an argum
xjz 2016/12/20 21:46:25 Done.
276 }
277 }
278
279 void RemotingRendererController::PosterImageDownloaded(const SkBitmap& image) {
miu 2016/12/20 00:48:06 naming nit: OnPosterImageDownloaded().
miu 2016/12/20 00:48:06 Recommend you double-check that the Poster URL has
xjz 2016/12/20 21:46:25 Done.
xjz 2016/12/20 21:46:25 Done.
280 DCHECK(thread_checker_.CalledOnValidThread());
281 DCHECK(remote_rendering_started_);
miu 2016/12/20 00:48:06 Since the downloading can take an unbounded amount
xjz 2016/12/20 21:46:25 Done.
282 // TODO(xjz): Draw interstitial on |image| and show it.
283 // https://codereview.chromium.org/2566223005/
284 }
285
246 } // namespace media 286 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698