diff options
Diffstat (limited to 'chromium/third_party/webrtc/modules/remote_bitrate_estimator')
56 files changed, 506 insertions, 581 deletions
diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc index 2d5573228d4..4820e6295f7 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.cc @@ -88,8 +88,7 @@ uint32_t AimdRateControl::LatestEstimate() const { 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 @@ void AimdRateControl::Update(const RateControlInput* input, int64_t now_ms) { 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 @@ uint32_t AimdRateControl::ChangeBitrate(uint32_t current_bitrate_bps, // 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::UpdateMaxBitRateEstimate(float incoming_bitrate_kbps) { 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/chromium/third_party/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h index bc5ca41dff4..93ae2190d61 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h @@ -84,4 +84,4 @@ class AimdRateControl { }; } // 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/chromium/third_party/webrtc/modules/remote_bitrate_estimator/bwe_simulations.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/bwe_simulations.cc index 9d86ba31be3..11fd64f84e7 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/bwe_simulations.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/bwe_simulations.cc @@ -74,7 +74,6 @@ TEST_P(BweSimulation, Verizon4gDownlinkTest) { } 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, Choke1000kbps500kbps1000kbpsBiDirectional) { } 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, PacerGoogleWifiTrace3Mbps) { } 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 @@ TEST_P(BweSimulation, SelfFairnessTest) { // 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())); } @@ -283,9 +281,9 @@ TEST_P(BweSimulation, PacedSelfFairness50msTest) { const int64_t kAverageOffsetMs = 20 * 1000; const int kNumRmcatFlows = 4; int64_t offsets_ms[kNumRmcatFlows]; - offsets_ms[0] = random_.Rand(0, 2 * kAverageOffsetMs); + offsets_ms[0] = random_.Rand(2 * kAverageOffsetMs); for (int i = 1; i < kNumRmcatFlows; ++i) { - offsets_ms[i] = offsets_ms[i - 1] + random_.Rand(0, 2 * kAverageOffsetMs); + offsets_ms[i] = offsets_ms[i - 1] + random_.Rand(2 * kAverageOffsetMs); } RunFairnessTest(GetParam(), kNumRmcatFlows, 0, 1000, 3000, 50, 50, 0, offsets_ms); @@ -295,9 +293,9 @@ TEST_P(BweSimulation, PacedSelfFairness500msTest) { const int64_t kAverageOffsetMs = 20 * 1000; const int kNumRmcatFlows = 4; int64_t offsets_ms[kNumRmcatFlows]; - offsets_ms[0] = random_.Rand(0, 2 * kAverageOffsetMs); + offsets_ms[0] = random_.Rand(2 * kAverageOffsetMs); for (int i = 1; i < kNumRmcatFlows; ++i) { - offsets_ms[i] = offsets_ms[i - 1] + random_.Rand(0, 2 * kAverageOffsetMs); + offsets_ms[i] = offsets_ms[i - 1] + random_.Rand(2 * kAverageOffsetMs); } RunFairnessTest(GetParam(), kNumRmcatFlows, 0, 1000, 3000, 500, 50, 0, offsets_ms); @@ -307,28 +305,28 @@ TEST_P(BweSimulation, PacedSelfFairness1000msTest) { const int64_t kAverageOffsetMs = 20 * 1000; const int kNumRmcatFlows = 4; int64_t offsets_ms[kNumRmcatFlows]; - offsets_ms[0] = random_.Rand(0, 2 * kAverageOffsetMs); + offsets_ms[0] = random_.Rand(2 * kAverageOffsetMs); for (int i = 1; i < kNumRmcatFlows; ++i) { - offsets_ms[i] = offsets_ms[i - 1] + random_.Rand(0, 2 * kAverageOffsetMs); + offsets_ms[i] = offsets_ms[i - 1] + random_.Rand(2 * kAverageOffsetMs); } RunFairnessTest(GetParam(), 4, 0, 1000, 3000, 1000, 50, 0, offsets_ms); } TEST_P(BweSimulation, TcpFairness50msTest) { const int64_t kAverageOffsetMs = 20 * 1000; - int64_t offset_ms[] = {random_.Rand(0, 2 * kAverageOffsetMs), 0}; + int64_t offset_ms[] = {random_.Rand(2 * kAverageOffsetMs), 0}; RunFairnessTest(GetParam(), 1, 1, 1000, 2000, 50, 50, 0, offset_ms); } TEST_P(BweSimulation, TcpFairness500msTest) { const int64_t kAverageOffsetMs = 20 * 1000; - int64_t offset_ms[] = {random_.Rand(0, 2 * kAverageOffsetMs), 0}; + int64_t offset_ms[] = {random_.Rand(2 * kAverageOffsetMs), 0}; RunFairnessTest(GetParam(), 1, 1, 1000, 2000, 500, 50, 0, offset_ms); } TEST_P(BweSimulation, TcpFairness1000msTest) { const int kAverageOffsetMs = 20 * 1000; - int64_t offset_ms[] = {random_.Rand(0, 2 * kAverageOffsetMs), 0}; + int64_t offset_ms[] = {random_.Rand(2 * kAverageOffsetMs), 0}; RunFairnessTest(GetParam(), 1, 1, 1000, 2000, 1000, 50, 0, offset_ms); } diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h index 844fde5b717..3fb7e29e5b2 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h +++ b/chromium/third_party/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 }; + +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) {} -class RateControlInput -{ -public: - RateControlInput(BandwidthUsage bwState, - uint32_t incomingBitRate, - double noiseVar) - : _bwState(bwState), - _incomingBitRate(incomingBitRate), - _noiseVar(noiseVar) {} - - 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/chromium/third_party/webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitrate_observer.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitrate_observer.h index edfac977a2c..ae05912b5f0 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitrate_observer.h +++ b/chromium/third_party/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 @@ class MockRemoteBitrateObserver : public RemoteBitrateObserver { } // 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/chromium/third_party/webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h index 4bd9d8c7bcb..0734cbf2558 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h @@ -17,9 +17,9 @@ #include <vector> #include "webrtc/common_types.h" -#include "webrtc/modules/interface/module.h" -#include "webrtc/modules/interface/module_common_types.h" -#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" +#include "webrtc/modules/include/module.h" +#include "webrtc/modules/include/module_common_types.h" +#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "webrtc/typedefs.h" namespace webrtc { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/include/send_time_history.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/include/send_time_history.h index e104ba661dc..a643c1f1030 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/include/send_time_history.h +++ b/chromium/third_party/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> @@ -21,11 +21,11 @@ namespace webrtc { class SendTimeHistory { public: - explicit SendTimeHistory(int64_t packet_age_limit); + SendTimeHistory(Clock* clock, int64_t packet_age_limit); virtual ~SendTimeHistory(); - void AddAndRemoveOld(const PacketInfo& packet); - bool UpdateSendTime(uint16_t sequence_number, int64_t timestamp); + void AddAndRemoveOld(uint16_t sequence_number, size_t length, bool was_paced); + bool OnSentPacket(uint16_t sequence_number, int64_t timestamp); // Look up PacketInfo for a sent packet, based on the sequence number, and // populate all fields except for receive_time. The packet parameter must // thus be non-null and have the sequence_number field set. @@ -33,9 +33,10 @@ class SendTimeHistory { void Clear(); private: - void EraseOld(int64_t limit); + void EraseOld(); void UpdateOldestSequenceNumber(); + Clock* const clock_; const int64_t packet_age_limit_; uint16_t oldest_sequence_number_; // Oldest may not be lowest. std::map<uint16_t, PacketInfo> history_; @@ -44,4 +45,4 @@ class SendTimeHistory { }; } // 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/chromium/third_party/webrtc/modules/remote_bitrate_estimator/inter_arrival.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/inter_arrival.cc index 3dee305bad1..f75bc2b03ea 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/inter_arrival.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/inter_arrival.cc @@ -14,7 +14,7 @@ #include <cassert> #include "webrtc/base/logging.h" -#include "webrtc/modules/interface/module_common_types.h" +#include "webrtc/modules/include/module_common_types.h" namespace webrtc { @@ -71,8 +71,7 @@ bool InterArrival::ComputeDeltas(uint32_t timestamp, 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/chromium/third_party/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc index 62bb2e1cac4..0acd7c29c54 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/overuse_detector.cc @@ -10,18 +10,20 @@ #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" #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" -#include "webrtc/system_wrappers/interface/field_trial.h" -#include "webrtc/system_wrappers/interface/trace.h" +#include "webrtc/system_wrappers/include/field_trial.h" +#include "webrtc/system_wrappers/include/trace.h" namespace webrtc { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/overuse_detector.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/overuse_detector.h index bb69a8a0a10..56e9c14206c 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/overuse_detector.h +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/overuse_detector.h @@ -13,7 +13,7 @@ #include <list> #include "webrtc/base/constructormagic.h" -#include "webrtc/modules/interface/module_common_types.h" +#include "webrtc/modules/include/module_common_types.h" #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" #include "webrtc/typedefs.h" diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/overuse_detector_unittest.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/overuse_detector_unittest.cc index c7d129718f6..50909ebd01c 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/overuse_detector_unittest.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/overuse_detector_unittest.cc @@ -9,20 +9,21 @@ */ #include <math.h> + +#include <algorithm> #include <cmath> #include <cstdlib> #include "testing/gtest/include/gtest/gtest.h" +#include "webrtc/base/random.h" #include "webrtc/base/scoped_ptr.h" #include "webrtc/common_types.h" #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h" #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h" #include "webrtc/modules/remote_bitrate_estimator/rate_statistics.h" -#include "webrtc/modules/remote_bitrate_estimator/test/random.h" #include "webrtc/test/field_trial.h" -#include "webrtc/test/testsupport/gtest_disable.h" namespace webrtc { namespace testing { @@ -38,7 +39,7 @@ class OveruseDetectorTest : public ::testing::Test { overuse_detector_(), overuse_estimator_(new OveruseEstimator(options_)), inter_arrival_(new InterArrival(5 * 90, kRtpTimestampToMs, true)), - random_(1234) {} + random_(123456789) {} protected: void SetUp() override { @@ -55,9 +56,10 @@ class OveruseDetectorTest : public ::testing::Test { } rtp_timestamp_ += mean_ms * 90; now_ms_ += mean_ms; - receive_time_ms_ = - std::max(receive_time_ms_, - now_ms_ + random_.Gaussian(0, standard_deviation_ms)); + receive_time_ms_ = std::max<int64_t>( + receive_time_ms_, + now_ms_ + static_cast<int64_t>( + random_.Gaussian(0, standard_deviation_ms) + 0.5)); if (kBwOverusing == overuse_detector_->State()) { if (last_overuse + 1 != i) { unique_overuse++; @@ -77,9 +79,10 @@ class OveruseDetectorTest : public ::testing::Test { } rtp_timestamp_ += mean_ms * 90; now_ms_ += mean_ms + drift_per_frame_ms; - receive_time_ms_ = - std::max(receive_time_ms_, - now_ms_ + random_.Gaussian(0, standard_deviation_ms)); + receive_time_ms_ = std::max<int64_t>( + receive_time_ms_, + now_ms_ + static_cast<int64_t>( + random_.Gaussian(0, standard_deviation_ms) + 0.5)); if (kBwOverusing == overuse_detector_->State()) { return i + 1; } @@ -222,7 +225,7 @@ TEST_F(OveruseDetectorTest, DISABLED_OveruseWithHighVariance100Kbit10fps) { UpdateDetector(rtp_timestamp, now_ms_, packet_size); rtp_timestamp += frame_duration_ms * 90; if (i % 2) { - offset = rand() % 50; + offset = random_.Rand(0, 49); now_ms_ += frame_duration_ms - offset; } else { now_ms_ += frame_duration_ms + offset; @@ -254,7 +257,7 @@ TEST_F(OveruseDetectorTest, DISABLED_OveruseWithLowVariance100Kbit10fps) { UpdateDetector(rtp_timestamp, now_ms_, packet_size); rtp_timestamp += frame_duration_ms * 90; if (i % 2) { - offset = rand() % 2; + offset = random_.Rand(0, 1); now_ms_ += frame_duration_ms - offset; } else { now_ms_ += frame_duration_ms + offset; @@ -290,7 +293,7 @@ TEST_F(OveruseDetectorTest, OveruseWithLowVariance2000Kbit30fps) { UpdateDetector(rtp_timestamp, now_ms_, packet_size); rtp_timestamp += frame_duration_ms * 90; if (i % 2) { - offset = rand() % 2; + offset = random_.Rand(0, 1); now_ms_ += frame_duration_ms - offset; } else { now_ms_ += frame_duration_ms + offset; @@ -314,8 +317,13 @@ TEST_F(OveruseDetectorTest, OveruseWithLowVariance2000Kbit30fps) { EXPECT_EQ(kBwOverusing, overuse_detector_->State()); } -TEST_F(OveruseDetectorTest, - DISABLED_ON_ANDROID(LowGaussianVariance30Kbit3fps)) { +#if defined(WEBRTC_ANDROID) +#define MAYBE_LowGaussianVariance30Kbit3fps \ + DISABLED_LowGaussianVariance30Kbit3fps +#else +#define MAYBE_LowGaussianVariance30Kbit3fps LowGaussianVariance30Kbit3fps +#endif +TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance30Kbit3fps) { size_t packet_size = 1200; int packets_per_frame = 1; int frame_duration_ms = 333; @@ -323,10 +331,10 @@ TEST_F(OveruseDetectorTest, int sigma_ms = 3; int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); - EXPECT_EQ(13, unique_overuse); + EXPECT_EQ(1, unique_overuse); int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, sigma_ms, drift_per_frame_ms); - EXPECT_EQ(14, frames_until_overuse); + EXPECT_EQ(13, frames_until_overuse); } TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift30Kbit3fps) { @@ -337,7 +345,7 @@ TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift30Kbit3fps) { int sigma_ms = 3; int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); - EXPECT_EQ(13, unique_overuse); + EXPECT_EQ(1, unique_overuse); int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, sigma_ms, drift_per_frame_ms); EXPECT_EQ(4, frames_until_overuse); @@ -351,10 +359,10 @@ TEST_F(OveruseDetectorTest, HighGaussianVariance30Kbit3fps) { int sigma_ms = 10; int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); - EXPECT_EQ(46, unique_overuse); + EXPECT_EQ(1, unique_overuse); int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, sigma_ms, drift_per_frame_ms); - EXPECT_EQ(42, frames_until_overuse); + EXPECT_EQ(32, frames_until_overuse); } TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift30Kbit3fps) { @@ -365,14 +373,19 @@ TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift30Kbit3fps) { int sigma_ms = 10; int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); - EXPECT_EQ(46, unique_overuse); + EXPECT_EQ(1, unique_overuse); int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, sigma_ms, drift_per_frame_ms); EXPECT_EQ(4, frames_until_overuse); } -TEST_F(OveruseDetectorTest, - DISABLED_ON_ANDROID(LowGaussianVariance100Kbit5fps)) { +#if defined(WEBRTC_ANDROID) +#define MAYBE_LowGaussianVariance100Kbit5fps \ + DISABLED_LowGaussianVariance100Kbit5fps +#else +#define MAYBE_LowGaussianVariance100Kbit5fps LowGaussianVariance100Kbit5fps +#endif +TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance100Kbit5fps) { size_t packet_size = 1200; int packets_per_frame = 2; int frame_duration_ms = 200; @@ -380,14 +393,19 @@ TEST_F(OveruseDetectorTest, int sigma_ms = 3; int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); - EXPECT_EQ(12, unique_overuse); + EXPECT_EQ(0, unique_overuse); int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, sigma_ms, drift_per_frame_ms); - EXPECT_EQ(12, frames_until_overuse); + EXPECT_EQ(13, frames_until_overuse); } -TEST_F(OveruseDetectorTest, - DISABLED_ON_ANDROID(HighGaussianVariance100Kbit5fps)) { +#if defined(WEBRTC_ANDROID) +#define MAYBE_HighGaussianVariance100Kbit5fps \ + DISABLED_HighGaussianVariance100Kbit5fps +#else +#define MAYBE_HighGaussianVariance100Kbit5fps HighGaussianVariance100Kbit5fps +#endif +TEST_F(OveruseDetectorTest, MAYBE_HighGaussianVariance100Kbit5fps) { size_t packet_size = 1200; int packets_per_frame = 2; int frame_duration_ms = 200; @@ -395,14 +413,19 @@ TEST_F(OveruseDetectorTest, int sigma_ms = 10; int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); - EXPECT_EQ(16, unique_overuse); + EXPECT_EQ(1, unique_overuse); int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, sigma_ms, drift_per_frame_ms); - EXPECT_EQ(37, frames_until_overuse); + EXPECT_EQ(32, frames_until_overuse); } -TEST_F(OveruseDetectorTest, - DISABLED_ON_ANDROID(LowGaussianVariance100Kbit10fps)) { +#if defined(WEBRTC_ANDROID) +#define MAYBE_LowGaussianVariance100Kbit10fps \ + DISABLED_LowGaussianVariance100Kbit10fps +#else +#define MAYBE_LowGaussianVariance100Kbit10fps LowGaussianVariance100Kbit10fps +#endif +TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance100Kbit10fps) { size_t packet_size = 1200; int packets_per_frame = 1; int frame_duration_ms = 100; @@ -410,14 +433,19 @@ TEST_F(OveruseDetectorTest, int sigma_ms = 3; int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); - EXPECT_EQ(12, unique_overuse); + EXPECT_EQ(1, unique_overuse); int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, sigma_ms, drift_per_frame_ms); - EXPECT_EQ(12, frames_until_overuse); + EXPECT_EQ(13, frames_until_overuse); } -TEST_F(OveruseDetectorTest, - DISABLED_ON_ANDROID(HighGaussianVariance100Kbit10fps)) { +#if defined(WEBRTC_ANDROID) +#define MAYBE_HighGaussianVariance100Kbit10fps \ + DISABLED_HighGaussianVariance100Kbit10fps +#else +#define MAYBE_HighGaussianVariance100Kbit10fps HighGaussianVariance100Kbit10fps +#endif +TEST_F(OveruseDetectorTest, MAYBE_HighGaussianVariance100Kbit10fps) { size_t packet_size = 1200; int packets_per_frame = 1; int frame_duration_ms = 100; @@ -425,14 +453,19 @@ TEST_F(OveruseDetectorTest, int sigma_ms = 10; int unique_overuse = Run100000Samples(packets_per_frame, packet_size, frame_duration_ms, sigma_ms); - EXPECT_EQ(12, unique_overuse); + EXPECT_EQ(0, unique_overuse); int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, sigma_ms, drift_per_frame_ms); - EXPECT_EQ(37, frames_until_overuse); + EXPECT_EQ(32, frames_until_overuse); } -TEST_F(OveruseDetectorTest, - DISABLED_ON_ANDROID(LowGaussianVariance300Kbit30fps)) { +#if defined(WEBRTC_ANDROID) +#define MAYBE_LowGaussianVariance300Kbit30fps \ + DISABLED_LowGaussianVariance300Kbit30fps +#else +#define MAYBE_LowGaussianVariance300Kbit30fps LowGaussianVariance300Kbit30fps +#endif +TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance300Kbit30fps) { size_t packet_size = 1200; int packets_per_frame = 1; int frame_duration_ms = 33; @@ -443,7 +476,7 @@ TEST_F(OveruseDetectorTest, EXPECT_EQ(0, unique_overuse); int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, sigma_ms, drift_per_frame_ms); - EXPECT_EQ(14, frames_until_overuse); + EXPECT_EQ(15, frames_until_overuse); } TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift300Kbit30fps) { @@ -471,7 +504,7 @@ TEST_F(OveruseDetectorTest, HighGaussianVariance300Kbit30fps) { EXPECT_EQ(0, unique_overuse); int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, sigma_ms, drift_per_frame_ms); - EXPECT_EQ(49, frames_until_overuse); + EXPECT_EQ(41, frames_until_overuse); } TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift300Kbit30fps) { @@ -485,11 +518,16 @@ TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift300Kbit30fps) { EXPECT_EQ(0, unique_overuse); int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, sigma_ms, drift_per_frame_ms); - EXPECT_EQ(8, frames_until_overuse); + EXPECT_EQ(10, frames_until_overuse); } -TEST_F(OveruseDetectorTest, - DISABLED_ON_ANDROID(LowGaussianVariance1000Kbit30fps)) { +#if defined(WEBRTC_ANDROID) +#define MAYBE_LowGaussianVariance1000Kbit30fps \ + DISABLED_LowGaussianVariance1000Kbit30fps +#else +#define MAYBE_LowGaussianVariance1000Kbit30fps LowGaussianVariance1000Kbit30fps +#endif +TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance1000Kbit30fps) { size_t packet_size = 1200; int packets_per_frame = 3; int frame_duration_ms = 33; @@ -500,7 +538,7 @@ TEST_F(OveruseDetectorTest, EXPECT_EQ(0, unique_overuse); int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, sigma_ms, drift_per_frame_ms); - EXPECT_EQ(14, frames_until_overuse); + EXPECT_EQ(15, frames_until_overuse); } TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift1000Kbit30fps) { @@ -528,7 +566,7 @@ TEST_F(OveruseDetectorTest, HighGaussianVariance1000Kbit30fps) { EXPECT_EQ(0, unique_overuse); int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, sigma_ms, drift_per_frame_ms); - EXPECT_EQ(49, frames_until_overuse); + EXPECT_EQ(41, frames_until_overuse); } TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift1000Kbit30fps) { @@ -542,11 +580,16 @@ TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift1000Kbit30fps) { EXPECT_EQ(0, unique_overuse); int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, sigma_ms, drift_per_frame_ms); - EXPECT_EQ(8, frames_until_overuse); + EXPECT_EQ(10, frames_until_overuse); } -TEST_F(OveruseDetectorTest, - DISABLED_ON_ANDROID(LowGaussianVariance2000Kbit30fps)) { +#if defined(WEBRTC_ANDROID) +#define MAYBE_LowGaussianVariance2000Kbit30fps \ + DISABLED_LowGaussianVariance2000Kbit30fps +#else +#define MAYBE_LowGaussianVariance2000Kbit30fps LowGaussianVariance2000Kbit30fps +#endif +TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance2000Kbit30fps) { size_t packet_size = 1200; int packets_per_frame = 6; int frame_duration_ms = 33; @@ -557,7 +600,7 @@ TEST_F(OveruseDetectorTest, EXPECT_EQ(0, unique_overuse); int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, sigma_ms, drift_per_frame_ms); - EXPECT_EQ(14, frames_until_overuse); + EXPECT_EQ(15, frames_until_overuse); } TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift2000Kbit30fps) { @@ -585,7 +628,7 @@ TEST_F(OveruseDetectorTest, HighGaussianVariance2000Kbit30fps) { EXPECT_EQ(0, unique_overuse); int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, sigma_ms, drift_per_frame_ms); - EXPECT_EQ(49, frames_until_overuse); + EXPECT_EQ(41, frames_until_overuse); } TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift2000Kbit30fps) { @@ -599,7 +642,7 @@ TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift2000Kbit30fps) { EXPECT_EQ(0, unique_overuse); int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, frame_duration_ms, sigma_ms, drift_per_frame_ms); - EXPECT_EQ(8, frames_until_overuse); + EXPECT_EQ(10, frames_until_overuse); } class OveruseDetectorExperimentTest : public OveruseDetectorTest { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc index cf7df2673be..83917912e88 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/overuse_estimator.cc @@ -10,14 +10,15 @@ #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" -#include "webrtc/system_wrappers/interface/logging.h" namespace webrtc { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator.gypi b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator.gypi index dbc58824561..d2af81e2f06 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator.gypi +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator.gypi @@ -85,8 +85,6 @@ 'test/packet_sender.cc', 'test/packet_sender.h', 'test/packet.h', - 'test/random.cc', - 'test/random.h', 'test/estimators/nada.cc', 'test/estimators/nada.h', 'test/estimators/remb.cc', diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc index 56a309c59db..97e5cd32e58 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.cc @@ -12,14 +12,16 @@ #include <math.h> +#include <algorithm> + #include "webrtc/base/constructormagic.h" +#include "webrtc/base/logging.h" #include "webrtc/base/scoped_ptr.h" #include "webrtc/base/thread_annotations.h" +#include "webrtc/modules/pacing/paced_sender.h" #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" -#include "webrtc/modules/pacing/include/paced_sender.h" -#include "webrtc/system_wrappers/interface/clock.h" -#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" -#include "webrtc/system_wrappers/interface/logging.h" +#include "webrtc/system_wrappers/include/clock.h" +#include "webrtc/system_wrappers/include/critical_section_wrapper.h" #include "webrtc/typedefs.h" namespace webrtc { @@ -64,6 +66,15 @@ std::vector<K> Keys(const std::map<K, V>& map) { return keys; } +uint32_t ConvertMsTo24Bits(int64_t time_ms) { + uint32_t time_24_bits = + static_cast<uint32_t>( + ((static_cast<uint64_t>(time_ms) << kAbsSendTimeFraction) + 500) / + 1000) & + 0x00FFFFFF; + return time_24_bits; +} + bool RemoteBitrateEstimatorAbsSendTime::IsWithinClusterBounds( int send_delta_ms, const Cluster& cluster_aggregate) { @@ -219,12 +230,8 @@ bool RemoteBitrateEstimatorAbsSendTime::IsBitrateImproving( void RemoteBitrateEstimatorAbsSendTime::IncomingPacketFeedbackVector( const std::vector<PacketInfo>& packet_feedback_vector) { for (const auto& packet_info : packet_feedback_vector) { - // TODO(holmer): We should get rid of this conversion if possible as we may - // lose precision. - uint32_t send_time_32bits = (packet_info.send_time_ms) / kTimestampToMs; - uint32_t send_time_24bits = - send_time_32bits >> kAbsSendTimeInterArrivalUpshift; - IncomingPacketInfo(packet_info.arrival_time_ms, send_time_24bits, + IncomingPacketInfo(packet_info.arrival_time_ms, + ConvertMsTo24Bits(packet_info.send_time_ms), packet_info.payload_size, 0, packet_info.was_paced); } } @@ -236,6 +243,7 @@ void RemoteBitrateEstimatorAbsSendTime::IncomingPacket(int64_t arrival_time_ms, if (!header.extension.hasAbsoluteSendTime) { LOG(LS_WARNING) << "RemoteBitrateEstimatorAbsSendTimeImpl: Incoming packet " "is missing absolute send time extension!"; + return; } IncomingPacketInfo(arrival_time_ms, header.extension.absoluteSendTime, payload_size, header.ssrc, was_paced); diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h index b5ec81568a8..549c437faf6 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h @@ -23,7 +23,7 @@ #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h" #include "webrtc/modules/remote_bitrate_estimator/rate_statistics.h" -#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" +#include "webrtc/system_wrappers/include/critical_section_wrapper.h" namespace webrtc { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc index 195c95aacbb..908daf6c31d 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time_unittest.cc @@ -17,7 +17,6 @@ namespace webrtc { class RemoteBitrateEstimatorAbsSendTimeTest : public RemoteBitrateEstimatorTest { public: - RemoteBitrateEstimatorAbsSendTimeTest() {} virtual void SetUp() { bitrate_estimator_.reset(new RemoteBitrateEstimatorAbsSendTime( diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc index 08e076e540a..4b7732c80f8 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.cc @@ -10,16 +10,18 @@ #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" #include "webrtc/base/thread_annotations.h" +#include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h" #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h" -#include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" -#include "webrtc/system_wrappers/interface/clock.h" -#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" -#include "webrtc/system_wrappers/interface/logging.h" +#include "webrtc/system_wrappers/include/clock.h" +#include "webrtc/system_wrappers/include/critical_section_wrapper.h" #include "webrtc/typedefs.h" namespace webrtc { @@ -28,19 +30,20 @@ enum { kTimestampGroupLengthMs = 5 }; 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/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h index 2816f8d97d4..35fe7216a5b 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h @@ -17,7 +17,7 @@ #include "webrtc/modules/remote_bitrate_estimator/aimd_rate_control.h" #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" #include "webrtc/modules/remote_bitrate_estimator/rate_statistics.h" -#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" +#include "webrtc/system_wrappers/include/critical_section_wrapper.h" namespace webrtc { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream_unittest.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream_unittest.cc index a6c182a7bc8..7a26a7e63b3 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream_unittest.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream_unittest.cc @@ -17,7 +17,6 @@ namespace webrtc { class RemoteBitrateEstimatorSingleTest : public RemoteBitrateEstimatorTest { public: - RemoteBitrateEstimatorSingleTest() {} virtual void SetUp() { bitrate_estimator_.reset(new RemoteBitrateEstimatorSingleStream( diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc index 315f5422d98..8b9c0b9a1d5 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.cc +++ b/chromium/third_party/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 @@ void RemoteBitrateEstimatorTest::RateIncreaseReorderingTestHelper( 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 @@ void RemoteBitrateEstimatorTest::TestTimestampGroupingTestHelper() { 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 @@ void RemoteBitrateEstimatorTest::TestTimestampGroupingTestHelper() { // 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/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h index b4fe7139b4d..8343d7d57b3 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_unittest_helper.h @@ -14,12 +14,13 @@ #include <list> #include <map> #include <utility> +#include <vector> #include "testing/gtest/include/gtest/gtest.h" #include "webrtc/base/constructormagic.h" #include "webrtc/base/scoped_ptr.h" #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" -#include "webrtc/system_wrappers/interface/clock.h" +#include "webrtc/system_wrappers/include/clock.h" namespace webrtc { namespace testing { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimators_test.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimators_test.cc index d6f049f6ac1..2ce144129b0 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimators_test.cc +++ b/chromium/third_party/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 @@ class BweFeedbackTest : 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 @@ TEST_P(BweFeedbackTest, PacedSelfFairness50msTest) { 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 @@ TEST_P(BweFeedbackTest, PacedSelfFairness500msTest) { 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 @@ TEST_P(BweFeedbackTest, PacedSelfFairness1000msTest) { 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 @@ TEST_P(BweFeedbackTest, TcpFairness50msTest) { 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 @@ TEST_P(BweFeedbackTest, TcpFairness500msTest) { 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 @@ TEST_P(BweFeedbackTest, TcpFairness1000msTest) { 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/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc index 73b7b15fa4a..15ca42dda92 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc @@ -12,15 +12,15 @@ #include "webrtc/base/checks.h" #include "webrtc/base/logging.h" -#include "webrtc/system_wrappers/interface/clock.h" -#include "webrtc/modules/pacing/include/packet_router.h" +#include "webrtc/system_wrappers/include/clock.h" +#include "webrtc/modules/pacing/packet_router.h" #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" -#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h" +#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" namespace webrtc { // TODO(sprang): Tune these! -const int RemoteEstimatorProxy::kDefaultProcessIntervalMs = 200; +const int RemoteEstimatorProxy::kDefaultProcessIntervalMs = 50; const int RemoteEstimatorProxy::kBackWindowMs = 500; RemoteEstimatorProxy::RemoteEstimatorProxy(Clock* clock, @@ -45,7 +45,11 @@ void RemoteEstimatorProxy::IncomingPacket(int64_t arrival_time_ms, size_t payload_size, const RTPHeader& header, bool was_paced) { - RTC_DCHECK(header.extension.hasTransportSequenceNumber); + if (!header.extension.hasTransportSequenceNumber) { + LOG(LS_WARNING) << "RemoteEstimatorProxy: Incoming packet " + "is missing the transport sequence number extension!"; + return; + } rtc::CritScope cs(&lock_); media_ssrc_ = header.ssrc; OnPacketArrival(header.extension.transportSequenceNumber, arrival_time_ms); diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h index e867ff77a45..98a68b3dcfe 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h @@ -15,7 +15,7 @@ #include <vector> #include "webrtc/base/criticalsection.h" -#include "webrtc/modules/interface/module_common_types.h" +#include "webrtc/modules/include/module_common_types.h" #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" namespace webrtc { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc index 5ebd921e7a5..7ddd31467b9 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy_unittest.cc @@ -11,10 +11,10 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/modules/pacing/include/packet_router.h" +#include "webrtc/modules/pacing/packet_router.h" #include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h" #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" -#include "webrtc/system_wrappers/interface/clock.h" +#include "webrtc/system_wrappers/include/clock.h" using ::testing::_; using ::testing::InSequence; diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/send_time_history.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/send_time_history.cc index fa51daddb6d..a58d12a1600 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/send_time_history.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/send_time_history.cc @@ -14,9 +14,10 @@ namespace webrtc { -SendTimeHistory::SendTimeHistory(int64_t packet_age_limit) - : packet_age_limit_(packet_age_limit), oldest_sequence_number_(0) { -} +SendTimeHistory::SendTimeHistory(Clock* clock, int64_t packet_age_limit) + : clock_(clock), + packet_age_limit_(packet_age_limit), + oldest_sequence_number_(0) {} SendTimeHistory::~SendTimeHistory() { } @@ -25,18 +26,21 @@ void SendTimeHistory::Clear() { history_.clear(); } -void SendTimeHistory::AddAndRemoveOld(const PacketInfo& packet) { - EraseOld(packet.send_time_ms - packet_age_limit_); +void SendTimeHistory::AddAndRemoveOld(uint16_t sequence_number, + size_t length, + bool was_paced) { + EraseOld(); if (history_.empty()) - oldest_sequence_number_ = packet.sequence_number; + oldest_sequence_number_ = sequence_number; - history_.insert( - std::pair<uint16_t, PacketInfo>(packet.sequence_number, packet)); + history_.insert(std::pair<uint16_t, PacketInfo>( + sequence_number, PacketInfo(clock_->TimeInMilliseconds(), 0, -1, + sequence_number, length, was_paced))); } -bool SendTimeHistory::UpdateSendTime(uint16_t sequence_number, - int64_t send_time_ms) { +bool SendTimeHistory::OnSentPacket(uint16_t sequence_number, + int64_t send_time_ms) { auto it = history_.find(sequence_number); if (it == history_.end()) return false; @@ -44,13 +48,15 @@ bool SendTimeHistory::UpdateSendTime(uint16_t sequence_number, return true; } -void SendTimeHistory::EraseOld(int64_t limit) { +void SendTimeHistory::EraseOld() { while (!history_.empty()) { auto it = history_.find(oldest_sequence_number_); assert(it != history_.end()); - if (it->second.send_time_ms > limit) + if (clock_->TimeInMilliseconds() - it->second.creation_time_ms <= + packet_age_limit_) { return; // Oldest packet within age limit, return. + } // TODO(sprang): Warn if erasing (too many) old items? history_.erase(it); diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/send_time_history_unittest.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/send_time_history_unittest.cc index e3d2c776195..b525813cdca 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/send_time_history_unittest.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/send_time_history_unittest.cc @@ -14,7 +14,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h" -#include "webrtc/system_wrappers/interface/clock.h" +#include "webrtc/system_wrappers/include/clock.h" namespace webrtc { namespace test { @@ -23,27 +23,39 @@ static const int kDefaultHistoryLengthMs = 1000; class SendTimeHistoryTest : public ::testing::Test { protected: - SendTimeHistoryTest() : history_(kDefaultHistoryLengthMs), clock_(0) {} + SendTimeHistoryTest() + : clock_(0), history_(&clock_, kDefaultHistoryLengthMs) {} ~SendTimeHistoryTest() {} virtual void SetUp() {} virtual void TearDown() {} - SendTimeHistory history_; + void AddPacketWithSendTime(uint16_t sequence_number, + size_t length, + bool was_paced, + int64_t send_time_ms) { + history_.AddAndRemoveOld(sequence_number, length, was_paced); + history_.OnSentPacket(sequence_number, send_time_ms); + } + webrtc::SimulatedClock clock_; + SendTimeHistory history_; }; // Help class extended so we can do EXPECT_EQ and collections. class PacketInfo : public webrtc::PacketInfo { public: - PacketInfo() : webrtc::PacketInfo(0, 0, 0, 0, false) {} + PacketInfo() : webrtc::PacketInfo(-1, 0, 0, 0, 0, false) {} + PacketInfo(int64_t arrival_time_ms, uint16_t sequence_number) + : PacketInfo(arrival_time_ms, 0, sequence_number, 0, false) {} PacketInfo(int64_t arrival_time_ms, int64_t send_time_ms, uint16_t sequence_number, size_t payload_size, bool was_paced) - : webrtc::PacketInfo(arrival_time_ms, + : webrtc::PacketInfo(-1, + arrival_time_ms, send_time_ms, sequence_number, payload_size, @@ -58,40 +70,19 @@ class PacketInfo : public webrtc::PacketInfo { TEST_F(SendTimeHistoryTest, AddRemoveOne) { const uint16_t kSeqNo = 10; - const PacketInfo kSentPacket = {0, 1, kSeqNo, 1, true}; - history_.AddAndRemoveOld(kSentPacket); + const PacketInfo kSentPacket(0, 1, kSeqNo, 1, true); + AddPacketWithSendTime(kSeqNo, 1, true, 1); - PacketInfo received_packet = {0, 0, kSeqNo, 0, false}; + PacketInfo received_packet(0, 0, kSeqNo, 0, false); EXPECT_TRUE(history_.GetInfo(&received_packet, false)); EXPECT_EQ(kSentPacket, received_packet); - received_packet = {0, 0, kSeqNo, 0, false}; - EXPECT_TRUE(history_.GetInfo(&received_packet, true)); - EXPECT_EQ(kSentPacket, received_packet); - - received_packet = {0, 0, kSeqNo, 0, false}; - EXPECT_FALSE(history_.GetInfo(&received_packet, true)); -} - -TEST_F(SendTimeHistoryTest, UpdateSendTime) { - const uint16_t kSeqNo = 10; - const int64_t kSendTime = 1000; - const int64_t kSendTimeUpdated = 2000; - const PacketInfo kSentPacket = {0, kSendTime, kSeqNo, 1, true}; - const PacketInfo kUpdatedPacket = {0, kSendTimeUpdated, kSeqNo, 1, true}; - - history_.AddAndRemoveOld(kSentPacket); - PacketInfo info = {0, 0, kSeqNo, 0, false}; - EXPECT_TRUE(history_.GetInfo(&info, false)); - EXPECT_EQ(kSentPacket, info); - - EXPECT_TRUE(history_.UpdateSendTime(kSeqNo, kSendTimeUpdated)); + PacketInfo received_packet2(0, 0, kSeqNo, 0, false); + EXPECT_TRUE(history_.GetInfo(&received_packet2, true)); + EXPECT_EQ(kSentPacket, received_packet2); - info = {0, 0, kSeqNo, 0, false}; - EXPECT_TRUE(history_.GetInfo(&info, true)); - EXPECT_EQ(kUpdatedPacket, info); - - EXPECT_FALSE(history_.UpdateSendTime(kSeqNo, kSendTimeUpdated)); + PacketInfo received_packet3(0, 0, kSeqNo, 0, false); + EXPECT_FALSE(history_.GetInfo(&received_packet3, true)); } TEST_F(SendTimeHistoryTest, PopulatesExpectedFields) { @@ -100,11 +91,10 @@ TEST_F(SendTimeHistoryTest, PopulatesExpectedFields) { const int64_t kReceiveTime = 2000; const size_t kPayloadSize = 42; const bool kPaced = true; - const PacketInfo kSentPacket = {0, kSendTime, kSeqNo, kPayloadSize, kPaced}; - history_.AddAndRemoveOld(kSentPacket); + AddPacketWithSendTime(kSeqNo, kPayloadSize, kPaced, kSendTime); - PacketInfo info = {kReceiveTime, 0, kSeqNo, 0, false}; + PacketInfo info(kReceiveTime, kSeqNo); EXPECT_TRUE(history_.GetInfo(&info, true)); EXPECT_EQ(kReceiveTime, info.arrival_time_ms); EXPECT_EQ(kSendTime, info.send_time_ms); @@ -128,8 +118,14 @@ TEST_F(SendTimeHistoryTest, AddThenRemoveOutOfOrder) { PacketInfo(static_cast<int64_t>(i) + kTransmissionTime, 0, static_cast<uint16_t>(i), kPacketSize, false)); } + for (size_t i = 0; i < num_items; ++i) { + history_.AddAndRemoveOld(sent_packets[i].sequence_number, + sent_packets[i].payload_size, + sent_packets[i].was_paced); + } for (size_t i = 0; i < num_items; ++i) - history_.AddAndRemoveOld(sent_packets[i]); + history_.OnSentPacket(sent_packets[i].sequence_number, + sent_packets[i].send_time_ms); std::random_shuffle(received_packets.begin(), received_packets.end()); for (size_t i = 0; i < num_items; ++i) { PacketInfo packet = received_packets[i]; @@ -145,54 +141,66 @@ TEST_F(SendTimeHistoryTest, AddThenRemoveOutOfOrder) { TEST_F(SendTimeHistoryTest, HistorySize) { const int kItems = kDefaultHistoryLengthMs / 100; - for (int i = 0; i < kItems; ++i) - history_.AddAndRemoveOld(PacketInfo(0, i * 100, i, 0, false)); for (int i = 0; i < kItems; ++i) { - PacketInfo info = {0, 0, static_cast<uint16_t>(i), 0, false}; + clock_.AdvanceTimeMilliseconds(100); + AddPacketWithSendTime(i, 0, false, i * 100); + } + for (int i = 0; i < kItems; ++i) { + PacketInfo info(0, 0, static_cast<uint16_t>(i), 0, false); EXPECT_TRUE(history_.GetInfo(&info, false)); EXPECT_EQ(i * 100, info.send_time_ms); } - history_.AddAndRemoveOld(PacketInfo(0, kItems * 100, kItems, 0, false)); - PacketInfo info = {0, 0, 0, 0, false}; + clock_.AdvanceTimeMilliseconds(101); + AddPacketWithSendTime(kItems, 0, false, kItems * 101); + PacketInfo info(0, 0, 0, 0, false); EXPECT_FALSE(history_.GetInfo(&info, false)); for (int i = 1; i < (kItems + 1); ++i) { - info = {0, 0, static_cast<uint16_t>(i), 0, false}; - EXPECT_TRUE(history_.GetInfo(&info, false)); - EXPECT_EQ(i * 100, info.send_time_ms); + PacketInfo info2(0, 0, static_cast<uint16_t>(i), 0, false); + EXPECT_TRUE(history_.GetInfo(&info2, false)); + int64_t expected_time_ms = (i == kItems) ? i * 101 : i * 100; + EXPECT_EQ(expected_time_ms, info2.send_time_ms); } } TEST_F(SendTimeHistoryTest, HistorySizeWithWraparound) { const uint16_t kMaxSeqNo = std::numeric_limits<uint16_t>::max(); - history_.AddAndRemoveOld(PacketInfo(0, 0, kMaxSeqNo - 2, 0, false)); - history_.AddAndRemoveOld(PacketInfo(0, 100, kMaxSeqNo - 1, 0, false)); - history_.AddAndRemoveOld(PacketInfo(0, 200, kMaxSeqNo, 0, false)); - history_.AddAndRemoveOld(PacketInfo(0, kDefaultHistoryLengthMs, 0, 0, false)); - PacketInfo info = {0, 0, static_cast<uint16_t>(kMaxSeqNo - 2), 0, false}; - EXPECT_FALSE(history_.GetInfo(&info, false)); - info = {0, 0, static_cast<uint16_t>(kMaxSeqNo - 1), 0, false}; - EXPECT_TRUE(history_.GetInfo(&info, false)); - info = {0, 0, static_cast<uint16_t>(kMaxSeqNo), 0, false}; - EXPECT_TRUE(history_.GetInfo(&info, false)); - info = {0, 0, 0, 0, false}; - EXPECT_TRUE(history_.GetInfo(&info, false)); + AddPacketWithSendTime(kMaxSeqNo - 2, 0, false, 0); - // Create a gap (kMaxSeqNo - 1) -> 0. - info = {0, 0, kMaxSeqNo, 0, false}; - EXPECT_TRUE(history_.GetInfo(&info, true)); + clock_.AdvanceTimeMilliseconds(100); + AddPacketWithSendTime(kMaxSeqNo - 1, 1, false, 100); - history_.AddAndRemoveOld(PacketInfo(0, 1100, 1, 0, false)); + clock_.AdvanceTimeMilliseconds(100); + AddPacketWithSendTime(kMaxSeqNo, 0, false, 200); - info = {0, 0, static_cast<uint16_t>(kMaxSeqNo - 2), 0, false}; - EXPECT_FALSE(history_.GetInfo(&info, false)); - info = {0, 0, static_cast<uint16_t>(kMaxSeqNo - 1), 0, false}; - EXPECT_FALSE(history_.GetInfo(&info, false)); - info = {0, 0, kMaxSeqNo, 0, false}; + clock_.AdvanceTimeMilliseconds(kDefaultHistoryLengthMs - 200 + 1); + AddPacketWithSendTime(0, 0, false, kDefaultHistoryLengthMs); + + PacketInfo info(0, static_cast<uint16_t>(kMaxSeqNo - 2)); EXPECT_FALSE(history_.GetInfo(&info, false)); - info = {0, 0, 0, 0, false}; - EXPECT_TRUE(history_.GetInfo(&info, false)); - info = {0, 0, 1, 0, false}; - EXPECT_TRUE(history_.GetInfo(&info, false)); + PacketInfo info2(0, static_cast<uint16_t>(kMaxSeqNo - 1)); + EXPECT_TRUE(history_.GetInfo(&info2, false)); + PacketInfo info3(0, static_cast<uint16_t>(kMaxSeqNo)); + EXPECT_TRUE(history_.GetInfo(&info3, false)); + PacketInfo info4(0, 0); + EXPECT_TRUE(history_.GetInfo(&info4, false)); + + // Create a gap (kMaxSeqNo - 1) -> 0. + PacketInfo info5(0, kMaxSeqNo); + EXPECT_TRUE(history_.GetInfo(&info5, true)); + + clock_.AdvanceTimeMilliseconds(100); + AddPacketWithSendTime(1, 0, false, 1100); + + PacketInfo info6(0, static_cast<uint16_t>(kMaxSeqNo - 2)); + EXPECT_FALSE(history_.GetInfo(&info6, false)); + PacketInfo info7(0, static_cast<uint16_t>(kMaxSeqNo - 1)); + EXPECT_FALSE(history_.GetInfo(&info7, false)); + PacketInfo info8(0, kMaxSeqNo); + EXPECT_FALSE(history_.GetInfo(&info8, false)); + PacketInfo info9(0, 0); + EXPECT_TRUE(history_.GetInfo(&info9, false)); + PacketInfo info10(0, 1); + EXPECT_TRUE(history_.GetInfo(&info10, false)); } TEST_F(SendTimeHistoryTest, InterlievedGetAndRemove) { @@ -202,22 +210,24 @@ TEST_F(SendTimeHistoryTest, InterlievedGetAndRemove) { {0, kTimestamp + 1, kSeqNo + 1, 0, false}, {0, kTimestamp + 2, kSeqNo + 2, 0, false}}; - history_.AddAndRemoveOld(packets[0]); - history_.AddAndRemoveOld(packets[1]); - - PacketInfo info = {0, 0, packets[0].sequence_number, 0, false}; + AddPacketWithSendTime(packets[0].sequence_number, packets[0].payload_size, + packets[0].was_paced, packets[0].send_time_ms); + AddPacketWithSendTime(packets[1].sequence_number, packets[1].payload_size, + packets[1].was_paced, packets[1].send_time_ms); + PacketInfo info(0, 0, packets[0].sequence_number, 0, false); EXPECT_TRUE(history_.GetInfo(&info, true)); EXPECT_EQ(packets[0], info); - history_.AddAndRemoveOld(packets[2]); + AddPacketWithSendTime(packets[2].sequence_number, packets[2].payload_size, + packets[2].was_paced, packets[2].send_time_ms); - info = {0, 0, packets[1].sequence_number, 0, false}; - EXPECT_TRUE(history_.GetInfo(&info, true)); - EXPECT_EQ(packets[1], info); + PacketInfo info2(0, 0, packets[1].sequence_number, 0, false); + EXPECT_TRUE(history_.GetInfo(&info2, true)); + EXPECT_EQ(packets[1], info2); - info = {0, 0, packets[2].sequence_number, 0, false}; - EXPECT_TRUE(history_.GetInfo(&info, true)); - EXPECT_EQ(packets[2], info); + PacketInfo info3(0, 0, packets[2].sequence_number, 0, false); + EXPECT_TRUE(history_.GetInfo(&info3, true)); + EXPECT_EQ(packets[2], info3); } } // namespace test diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe.h index ef9b3149d77..8d29de26192 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe.h +++ b/chromium/third_party/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/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test.cc index 72283b98c76..9da21c1aaac 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test.cc @@ -12,14 +12,15 @@ #include <sstream> +#include "webrtc/base/arraysize.h" #include "webrtc/base/common.h" #include "webrtc/base/scoped_ptr.h" -#include "webrtc/modules/interface/module_common_types.h" +#include "webrtc/modules/include/module_common_types.h" #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h" #include "webrtc/modules/remote_bitrate_estimator/test/metric_recorder.h" #include "webrtc/modules/remote_bitrate_estimator/test/packet_receiver.h" #include "webrtc/modules/remote_bitrate_estimator/test/packet_sender.h" -#include "webrtc/system_wrappers/interface/clock.h" +#include "webrtc/system_wrappers/include/clock.h" #include "webrtc/test/testsupport/perf_test.h" using std::string; @@ -662,7 +663,7 @@ void BweTest::RunSelfFairness(BandwidthEstimatorType bwe_type) { void BweTest::RunRoundTripTimeFairness(BandwidthEstimatorType bwe_type) { const int kAllFlowIds[] = {0, 1, 2, 3, 4}; // Five RMCAT flows. const int64_t kAllOneWayDelayMs[] = {10, 25, 50, 100, 150}; - const size_t kNumFlows = ARRAY_SIZE(kAllFlowIds); + const size_t kNumFlows = arraysize(kAllFlowIds); rtc::scoped_ptr<AdaptiveVideoSource> sources[kNumFlows]; rtc::scoped_ptr<VideoSender> senders[kNumFlows]; rtc::scoped_ptr<MetricRecorder> metric_recorders[kNumFlows]; @@ -774,10 +775,10 @@ void BweTest::RunMultipleShortTcpFairness( const int kAllTcpFlowIds[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; assert(tcp_starting_times_ms.size() == tcp_file_sizes_bytes.size() && - tcp_starting_times_ms.size() == ARRAY_SIZE(kAllTcpFlowIds)); + tcp_starting_times_ms.size() == arraysize(kAllTcpFlowIds)); - const size_t kNumRmcatFlows = ARRAY_SIZE(kAllRmcatFlowIds); - const size_t kNumTotalFlows = kNumRmcatFlows + ARRAY_SIZE(kAllTcpFlowIds); + const size_t kNumRmcatFlows = arraysize(kAllRmcatFlowIds); + const size_t kNumTotalFlows = kNumRmcatFlows + arraysize(kAllTcpFlowIds); rtc::scoped_ptr<AdaptiveVideoSource> sources[kNumRmcatFlows]; rtc::scoped_ptr<PacketSender> senders[kNumTotalFlows]; @@ -869,7 +870,7 @@ void BweTest::RunMultipleShortTcpFairness( // During the test, one of the flows is paused and later resumed. void BweTest::RunPauseResumeFlows(BandwidthEstimatorType bwe_type) { const int kAllFlowIds[] = {0, 1, 2}; // Three RMCAT flows. - const size_t kNumFlows = ARRAY_SIZE(kAllFlowIds); + const size_t kNumFlows = arraysize(kAllFlowIds); rtc::scoped_ptr<AdaptiveVideoSource> sources[kNumFlows]; rtc::scoped_ptr<VideoSender> senders[kNumFlows]; diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_baselinefile.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_baselinefile.h index 64dfa855355..b3df7124e3a 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_baselinefile.h +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_baselinefile.h @@ -12,7 +12,7 @@ #define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_BWE_TEST_BASELINEFILE_H_ #include <string> -#include "webrtc/modules/interface/module_common_types.h" +#include "webrtc/modules/include/module_common_types.h" namespace webrtc { namespace testing { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_fileutils.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_fileutils.h index 2881eba424d..d470324ac39 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_fileutils.h +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_fileutils.h @@ -16,7 +16,7 @@ #include <string> #include "webrtc/base/constructormagic.h" -#include "webrtc/modules/interface/module_common_types.h" +#include "webrtc/modules/include/module_common_types.h" namespace webrtc { namespace testing { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc index d4201933e78..41bf836c9e9 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc @@ -92,41 +92,6 @@ double RateCounter::BitrateWindowS() const { return static_cast<double>(window_size_us_) / (1000 * 1000); } -Random::Random(uint32_t seed) : a_(0x531FDB97 ^ seed), b_(0x6420ECA8 + seed) { -} - -float Random::Rand() { - const float kScale = 1.0f / 0xffffffff; - float result = kScale * b_; - a_ ^= b_; - b_ += a_; - return result; -} - -int Random::Rand(int low, int high) { - float uniform = Rand() * (high - low + 1) + low; - return static_cast<int>(uniform); -} - -int Random::Gaussian(int mean, int standard_deviation) { - // Creating a Normal distribution variable from two independent uniform - // variables based on the Box-Muller transform, which is defined on the - // interval (0, 1], hence the mask+add below. - const double kPi = 3.14159265358979323846; - const double kScale = 1.0 / 0x80000000ul; - double u1 = kScale * ((a_ & 0x7ffffffful) + 1); - double u2 = kScale * ((b_ & 0x7ffffffful) + 1); - a_ ^= b_; - b_ += a_; - return static_cast<int>( - mean + standard_deviation * sqrt(-2 * log(u1)) * cos(2 * kPi * u2)); -} - -int Random::Exponential(float lambda) { - float uniform = Rand(); - return static_cast<int>(-log(uniform) / lambda); -} - Packet::Packet() : flow_id_(0), creation_time_us_(-1), @@ -358,7 +323,7 @@ void LossFilter::SetLoss(float loss_percent) { void LossFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) { assert(in_out); for (PacketsIt it = in_out->begin(); it != in_out->end(); ) { - if (random_.Rand() < loss_fraction_) { + if (random_.Rand<float>() < loss_fraction_) { delete *it; it = in_out->erase(it); } else { @@ -494,7 +459,7 @@ void ReorderFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) { PacketsIt last_it = in_out->begin(); PacketsIt it = last_it; while (++it != in_out->end()) { - if (random_.Rand() < reorder_fraction_) { + if (random_.Rand<float>() < reorder_fraction_) { int64_t t1 = (*last_it)->send_time_us(); int64_t t2 = (*it)->send_time_us(); std::swap(*last_it, *it); @@ -621,7 +586,7 @@ bool TraceBasedDeliveryFilter::Init(const std::string& filename) { 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)) { @@ -715,6 +680,7 @@ VideoSource::VideoSource(int flow_id, 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), @@ -748,9 +714,7 @@ void VideoSource::RunFor(int64_t time_ms, Packets* in_out) { 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/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h index 77b03fe7b12..3bb9b95f4bf 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h @@ -17,21 +17,23 @@ #include <algorithm> #include <list> #include <numeric> +#include <set> #include <sstream> #include <string> +#include <utility> #include <vector> #include "webrtc/base/common.h" +#include "webrtc/base/random.h" #include "webrtc/base/scoped_ptr.h" #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" -#include "webrtc/modules/interface/module_common_types.h" -#include "webrtc/modules/pacing/include/paced_sender.h" +#include "webrtc/modules/include/module_common_types.h" +#include "webrtc/modules/pacing/paced_sender.h" #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" #include "webrtc/modules/remote_bitrate_estimator/test/packet.h" -#include "webrtc/modules/remote_bitrate_estimator/test/random.h" -#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" -#include "webrtc/system_wrappers/interface/clock.h" +#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" +#include "webrtc/system_wrappers/include/clock.h" namespace webrtc { @@ -44,7 +46,7 @@ class DelayCapHelper; 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), @@ -173,32 +175,6 @@ template<typename T> class Stats { T max_; }; -class Random { - public: - explicit Random(uint32_t seed); - - // Return pseudo random number in the interval [0.0, 1.0]. - float Rand(); - - // Return pseudo rounded random number in interval [low, high]. - int Rand(int low, int high); - - // Normal Distribution. - int Gaussian(int mean, int standard_deviation); - - // Exponential Distribution. - int Exponential(float lambda); - - // TODO(solenberg): Random from histogram. - // template<typename T> int Distribution(const std::vector<T> histogram) { - - private: - uint32_t a_; - uint32_t b_; - - RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Random); -}; - bool IsTimeSorted(const Packets& packets); class PacketProcessor; @@ -441,6 +417,7 @@ class VideoSource { 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/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework_unittest.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework_unittest.cc index 6cd6ee7efe6..6bdfa847dfd 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework_unittest.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework_unittest.cc @@ -22,39 +22,6 @@ namespace webrtc { namespace testing { namespace bwe { -TEST(BweTestFramework_RandomTest, Gaussian) { - enum { - kN = 100000, - kBuckets = 100, - kMean = 49, - kStddev = 10 - }; - - Random random(0x12345678); - - int buckets[kBuckets] = {0}; - for (int i = 0; i < kN; ++i) { - int index = random.Gaussian(kMean, kStddev); - if (index >= 0 && index < kBuckets) { - buckets[index]++; - } - } - - const double kPi = 3.14159265358979323846; - const double kScale = kN / (kStddev * sqrt(2.0 * kPi)); - const double kDiv = -2.0 * kStddev * kStddev; - double self_corr = 0.0; - double bucket_corr = 0.0; - for (int n = 0; n < kBuckets; ++n) { - double normal_dist = kScale * exp((n - kMean) * (n - kMean) / kDiv); - self_corr += normal_dist * normal_dist; - bucket_corr += normal_dist * buckets[n]; - } - printf("Correlation: %f (random sample), %f (self), %f (quotient)\n", - bucket_corr, self_corr, bucket_corr / self_corr); - EXPECT_NEAR(1.0, bucket_corr / self_corr, 0.0004); -} - static bool IsSequenceNumberSorted(const Packets& packets) { PacketsConstIt last_it = packets.begin(); for (PacketsConstIt it = last_it; it != packets.end(); ++it) { @@ -533,7 +500,7 @@ TEST(BweTestFramework_JitterFilterTest, Jitter1031) { TestJitterFilter(1031); } -static void TestReorderFilter(uint16_t reorder_percent, uint16_t near_value) { +static void TestReorderFilter(uint16_t reorder_percent) { const uint16_t kPacketCount = 10000; // Generate packets with 10 ms interval. @@ -559,16 +526,23 @@ static void TestReorderFilter(uint16_t reorder_percent, uint16_t near_value) { for (auto* packet : packets) { const MediaPacket* media_packet = static_cast<const MediaPacket*>(packet); uint16_t sequence_number = media_packet->header().sequenceNumber; + // The expected position for sequence number s is in position s-1. if (sequence_number < last_sequence_number) { distance += last_sequence_number - sequence_number; } last_sequence_number = sequence_number; } - // Because reordering is random, we allow a threshold when comparing. The - // maximum distance a packet can be moved is PacketCount - 1. - EXPECT_NEAR( - ((kPacketCount - 1) * reorder_percent) / 100, distance, near_value); + // The probability that two elements are swapped is p = reorder_percent / 100. + double p = static_cast<double>(reorder_percent) / 100; + // The expected number of swaps we perform is p * (PacketCount - 1), + // and each swap increases the distance by one. + double mean = p * (kPacketCount - 1); + // If pair i is chosen to be swapped with probability p, the variance for that + // pair is p * (1 - p). Since there are (kPacketCount - 1) independent pairs, + // the variance for the number of swaps is (kPacketCount - 1) * p * (1 - p). + double std_deviation = sqrt((kPacketCount - 1) * p * (1 - p)); + EXPECT_NEAR(mean, distance, 3 * std_deviation); for (auto* packet : packets) delete packet; @@ -576,23 +550,23 @@ static void TestReorderFilter(uint16_t reorder_percent, uint16_t near_value) { TEST(BweTestFramework_ReorderFilterTest, Reorder0) { // For 0% reordering, no packets should have been moved, so result is exact. - TestReorderFilter(0, 0); + TestReorderFilter(0); } TEST(BweTestFramework_ReorderFilterTest, Reorder10) { - TestReorderFilter(10, 30); + TestReorderFilter(10); } TEST(BweTestFramework_ReorderFilterTest, Reorder20) { - TestReorderFilter(20, 20); + TestReorderFilter(20); } TEST(BweTestFramework_ReorderFilterTest, Reorder50) { - TestReorderFilter(50, 20); + TestReorderFilter(50); } TEST(BweTestFramework_ReorderFilterTest, Reorder70) { - TestReorderFilter(70, 20); + TestReorderFilter(70); } TEST(BweTestFramework_ReorderFilterTest, Reorder100) { @@ -600,7 +574,7 @@ TEST(BweTestFramework_ReorderFilterTest, Reorder100) { // adjacent packets, when the likelihood of a swap is 1.0, a swap will always // occur, so the stream will be in order except for the first packet, which // has been moved to the end. Therefore we expect the result to be exact here. - TestReorderFilter(100.0, 0); + TestReorderFilter(100.0); } class BweTestFramework_ChokeFilterTest : public ::testing::Test { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.cc index 94233131815..3a84e81a0b9 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.cc @@ -18,8 +18,8 @@ #include <algorithm> #include <sstream> -#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" -#include "webrtc/system_wrappers/interface/thread_wrapper.h" +#include "webrtc/base/platform_thread.h" +#include "webrtc/system_wrappers/include/critical_section_wrapper.h" namespace webrtc { namespace testing { @@ -57,27 +57,27 @@ Logging* Logging::GetInstance() { void Logging::SetGlobalContext(uint32_t name) { CriticalSectionScoped cs(crit_sect_.get()); - thread_map_[ThreadWrapper::GetThreadId()].global_state.tag = ToString(name); + thread_map_[rtc::CurrentThreadId()].global_state.tag = ToString(name); } void Logging::SetGlobalContext(const std::string& name) { CriticalSectionScoped cs(crit_sect_.get()); - thread_map_[ThreadWrapper::GetThreadId()].global_state.tag = name; + thread_map_[rtc::CurrentThreadId()].global_state.tag = name; } void Logging::SetGlobalContext(const char* name) { CriticalSectionScoped cs(crit_sect_.get()); - thread_map_[ThreadWrapper::GetThreadId()].global_state.tag = name; + thread_map_[rtc::CurrentThreadId()].global_state.tag = name; } void Logging::SetGlobalEnable(bool enabled) { CriticalSectionScoped cs(crit_sect_.get()); - thread_map_[ThreadWrapper::GetThreadId()].global_state.enabled = enabled; + thread_map_[rtc::CurrentThreadId()].global_state.enabled = enabled; } void Logging::Log(const char format[], ...) { CriticalSectionScoped cs(crit_sect_.get()); - ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); + ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); assert(it != thread_map_.end()); const State& state = it->second.stack.top(); if (state.enabled) { @@ -96,7 +96,7 @@ void Logging::Plot(int figure, double value) { void Logging::Plot(int figure, double value, const std::string& alg_name) { CriticalSectionScoped cs(crit_sect_.get()); - ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); + ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); assert(it != thread_map_.end()); const State& state = it->second.stack.top(); std::string label = state.tag + '@' + alg_name; @@ -119,7 +119,7 @@ void Logging::PlotBar(int figure, double value, int flow_id) { CriticalSectionScoped cs(crit_sect_.get()); - ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); + ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); assert(it != thread_map_.end()); const State& state = it->second.stack.top(); if (state.enabled) { @@ -132,7 +132,7 @@ void Logging::PlotBaselineBar(int figure, double value, int flow_id) { CriticalSectionScoped cs(crit_sect_.get()); - ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); + ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); assert(it != thread_map_.end()); const State& state = it->second.stack.top(); if (state.enabled) { @@ -148,7 +148,7 @@ void Logging::PlotErrorBar(int figure, const std::string& error_title, int flow_id) { CriticalSectionScoped cs(crit_sect_.get()); - ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); + ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); assert(it != thread_map_.end()); const State& state = it->second.stack.top(); if (state.enabled) { @@ -167,7 +167,7 @@ void Logging::PlotLimitErrorBar(int figure, const std::string& limit_title, int flow_id) { CriticalSectionScoped cs(crit_sect_.get()); - ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); + ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); assert(it != thread_map_.end()); const State& state = it->second.stack.top(); if (state.enabled) { @@ -182,7 +182,7 @@ void Logging::PlotLabel(int figure, const std::string& y_label, int num_flows) { CriticalSectionScoped cs(crit_sect_.get()); - ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); + ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); assert(it != thread_map_.end()); const State& state = it->second.stack.top(); if (state.enabled) { @@ -219,7 +219,7 @@ void Logging::PushState(const std::string& append_to_tag, int64_t timestamp_ms, bool enabled) { CriticalSectionScoped cs(crit_sect_.get()); State new_state(append_to_tag, timestamp_ms, enabled); - ThreadState* thread_state = &thread_map_[ThreadWrapper::GetThreadId()]; + ThreadState* thread_state = &thread_map_[rtc::CurrentThreadId()]; std::stack<State>* stack = &thread_state->stack; if (stack->empty()) { new_state.MergePrevious(thread_state->global_state); @@ -231,7 +231,7 @@ void Logging::PushState(const std::string& append_to_tag, int64_t timestamp_ms, void Logging::PopState() { CriticalSectionScoped cs(crit_sect_.get()); - ThreadMap::iterator it = thread_map_.find(ThreadWrapper::GetThreadId()); + ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); assert(it != thread_map_.end()); std::stack<State>* stack = &it->second.stack; int64_t newest_timestamp_ms = stack->top().timestamp_ms; diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h index 4115d30c2a6..cc7807ba8aa 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h @@ -130,12 +130,12 @@ #define BWE_TEST_LOGGING_GLOBAL_CONTEXT(name) \ do { \ webrtc::testing::bwe::Logging::GetInstance()->SetGlobalContext(name); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_GLOBAL_ENABLE(enabled) \ do { \ webrtc::testing::bwe::Logging::GetInstance()->SetGlobalEnable(enabled); \ - } while (0); + } while (0) #define __BWE_TEST_LOGGING_CONTEXT_NAME(ctx, line) ctx ## line #define __BWE_TEST_LOGGING_CONTEXT_DECLARE(ctx, line, name, time, enabled) \ @@ -155,36 +155,36 @@ do { \ BWE_TEST_LOGGING_CONTEXT(name); \ webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_LOG2(name, format, _1, _2) \ do { \ BWE_TEST_LOGGING_CONTEXT(name); \ webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_LOG3(name, format, _1, _2, _3) \ do { \ BWE_TEST_LOGGING_CONTEXT(name); \ webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_LOG4(name, format, _1, _2, _3, _4) \ do { \ BWE_TEST_LOGGING_CONTEXT(name); \ webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, \ _4); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_LOG5(name, format, _1, _2, _3, _4, _5) \ do {\ BWE_TEST_LOGGING_CONTEXT(name); \ webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, \ _4, _5); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_PLOT(figure, name, time, value) \ do { \ __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __PLOT__, name, \ static_cast<int64_t>(time), true); \ webrtc::testing::bwe::Logging::GetInstance()->Plot(figure, value); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_PLOT_WITH_NAME(figure, name, time, value, alg_name) \ do { \ @@ -192,21 +192,21 @@ static_cast<int64_t>(time), true); \ webrtc::testing::bwe::Logging::GetInstance()->Plot(figure, value, \ alg_name); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_BAR(figure, name, value, flow_id) \ do { \ BWE_TEST_LOGGING_CONTEXT(name); \ webrtc::testing::bwe::Logging::GetInstance()->PlotBar(figure, name, value, \ flow_id); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_BASELINEBAR(figure, name, value, flow_id) \ do { \ BWE_TEST_LOGGING_CONTEXT(name); \ webrtc::testing::bwe::Logging::GetInstance()->PlotBaselineBar( \ figure, name, value, flow_id); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_ERRORBAR(figure, name, value, ylow, yhigh, title, \ flow_id) \ @@ -214,7 +214,7 @@ BWE_TEST_LOGGING_CONTEXT(name); \ webrtc::testing::bwe::Logging::GetInstance()->PlotErrorBar( \ figure, name, value, ylow, yhigh, title, flow_id); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_LIMITERRORBAR( \ figure, name, value, ylow, yhigh, error_title, ymax, limit_title, flow_id) \ @@ -223,14 +223,14 @@ webrtc::testing::bwe::Logging::GetInstance()->PlotLimitErrorBar( \ figure, name, value, ylow, yhigh, error_title, ymax, limit_title, \ flow_id); \ - } while (0); + } while (0) #define BWE_TEST_LOGGING_LABEL(figure, title, y_label, num_flows) \ do { \ BWE_TEST_LOGGING_CONTEXT(title); \ webrtc::testing::bwe::Logging::GetInstance()->PlotLabel( \ figure, title, y_label, num_flows); \ - } while (0); + } while (0) namespace webrtc { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_unittest.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_unittest.cc index 6b3ce4847cf..6245ccd25d4 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_unittest.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/bwe_unittest.cc @@ -13,6 +13,7 @@ #include <vector> #include "testing/gtest/include/gtest/gtest.h" +#include "webrtc/base/arraysize.h" namespace webrtc { namespace testing { @@ -241,7 +242,7 @@ TEST_F(BweReceiverTest, PacketLossDuplicatedPackets) { // Missing the element 5. const uint16_t kSequenceNumbers[] = {1, 2, 3, 4, 6, 7, 8}; - const int kNumPackets = ARRAY_SIZE(kSequenceNumbers); + const int kNumPackets = arraysize(kSequenceNumbers); // Insert each sequence number twice. for (int i = 0; i < 2; ++i) { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc index d77447f1ea1..6166ff8c2d4 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc @@ -18,10 +18,11 @@ #include <algorithm> #include <vector> +#include "webrtc/base/arraysize.h" #include "webrtc/base/common.h" #include "webrtc/modules/remote_bitrate_estimator/test/estimators/nada.h" #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" -#include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" +#include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" namespace webrtc { namespace testing { @@ -63,7 +64,7 @@ void NadaBweReceiver::ReceivePacket(int64_t arrival_time_ms, } delay_signal_ms_ = delay_ms - baseline_delay_ms_; // Refered as d_n. - const int kMedian = ARRAY_SIZE(last_delays_ms_); + const int kMedian = arraysize(last_delays_ms_); last_delays_ms_[(last_delays_index_++) % kMedian] = delay_signal_ms_; int size = std::min(last_delays_index_, kMedian); diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.h index eee90cf4632..bf23d09884d 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.h +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.h @@ -20,7 +20,7 @@ #include <list> #include <map> -#include "webrtc/modules/interface/module_common_types.h" +#include "webrtc/modules/include/module_common_types.h" #include "webrtc/modules/remote_bitrate_estimator/test/bwe.h" #include "webrtc/voice_engine/channel.h" diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc index a0f56b73b7d..51afae1df46 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc @@ -13,6 +13,7 @@ #include <algorithm> #include <numeric> +#include "webrtc/base/arraysize.h" #include "webrtc/base/common.h" #include "webrtc/base/scoped_ptr.h" #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h" @@ -357,7 +358,7 @@ TEST_F(NadaReceiverSideTest, FeedbackIncreasingDelay) { // Baseline delay will be 50 ms. // Delay signals should be: [0 10 20 30 40 50 60 70] ms. const int64_t kMedianFilteredDelaysMs[] = {0, 5, 10, 15, 20, 30, 40, 50}; - const int kNumPackets = ARRAY_SIZE(kMedianFilteredDelaysMs); + const int kNumPackets = arraysize(kMedianFilteredDelaysMs); const float kAlpha = 0.1f; // Used for exponential smoothing. int64_t exp_smoothed_delays_ms[kNumPackets]; @@ -426,7 +427,7 @@ TEST_F(NadaReceiverSideTest, FeedbackWarpedDelay) { // Delay signals should be: [0 200 400 600 800 1000 1200 1400] ms. const int64_t kMedianFilteredDelaysMs[] = { 0, 100, 200, 300, 400, 600, 800, 1000}; - const int kNumPackets = ARRAY_SIZE(kMedianFilteredDelaysMs); + const int kNumPackets = arraysize(kMedianFilteredDelaysMs); const float kAlpha = 0.1f; // Used for exponential smoothing. int64_t exp_smoothed_delays_ms[kNumPackets]; @@ -480,7 +481,7 @@ TEST_F(FilterTest, ExponentialSmoothingConstantArray) { TEST_F(FilterTest, ExponentialSmoothingInitialPertubation) { const int64_t kSignal[] = {90000, 0, 0, 0, 0, 0}; - const int kNumElements = ARRAY_SIZE(kSignal); + const int kNumElements = arraysize(kSignal); int64_t exp_smoothed[kNumElements]; ExponentialSmoothingFilter(kSignal, kNumElements, exp_smoothed); for (int i = 1; i < kNumElements; ++i) { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.cc index b18b9f06b99..9599b019332 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.cc @@ -17,7 +17,7 @@ #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h" #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" -#include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" +#include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" namespace webrtc { namespace testing { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/send_side.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/send_side.cc index 250d0c1262a..8a7352874b4 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/send_side.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/send_side.cc @@ -26,7 +26,7 @@ FullBweSender::FullBweSender(int kbps, BitrateObserver* observer, Clock* clock) rbe_(new RemoteBitrateEstimatorAbsSendTime(this, clock)), feedback_observer_(bitrate_controller_->CreateRtcpBandwidthObserver()), clock_(clock), - send_time_history_(10000), + send_time_history_(clock_, 10000), has_received_ack_(false), last_acked_seq_num_(0) { assert(kbps >= kMinBitrateKbps); @@ -92,10 +92,11 @@ void FullBweSender::OnPacketsSent(const Packets& packets) { for (Packet* packet : packets) { if (packet->GetPacketType() == Packet::kMedia) { MediaPacket* media_packet = static_cast<MediaPacket*>(packet); - PacketInfo info(0, media_packet->sender_timestamp_ms(), - media_packet->header().sequenceNumber, - media_packet->payload_size(), packet->paced()); - send_time_history_.AddAndRemoveOld(info); + send_time_history_.AddAndRemoveOld(media_packet->header().sequenceNumber, + media_packet->payload_size(), + packet->paced()); + send_time_history_.OnSentPacket(media_packet->header().sequenceNumber, + media_packet->sender_timestamp_ms()); } } } @@ -125,7 +126,7 @@ SendSideBweReceiver::~SendSideBweReceiver() { void SendSideBweReceiver::ReceivePacket(int64_t arrival_time_ms, const MediaPacket& media_packet) { packet_feedback_vector_.push_back(PacketInfo( - arrival_time_ms, media_packet.sender_timestamp_ms(), + -1, arrival_time_ms, media_packet.sender_timestamp_ms(), media_packet.header().sequenceNumber, media_packet.payload_size(), true)); // Log received packet information. diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/tcp.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/tcp.cc index a02abc6ab8f..b7e4f971fa4 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/tcp.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/estimators/tcp.cc @@ -16,7 +16,7 @@ #include "webrtc/base/common.h" #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" -#include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" +#include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" namespace webrtc { namespace testing { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/metric_recorder.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/metric_recorder.cc index 6202b4a6a30..559757c0eb6 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/metric_recorder.cc +++ b/chromium/third_party/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/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/packet.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/packet.h index 11885a4544f..4a361c4dc20 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/packet.h +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/packet.h @@ -16,7 +16,7 @@ #include <vector> #include "webrtc/common_types.h" -#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" +#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" namespace webrtc { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/packet_receiver.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/packet_receiver.cc index 0edfeca4a6f..793e06421f4 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/packet_receiver.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/packet_receiver.cc @@ -14,11 +14,11 @@ #include "testing/gtest/include/gtest/gtest.h" #include "webrtc/base/common.h" -#include "webrtc/modules/interface/module_common_types.h" +#include "webrtc/modules/include/module_common_types.h" #include "webrtc/modules/remote_bitrate_estimator/test/bwe.h" #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h" -#include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" -#include "webrtc/system_wrappers/interface/clock.h" +#include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" +#include "webrtc/system_wrappers/include/clock.h" namespace webrtc { namespace testing { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/packet_sender.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/packet_sender.cc index 21c2f365ae1..3bcbc0a071b 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/packet_sender.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/packet_sender.cc @@ -15,7 +15,7 @@ #include <sstream> #include "webrtc/base/checks.h" -#include "webrtc/modules/interface/module_common_types.h" +#include "webrtc/modules/include/module_common_types.h" #include "webrtc/modules/remote_bitrate_estimator/test/bwe.h" #include "webrtc/modules/remote_bitrate_estimator/test/metric_recorder.h" @@ -209,7 +209,7 @@ void PacedVideoSender::RunFor(int64_t time_ms, Packets* in_out) { if (!generated_packets.empty()) { for (Packet* packet : generated_packets) { MediaPacket* media_packet = static_cast<MediaPacket*>(packet); - pacer_.SendPacket( + pacer_.InsertPacket( PacedSender::kNormalPriority, media_packet->header().ssrc, media_packet->header().sequenceNumber, media_packet->send_time_ms(), media_packet->payload_size(), false); diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/packet_sender.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/packet_sender.h index c42647e2d3f..f48ed62f579 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/packet_sender.h +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/packet_sender.h @@ -13,11 +13,12 @@ #include <list> #include <limits> +#include <set> #include <string> #include "webrtc/base/constructormagic.h" #include "webrtc/base/scoped_ptr.h" -#include "webrtc/modules/interface/module.h" +#include "webrtc/modules/include/module.h" #include "webrtc/modules/remote_bitrate_estimator/test/bwe.h" #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h" @@ -149,7 +150,7 @@ class TcpSender : public PacketSender { 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/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/random.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/random.cc deleted file mode 100644 index d803be06368..00000000000 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/random.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/remote_bitrate_estimator/test/random.h" - -#include <math.h> - -namespace webrtc { - -Random::Random(uint32_t seed) : a_(0x531FDB97 ^ seed), b_(0x6420ECA8 + seed) { -} - -float Random::Rand() { - const float kScale = 1.0f / 0xffffffff; - float result = kScale * b_; - a_ ^= b_; - b_ += a_; - return result; -} - -int Random::Gaussian(int mean, int standard_deviation) { - // Creating a Normal distribution variable from two independent uniform - // variables based on the Box-Muller transform, which is defined on the - // interval (0, 1], hence the mask+add below. - const double kPi = 3.14159265358979323846; - const double kScale = 1.0 / 0x80000000ul; - double u1 = kScale * ((a_ & 0x7ffffffful) + 1); - double u2 = kScale * ((b_ & 0x7ffffffful) + 1); - a_ ^= b_; - b_ += a_; - return static_cast<int>( - mean + standard_deviation * sqrt(-2 * log(u1)) * cos(2 * kPi * u2)); -} -} // namespace webrtc diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/random.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/random.h deleted file mode 100644 index 31c1ec142eb..00000000000 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/test/random.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_RANDOM_H_ -#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_RANDOM_H_ - -#include "webrtc/typedefs.h" -#include "webrtc/base/constructormagic.h" - -namespace webrtc { - -class Random { - public: - explicit Random(uint32_t seed); - - // Return pseudo-random number in the interval [0.0, 1.0]. - float Rand(); - - // Normal Distribution. - int Gaussian(int mean, int standard_deviation); - - // TODO(solenberg): Random from histogram. - // template<typename T> int Distribution(const std::vector<T> histogram) { - - private: - uint32_t a_; - uint32_t b_; - - RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Random); -}; -} // namespace webrtc - -#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_RANDOM_H_ diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.cc index 9493805a1c7..f138035de53 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.cc @@ -10,15 +10,17 @@ #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" #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h" #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h" -#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" -#include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h" +#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" +#include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" #include "webrtc/test/rtp_file_reader.h" namespace flags { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc index 19e4a07b4d3..4574faf8b7c 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc @@ -14,8 +14,8 @@ #include "webrtc/base/scoped_ptr.h" #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" #include "webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.h" -#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" -#include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h" +#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" +#include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" #include "webrtc/test/rtp_file_reader.h" class Observer : public webrtc::RemoteBitrateObserver { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/tools/rtp_to_text.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/tools/rtp_to_text.cc index e2774818861..bf698728e81 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/tools/rtp_to_text.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/tools/rtp_to_text.cc @@ -14,8 +14,8 @@ #include "webrtc/base/format_macros.h" #include "webrtc/base/scoped_ptr.h" #include "webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.h" -#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" -#include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h" +#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" +#include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" #include "webrtc/test/rtp_file_reader.h" int main(int argc, char** argv) { diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.cc index 5f51bc55e9c..5904594ac87 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.cc @@ -8,14 +8,15 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h" + #include <limits> #include "webrtc/base/checks.h" #include "webrtc/base/logging.h" #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h" -#include "webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h" #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" -#include "webrtc/modules/utility/interface/process_thread.h" +#include "webrtc/modules/utility/include/process_thread.h" namespace webrtc { @@ -29,7 +30,7 @@ TransportFeedbackAdapter::TransportFeedbackAdapter( RtcpBandwidthObserver* bandwidth_observer, Clock* clock, ProcessThread* process_thread) - : send_time_history_(kSendTimeHistoryWindowMs), + : send_time_history_(clock, kSendTimeHistoryWindowMs), rtcp_bandwidth_observer_(bandwidth_observer), process_thread_(process_thread), clock_(clock), @@ -49,9 +50,17 @@ void TransportFeedbackAdapter::SetBitrateEstimator( } } -void TransportFeedbackAdapter::OnPacketSent(const PacketInfo& info) { +void TransportFeedbackAdapter::AddPacket(uint16_t sequence_number, + size_t length, + bool was_paced) { + rtc::CritScope cs(&lock_); + send_time_history_.AddAndRemoveOld(sequence_number, length, was_paced); +} + +void TransportFeedbackAdapter::OnSentPacket(uint16_t sequence_number, + int64_t send_time_ms) { rtc::CritScope cs(&lock_); - send_time_history_.AddAndRemoveOld(info); + send_time_history_.OnSentPacket(sequence_number, send_time_ms); } void TransportFeedbackAdapter::OnTransportFeedback( @@ -91,8 +100,8 @@ void TransportFeedbackAdapter::OnTransportFeedback( RTC_DCHECK(delta_it != delta_vec.end()); offset_us += *(delta_it++); int64_t timestamp_ms = current_offset_ms_ + (offset_us / 1000); - PacketInfo info = {timestamp_ms, 0, sequence_number, 0, false}; - if (send_time_history_.GetInfo(&info, true)) { + PacketInfo info(timestamp_ms, sequence_number); + if (send_time_history_.GetInfo(&info, true) && info.send_time_ms >= 0) { packet_feedback_vector.push_back(info); } else { ++failed_lookups; diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h index 56b2c73873d..93f30e6cee2 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h @@ -15,8 +15,8 @@ #include "webrtc/base/criticalsection.h" #include "webrtc/base/thread_annotations.h" -#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" -#include "webrtc/modules/interface/module_common_types.h" +#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" +#include "webrtc/modules/include/module_common_types.h" #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" #include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h" @@ -33,7 +33,11 @@ class TransportFeedbackAdapter : public TransportFeedbackObserver, ProcessThread* process_thread); virtual ~TransportFeedbackAdapter(); - void OnPacketSent(const PacketInfo& info) override; + void AddPacket(uint16_t sequence_number, + size_t length, + bool was_paced) override; + + void OnSentPacket(uint16_t sequence_number, int64_t send_time_ms); void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override; diff --git a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter_unittest.cc b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter_unittest.cc index 1bf4b1ec3e7..64d0e553973 100644 --- a/chromium/third_party/webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter_unittest.cc +++ b/chromium/third_party/webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter_unittest.cc @@ -18,10 +18,10 @@ #include "webrtc/base/scoped_ptr.h" #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitrate_estimator.h" #include "webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h" -#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" +#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" -#include "webrtc/modules/utility/interface/mock/mock_process_thread.h" -#include "webrtc/system_wrappers/interface/clock.h" +#include "webrtc/modules/utility/include/mock/mock_process_thread.h" +#include "webrtc/system_wrappers/include/clock.h" using ::testing::_; using ::testing::Invoke; @@ -103,9 +103,11 @@ class TransportFeedbackAdapterTest : public ::testing::Test { } // Utility method, to reset arrival_time_ms before adding send time. - void OnPacketSent(PacketInfo info) { + void OnSentPacket(PacketInfo info) { info.arrival_time_ms = 0; - adapter_->OnPacketSent(info); + adapter_->AddPacket(info.sequence_number, info.payload_size, + info.was_paced); + adapter_->OnSentPacket(info.sequence_number, info.send_time_ms); } SimulatedClock clock_; @@ -125,7 +127,7 @@ TEST_F(TransportFeedbackAdapterTest, AdaptsFeedbackAndPopulatesSendTimes) { packets.push_back(PacketInfo(140, 240, 4, 1500, true)); for (const PacketInfo& packet : packets) - OnPacketSent(packet); + OnSentPacket(packet); rtcp::TransportFeedback feedback; feedback.WithBase(packets[0].sequence_number, @@ -160,7 +162,7 @@ TEST_F(TransportFeedbackAdapterTest, HandlesDroppedPackets) { for (const PacketInfo& packet : packets) { if (packet.sequence_number >= kSendSideDropBefore) - OnPacketSent(packet); + OnSentPacket(packet); } rtcp::TransportFeedback feedback; @@ -199,7 +201,7 @@ TEST_F(TransportFeedbackAdapterTest, SendTimeWrapsBothWays) { packets.push_back(PacketInfo(kHighArrivalTimeMs, 220, 2, 1500, true)); for (const PacketInfo& packet : packets) - OnPacketSent(packet); + OnSentPacket(packet); for (size_t i = 0; i < packets.size(); ++i) { rtc::scoped_ptr<rtcp::TransportFeedback> feedback( @@ -263,8 +265,8 @@ TEST_F(TransportFeedbackAdapterTest, TimestampDeltas) { // Packets will be added to send history. for (const PacketInfo& packet : sent_packets) - OnPacketSent(packet); - OnPacketSent(info); + OnSentPacket(packet); + OnSentPacket(info); // Create expected feedback and send into adapter. rtc::scoped_ptr<rtcp::TransportFeedback> feedback( |