Simple CL to fix lint errors in webrtc/modules/remote_bitrate_estimator. Added the lint check for the folder to the presubmit script.
BUG=webrtc:5310
Review URL: https://codereview.webrtc.org/1520513003
Cr-Commit-Position: refs/heads/master@{#11021}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index cd356ca..9db9d82 100755
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -20,6 +20,7 @@
'webrtc/call',
'webrtc/common_video',
'webrtc/examples',
+ 'webrtc/modules/remote_bitrate_estimator',
'webrtc/modules/video_processing',
'webrtc/sound',
'webrtc/tools',
diff --git a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc
index 2d55732..4820e62 100644
--- a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc
+++ b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc
@@ -88,8 +88,7 @@
uint32_t AimdRateControl::UpdateBandwidthEstimate(int64_t now_ms) {
current_bitrate_bps_ = ChangeBitrate(current_bitrate_bps_,
- current_input_._incomingBitRate,
- now_ms);
+ current_input_.incoming_bitrate, now_ms);
if (now_ms - time_of_last_log_ > kLogIntervalMs) {
time_of_last_log_ = now_ms;
}
@@ -109,21 +108,21 @@
const int64_t kInitializationTimeMs = 5000;
RTC_DCHECK_LE(kBitrateWindowMs, kInitializationTimeMs);
if (time_first_incoming_estimate_ < 0) {
- if (input->_incomingBitRate > 0) {
+ if (input->incoming_bitrate > 0) {
time_first_incoming_estimate_ = now_ms;
}
} else if (now_ms - time_first_incoming_estimate_ > kInitializationTimeMs &&
- input->_incomingBitRate > 0) {
- current_bitrate_bps_ = input->_incomingBitRate;
+ input->incoming_bitrate > 0) {
+ current_bitrate_bps_ = input->incoming_bitrate;
bitrate_is_initialized_ = true;
}
}
- if (updated_ && current_input_._bwState == kBwOverusing) {
+ if (updated_ && current_input_.bw_state == kBwOverusing) {
// Only update delay factor and incoming bit rate. We always want to react
// on an over-use.
- current_input_._noiseVar = input->_noiseVar;
- current_input_._incomingBitRate = input->_incomingBitRate;
+ current_input_.noise_var = input->noise_var;
+ current_input_.incoming_bitrate = input->incoming_bitrate;
} else {
updated_ = true;
current_input_ = *input;
@@ -145,7 +144,7 @@
// An over-use should always trigger us to reduce the bitrate, even though
// we have not yet established our first estimate. By acting on the over-use,
// we will end up with a valid estimate.
- if (!bitrate_is_initialized_ && current_input_._bwState != kBwOverusing)
+ if (!bitrate_is_initialized_ && current_input_.bw_state != kBwOverusing)
return current_bitrate_bps_;
updated_ = false;
ChangeState(current_input_, now_ms);
@@ -284,7 +283,7 @@
void AimdRateControl::ChangeState(const RateControlInput& input,
int64_t now_ms) {
- switch (current_input_._bwState) {
+ switch (current_input_.bw_state) {
case kBwNormal:
if (rate_control_state_ == kRcHold) {
time_last_bitrate_change_ = now_ms;
diff --git a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h
index bc5ca41..93ae219 100644
--- a/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h
+++ b/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h
@@ -84,4 +84,4 @@
};
} // namespace webrtc
-#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_AIMD_RATE_CONTROL_H_
+#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_AIMD_RATE_CONTROL_H_
diff --git a/webrtc/modules/remote_bitrate_estimator/bwe_simulations.cc b/webrtc/modules/remote_bitrate_estimator/bwe_simulations.cc
index 309ff8d..11fd64f 100644
--- a/webrtc/modules/remote_bitrate_estimator/bwe_simulations.cc
+++ b/webrtc/modules/remote_bitrate_estimator/bwe_simulations.cc
@@ -74,7 +74,6 @@
}
TEST_P(BweSimulation, Choke1000kbps500kbps1000kbpsBiDirectional) {
-
const int kFlowIds[] = {0, 1};
const size_t kNumFlows = sizeof(kFlowIds) / sizeof(kFlowIds[0]);
@@ -106,7 +105,6 @@
}
TEST_P(BweSimulation, Choke1000kbps500kbps1000kbps) {
-
AdaptiveVideoSource source(0, 30, 300, 0, 0);
VideoSender sender(&uplink_, &source, GetParam());
ChokeFilter choke(&uplink_, 0);
@@ -243,7 +241,7 @@
}
TEST_P(BweSimulation, SelfFairnessTest) {
- srand(Clock::GetRealTimeClock()->TimeInMicroseconds());
+ Random prng(Clock::GetRealTimeClock()->TimeInMicroseconds());
const int kAllFlowIds[] = {0, 1, 2, 3};
const size_t kNumFlows = sizeof(kAllFlowIds) / sizeof(kAllFlowIds[0]);
rtc::scoped_ptr<VideoSource> sources[kNumFlows];
@@ -252,7 +250,7 @@
// Streams started 20 seconds apart to give them different advantage when
// competing for the bandwidth.
sources[i].reset(new AdaptiveVideoSource(kAllFlowIds[i], 30, 300, 0,
- i * (rand() % 40000)));
+ i * prng.Rand(39999)));
senders[i].reset(new VideoSender(&uplink_, sources[i].get(), GetParam()));
}
diff --git a/webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h b/webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h
index 844fde5..3fb7e29 100644
--- a/webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h
+++ b/webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h
@@ -8,53 +8,40 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_BWE_DEFINES_H_
-#define WEBRTC_MODULES_RTP_RTCP_SOURCE_BWE_DEFINES_H_
+#ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_BWE_DEFINES_H_
+#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_BWE_DEFINES_H_
#include "webrtc/typedefs.h"
-#define BWE_MAX(a,b) ((a)>(b)?(a):(b))
-#define BWE_MIN(a,b) ((a)<(b)?(a):(b))
+#define BWE_MAX(a, b) ((a) > (b) ? (a) : (b))
+#define BWE_MIN(a, b) ((a) < (b) ? (a) : (b))
namespace webrtc {
static const int64_t kBitrateWindowMs = 1000;
-enum BandwidthUsage
-{
- kBwNormal = 0,
- kBwUnderusing = 1,
- kBwOverusing = 2,
+enum BandwidthUsage {
+ kBwNormal = 0,
+ kBwUnderusing = 1,
+ kBwOverusing = 2,
};
-enum RateControlState
-{
- kRcHold,
- kRcIncrease,
- kRcDecrease
-};
+enum RateControlState { kRcHold, kRcIncrease, kRcDecrease };
-enum RateControlRegion
-{
- kRcNearMax,
- kRcAboveMax,
- kRcMaxUnknown
-};
+enum RateControlRegion { kRcNearMax, kRcAboveMax, kRcMaxUnknown };
-class RateControlInput
-{
-public:
- RateControlInput(BandwidthUsage bwState,
- uint32_t incomingBitRate,
- double noiseVar)
- : _bwState(bwState),
- _incomingBitRate(incomingBitRate),
- _noiseVar(noiseVar) {}
+struct RateControlInput {
+ RateControlInput(BandwidthUsage bw_state,
+ uint32_t incoming_bitrate,
+ double noise_var)
+ : bw_state(bw_state),
+ incoming_bitrate(incoming_bitrate),
+ noise_var(noise_var) {}
- BandwidthUsage _bwState;
- uint32_t _incomingBitRate;
- double _noiseVar;
+ BandwidthUsage bw_state;
+ uint32_t incoming_bitrate;
+ double noise_var;
};
} // namespace webrtc
-#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_BWE_DEFINES_H_
+#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_BWE_DEFINES_H_
diff --git a/webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitrate_observer.h b/webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitrate_observer.h
index edfac97..ae05912 100644
--- a/webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitrate_observer.h
+++ b/webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitrate_observer.h
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_MOCK_MOCK_REMOTE_BITRATE_ESTIMATOR_H_
-#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_MOCK_MOCK_REMOTE_BITRATE_ESTIMATOR_H_
+#ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_MOCK_MOCK_REMOTE_BITRATE_OBSERVER_H_
+#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_MOCK_MOCK_REMOTE_BITRATE_OBSERVER_H_
#include <vector>
@@ -26,4 +26,4 @@
} // namespace webrtc
-#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_MOCK_MOCK_REMOTE_BITRATE_ESTIMATOR_H_
+#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_MOCK_MOCK_REMOTE_BITRATE_OBSERVER_H_
diff --git a/webrtc/modules/remote_bitrate_estimator/include/send_time_history.h b/webrtc/modules/remote_bitrate_estimator/include/send_time_history.h
index 92d2e28..a643c1f 100644
--- a/webrtc/modules/remote_bitrate_estimator/include/send_time_history.h
+++ b/webrtc/modules/remote_bitrate_estimator/include/send_time_history.h
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#ifndef WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_TIME_HISTORY_H_
-#define WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_TIME_HISTORY_H_
+#ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_SEND_TIME_HISTORY_H_
+#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_SEND_TIME_HISTORY_H_
#include <map>
@@ -45,4 +45,4 @@
};
} // namespace webrtc
-#endif // WEBRTC_MODULES_BITRATE_CONTROLLER_SEND_TIME_HISTORY_H_
+#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_SEND_TIME_HISTORY_H_
diff --git a/webrtc/modules/remote_bitrate_estimator/inter_arrival.cc b/webrtc/modules/remote_bitrate_estimator/inter_arrival.cc
index 961d6bf..f75bc2b 100644
--- a/webrtc/modules/remote_bitrate_estimator/inter_arrival.cc
+++ b/webrtc/modules/remote_bitrate_estimator/inter_arrival.cc
@@ -71,8 +71,7 @@
current_timestamp_group_.first_timestamp = timestamp;
current_timestamp_group_.timestamp = timestamp;
current_timestamp_group_.size = 0;
- }
- else {
+ } else {
current_timestamp_group_.timestamp = LatestTimestamp(
current_timestamp_group_.timestamp, timestamp);
}
diff --git a/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc b/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc
index c934089..0acd7c2 100644
--- a/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc
+++ b/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc
@@ -10,11 +10,13 @@
#include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h"
-#include <algorithm>
-#include <sstream>
#include <math.h>
#include <stdlib.h>
+#include <algorithm>
+#include <sstream>
+#include <string>
+
#include "webrtc/base/checks.h"
#include "webrtc/base/common.h"
#include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
diff --git a/webrtc/modules/remote_bitrate_estimator/overuse_detector_unittest.cc b/webrtc/modules/remote_bitrate_estimator/overuse_detector_unittest.cc
index 53cffa8..f95067b 100644
--- a/webrtc/modules/remote_bitrate_estimator/overuse_detector_unittest.cc
+++ b/webrtc/modules/remote_bitrate_estimator/overuse_detector_unittest.cc
@@ -9,6 +9,8 @@
*/
#include <math.h>
+
+#include <algorithm>
#include <cmath>
#include <cstdlib>
diff --git a/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc b/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc
index 36c3acd..8391791 100644
--- a/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc
+++ b/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc
@@ -10,12 +10,13 @@
#include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h"
-#include <algorithm>
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
+#include <algorithm>
+
#include "webrtc/base/logging.h"
#include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc
index 8006fe8..97e5cd3 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc
+++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc
@@ -12,6 +12,8 @@
#include <math.h>
+#include <algorithm>
+
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/scoped_ptr.h"
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc
index 195c95a..908daf6 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc
+++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc
@@ -17,7 +17,6 @@
class RemoteBitrateEstimatorAbsSendTimeTest :
public RemoteBitrateEstimatorTest {
public:
-
RemoteBitrateEstimatorAbsSendTimeTest() {}
virtual void SetUp() {
bitrate_estimator_.reset(new RemoteBitrateEstimatorAbsSendTime(
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc
index a84377b..4b7732c 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc
+++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc
@@ -10,6 +10,8 @@
#include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h"
+#include <utility>
+
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/scoped_ptr.h"
@@ -28,19 +30,20 @@
static const double kTimestampToMs = 1.0 / 90.0;
struct RemoteBitrateEstimatorSingleStream::Detector {
- explicit Detector(int64_t last_packet_time_ms,
- const OverUseDetectorOptions& options,
- bool enable_burst_grouping)
- : last_packet_time_ms(last_packet_time_ms),
- inter_arrival(90 * kTimestampGroupLengthMs, kTimestampToMs,
- enable_burst_grouping),
- estimator(options),
- detector(options) {}
- int64_t last_packet_time_ms;
- InterArrival inter_arrival;
- OveruseEstimator estimator;
- OveruseDetector detector;
- };
+ explicit Detector(int64_t last_packet_time_ms,
+ const OverUseDetectorOptions& options,
+ bool enable_burst_grouping)
+ : last_packet_time_ms(last_packet_time_ms),
+ inter_arrival(90 * kTimestampGroupLengthMs,
+ kTimestampToMs,
+ enable_burst_grouping),
+ estimator(options),
+ detector(options) {}
+ int64_t last_packet_time_ms;
+ InterArrival inter_arrival;
+ OveruseEstimator estimator;
+ OveruseDetector detector;
+};
RemoteBitrateEstimatorSingleStream::RemoteBitrateEstimatorSingleStream(
RemoteBitrateObserver* observer,
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream_unittest.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream_unittest.cc
index a6c182a..7a26a7e 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream_unittest.cc
+++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream_unittest.cc
@@ -17,7 +17,6 @@
class RemoteBitrateEstimatorSingleTest :
public RemoteBitrateEstimatorTest {
public:
-
RemoteBitrateEstimatorSingleTest() {}
virtual void SetUp() {
bitrate_estimator_.reset(new RemoteBitrateEstimatorSingleStream(
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc
index 315f542..8b9c0b9 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc
+++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc
@@ -10,6 +10,7 @@
#include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h"
#include <algorithm>
+#include <limits>
#include <utility>
namespace webrtc {
@@ -383,11 +384,11 @@
2 * kFrameIntervalAbsSendTime);
IncomingPacket(kDefaultSsrc, 1000, clock_.TimeInMilliseconds(), timestamp,
absolute_send_time, true);
- IncomingPacket(
- kDefaultSsrc, 1000, clock_.TimeInMilliseconds(),
- timestamp - 90 * kFrameIntervalMs,
- AddAbsSendTime(absolute_send_time, -int(kFrameIntervalAbsSendTime)),
- true);
+ IncomingPacket(kDefaultSsrc, 1000, clock_.TimeInMilliseconds(),
+ timestamp - 90 * kFrameIntervalMs,
+ AddAbsSendTime(absolute_send_time,
+ -static_cast<int>(kFrameIntervalAbsSendTime)),
+ true);
}
bitrate_estimator_->Process();
EXPECT_TRUE(bitrate_observer_->updated());
@@ -520,8 +521,8 @@
uint32_t timestamp = 0;
// Initialize absolute_send_time (24 bits) so that it will definitely wrap
// during the test.
- uint32_t absolute_send_time =
- AddAbsSendTime((1 << 24), -int(50 * kFrameIntervalAbsSendTime));
+ uint32_t absolute_send_time = AddAbsSendTime(
+ (1 << 24), -static_cast<int>(50 * kFrameIntervalAbsSendTime));
// Initial set of frames to increase the bitrate. 6 seconds to have enough
// time for the first estimate to be generated and for Process() to be called.
for (int i = 0; i <= 6 * kFramerate; ++i) {
@@ -556,8 +557,10 @@
// Increase time until next batch to simulate over-use.
clock_.AdvanceTimeMilliseconds(10);
timestamp += 90 * kFrameIntervalMs - kTimestampGroupLength;
- absolute_send_time = AddAbsSendTime(absolute_send_time, AddAbsSendTime(
- kFrameIntervalAbsSendTime, -int(kTimestampGroupLengthAbsSendTime)));
+ absolute_send_time = AddAbsSendTime(
+ absolute_send_time,
+ AddAbsSendTime(kFrameIntervalAbsSendTime,
+ -static_cast<int>(kTimestampGroupLengthAbsSendTime)));
bitrate_estimator_->Process();
}
EXPECT_TRUE(bitrate_observer_->updated());
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h
index 606bb6c..8343d7d 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h
+++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h
@@ -14,6 +14,7 @@
#include <list>
#include <map>
#include <utility>
+#include <vector>
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/constructormagic.h"
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimators_test.cc b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimators_test.cc
index d6f049f..2ce1441 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimators_test.cc
+++ b/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimators_test.cc
@@ -13,8 +13,10 @@
#include <unistd.h>
#endif
+#include <algorithm>
#include <sstream>
+#include "webrtc/base/random.h"
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
#include "webrtc/modules/remote_bitrate_estimator/test/bwe_test.h"
#include "webrtc/modules/remote_bitrate_estimator/test/packet_receiver.h"
@@ -242,18 +244,20 @@
: public BweTest,
public ::testing::TestWithParam<BandwidthEstimatorType> {
public:
- BweFeedbackTest() : BweTest() {}
+#ifdef WEBRTC_WIN
+ BweFeedbackTest()
+ : BweTest(), random_(Clock::GetRealTimeClock()->TimeInMicroseconds()) {}
+#else
+ BweFeedbackTest()
+ : BweTest(),
+ // Multiply the time by a random-ish odd number derived from the PID.
+ random_((getpid() | 1) *
+ Clock::GetRealTimeClock()->TimeInMicroseconds()) {}
+#endif
virtual ~BweFeedbackTest() {}
protected:
- void SetUp() override {
- unsigned int seed = Clock::GetRealTimeClock()->TimeInMicroseconds();
-#ifndef WEBRTC_WIN
- seed *= getpid();
-#endif
- srand(seed);
- BweTest::SetUp();
- }
+ Random random_;
private:
RTC_DISALLOW_COPY_AND_ASSIGN(BweFeedbackTest);
@@ -356,7 +360,7 @@
const int kNumRmcatFlows = 4;
int64_t offset_ms[kNumRmcatFlows];
for (int i = 0; i < kNumRmcatFlows; ++i) {
- offset_ms[i] = std::max(0, 5000 * i + rand() % 2001 - 1000);
+ offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
}
RunFairnessTest(GetParam(), kNumRmcatFlows, 0, 300, 3000, 50, kRttMs,
@@ -370,7 +374,7 @@
const int kNumRmcatFlows = 4;
int64_t offset_ms[kNumRmcatFlows];
for (int i = 0; i < kNumRmcatFlows; ++i) {
- offset_ms[i] = std::max(0, 5000 * i + rand() % 2001 - 1000);
+ offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
}
RunFairnessTest(GetParam(), kNumRmcatFlows, 0, 300, 3000, 500, kRttMs,
@@ -384,7 +388,7 @@
const int kNumRmcatFlows = 4;
int64_t offset_ms[kNumRmcatFlows];
for (int i = 0; i < kNumRmcatFlows; ++i) {
- offset_ms[i] = std::max(0, 5000 * i + rand() % 2001 - 1000);
+ offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
}
RunFairnessTest(GetParam(), kNumRmcatFlows, 0, 300, 3000, 1000, kRttMs,
@@ -397,7 +401,7 @@
int64_t offset_ms[2]; // One TCP, one RMCAT flow.
for (int i = 0; i < 2; ++i) {
- offset_ms[i] = std::max(0, 5000 * i + rand() % 2001 - 1000);
+ offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
}
RunFairnessTest(GetParam(), 1, 1, 300, 2000, 50, kRttMs, kMaxJitterMs,
@@ -410,7 +414,7 @@
int64_t offset_ms[2]; // One TCP, one RMCAT flow.
for (int i = 0; i < 2; ++i) {
- offset_ms[i] = std::max(0, 5000 * i + rand() % 2001 - 1000);
+ offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
}
RunFairnessTest(GetParam(), 1, 1, 300, 2000, 500, kRttMs, kMaxJitterMs,
@@ -423,7 +427,7 @@
int64_t offset_ms[2]; // One TCP, one RMCAT flow.
for (int i = 0; i < 2; ++i) {
- offset_ms[i] = std::max(0, 5000 * i + rand() % 2001 - 1000);
+ offset_ms[i] = std::max(0, 5000 * i + random_.Rand(-1000, 1000));
}
RunFairnessTest(GetParam(), 1, 1, 300, 2000, 1000, kRttMs, kMaxJitterMs,
diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe.h b/webrtc/modules/remote_bitrate_estimator/test/bwe.h
index ef9b314..8d29de2 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/bwe.h
+++ b/webrtc/modules/remote_bitrate_estimator/test/bwe.h
@@ -11,7 +11,10 @@
#ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_BWE_H_
#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_BWE_H_
+#include <list>
+#include <map>
#include <sstream>
+#include <string>
#include "webrtc/test/testsupport/gtest_prod_util.h"
#include "webrtc/modules/remote_bitrate_estimator/test/packet.h"
diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc
index c3a65c1..41bf836 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc
+++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc
@@ -586,7 +586,7 @@
return false;
}
int64_t first_timestamp = -1;
- while(!feof(trace_file)) {
+ while (!feof(trace_file)) {
const size_t kMaxLineLength = 100;
char line[kMaxLineLength];
if (fgets(line, kMaxLineLength, trace_file)) {
@@ -680,6 +680,7 @@
frame_period_ms_(1000.0 / fps),
bits_per_second_(1000 * kbps),
frame_size_bytes_(bits_per_second_ / 8 / fps),
+ random_(0x12345678),
flow_id_(flow_id),
next_frame_ms_(first_frame_offset_ms),
next_frame_rand_ms_(0),
@@ -713,9 +714,7 @@
const int64_t kRandAmplitude = 2;
// A variance picked uniformly from {-1, 0, 1} ms is added to the frame
// timestamp.
- next_frame_rand_ms_ =
- kRandAmplitude * static_cast<float>(rand()) / RAND_MAX -
- kRandAmplitude / 2;
+ next_frame_rand_ms_ = kRandAmplitude * (random_.Rand<float>() - 0.5);
// Ensure frame will not have a negative timestamp.
int64_t next_frame_ms =
diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h
index f7c1d1f..3bb9b95 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h
+++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h
@@ -17,8 +17,10 @@
#include <algorithm>
#include <list>
#include <numeric>
+#include <set>
#include <sstream>
#include <string>
+#include <utility>
#include <vector>
#include "webrtc/base/common.h"
@@ -44,7 +46,7 @@
class RateCounter {
public:
- RateCounter(int64_t window_size_ms)
+ explicit RateCounter(int64_t window_size_ms)
: window_size_us_(1000 * window_size_ms),
recently_received_packets_(0),
recently_received_bytes_(0),
@@ -415,6 +417,7 @@
uint32_t frame_size_bytes_;
private:
+ Random random_;
const int flow_id_;
int64_t next_frame_ms_;
int64_t next_frame_rand_ms_;
diff --git a/webrtc/modules/remote_bitrate_estimator/test/metric_recorder.cc b/webrtc/modules/remote_bitrate_estimator/test/metric_recorder.cc
index 6202b4a..559757c 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/metric_recorder.cc
+++ b/webrtc/modules/remote_bitrate_estimator/test/metric_recorder.cc
@@ -10,10 +10,10 @@
#include "webrtc/modules/remote_bitrate_estimator/test/metric_recorder.h"
-#include "webrtc/modules/remote_bitrate_estimator/test/packet_sender.h"
-
#include <algorithm>
+#include "webrtc/modules/remote_bitrate_estimator/test/packet_sender.h"
+
namespace webrtc {
namespace testing {
namespace bwe {
diff --git a/webrtc/modules/remote_bitrate_estimator/test/packet_sender.h b/webrtc/modules/remote_bitrate_estimator/test/packet_sender.h
index 0b3741d..f48ed62 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/packet_sender.h
+++ b/webrtc/modules/remote_bitrate_estimator/test/packet_sender.h
@@ -13,6 +13,7 @@
#include <list>
#include <limits>
+#include <set>
#include <string>
#include "webrtc/base/constructormagic.h"
@@ -149,7 +150,7 @@
private:
struct InFlight {
public:
- InFlight(const MediaPacket& packet)
+ explicit InFlight(const MediaPacket& packet)
: sequence_number(packet.header().sequenceNumber),
time_ms(packet.send_time_ms()) {}
diff --git a/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.cc b/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.cc
index 083d1fd..f138035 100644
--- a/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.cc
+++ b/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.cc
@@ -10,8 +10,10 @@
#include "webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.h"
-#include <sstream>
#include <stdio.h>
+
+#include <set>
+#include <sstream>
#include <string>
#include "gflags/gflags.h"