From 631cafafcc0eae1b66800a5b2bc0defe3672bbfe Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Tue, 21 Aug 2018 21:01:00 +0200 Subject: [PATCH] Eliminate methods SetConfig() from DirectTransport and FakeNetworkPipe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:9630 Change-Id: If67d7dc79436614beb17b97c0f69814093e4fbb8 Reviewed-on: https://webrtc-review.googlesource.com/95140 Reviewed-by: Patrik Höglund Reviewed-by: Sebastian Jansson Commit-Queue: Artem Titov Cr-Commit-Position: refs/heads/master@{#24386} --- call/call_perf_tests.cc | 38 +++++++++++++------------ call/fake_network_pipe.cc | 5 ---- call/fake_network_pipe.h | 5 ---- call/rampup_tests.cc | 11 +++---- call/rampup_tests.h | 3 ++ call/simulated_packet_receiver.h | 5 ---- test/direct_transport.cc | 4 --- test/direct_transport.h | 2 -- video/end_to_end_tests/probing_tests.cc | 18 ++++++------ 9 files changed, 38 insertions(+), 53 deletions(-) diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc index f2100cd60b..97cf24f496 100644 --- a/call/call_perf_tests.cc +++ b/call/call_perf_tests.cc @@ -854,24 +854,26 @@ void CallPerfTest::TestMinAudioVideoBitrate( test::PacketTransport* CreateSendTransport( test::SingleThreadedTaskQueueForTesting* task_queue, Call* sender_call) override { - return send_transport_ = new test::PacketTransport( - task_queue, sender_call, this, test::PacketTransport::kSender, - test::CallTest::payload_type_map_, - absl::make_unique( - Clock::GetRealTimeClock(), - absl::make_unique( - GetFakeNetworkPipeConfig()))); + auto network = + absl::make_unique(GetFakeNetworkPipeConfig()); + send_simulated_network_ = network.get(); + return new test::PacketTransport( + task_queue, sender_call, this, test::PacketTransport::kSender, + test::CallTest::payload_type_map_, + absl::make_unique(Clock::GetRealTimeClock(), + std::move(network))); } test::PacketTransport* CreateReceiveTransport( test::SingleThreadedTaskQueueForTesting* task_queue) override { - return receive_transport_ = new test::PacketTransport( - task_queue, nullptr, this, test::PacketTransport::kReceiver, - test::CallTest::payload_type_map_, - absl::make_unique( - Clock::GetRealTimeClock(), - absl::make_unique( - GetFakeNetworkPipeConfig()))); + auto network = + absl::make_unique(GetFakeNetworkPipeConfig()); + receive_simulated_network_ = network.get(); + return new test::PacketTransport( + task_queue, nullptr, this, test::PacketTransport::kReceiver, + test::CallTest::payload_type_map_, + absl::make_unique(Clock::GetRealTimeClock(), + std::move(network))); } void PerformTest() override { @@ -883,8 +885,8 @@ void CallPerfTest::TestMinAudioVideoBitrate( test_bitrate += test_bitrate_step_) { DefaultNetworkSimulationConfig pipe_config; pipe_config.link_capacity_kbps = test_bitrate; - send_transport_->SetConfig(pipe_config); - receive_transport_->SetConfig(pipe_config); + send_simulated_network_->SetConfig(pipe_config); + receive_simulated_network_->SetConfig(pipe_config); rtc::ThreadManager::Instance()->CurrentThread()->SleepMs( kBitrateStabilizationMs); @@ -952,8 +954,8 @@ void CallPerfTest::TestMinAudioVideoBitrate( const int min_bwe_; const int start_bwe_; const int max_bwe_; - test::PacketTransport* send_transport_; - test::PacketTransport* receive_transport_; + SimulatedNetwork* send_simulated_network_; + SimulatedNetwork* receive_simulated_network_; Call* sender_call_; } test(use_bitrate_allocation_strategy, test_bitrate_from, test_bitrate_to, test_bitrate_step, min_bwe, start_bwe, max_bwe); diff --git a/call/fake_network_pipe.cc b/call/fake_network_pipe.cc index a71ba4d718..232ed9ae4f 100644 --- a/call/fake_network_pipe.cc +++ b/call/fake_network_pipe.cc @@ -185,11 +185,6 @@ void FakeNetworkPipe::SetClockOffset(int64_t offset_ms) { clock_offset_ms_ = offset_ms; } -void FakeNetworkPipe::SetConfig(const FakeNetworkPipe::Config& config) { - network_simulation_->SetConfig(config); -} - - FakeNetworkPipe::StoredPacket::StoredPacket(NetworkPacket&& packet) : packet(std::move(packet)) {} diff --git a/call/fake_network_pipe.h b/call/fake_network_pipe.h index fd540fb9b6..d71e25c67a 100644 --- a/call/fake_network_pipe.h +++ b/call/fake_network_pipe.h @@ -138,11 +138,6 @@ class FakeNetworkPipe : public webrtc::SimulatedPacketReceiverInterface, void SetClockOffset(int64_t offset_ms); - // Deprecated. DO NOT USE. Hold direct reference on NetworkSimulationInterface - // instead and call SetConfig on that object directly. Will be removed soon. - // Sets a new configuration. This won't affect packets already in the pipe. - void SetConfig(const DefaultNetworkSimulationConfig& config) override; - // Must not be called in parallel with DeliverPacket or Process. void SetReceiver(PacketReceiver* receiver) override; diff --git a/call/rampup_tests.cc b/call/rampup_tests.cc index 21caf175c8..47cb7e4848 100644 --- a/call/rampup_tests.cc +++ b/call/rampup_tests.cc @@ -11,7 +11,6 @@ #include "call/rampup_tests.h" #include "call/fake_network_pipe.h" -#include "call/simulated_network.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/platform_thread.h" @@ -60,6 +59,7 @@ RampUpTester::RampUpTester(size_t num_video_streams, sender_call_(nullptr), send_stream_(nullptr), send_transport_(nullptr), + send_simulated_network_(nullptr), start_bitrate_bps_(start_bitrate_bps), min_run_time_ms_(min_run_time_ms), expected_bitrate_bps_(0), @@ -95,12 +95,13 @@ void RampUpTester::OnVideoStreamsCreated( test::PacketTransport* RampUpTester::CreateSendTransport( test::SingleThreadedTaskQueueForTesting* task_queue, Call* sender_call) { + auto network = absl::make_unique(forward_transport_config_); + send_simulated_network_ = network.get(); send_transport_ = new test::PacketTransport( task_queue, sender_call, this, test::PacketTransport::kSender, test::CallTest::payload_type_map_, - absl::make_unique( - Clock::GetRealTimeClock(), - absl::make_unique(forward_transport_config_))); + absl::make_unique(Clock::GetRealTimeClock(), + std::move(network))); return send_transport_; } @@ -551,7 +552,7 @@ void RampUpDownUpTester::EvolveTestState(int bitrate_bps, bool suspended) { state_start_ms_ = now; interval_start_ms_ = now; sent_bytes_ = 0; - send_transport_->SetConfig(forward_transport_config_); + send_simulated_network_->SetConfig(forward_transport_config_); } break; } diff --git a/call/rampup_tests.h b/call/rampup_tests.h index 5fd089fb27..6cc65ce2a2 100644 --- a/call/rampup_tests.h +++ b/call/rampup_tests.h @@ -13,10 +13,12 @@ #include #include +#include #include #include "api/test/simulated_network.h" #include "call/call.h" +#include "call/simulated_network.h" #include "logging/rtc_event_log/rtc_event_log.h" #include "rtc_base/event.h" #include "test/call_test.h" @@ -75,6 +77,7 @@ class RampUpTester : public test::EndToEndTest { Call* sender_call_; VideoSendStream* send_stream_; test::PacketTransport* send_transport_; + SimulatedNetwork* send_simulated_network_; private: typedef std::map SsrcMap; diff --git a/call/simulated_packet_receiver.h b/call/simulated_packet_receiver.h index 3137ba1b1b..03d7e96ea6 100644 --- a/call/simulated_packet_receiver.h +++ b/call/simulated_packet_receiver.h @@ -27,11 +27,6 @@ class SimulatedPacketReceiverInterface : public PacketReceiver, public Module { // Reports average packet delay. virtual int AverageDelay() = 0; - - // Deprecated. DO NOT USE. Temporary added to be able to introduce - // SimulatedPacketReceiverInterface into DirectTransport instead of - // FakeNetworkPipe, will be removed soon. - virtual void SetConfig(const DefaultNetworkSimulationConfig& config) = 0; }; } // namespace webrtc diff --git a/test/direct_transport.cc b/test/direct_transport.cc index 16416ef980..fe463e93cf 100644 --- a/test/direct_transport.cc +++ b/test/direct_transport.cc @@ -78,10 +78,6 @@ DirectTransport::~DirectTransport() { task_queue_->CancelTask(next_scheduled_task_); } -void DirectTransport::SetConfig(const DefaultNetworkSimulationConfig& config) { - fake_network_->SetConfig(config); -} - void DirectTransport::StopSending() { RTC_DCHECK_CALLED_SEQUENTIALLY(&sequence_checker_); task_queue_->CancelTask(next_scheduled_task_); diff --git a/test/direct_transport.h b/test/direct_transport.h index f47f1b9bfb..a2d79c05eb 100644 --- a/test/direct_transport.h +++ b/test/direct_transport.h @@ -66,8 +66,6 @@ class DirectTransport : public Transport { ~DirectTransport() override; - void SetConfig(const DefaultNetworkSimulationConfig& config); - RTC_DEPRECATED void StopSending(); // TODO(holmer): Look into moving this to the constructor. diff --git a/video/end_to_end_tests/probing_tests.cc b/video/end_to_end_tests/probing_tests.cc index 36f1c58109..985d917a99 100644 --- a/video/end_to_end_tests/probing_tests.cc +++ b/video/end_to_end_tests/probing_tests.cc @@ -221,14 +221,14 @@ TEST_P(ProbingEndToEndTest, ProbeOnVideoEncoderReconfiguration) { test::PacketTransport* CreateSendTransport( test::SingleThreadedTaskQueueForTesting* task_queue, Call* sender_call) override { - send_transport_ = new test::PacketTransport( + auto network = + absl::make_unique(DefaultNetworkSimulationConfig()); + send_simulated_network_ = network.get(); + return new test::PacketTransport( task_queue, sender_call, this, test::PacketTransport::kSender, CallTest::payload_type_map_, - absl::make_unique( - Clock::GetRealTimeClock(), - absl::make_unique( - DefaultNetworkSimulationConfig()))); - return send_transport_; + absl::make_unique(Clock::GetRealTimeClock(), + std::move(network))); } void PerformTest() override { @@ -248,7 +248,7 @@ TEST_P(ProbingEndToEndTest, ProbeOnVideoEncoderReconfiguration) { stats.send_bandwidth_bps <= 350000) { DefaultNetworkSimulationConfig config; config.link_capacity_kbps = 200; - send_transport_->SetConfig(config); + send_simulated_network_->SetConfig(config); // In order to speed up the test we can interrupt exponential // probing by toggling the network availability. The alternative @@ -263,7 +263,7 @@ TEST_P(ProbingEndToEndTest, ProbeOnVideoEncoderReconfiguration) { if (stats.send_bandwidth_bps <= 210000) { DefaultNetworkSimulationConfig config; config.link_capacity_kbps = 5000; - send_transport_->SetConfig(config); + send_simulated_network_->SetConfig(config); encoder_config_->max_bitrate_bps = 2000000; encoder_config_->simulcast_layers[0].max_bitrate_bps = 1200000; @@ -288,7 +288,7 @@ TEST_P(ProbingEndToEndTest, ProbeOnVideoEncoderReconfiguration) { const int kTimeoutMs = 3000; test::SingleThreadedTaskQueueForTesting* const task_queue_; bool* const success_; - test::PacketTransport* send_transport_; + SimulatedNetwork* send_simulated_network_; VideoSendStream* send_stream_; VideoEncoderConfig* encoder_config_; RtpTransportControllerSend* transport_controller_;