| 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..85ef1dd16c4ee310d8993b632cf1a4eca9f06b3c 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 <algorithm>
|
|
|
| #include "webrtc/base/checks.h"
|
| #include "webrtc/base/logging.h"
|
| @@ -22,8 +23,10 @@
|
| namespace webrtc {
|
|
|
| // TODO(sprang): Tune these!
|
| -const int RemoteEstimatorProxy::kDefaultProcessIntervalMs = 50;
|
| const int RemoteEstimatorProxy::kBackWindowMs = 500;
|
| +const int RemoteEstimatorProxy::kMinSendIntervalMs = 50;
|
| +const int RemoteEstimatorProxy::kMaxSendIntervalMs = 250;
|
| +const int RemoteEstimatorProxy::kDefaultSendIntervalMs = 100;
|
|
|
| // The maximum allowed value for a timestamp in milliseconds. This is lower
|
| // than the numerical limit since we often convert to microseconds.
|
| @@ -37,7 +40,8 @@ RemoteEstimatorProxy::RemoteEstimatorProxy(Clock* clock,
|
| last_process_time_ms_(-1),
|
| media_ssrc_(0),
|
| feedback_sequence_(0),
|
| - window_start_seq_(-1) {}
|
| + window_start_seq_(-1),
|
| + send_interval_ms_(kDefaultSendIntervalMs) {}
|
|
|
| RemoteEstimatorProxy::~RemoteEstimatorProxy() {}
|
|
|
| @@ -68,11 +72,12 @@ bool RemoteEstimatorProxy::LatestEstimate(std::vector<unsigned int>* ssrcs,
|
| }
|
|
|
| int64_t RemoteEstimatorProxy::TimeUntilNextProcess() {
|
| - int64_t now = clock_->TimeInMilliseconds();
|
| int64_t time_until_next = 0;
|
| - if (last_process_time_ms_ != -1 &&
|
| - now - last_process_time_ms_ < kDefaultProcessIntervalMs) {
|
| - time_until_next = (last_process_time_ms_ + kDefaultProcessIntervalMs - now);
|
| + if (last_process_time_ms_ != -1) {
|
| + rtc::CritScope cs(&lock_);
|
| + int64_t now = clock_->TimeInMilliseconds();
|
| + if (now - last_process_time_ms_ < send_interval_ms_)
|
| + time_until_next = (last_process_time_ms_ + send_interval_ms_ - now);
|
| }
|
| return time_until_next;
|
| }
|
| @@ -92,6 +97,23 @@ void RemoteEstimatorProxy::Process() {
|
| }
|
| }
|
|
|
| +void RemoteEstimatorProxy::OnBitrateChanged(int bitrate_bps) {
|
| + // TwccReportSize = Ipv4(20B) + UDP(8B) + SRTP(10B) +
|
| + // AverageTwccReport(30B)
|
| + // TwccReport size at 50ms interval is 24 byte.
|
| + // TwccReport size at 250ms interval is 36 byte.
|
| + // AverageTwccReport = (TwccReport(50ms) + TwccReport(250ms)) / 2
|
| + constexpr int kTwccReportSize = 20 + 8 + 10 + 30;
|
| +
|
| + // Let TWCC reports occupy 5% of total bandwidth.
|
| + rtc::CritScope cs(&lock_);
|
| + send_interval_ms_ = std::min(
|
| + std::max(static_cast<int>(
|
| + kTwccReportSize * 8.0 * 1000.0 / (0.05 * bitrate_bps) + 0.5),
|
| + kMinSendIntervalMs),
|
| + kMaxSendIntervalMs);
|
| +}
|
| +
|
| void RemoteEstimatorProxy::OnPacketArrival(uint16_t sequence_number,
|
| int64_t arrival_time) {
|
| if (arrival_time < 0 || arrival_time > kMaxTimeMs) {
|
|
|