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

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

Issue 2538853002: Media Remoting: Draw remoting interstitial on poster image. (Closed)
Patch Set: Addressed comments. 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
« no previous file with comments | « media/remoting/remoting_renderer_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 const GURL old_url = poster_url_;
80 poster_url_ = poster_url;
81
82 // TODO(xjz): Only download the image when we need to draw/update remoting
miu 2016/12/20 23:34:22 I'm not sure this is what we would want. It could
xjz 2016/12/21 01:28:40 hmm, I think we don't want to download and keep a
83 // interstitial. Early return if the show interstitial callback is not set.
84 // https://codereview.chromium.org/2566223005/.
85 if (download_poster_cb_.is_null())
86 return;
87
88 if (old_url != poster_url_) {
89 download_poster_cb_.Run(
90 poster_url_,
91 base::Bind(&RemotingRendererController::OnPosterImageDownloaded,
92 weak_factory_.GetWeakPtr(), poster_url_));
93 }
94 }
95
76 void RemotingRendererController::SetSwitchRendererCallback( 96 void RemotingRendererController::SetSwitchRendererCallback(
77 const base::Closure& cb) { 97 const base::Closure& cb) {
78 DCHECK(thread_checker_.CalledOnValidThread()); 98 DCHECK(thread_checker_.CalledOnValidThread());
79 DCHECK(!cb.is_null()); 99 DCHECK(!cb.is_null());
80 100
81 switch_renderer_cb_ = cb; 101 switch_renderer_cb_ = cb;
82 UpdateAndMaybeSwitch(); 102 UpdateAndMaybeSwitch();
83 } 103 }
84 104
85 base::WeakPtr<remoting::RpcBroker> RemotingRendererController::GetRpcBroker() 105 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, 256 // For encrypted content, it's only valid to switch to remoting renderer,
237 // and never back to the local renderer. The RemotingCdmController will 257 // and never back to the local renderer. The RemotingCdmController will
238 // force-stop the session when remoting has ended; so no need to call 258 // force-stop the session when remoting has ended; so no need to call
239 // StopRemoting() from here. 259 // StopRemoting() from here.
240 DCHECK(!is_encrypted_); 260 DCHECK(!is_encrypted_);
241 switch_renderer_cb_.Run(); 261 switch_renderer_cb_.Run();
242 remoting_source_->StopRemoting(this); 262 remoting_source_->StopRemoting(this);
243 } 263 }
244 } 264 }
245 265
266 void RemotingRendererController::SetDownloadPosterCallback(
267 const DownloadPosterCallback& cb) {
268 DCHECK(thread_checker_.CalledOnValidThread());
269 DCHECK(download_poster_cb_.is_null());
270 download_poster_cb_ = cb;
miu 2016/12/20 23:34:22 This just occurred to me: What if the poster URL i
xjz 2016/12/21 01:28:40 Done. I didn't realize this. Thanks for pointing t
271 }
272
273 void RemotingRendererController::UpdateInterstitial(const SkBitmap& image) {
274 DCHECK(thread_checker_.CalledOnValidThread());
275 if (pipeline_metadata_.natural_size.IsEmpty() || !remote_rendering_started_)
276 return;
277
278 // TODO(xjz): Update interstitial.
279 // https://codereview.chromium.org/2566223005/
280 }
281
282 void RemotingRendererController::OnPosterImageDownloaded(
283 const GURL& download_url,
284 const SkBitmap& image) {
285 DCHECK(thread_checker_.CalledOnValidThread());
286
287 if (download_url != poster_url_)
288 return; // The poster image URL has changed during the download.
289 UpdateInterstitial(image);
290 }
291
246 } // namespace media 292 } // namespace media
OLDNEW
« no previous file with comments | « media/remoting/remoting_renderer_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698