diff --git a/webrtc/modules/BUILD.gn b/webrtc/modules/BUILD.gn index b6978258da..258683165d 100644 --- a/webrtc/modules/BUILD.gn +++ b/webrtc/modules/BUILD.gn @@ -198,7 +198,6 @@ if (rtc_include_tests) { "//resources/verizon4g-uplink.rx", "//resources/voice_engine/audio_tiny48.wav", ] - if (is_ios) { bundle_data("modules_unittests_bundle_data") { testonly = true diff --git a/webrtc/modules/remote_bitrate_estimator/BUILD.gn b/webrtc/modules/remote_bitrate_estimator/BUILD.gn index 04f2f7cc55..49b5d3285d 100644 --- a/webrtc/modules/remote_bitrate_estimator/BUILD.gn +++ b/webrtc/modules/remote_bitrate_estimator/BUILD.gn @@ -72,6 +72,11 @@ if (rtc_include_tests) { "test/bwe_test_framework.cc", "test/bwe_test_framework.h", "test/bwe_test_logging.h", + "test/estimators/bbr.cc", + "test/estimators/bbr.h", + "test/estimators/congestion_window.h", + "test/estimators/max_bandwidth_filter.h", + "test/estimators/min_rtt_filter.h", "test/estimators/nada.cc", "test/estimators/nada.h", "test/estimators/remb.cc", diff --git a/webrtc/modules/remote_bitrate_estimator/bwe_simulations.cc b/webrtc/modules/remote_bitrate_estimator/bwe_simulations.cc index cff7e70c5d..c8817c1fcb 100644 --- a/webrtc/modules/remote_bitrate_estimator/bwe_simulations.cc +++ b/webrtc/modules/remote_bitrate_estimator/bwe_simulations.cc @@ -48,7 +48,8 @@ INSTANTIATE_TEST_CASE_P(VideoSendersTest, BweSimulation, ::testing::Values(kRembEstimator, kSendSideEstimator, - kNadaEstimator)); + kNadaEstimator, + kBbrEstimator)); TEST_P(BweSimulation, SprintUplinkTest) { AdaptiveVideoSource source(0, 30, 300, 0, 0); diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe.cc b/webrtc/modules/remote_bitrate_estimator/test/bwe.cc index 086e3c3264..bc5c3f32e1 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/bwe.cc +++ b/webrtc/modules/remote_bitrate_estimator/test/bwe.cc @@ -13,6 +13,7 @@ #include #include "webrtc/base/constructormagic.h" +#include "webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h" #include "webrtc/modules/remote_bitrate_estimator/test/estimators/nada.h" #include "webrtc/modules/remote_bitrate_estimator/test/estimators/remb.h" #include "webrtc/modules/remote_bitrate_estimator/test/estimators/send_side.h" @@ -93,6 +94,8 @@ BweSender* CreateBweSender(BandwidthEstimatorType estimator, return new SendSideBweSender(kbps, observer, clock); case kNadaEstimator: return new NadaBweSender(kbps, observer, clock); + case kBbrEstimator: + return new BbrBweSender(); case kTcpEstimator: FALLTHROUGH(); case kNullEstimator: @@ -112,6 +115,8 @@ BweReceiver* CreateBweReceiver(BandwidthEstimatorType type, return new SendSideBweReceiver(flow_id); case kNadaEstimator: return new NadaBweReceiver(flow_id); + case kBbrEstimator: + return new BbrBweReceiver(flow_id); case kTcpEstimator: return new TcpBweReceiver(flow_id); case kNullEstimator: diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe.h b/webrtc/modules/remote_bitrate_estimator/test/bwe.h index 89a28acb4e..5ff1190758 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/bwe.h +++ b/webrtc/modules/remote_bitrate_estimator/test/bwe.h @@ -177,10 +177,11 @@ enum BandwidthEstimatorType { kNadaEstimator, kRembEstimator, kSendSideEstimator, - kTcpEstimator + kTcpEstimator, + kBbrEstimator }; -const char* const bwe_names[] = {"Null", "NADA", "REMB", "GCC", "TCP"}; +const char* const bwe_names[] = {"Null", "NADA", "REMB", "GCC", "TCP", "BBR"}; int64_t GetAbsSendTimeInMs(uint32_t abs_send_time); diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc index f9313a6724..15e759b654 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc +++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc @@ -152,6 +152,14 @@ void MediaPacket::SetAbsSendTimeMs(int64_t abs_send_time_ms) { (1 << 18)) + 500) / 1000) & 0x00fffffful; } +BbrBweFeedback::BbrBweFeedback( + int flow_id, + int64_t send_time_us, + int64_t latest_send_time_ms, + const std::vector>& packet_feedback_vector) + : FeedbackPacket(flow_id, send_time_us, latest_send_time_ms), + packet_feedback_vector_(packet_feedback_vector) {} + RembFeedback::RembFeedback(int flow_id, int64_t send_time_us, int64_t last_send_time_ms, diff --git a/webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.cc b/webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.cc new file mode 100644 index 0000000000..0d4dfb4c4b --- /dev/null +++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.cc @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2017 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/estimators/bbr.h" + +#include +#include +#include + +#include "webrtc/base/logging.h" +#include "webrtc/modules/congestion_controller/delay_based_bwe.h" +#include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" + +namespace webrtc { +namespace testing { +namespace bwe { +BbrBweSender::BbrBweSender() : BweSender() { + // Initially enter Startup mode. + EnterStartup(); +} + +BbrBweSender::~BbrBweSender() {} + +int BbrBweSender::GetFeedbackIntervalMs() const { + return 0; +} + +void BbrBweSender::GiveFeedback(const FeedbackPacket& feedback) {} + +bool BbrBweSender::UpdateBandwidthAndMinRtt() { + return false; +} + +void BbrBweSender::EnterStartup() {} + +void BbrBweSender::TryExitingStartup() {} + +void BbrBweSender::TryExitingDrain(int64_t now) {} + +void BbrBweSender::EnterProbeBw(int64_t now) {} + +void BbrBweSender::TryUpdatingCyclePhase(int64_t now) {} + +void BbrBweSender::EnterProbeRtt(int64_t now) {} + +void BbrBweSender::TryExitingProbeRtt(int64_t now) {} + +int64_t BbrBweSender::TimeUntilNextProcess() { + return 100; +} + +void BbrBweSender::OnPacketsSent(const Packets& packets) {} + +void BbrBweSender::Process() {} + +BbrBweReceiver::BbrBweReceiver(int flow_id) + : BweReceiver(flow_id, kReceivingRateTimeWindowMs), + clock_(0), + packet_feedbacks_() {} + +BbrBweReceiver::~BbrBweReceiver() {} + +void BbrBweReceiver::ReceivePacket(int64_t arrival_time_ms, + const MediaPacket& media_packet) {} + +FeedbackPacket* BbrBweReceiver::GetFeedback(int64_t now_ms) { + return nullptr; +} +} // namespace bwe +} // namespace testing +} // namespace webrtc diff --git a/webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h b/webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h new file mode 100644 index 0000000000..ebb2e6e5ee --- /dev/null +++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/bbr.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2017 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_ESTIMATORS_BBR_H_ +#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_BBR_H_ + +#include +#include +#include +#include +#include + +#include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h" +#include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h" +#include "webrtc/modules/remote_bitrate_estimator/test/bwe.h" + +namespace webrtc { +namespace testing { +namespace bwe { +class MaxBandwidthFilter; +class MinRttFilter; +class CongestionWindow; +class BbrBweSender : public BweSender { + public: + BbrBweSender(); + virtual ~BbrBweSender(); + enum Mode { + // Startup phase. + STARTUP, + // Queue draining phase, which where created during startup. + DRAIN, + // Cruising, probing new bandwidth. + PROBE_BW, + // Temporarily limiting congestion window size in order to measure + // minimum RTT. + PROBE_RTT + }; + struct PacketStats { + PacketStats() {} + PacketStats(int64_t send_time_, size_t payload_size_) + : send_time(send_time_), payload_size(payload_size_) {} + + int64_t send_time; + size_t payload_size; + }; + void OnPacketsSent(const Packets& packets) override; + int GetFeedbackIntervalMs() const override; + void GiveFeedback(const FeedbackPacket& feedback) override; + int64_t TimeUntilNextProcess() override; + void Process() override; + + private: + void EnterStartup(); + bool UpdateBandwidthAndMinRtt(); + void TryExitingStartup(); + void TryExitingDrain(int64_t now); + void EnterProbeBw(int64_t now); + void EnterProbeRtt(int64_t now); + void TryExitingProbeRtt(int64_t now); + void TryUpdatingCyclePhase(int64_t now); +}; + +class BbrBweReceiver : public BweReceiver { + public: + explicit BbrBweReceiver(int flow_id); + virtual ~BbrBweReceiver(); + void ReceivePacket(int64_t arrival_time_ms, + const MediaPacket& media_packet) override; + FeedbackPacket* GetFeedback(int64_t now_ms) override; + + private: + SimulatedClock clock_; + std::vector> packet_feedbacks_; +}; +} // namespace bwe +} // namespace testing +} // namespace webrtc + +#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_BBR_H_ diff --git a/webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window.h b/webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window.h new file mode 100644 index 0000000000..5a3a460d80 --- /dev/null +++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/congestion_window.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017 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_ESTIMATORS_CONGESTION_WINDOW_H_ +#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_CONGESTION_WINDOW_H_ + +#include +#include +#include +#include +#include +#include + +#include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h" +#include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h" +#include "webrtc/modules/remote_bitrate_estimator/test/bwe.h" + +namespace webrtc { +namespace testing { +namespace bwe { +class CongestionWindow { + public: + void set_gain(float gain); + size_t data_inflight(); + int64_t GetCongestionWindow(); + + // Packet sent from sender, meaning it is inflight + // until we receive it and we should add packet's size to data_inflight. + void PacketSent(); + + // Ack was received by sender, meaning + // packet is no longer inflight. + void AckReceived(); + + // Returnes whether or not data inflight has been under + // fixed value for past x rounds and y ms. + bool DataInflightDecreased(); +}; +} // namespace bwe +} // namespace testing +} // namespace webrtc + +#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_CONGESTION_WINDOW_H_ diff --git a/webrtc/modules/remote_bitrate_estimator/test/estimators/max_bandwidth_filter.h b/webrtc/modules/remote_bitrate_estimator/test/estimators/max_bandwidth_filter.h new file mode 100644 index 0000000000..84fab2cc52 --- /dev/null +++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/max_bandwidth_filter.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2017 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_ESTIMATORS_MAX_BANDWIDTH_FILTER_H_ +#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MAX_BANDWIDTH_FILTER_H_ + +#include +#include +#include +#include +#include +#include + +#include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h" +#include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h" +#include "webrtc/modules/remote_bitrate_estimator/test/bwe.h" + +namespace webrtc { +namespace testing { +namespace bwe { +class MaxBandwidthFilter { + public: + MaxBandwidthFilter(); + ~MaxBandwidthFilter(); + int64_t max_bandwidth_estimate(); + + // Save bandwidth sample for the current round. + // We save bandwidth samples for past 10 rounds to + // provide better bandwidth estimate. + + void AddBandwidthSample(int64_t round); + + // Check if bandwidth has grown by certain multiplier for past x rounds, + // to decide whether or not delivery rate plateaued. + bool DeliveryRateGrows(); +}; +} // namespace bwe +} // namespace testing +} // namespace webrtc + +#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MAX_BANDWIDTH_FILTER_H_ diff --git a/webrtc/modules/remote_bitrate_estimator/test/estimators/min_rtt_filter.h b/webrtc/modules/remote_bitrate_estimator/test/estimators/min_rtt_filter.h new file mode 100644 index 0000000000..9f9cfc8190 --- /dev/null +++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/min_rtt_filter.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017 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_ESTIMATORS_MIN_RTT_FILTER_H_ +#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MIN_RTT_FILTER_H_ + +#include +#include +#include +#include +#include + +#include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h" +#include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h" +#include "webrtc/modules/remote_bitrate_estimator/test/bwe.h" + +namespace webrtc { +namespace testing { +namespace bwe { +class MinRttFilter { + public: + MinRttFilter(); + ~MinRttFilter(); + int64_t min_rtt(); + void UpdateMinRtt(int64_t min_rtt); + + // Checks whether or last discovered min_rtt value + // is older than x seconds. + bool MinRttExpired(int64_t now); + void set_min_rtt_discovery_time(int64_t discovery_time); +}; +} // namespace bwe +} // namespace testing +} // namespace webrtc + +#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_ESTIMATORS_MIN_RTT_FILTER_H_ diff --git a/webrtc/modules/remote_bitrate_estimator/test/packet.h b/webrtc/modules/remote_bitrate_estimator/test/packet.h index c9680c6fcd..223a50ba8f 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/packet.h +++ b/webrtc/modules/remote_bitrate_estimator/test/packet.h @@ -13,6 +13,7 @@ #include #include +#include #include #include "webrtc/common_types.h" @@ -108,6 +109,24 @@ class FeedbackPacket : public Packet { int64_t latest_send_time_ms_; // Time stamp for the latest sent FbPacket. }; +class BbrBweFeedback : public FeedbackPacket { + public: + BbrBweFeedback( + int flow_id, + int64_t send_time_us, + int64_t latest_send_time_ms, + const std::vector>& packet_feedback_vector); + virtual ~BbrBweFeedback() {} + + const std::vector>& packet_feedback_vector() + const { + return packet_feedback_vector_; + } + + private: + const std::vector> packet_feedback_vector_; +}; + class RembFeedback : public FeedbackPacket { public: RembFeedback(int flow_id,