Index: webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc |
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc b/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc |
index b08b30a8ce0b856aed2310bc9c36cc00892ce01d..55e1abebd1625402e8d1358a99c4f0825719e771 100644 |
--- a/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc |
+++ b/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc |
@@ -11,6 +11,7 @@ |
#include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" |
#include <limits> |
+#include <utility> |
#include "webrtc/base/checks.h" |
#include "webrtc/base/logging.h" |
@@ -22,7 +23,11 @@ |
namespace webrtc { |
// TODO(sprang): Tune these! |
-const int RemoteEstimatorProxy::kDefaultProcessIntervalMs = 50; |
+const int RemoteEstimatorProxy::kHighBitrateProcessIntervalMs = 50; |
+const int RemoteEstimatorProxy::kLowBitrateProcessIntervalMs = 200; |
+const int RemoteEstimatorProxy::kSwitchToLowBitrateProcessIntervalBps = 50000; |
+const int RemoteEstimatorProxy::kSwitchToHighBitrateProcessIntervalBps = 100000; |
stefan-webrtc
2016/10/17 18:55:21
I'm starting to lean towards making the interval a
|
+const int RemoteEstimatorProxy::kMinPacketCountRecievedBitrate = 50; |
const int RemoteEstimatorProxy::kBackWindowMs = 500; |
// The maximum allowed value for a timestamp in milliseconds. This is lower |
@@ -30,14 +35,18 @@ const int RemoteEstimatorProxy::kBackWindowMs = 500; |
static constexpr int64_t kMaxTimeMs = |
std::numeric_limits<int64_t>::max() / 1000; |
-RemoteEstimatorProxy::RemoteEstimatorProxy(Clock* clock, |
- PacketRouter* packet_router) |
+RemoteEstimatorProxy::RemoteEstimatorProxy( |
+ Clock* clock, |
+ PacketRouter* packet_router, |
+ std::unique_ptr<rtc::RateTracker> recieved_bitrate_tracker) |
: clock_(clock), |
packet_router_(packet_router), |
last_process_time_ms_(-1), |
media_ssrc_(0), |
feedback_sequence_(0), |
- window_start_seq_(-1) {} |
+ window_start_seq_(-1), |
+ process_interval_ms_(kHighBitrateProcessIntervalMs), |
+ received_bitrate_tracker_bps_(std::move(recieved_bitrate_tracker)) {} |
RemoteEstimatorProxy::~RemoteEstimatorProxy() {} |
@@ -58,7 +67,7 @@ void RemoteEstimatorProxy::IncomingPacket(int64_t arrival_time_ms, |
} |
rtc::CritScope cs(&lock_); |
media_ssrc_ = header.ssrc; |
- |
+ received_bitrate_tracker_bps_->AddSamples(payload_size * 8); |
OnPacketArrival(header.extension.transportSequenceNumber, arrival_time_ms); |
} |
@@ -70,9 +79,20 @@ bool RemoteEstimatorProxy::LatestEstimate(std::vector<unsigned int>* ssrcs, |
int64_t RemoteEstimatorProxy::TimeUntilNextProcess() { |
int64_t now = clock_->TimeInMilliseconds(); |
int64_t time_until_next = 0; |
+ { |
+ rtc::CritScope cs(&lock_); |
+ if (received_bitrate_tracker_bps_->TotalSampleCount() > |
+ kMinPacketCountRecievedBitrate) { |
+ double recieved_bitrate = received_bitrate_tracker_bps_->ComputeRate(); |
+ if (recieved_bitrate <= kSwitchToLowBitrateProcessIntervalBps) |
+ process_interval_ms_ = kLowBitrateProcessIntervalMs; |
+ if (recieved_bitrate >= kSwitchToHighBitrateProcessIntervalBps) |
+ process_interval_ms_ = kHighBitrateProcessIntervalMs; |
+ } |
+ } |
if (last_process_time_ms_ != -1 && |
- now - last_process_time_ms_ < kDefaultProcessIntervalMs) { |
- time_until_next = (last_process_time_ms_ + kDefaultProcessIntervalMs - now); |
+ now - last_process_time_ms_ < process_interval_ms_) { |
+ time_until_next = (last_process_time_ms_ + process_interval_ms_ - now); |
} |
return time_until_next; |
} |