Use int64_t more consistently for times, in particular for RTT values.
Existing code was inconsistent about whether to use uint16_t, int, unsigned int, or uint32_t, and sometimes silently truncated one to another, or truncated int64_t. Because most core time-handling functions use int64_t, being consistent about using int64_t unless otherwise necessary minimizes the number of explicit or implicit casts. BUG=chromium:81439 TEST=none R=henrik.lundin@webrtc.org, holmer@google.com, tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/31349004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@8045 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -18,7 +18,7 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
static const uint32_t kDefaultRttMs = 200;
|
||||
static const int64_t kDefaultRttMs = 200;
|
||||
static const int64_t kLogIntervalMs = 1000;
|
||||
static const double kWithinIncomingBitrateHysteresis = 1.05;
|
||||
|
||||
@ -66,7 +66,8 @@ int64_t AimdRateControl::GetFeedbackInterval() const {
|
||||
|
||||
bool AimdRateControl::TimeToReduceFurther(int64_t time_now,
|
||||
uint32_t incoming_bitrate_bps) const {
|
||||
const int bitrate_reduction_interval = std::max(std::min(rtt_, 200u), 10u);
|
||||
const int64_t bitrate_reduction_interval =
|
||||
std::max<int64_t>(std::min<int64_t>(rtt_, 200), 10);
|
||||
if (time_now - time_last_bitrate_change_ >= bitrate_reduction_interval) {
|
||||
return true;
|
||||
}
|
||||
@ -93,7 +94,7 @@ uint32_t AimdRateControl::UpdateBandwidthEstimate(int64_t now_ms) {
|
||||
return current_bitrate_bps_;
|
||||
}
|
||||
|
||||
void AimdRateControl::SetRtt(uint32_t rtt) {
|
||||
void AimdRateControl::SetRtt(int64_t rtt) {
|
||||
rtt_ = rtt;
|
||||
}
|
||||
|
||||
@ -168,7 +169,7 @@ uint32_t AimdRateControl::ChangeBitrate(uint32_t current_bitrate_bps,
|
||||
}
|
||||
if (rate_control_region_ == kRcNearMax) {
|
||||
// Approximate the over-use estimator delay to 100 ms.
|
||||
const uint32_t response_time = rtt_ + 100;
|
||||
const int64_t response_time = rtt_ + 100;
|
||||
uint32_t additive_increase_bps = AdditiveRateIncrease(
|
||||
now_ms, time_last_bitrate_change_, response_time);
|
||||
BWE_TEST_LOGGING_PLOT("add_increase#1", -1,
|
||||
@ -253,7 +254,7 @@ uint32_t AimdRateControl::MultiplicativeRateIncrease(
|
||||
}
|
||||
|
||||
uint32_t AimdRateControl::AdditiveRateIncrease(
|
||||
int64_t now_ms, int64_t last_ms, uint32_t response_time_ms) const {
|
||||
int64_t now_ms, int64_t last_ms, int64_t response_time_ms) const {
|
||||
assert(response_time_ms > 0);
|
||||
double beta = 0.0;
|
||||
if (last_ms > 0) {
|
||||
|
||||
@ -39,7 +39,7 @@ class AimdRateControl : public RemoteRateControl {
|
||||
int64_t time_now, uint32_t incoming_bitrate_bps) const OVERRIDE;
|
||||
virtual uint32_t LatestEstimate() const OVERRIDE;
|
||||
virtual uint32_t UpdateBandwidthEstimate(int64_t now_ms) OVERRIDE;
|
||||
virtual void SetRtt(uint32_t rtt) OVERRIDE;
|
||||
virtual void SetRtt(int64_t rtt) OVERRIDE;
|
||||
virtual RateControlRegion Update(const RateControlInput* input,
|
||||
int64_t now_ms) OVERRIDE;
|
||||
virtual void SetEstimate(int bitrate_bps, int64_t now_ms) OVERRIDE;
|
||||
@ -58,7 +58,7 @@ class AimdRateControl : public RemoteRateControl {
|
||||
uint32_t MultiplicativeRateIncrease(int64_t now_ms, int64_t last_ms,
|
||||
uint32_t current_bitrate_bps) const;
|
||||
uint32_t AdditiveRateIncrease(int64_t now_ms, int64_t last_ms,
|
||||
uint32_t response_time_ms) const;
|
||||
int64_t response_time_ms) const;
|
||||
void UpdateChangePeriod(int64_t now_ms);
|
||||
void UpdateMaxBitRateEstimate(float incoming_bit_rate_kbps);
|
||||
void ChangeState(const RateControlInput& input, int64_t now_ms);
|
||||
@ -80,7 +80,7 @@ class AimdRateControl : public RemoteRateControl {
|
||||
int64_t time_first_incoming_estimate_;
|
||||
bool bitrate_is_initialized_;
|
||||
float beta_;
|
||||
uint32_t rtt_;
|
||||
int64_t rtt_;
|
||||
int64_t time_of_last_log_;
|
||||
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(AimdRateControl);
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
const uint32_t kDefaultRttMs = 200;
|
||||
const int64_t kDefaultRttMs = 200;
|
||||
const int64_t kLogIntervalMs = 1000;
|
||||
|
||||
MimdRateControl::MimdRateControl(uint32_t min_bitrate_bps)
|
||||
@ -61,7 +61,8 @@ int64_t MimdRateControl::GetFeedbackInterval() const {
|
||||
|
||||
bool MimdRateControl::TimeToReduceFurther(int64_t time_now,
|
||||
uint32_t incoming_bitrate_bps) const {
|
||||
const int bitrate_reduction_interval = std::max(std::min(rtt_, 200u), 10u);
|
||||
const int64_t bitrate_reduction_interval =
|
||||
std::max<int64_t>(std::min<int64_t>(rtt_, 200), 10);
|
||||
if (time_now - last_bit_rate_change_ >= bitrate_reduction_interval) {
|
||||
return true;
|
||||
}
|
||||
@ -88,7 +89,7 @@ uint32_t MimdRateControl::UpdateBandwidthEstimate(int64_t now_ms) {
|
||||
return current_bit_rate_;
|
||||
}
|
||||
|
||||
void MimdRateControl::SetRtt(uint32_t rtt) {
|
||||
void MimdRateControl::SetRtt(int64_t rtt) {
|
||||
rtt_ = rtt;
|
||||
}
|
||||
|
||||
@ -156,8 +157,8 @@ uint32_t MimdRateControl::ChangeBitRate(uint32_t current_bit_rate,
|
||||
ChangeRegion(kRcAboveMax);
|
||||
}
|
||||
}
|
||||
const uint32_t response_time = static_cast<uint32_t>(avg_change_period_ +
|
||||
0.5f) + rtt_ + 300;
|
||||
const int64_t response_time =
|
||||
static_cast<int64_t>(avg_change_period_ + 0.5f) + rtt_ + 300;
|
||||
double alpha = RateIncreaseFactor(now_ms, last_bit_rate_change_,
|
||||
response_time, noise_var);
|
||||
|
||||
@ -215,9 +216,9 @@ uint32_t MimdRateControl::ChangeBitRate(uint32_t current_bit_rate,
|
||||
}
|
||||
|
||||
double MimdRateControl::RateIncreaseFactor(int64_t now_ms,
|
||||
int64_t last_ms,
|
||||
uint32_t reaction_time_ms,
|
||||
double noise_var) const {
|
||||
int64_t last_ms,
|
||||
int64_t reaction_time_ms,
|
||||
double noise_var) const {
|
||||
// alpha = 1.02 + B ./ (1 + exp(b*(tr - (c1*s2 + c2))))
|
||||
// Parameters
|
||||
const double B = 0.0407;
|
||||
|
||||
@ -33,7 +33,7 @@ class MimdRateControl : public RemoteRateControl {
|
||||
int64_t time_now, uint32_t incoming_bitrate_bps) const OVERRIDE;
|
||||
virtual uint32_t LatestEstimate() const OVERRIDE;
|
||||
virtual uint32_t UpdateBandwidthEstimate(int64_t now_ms) OVERRIDE;
|
||||
virtual void SetRtt(uint32_t rtt) OVERRIDE;
|
||||
virtual void SetRtt(int64_t rtt) OVERRIDE;
|
||||
virtual RateControlRegion Update(const RateControlInput* input,
|
||||
int64_t now_ms) OVERRIDE;
|
||||
virtual void SetEstimate(int bitrate_bps, int64_t now_ms) OVERRIDE;
|
||||
@ -45,7 +45,7 @@ class MimdRateControl : public RemoteRateControl {
|
||||
int64_t now_ms);
|
||||
double RateIncreaseFactor(int64_t now_ms,
|
||||
int64_t last_ms,
|
||||
uint32_t reaction_time_ms,
|
||||
int64_t reaction_time_ms,
|
||||
double noise_var) const;
|
||||
void UpdateChangePeriod(int64_t now_ms);
|
||||
void UpdateMaxBitRateEstimate(float incoming_bit_rate_kbps);
|
||||
@ -70,7 +70,7 @@ class MimdRateControl : public RemoteRateControl {
|
||||
float avg_change_period_;
|
||||
int64_t last_change_ms_;
|
||||
float beta_;
|
||||
uint32_t rtt_;
|
||||
int64_t rtt_;
|
||||
int64_t time_of_last_log_;
|
||||
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(MimdRateControl);
|
||||
|
||||
@ -84,7 +84,7 @@ class RemoteBitrateEstimatorAbsSendTimeImpl : public RemoteBitrateEstimator {
|
||||
// deleted.
|
||||
virtual int32_t Process() OVERRIDE;
|
||||
virtual int64_t TimeUntilNextProcess() OVERRIDE;
|
||||
virtual void OnRttUpdate(uint32_t rtt) OVERRIDE;
|
||||
virtual void OnRttUpdate(int64_t rtt) OVERRIDE;
|
||||
virtual void RemoveStream(unsigned int ssrc) OVERRIDE;
|
||||
virtual bool LatestEstimate(std::vector<unsigned int>* ssrcs,
|
||||
unsigned int* bitrate_bps) const OVERRIDE;
|
||||
@ -419,7 +419,7 @@ void RemoteBitrateEstimatorAbsSendTimeImpl::UpdateEstimate(int64_t now_ms) {
|
||||
detector_.SetRateControlRegion(region);
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorAbsSendTimeImpl::OnRttUpdate(uint32_t rtt) {
|
||||
void RemoteBitrateEstimatorAbsSendTimeImpl::OnRttUpdate(int64_t rtt) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
remote_rate_->SetRtt(rtt);
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ class RemoteBitrateEstimatorImpl : public RemoteBitrateEstimator {
|
||||
const RTPHeader& header) OVERRIDE;
|
||||
virtual int32_t Process() OVERRIDE;
|
||||
virtual int64_t TimeUntilNextProcess() OVERRIDE;
|
||||
virtual void OnRttUpdate(uint32_t rtt) OVERRIDE;
|
||||
virtual void OnRttUpdate(int64_t rtt) OVERRIDE;
|
||||
virtual void RemoveStream(unsigned int ssrc) OVERRIDE;
|
||||
virtual bool LatestEstimate(std::vector<unsigned int>* ssrcs,
|
||||
unsigned int* bitrate_bps) const OVERRIDE;
|
||||
@ -230,7 +230,7 @@ void RemoteBitrateEstimatorImpl::UpdateEstimate(int64_t now_ms) {
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteBitrateEstimatorImpl::OnRttUpdate(uint32_t rtt) {
|
||||
void RemoteBitrateEstimatorImpl::OnRttUpdate(int64_t rtt) {
|
||||
CriticalSectionScoped cs(crit_sect_.get());
|
||||
remote_rate_->SetRtt(rtt);
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ class RemoteRateControl {
|
||||
uint32_t incoming_bitrate_bps) const = 0;
|
||||
virtual uint32_t LatestEstimate() const = 0;
|
||||
virtual uint32_t UpdateBandwidthEstimate(int64_t now_ms) = 0;
|
||||
virtual void SetRtt(unsigned int rtt) = 0;
|
||||
virtual void SetRtt(int64_t rtt) = 0;
|
||||
virtual RateControlRegion Update(const RateControlInput* input,
|
||||
int64_t now_ms) = 0;
|
||||
virtual void SetEstimate(int bitrate_bps, int64_t time_now_ms) = 0;
|
||||
|
||||
Reference in New Issue
Block a user