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..7542c47513c1a28c013323c1b871d21af3336223 100644 |
--- a/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc |
+++ b/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc |
@@ -11,10 +11,12 @@ |
#include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" |
#include <limits> |
+#include <algorithm> |
#include "webrtc/base/checks.h" |
#include "webrtc/base/logging.h" |
#include "webrtc/system_wrappers/include/clock.h" |
+#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
#include "webrtc/modules/pacing/packet_router.h" |
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
@@ -22,22 +24,27 @@ |
namespace webrtc { |
// TODO(sprang): Tune these! |
-const int RemoteEstimatorProxy::kDefaultProcessIntervalMs = 50; |
+const int RemoteEstimatorProxy::kMinPacketCountRecievedBitrate = 50; |
const int RemoteEstimatorProxy::kBackWindowMs = 500; |
+const int RemoteEstimatorProxy::kMinSendIntervalMs = 50; |
+const int RemoteEstimatorProxy::kMaxSendIntervalMs = 250; |
// The maximum allowed value for a timestamp in milliseconds. This is lower |
// than the numerical limit since we often convert to microseconds. |
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, |
+ BitrateController* bitrate_controller) |
: 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), |
+ bitrate_controller_(bitrate_controller) {} |
RemoteEstimatorProxy::~RemoteEstimatorProxy() {} |
@@ -70,9 +77,17 @@ 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) { |
+ uint32_t bitrate = 0; |
+ bitrate_controller_->AvailableBandwidth(&bitrate); |
+ // Ipv4(20B) + UDP(8B) + SRTP(4B) + AverageTwccReport(20B) |
stefan-webrtc
2016/10/26 14:45:16
Is SRTP always 4B?
michaelt
2016/10/27 15:15:44
No i depends on the crypto. which is used. Will ta
stefan-webrtc
2016/10/31 08:54:36
Could you also add a short comment on how you deri
michaelt
2016/10/31 13:03:15
Did a mistake in the first measurement. I used the
stefan-webrtc
2016/10/31 14:04:19
I see. Could you just add a comment on that so tha
michaelt
2016/11/02 10:10:06
Done.
|
+ constexpr int kTwccReportSize = 20 + 8 + 4 + 20; |
+ int send_interval_ms = |
+ kTwccReportSize * 8.0 * 1000.0 / (0.05 * bitrate) + 0.5; |
stefan-webrtc
2016/10/26 14:45:16
You may have to explicitly cast to int.
michaelt
2016/10/27 15:15:44
Ok
|
+ send_interval_ms = std::min(std::max(send_interval_ms, kMinSendIntervalMs), |
+ kMaxSendIntervalMs); |
+ if (now - last_process_time_ms_ < send_interval_ms) |
+ time_until_next = (last_process_time_ms_ + send_interval_ms - now); |
} |
return time_until_next; |
} |