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

Unified Diff: remoting/protocol/webrtc_frame_scheduler_simple.cc

Issue 2366053002: Account for expected capture and encode latency in WebrtcFrameSchedulerSimple (Closed)
Patch Set: Created 4 years, 3 months 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
« no previous file with comments | « remoting/protocol/webrtc_frame_scheduler_simple.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/webrtc_frame_scheduler_simple.cc
diff --git a/remoting/protocol/webrtc_frame_scheduler_simple.cc b/remoting/protocol/webrtc_frame_scheduler_simple.cc
index daedb6f3aa3d2afdc6fe737756347b3d29708790..8c40dc604b7b7fdbaec9508c4f4841fc8e3af4a5 100644
--- a/remoting/protocol/webrtc_frame_scheduler_simple.cc
+++ b/remoting/protocol/webrtc_frame_scheduler_simple.cc
@@ -13,6 +13,9 @@ namespace protocol {
namespace {
+// Number of samples used to estimate processing time for the next frame.
+const int kStatsWindow = 5;
+
const int kTargetFrameRate = 30;
constexpr base::TimeDelta kTargetFrameInterval =
base::TimeDelta::FromMilliseconds(1000 / kTargetFrameRate);
@@ -22,7 +25,8 @@ const int kTargetQuantizerForVp8TopOff = 30;
} // namespace
-WebrtcFrameSchedulerSimple::WebrtcFrameSchedulerSimple() {}
+WebrtcFrameSchedulerSimple::WebrtcFrameSchedulerSimple()
+ : frame_processing_delay_us_(kStatsWindow) {}
WebrtcFrameSchedulerSimple::~WebrtcFrameSchedulerSimple() {}
void WebrtcFrameSchedulerSimple::Start(const base::Closure& capture_callback) {
@@ -82,6 +86,9 @@ void WebrtcFrameSchedulerSimple::OnFrameEncoded(
return;
}
+ frame_processing_delay_us_.Record(
+ (base::TimeTicks::Now() - last_capture_started_time_).InMicroseconds());
+
// Top-off until the target quantizer value is reached.
top_off_is_active_ = encoded_frame.quantizer > kTargetQuantizerForVp8TopOff;
@@ -104,7 +111,10 @@ void WebrtcFrameSchedulerSimple::ScheduleNextFrame() {
// If this is not the first frame then capture next frame after the previous
// one has finished sending.
if (!last_frame_send_finish_time_.is_null()) {
- delay = std::max(base::TimeDelta(), last_frame_send_finish_time_ - now);
+ base::TimeDelta expected_processing_time =
+ base::TimeDelta::FromMicroseconds(frame_processing_delay_us_.Max());
Irfan 2016/09/27 18:04:51 assigning expected value to Max() seems confusing.
Sergey Ulanov 2016/09/27 18:49:09 I think we want to approximate the upper bound of
+ delay = std::max(base::TimeDelta(), last_frame_send_finish_time_ -
+ expected_processing_time - now);
}
// Cap interval between frames to kTargetFrameInterval.
« no previous file with comments | « remoting/protocol/webrtc_frame_scheduler_simple.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698