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

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

Issue 2475643004: Monitor the intersection of video and viewport. (Closed)
Patch Set: Addressed comments. Observe intersection changing. Created 4 years, 1 month 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_controller.h" 5 #include "media/remoting/remoting_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 UpdateAndMaybeSwitch(); 135 UpdateAndMaybeSwitch();
136 } 136 }
137 137
138 void RemotingController::OnExitedFullscreen() { 138 void RemotingController::OnExitedFullscreen() {
139 DCHECK(task_runner_->BelongsToCurrentThread()); 139 DCHECK(task_runner_->BelongsToCurrentThread());
140 140
141 is_fullscreen_ = false; 141 is_fullscreen_ = false;
142 UpdateAndMaybeSwitch(); 142 UpdateAndMaybeSwitch();
143 } 143 }
144 144
145 void RemotingController::OnVideoViewportIntersectionChanged(
146 const ViewportIntersectionInfo& info) {
147 DCHECK(task_runner_->BelongsToCurrentThread());
148
149 // Reset on any notification, since this indicates the user is scrolling
150 // around in the document, the document is changing layout, etc.
151 viewport_fill_debouncer_timer_.Stop();
152
153 // Dropping below the threshold should instantly stop remote rendering.
154 if (info.ratio < 0.85) {
155 if (is_mostly_filling_viewport_) {
156 is_mostly_filling_viewport_ = false;
157 UpdateAndMaybeSwitch();
158 }
159 return;
160 }
161
162 // Meeting/Exceeding the threshold should hold steady for 5 seconds before
163 // starting remote rendering.
164 if (!is_mostly_filling_viewport_) {
165 viewport_fill_debouncer_timer_.Start(
166 FROM_HERE, base::TimeDelta::FromSeconds(5),
167 base::Bind(&RemotingController::OnViewportMostlyFilledAndUnchanging,
168 weak_factory_.GetWeakPtr()));
169 }
170 }
171
172 void RemotingController::OnViewportMostlyFilledAndUnchanging() {
173 is_mostly_filling_viewport_ = true;
174 UpdateAndMaybeSwitch();
175 }
176
145 void RemotingController::OnSetCdm(CdmContext* cdm_context) { 177 void RemotingController::OnSetCdm(CdmContext* cdm_context) {
146 DCHECK(task_runner_->BelongsToCurrentThread()); 178 DCHECK(task_runner_->BelongsToCurrentThread());
147 179
148 // TODO(xjz): Not implemented. Will add in up-coming change. 180 // TODO(xjz): Not implemented. Will add in up-coming change.
149 NOTIMPLEMENTED(); 181 NOTIMPLEMENTED();
150 } 182 }
151 183
152 void RemotingController::SetSwitchRendererCallback( 184 void RemotingController::SetSwitchRendererCallback(
153 const SwitchRendererCallback& cb) { 185 const SwitchRendererCallback& cb) {
154 DCHECK(task_runner_->BelongsToCurrentThread()); 186 DCHECK(task_runner_->BelongsToCurrentThread());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 257
226 bool RemotingController::ShouldBeRemoting() { 258 bool RemotingController::ShouldBeRemoting() {
227 DCHECK(task_runner_->BelongsToCurrentThread()); 259 DCHECK(task_runner_->BelongsToCurrentThread());
228 260
229 // TODO(xjz): The control logic for EME will be added in a later CL. 261 // TODO(xjz): The control logic for EME will be added in a later CL.
230 if (is_encrypted_) 262 if (is_encrypted_)
231 return false; 263 return false;
232 264
233 if (!is_sink_available_) 265 if (!is_sink_available_)
234 return false; 266 return false;
235 if (!is_fullscreen_)
236 return false;
237 if (has_video_ && !IsVideoCodecSupported()) 267 if (has_video_ && !IsVideoCodecSupported())
238 return false; 268 return false;
239 if (has_audio_ && !IsAudioCodecSupported()) 269 if (has_audio_ && !IsAudioCodecSupported())
240 return false; 270 return false;
241 return true; 271 return is_fullscreen_ || is_mostly_filling_viewport_;
242 } 272 }
243 273
244 void RemotingController::UpdateAndMaybeSwitch() { 274 void RemotingController::UpdateAndMaybeSwitch() {
245 DCHECK(task_runner_->BelongsToCurrentThread()); 275 DCHECK(task_runner_->BelongsToCurrentThread());
246 276
247 // TODO(xjz): The switching logic for encrypted content will be added in a 277 // TODO(xjz): The switching logic for encrypted content will be added in a
248 // later CL. 278 // later CL.
249 279
250 // Demuxer is not initialized yet. 280 // Demuxer is not initialized yet.
251 if (!has_audio_ && !has_video_) 281 if (!has_audio_ && !has_video_)
(...skipping 11 matching lines...) Expand all
263 // |swithc_renderer_cb_.Run()| will be called after remoting is started 293 // |swithc_renderer_cb_.Run()| will be called after remoting is started
264 // successfully. 294 // successfully.
265 remoter_->Start(); 295 remoter_->Start();
266 } else { 296 } else {
267 switch_renderer_cb_.Run(); 297 switch_renderer_cb_.Run();
268 remoter_->Stop(mojom::RemotingStopReason::LOCAL_PLAYBACK); 298 remoter_->Stop(mojom::RemotingStopReason::LOCAL_PLAYBACK);
269 } 299 }
270 } 300 }
271 301
272 } // namespace media 302 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698