diff --git a/call/BUILD.gn b/call/BUILD.gn index caa17b2bb1..f647fc7f9e 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -242,7 +242,6 @@ if (rtc_include_tests) { "../modules/audio_processing:mocks", "../modules/bitrate_controller", "../modules/congestion_controller", - "../modules/congestion_controller:mock_congestion_controller", "../modules/pacing", "../modules/pacing:mock_paced_sender", "../modules/rtp_rtcp", @@ -308,14 +307,10 @@ if (rtc_include_tests) { testonly = true sources = [ - "fake_rtp_transport_controller_send.h", "test/mock_rtp_packet_sink_interface.h", ] deps = [ ":rtp_interfaces", - "..:webrtc_common", - "../modules/congestion_controller:congestion_controller", - "../modules/pacing:pacing", "../test:test_support", ] } diff --git a/call/call_unittest.cc b/call/call_unittest.cc index cf44f1480e..745de5923a 100644 --- a/call/call_unittest.cc +++ b/call/call_unittest.cc @@ -19,11 +19,9 @@ #include "audio/audio_receive_stream.h" #include "call/audio_state.h" #include "call/call.h" -#include "call/fake_rtp_transport_controller_send.h" #include "logging/rtc_event_log/rtc_event_log.h" #include "modules/audio_device/include/mock_audio_device.h" #include "modules/audio_processing/include/mock_audio_processing.h" -#include "modules/congestion_controller/include/mock/mock_send_side_congestion_controller.h" #include "modules/pacing/mock/mock_paced_sender.h" #include "modules/rtp_rtcp/include/rtp_rtcp.h" #include "rtc_base/ptr_util.h" @@ -252,114 +250,6 @@ TEST(CallTest, MultipleFlexfecReceiveStreamsProtectingSingleVideoStream) { } } -namespace { -struct CallBitrateHelper { - CallBitrateHelper() : CallBitrateHelper(BitrateConstraints()) {} - - explicit CallBitrateHelper(const BitrateConstraints& bitrate_config) - : mock_cc_(Clock::GetRealTimeClock(), &event_log_, &pacer_) { - Call::Config config(&event_log_); - config.bitrate_config = bitrate_config; - call_.reset( - Call::Create(config, rtc::MakeUnique( - &packet_router_, &pacer_, &mock_cc_))); - } - - webrtc::Call* operator->() { return call_.get(); } - testing::NiceMock& mock_cc() { - return mock_cc_; - } - - private: - webrtc::RtcEventLogNullImpl event_log_; - PacketRouter packet_router_; - testing::NiceMock pacer_; - testing::NiceMock mock_cc_; - std::unique_ptr call_; -}; -} // namespace - -TEST(CallBitrateTest, SetBitrateConfigWithValidConfigCallsSetBweBitrates) { - CallBitrateHelper call; - - BitrateConstraints bitrate_config; - bitrate_config.min_bitrate_bps = 1; - bitrate_config.start_bitrate_bps = 2; - bitrate_config.max_bitrate_bps = 3; - - EXPECT_CALL(call.mock_cc(), SetBweBitrates(1, 2, 3)); - call->SetBitrateConfig(bitrate_config); -} - -TEST(CallBitrateTest, SetBitrateConfigWithDifferentMinCallsSetBweBitrates) { - CallBitrateHelper call; - - BitrateConstraints bitrate_config; - bitrate_config.min_bitrate_bps = 10; - bitrate_config.start_bitrate_bps = 20; - bitrate_config.max_bitrate_bps = 30; - call->SetBitrateConfig(bitrate_config); - - bitrate_config.min_bitrate_bps = 11; - EXPECT_CALL(call.mock_cc(), SetBweBitrates(11, -1, 30)); - call->SetBitrateConfig(bitrate_config); -} - -TEST(CallBitrateTest, SetBitrateConfigWithDifferentStartCallsSetBweBitrates) { - CallBitrateHelper call; - - BitrateConstraints bitrate_config; - bitrate_config.min_bitrate_bps = 10; - bitrate_config.start_bitrate_bps = 20; - bitrate_config.max_bitrate_bps = 30; - call->SetBitrateConfig(bitrate_config); - - bitrate_config.start_bitrate_bps = 21; - EXPECT_CALL(call.mock_cc(), SetBweBitrates(10, 21, 30)); - call->SetBitrateConfig(bitrate_config); -} - -TEST(CallBitrateTest, SetBitrateConfigWithDifferentMaxCallsSetBweBitrates) { - CallBitrateHelper call; - - BitrateConstraints bitrate_config; - bitrate_config.min_bitrate_bps = 10; - bitrate_config.start_bitrate_bps = 20; - bitrate_config.max_bitrate_bps = 30; - call->SetBitrateConfig(bitrate_config); - - bitrate_config.max_bitrate_bps = 31; - EXPECT_CALL(call.mock_cc(), SetBweBitrates(10, -1, 31)); - call->SetBitrateConfig(bitrate_config); -} - -TEST(CallBitrateTest, SetBitrateConfigWithSameConfigElidesSecondCall) { - CallBitrateHelper call; - BitrateConstraints bitrate_config; - bitrate_config.min_bitrate_bps = 1; - bitrate_config.start_bitrate_bps = 2; - bitrate_config.max_bitrate_bps = 3; - - EXPECT_CALL(call.mock_cc(), SetBweBitrates(1, 2, 3)).Times(1); - call->SetBitrateConfig(bitrate_config); - call->SetBitrateConfig(bitrate_config); -} - -TEST(CallBitrateTest, - SetBitrateConfigWithSameMinMaxAndNegativeStartElidesSecondCall) { - CallBitrateHelper call; - - BitrateConstraints bitrate_config; - bitrate_config.min_bitrate_bps = 1; - bitrate_config.start_bitrate_bps = 2; - bitrate_config.max_bitrate_bps = 3; - - EXPECT_CALL(call.mock_cc(), SetBweBitrates(1, 2, 3)).Times(1); - call->SetBitrateConfig(bitrate_config); - - bitrate_config.start_bitrate_bps = -1; - call->SetBitrateConfig(bitrate_config); -} TEST(CallTest, RecreatingAudioStreamWithSameSsrcReusesRtpState) { constexpr uint32_t kSSRC = 12345; @@ -387,222 +277,5 @@ TEST(CallTest, RecreatingAudioStreamWithSameSsrcReusesRtpState) { EXPECT_EQ(rtp_state1.media_has_been_sent, rtp_state2.media_has_been_sent); } -TEST(CallBitrateTest, BiggerMaskMinUsed) { - CallBitrateHelper call; - BitrateConstraintsMask mask; - mask.min_bitrate_bps = 1234; - - EXPECT_CALL(call.mock_cc(), - SetBweBitrates(*mask.min_bitrate_bps, testing::_, testing::_)); - call->SetBitrateConfigMask(mask); -} - -TEST(CallBitrateTest, BiggerConfigMinUsed) { - CallBitrateHelper call; - BitrateConstraintsMask mask; - mask.min_bitrate_bps = 1000; - EXPECT_CALL(call.mock_cc(), SetBweBitrates(1000, testing::_, testing::_)); - call->SetBitrateConfigMask(mask); - - BitrateConstraints config; - config.min_bitrate_bps = 1234; - - EXPECT_CALL(call.mock_cc(), SetBweBitrates(1234, testing::_, testing::_)); - call->SetBitrateConfig(config); -} - -// The last call to set start should be used. -TEST(CallBitrateTest, LatestStartMaskPreferred) { - CallBitrateHelper call; - BitrateConstraintsMask mask; - mask.start_bitrate_bps = 1300; - - EXPECT_CALL(call.mock_cc(), - SetBweBitrates(testing::_, *mask.start_bitrate_bps, testing::_)); - call->SetBitrateConfigMask(mask); - - BitrateConstraints bitrate_config; - bitrate_config.start_bitrate_bps = 1200; - - EXPECT_CALL( - call.mock_cc(), - SetBweBitrates(testing::_, bitrate_config.start_bitrate_bps, testing::_)); - call->SetBitrateConfig(bitrate_config); -} - -TEST(CallBitrateTest, SmallerMaskMaxUsed) { - BitrateConstraints bitrate_config; - bitrate_config.max_bitrate_bps = bitrate_config.start_bitrate_bps + 2000; - CallBitrateHelper call(bitrate_config); - - BitrateConstraintsMask mask; - mask.max_bitrate_bps = bitrate_config.start_bitrate_bps + 1000; - - EXPECT_CALL(call.mock_cc(), - SetBweBitrates(testing::_, testing::_, *mask.max_bitrate_bps)); - call->SetBitrateConfigMask(mask); -} - -TEST(CallBitrateTest, SmallerConfigMaxUsed) { - BitrateConstraints bitrate_config; - bitrate_config.max_bitrate_bps = bitrate_config.start_bitrate_bps + 1000; - CallBitrateHelper call(bitrate_config); - - BitrateConstraintsMask mask; - mask.max_bitrate_bps = bitrate_config.start_bitrate_bps + 2000; - - // Expect no calls because nothing changes - EXPECT_CALL(call.mock_cc(), - SetBweBitrates(testing::_, testing::_, testing::_)) - .Times(0); - call->SetBitrateConfigMask(mask); -} - -TEST(CallBitrateTest, MaskStartLessThanConfigMinClamped) { - BitrateConstraints bitrate_config; - bitrate_config.min_bitrate_bps = 2000; - CallBitrateHelper call(bitrate_config); - - BitrateConstraintsMask mask; - mask.start_bitrate_bps = 1000; - - EXPECT_CALL(call.mock_cc(), SetBweBitrates(2000, 2000, testing::_)); - call->SetBitrateConfigMask(mask); -} - -TEST(CallBitrateTest, MaskStartGreaterThanConfigMaxClamped) { - BitrateConstraints bitrate_config; - bitrate_config.start_bitrate_bps = 2000; - CallBitrateHelper call(bitrate_config); - - BitrateConstraintsMask mask; - mask.max_bitrate_bps = 1000; - - EXPECT_CALL(call.mock_cc(), SetBweBitrates(testing::_, -1, 1000)); - call->SetBitrateConfigMask(mask); -} - -TEST(CallBitrateTest, MaskMinGreaterThanConfigMaxClamped) { - BitrateConstraints bitrate_config; - bitrate_config.min_bitrate_bps = 2000; - CallBitrateHelper call(bitrate_config); - - BitrateConstraintsMask mask; - mask.max_bitrate_bps = 1000; - - EXPECT_CALL(call.mock_cc(), SetBweBitrates(1000, testing::_, 1000)); - call->SetBitrateConfigMask(mask); -} - -TEST(CallBitrateTest, SettingMaskStartForcesUpdate) { - CallBitrateHelper call; - - BitrateConstraintsMask mask; - mask.start_bitrate_bps = 1000; - - // SetBweBitrates should be called twice with the same params since - // start_bitrate_bps is set. - EXPECT_CALL(call.mock_cc(), SetBweBitrates(testing::_, 1000, testing::_)) - .Times(2); - call->SetBitrateConfigMask(mask); - call->SetBitrateConfigMask(mask); -} - -TEST(CallBitrateTest, SetBitrateConfigWithNoChangesDoesNotCallSetBweBitrates) { - CallBitrateHelper call; - - BitrateConstraints config1; - config1.min_bitrate_bps = 0; - config1.start_bitrate_bps = 1000; - config1.max_bitrate_bps = -1; - - BitrateConstraints config2; - config2.min_bitrate_bps = 0; - config2.start_bitrate_bps = -1; - config2.max_bitrate_bps = -1; - - // The second call should not call SetBweBitrates because it doesn't - // change any values. - EXPECT_CALL(call.mock_cc(), SetBweBitrates(0, 1000, -1)); - call->SetBitrateConfig(config1); - call->SetBitrateConfig(config2); -} - -// If SetBitrateConfig changes the max, but not the effective max, -// SetBweBitrates shouldn't be called, to avoid unnecessary encoder -// reconfigurations. -TEST(CallBitrateTest, SetBweBitratesNotCalledWhenEffectiveMaxUnchanged) { - CallBitrateHelper call; - - BitrateConstraints config; - config.min_bitrate_bps = 0; - config.start_bitrate_bps = -1; - config.max_bitrate_bps = 2000; - EXPECT_CALL(call.mock_cc(), SetBweBitrates(testing::_, testing::_, 2000)); - call->SetBitrateConfig(config); - - // Reduce effective max to 1000 with the mask. - BitrateConstraintsMask mask; - mask.max_bitrate_bps = 1000; - EXPECT_CALL(call.mock_cc(), SetBweBitrates(testing::_, testing::_, 1000)); - call->SetBitrateConfigMask(mask); - - // This leaves the effective max unchanged, so SetBweBitrates shouldn't be - // called again. - config.max_bitrate_bps = 1000; - call->SetBitrateConfig(config); -} - -// When the "start bitrate" mask is removed, SetBweBitrates shouldn't be called -// again, since nothing's changing. -TEST(CallBitrateTest, SetBweBitratesNotCalledWhenStartMaskRemoved) { - CallBitrateHelper call; - - BitrateConstraintsMask mask; - mask.start_bitrate_bps = 1000; - EXPECT_CALL(call.mock_cc(), SetBweBitrates(0, 1000, -1)); - call->SetBitrateConfigMask(mask); - - mask.start_bitrate_bps.reset(); - call->SetBitrateConfigMask(mask); -} - -// Test that if SetBitrateConfig is called after SetBitrateConfigMask applies a -// "start" value, the SetBitrateConfig call won't apply that start value a -// second time. -TEST(CallBitrateTest, SetBitrateConfigAfterSetBitrateConfigMaskWithStart) { - CallBitrateHelper call; - - BitrateConstraintsMask mask; - mask.start_bitrate_bps = 1000; - EXPECT_CALL(call.mock_cc(), SetBweBitrates(0, 1000, -1)); - call->SetBitrateConfigMask(mask); - - BitrateConstraints config; - config.min_bitrate_bps = 0; - config.start_bitrate_bps = -1; - config.max_bitrate_bps = 5000; - // The start value isn't changing, so SetBweBitrates should be called with - // -1. - EXPECT_CALL(call.mock_cc(), SetBweBitrates(0, -1, 5000)); - call->SetBitrateConfig(config); -} - -TEST(CallBitrateTest, SetBweBitratesNotCalledWhenClampedMinUnchanged) { - BitrateConstraints bitrate_config; - bitrate_config.start_bitrate_bps = 500; - bitrate_config.max_bitrate_bps = 1000; - CallBitrateHelper call(bitrate_config); - - // Set min to 2000; it is clamped to the max (1000). - BitrateConstraintsMask mask; - mask.min_bitrate_bps = 2000; - EXPECT_CALL(call.mock_cc(), SetBweBitrates(1000, -1, 1000)); - call->SetBitrateConfigMask(mask); - - // Set min to 3000; the clamped value stays the same so nothing happens. - mask.min_bitrate_bps = 3000; - call->SetBitrateConfigMask(mask); -} } // namespace webrtc diff --git a/call/fake_rtp_transport_controller_send.h b/call/fake_rtp_transport_controller_send.h deleted file mode 100644 index ed671f3522..0000000000 --- a/call/fake_rtp_transport_controller_send.h +++ /dev/null @@ -1,128 +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 CALL_FAKE_RTP_TRANSPORT_CONTROLLER_SEND_H_ -#define CALL_FAKE_RTP_TRANSPORT_CONTROLLER_SEND_H_ - -#include "call/rtp_transport_controller_send_interface.h" -#include "common_types.h" // NOLINT(build/include) -#include "modules/congestion_controller/include/send_side_congestion_controller.h" -#include "modules/pacing/packet_router.h" - -namespace webrtc { - -class FakeRtpTransportControllerSend - : public RtpTransportControllerSendInterface { - public: - explicit FakeRtpTransportControllerSend( - PacketRouter* packet_router, - PacedSender* paced_sender, - SendSideCongestionController* send_side_cc) - : packet_router_(packet_router), - paced_sender_(paced_sender), - send_side_cc_(send_side_cc) { - RTC_DCHECK(send_side_cc); - } - - PacketRouter* packet_router() override { return packet_router_; } - - TransportFeedbackObserver* transport_feedback_observer() override { - return send_side_cc_; - } - - RtpPacketSender* packet_sender() override { return paced_sender_; } - - const RtpKeepAliveConfig& keepalive_config() const override { - return keepalive_; - } - - void SetAllocatedSendBitrateLimits(int min_send_bitrate_bps, - int max_padding_bitrate_bps) override {} - - void set_keepalive_config(const RtpKeepAliveConfig& keepalive_config) { - keepalive_ = keepalive_config; - } - - Module* GetPacerModule() override { return paced_sender_; } - void SetPacingFactor(float pacing_factor) override { - paced_sender_->SetPacingFactor(pacing_factor); - } - void SetQueueTimeLimit(int limit_ms) override { - paced_sender_->SetQueueTimeLimit(limit_ms); - } - Module* GetModule() override { return send_side_cc_; } - CallStatsObserver* GetCallStatsObserver() override { return send_side_cc_; } - void RegisterPacketFeedbackObserver( - PacketFeedbackObserver* observer) override { - send_side_cc_->RegisterPacketFeedbackObserver(observer); - } - void DeRegisterPacketFeedbackObserver( - PacketFeedbackObserver* observer) override { - send_side_cc_->DeRegisterPacketFeedbackObserver(observer); - } - void RegisterNetworkObserver(NetworkChangedObserver* observer) override { - send_side_cc_->RegisterNetworkObserver(observer); - } - void DeRegisterNetworkObserver(NetworkChangedObserver* observer) override { - send_side_cc_->RegisterNetworkObserver(observer); - } - void SetBweBitrates(int min_bitrate_bps, - int start_bitrate_bps, - int max_bitrate_bps) override { - send_side_cc_->SetBweBitrates(min_bitrate_bps, start_bitrate_bps, - max_bitrate_bps); - } - void OnNetworkRouteChanged(const rtc::NetworkRoute& network_route, - int start_bitrate_bps, - int min_bitrate_bps, - int max_bitrate_bps) override { - send_side_cc_->OnNetworkRouteChanged(network_route, start_bitrate_bps, - min_bitrate_bps, max_bitrate_bps); - } - void OnNetworkAvailability(bool network_available) override { - send_side_cc_->SignalNetworkState(network_available ? kNetworkUp - : kNetworkDown); - } - void SetTransportOverhead( - size_t transport_overhead_bytes_per_packet) override { - send_side_cc_->SetTransportOverhead(transport_overhead_bytes_per_packet); - } - RtcpBandwidthObserver* GetBandwidthObserver() override { - return send_side_cc_->GetBandwidthObserver(); - } - bool AvailableBandwidth(uint32_t* bandwidth) const override { - return send_side_cc_->AvailableBandwidth(bandwidth); - } - int64_t GetPacerQueuingDelayMs() const override { - return send_side_cc_->GetPacerQueuingDelayMs(); - } - int64_t GetFirstPacketTimeMs() const override { - return send_side_cc_->GetFirstPacketTimeMs(); - } - RateLimiter* GetRetransmissionRateLimiter() override { - return send_side_cc_->GetRetransmissionRateLimiter(); - } - void EnablePeriodicAlrProbing(bool enable) override { - send_side_cc_->EnablePeriodicAlrProbing(enable); - } - void OnSentPacket(const rtc::SentPacket& sent_packet) override { - send_side_cc_->OnSentPacket(sent_packet); - } - - private: - PacketRouter* packet_router_; - PacedSender* paced_sender_; - SendSideCongestionController* send_side_cc_; - RtpKeepAliveConfig keepalive_; -}; - -} // namespace webrtc - -#endif // CALL_FAKE_RTP_TRANSPORT_CONTROLLER_SEND_H_ diff --git a/modules/congestion_controller/BUILD.gn b/modules/congestion_controller/BUILD.gn index 6709c858de..1429c49d5b 100644 --- a/modules/congestion_controller/BUILD.gn +++ b/modules/congestion_controller/BUILD.gn @@ -192,7 +192,6 @@ if (rtc_include_tests) { testonly = true sources = [ "include/mock/mock_congestion_observer.h", - "include/mock/mock_send_side_congestion_controller.h", ] deps = [ ":congestion_controller", diff --git a/modules/congestion_controller/include/mock/mock_send_side_congestion_controller.h b/modules/congestion_controller/include/mock/mock_send_side_congestion_controller.h deleted file mode 100644 index 6ec7bb1b6e..0000000000 --- a/modules/congestion_controller/include/mock/mock_send_side_congestion_controller.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 MODULES_CONGESTION_CONTROLLER_INCLUDE_MOCK_MOCK_SEND_SIDE_CONGESTION_CONTROLLER_H_ -#define MODULES_CONGESTION_CONTROLLER_INCLUDE_MOCK_MOCK_SEND_SIDE_CONGESTION_CONTROLLER_H_ - -#include "modules/congestion_controller/include/send_side_congestion_controller.h" -#include "test/gmock.h" - -namespace webrtc { -namespace test { - -class MockSendSideCongestionController : public SendSideCongestionController { - public: - MockSendSideCongestionController(const Clock* clock, - RtcEventLog* event_log, - PacedSender* paced_sender) - : SendSideCongestionController(clock, - nullptr /* observer */, - event_log, - paced_sender) {} - - MOCK_METHOD3(SetBweBitrates, - void(int min_bitrate_bps, - int start_bitrate_bps, - int max_bitrate_bps)); -}; - -} // namespace test -} // namespace webrtc - -#endif // MODULES_CONGESTION_CONTROLLER_INCLUDE_MOCK_MOCK_SEND_SIDE_CONGESTION_CONTROLLER_H_