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

Unified Diff: media/remoting/remoting_controller.cc

Issue 2475643004: Monitor the intersection of video and viewport. (Closed)
Patch Set: Addressed miu's comments. 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 side-by-side diff with in-line comments
Download patch
Index: media/remoting/remoting_controller.cc
diff --git a/media/remoting/remoting_controller.cc b/media/remoting/remoting_controller.cc
index 73c372f68673518e429677979a24dbd83fd66864..3511e1cc683ff83e563fbb2602accc6a17590c1f 100644
--- a/media/remoting/remoting_controller.cc
+++ b/media/remoting/remoting_controller.cc
@@ -142,6 +142,37 @@ void RemotingController::OnExitedFullscreen() {
UpdateAndMaybeSwitch();
}
+void RemotingController::OnVideoViewportRatioChanged(float ratio) {
+ DCHECK(task_runner_->BelongsToCurrentThread());
+
+ // Reset on any notification, since this indicates the user is scrolling
+ // around in the document, the document is changing layout, etc.
+ viewport_fill_debouncer_timer_.Stop();
+
+ // Dropping below the threshold should instantly stop remote rendering.
+ if (ratio < 0.85) {
+ if (is_mostly_filling_viewport_) {
+ is_mostly_filling_viewport_ = false;
+ UpdateAndMaybeSwitch();
+ }
+ return;
+ }
+
+ // Meeting/Exceeding the threshold should hold steady for 5 seconds before
+ // starting remote rendering.
+ if (!is_mostly_filling_viewport_) {
+ viewport_fill_debouncer_timer_.Start(
+ FROM_HERE, base::TimeDelta::FromSeconds(5),
+ base::Bind(&RemotingController::OnViewportMostlyFilledAndUnchanging,
+ weak_factory_.GetWeakPtr()));
+ }
+}
+
+void RemotingController::OnViewportMostlyFilledAndUnchanging() {
+ is_mostly_filling_viewport_ = true;
+ UpdateAndMaybeSwitch();
+}
+
void RemotingController::OnSetCdm(CdmContext* cdm_context) {
DCHECK(task_runner_->BelongsToCurrentThread());
@@ -232,13 +263,11 @@ bool RemotingController::ShouldBeRemoting() {
if (!is_sink_available_)
return false;
- if (!is_fullscreen_)
- return false;
if (has_video_ && !IsVideoCodecSupported())
return false;
if (has_audio_ && !IsAudioCodecSupported())
return false;
- return true;
+ return is_fullscreen_ || is_mostly_filling_viewport_;
}
void RemotingController::UpdateAndMaybeSwitch() {

Powered by Google App Engine
This is Rietveld 408576698