Eliminate methods SetConfig() from DirectTransport and FakeNetworkPipe

Bug: webrtc:9630
Change-Id: If67d7dc79436614beb17b97c0f69814093e4fbb8
Reviewed-on: https://webrtc-review.googlesource.com/95140
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24386}
diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc
index f2100cd..97cf24f 100644
--- a/call/call_perf_tests.cc
+++ b/call/call_perf_tests.cc
@@ -854,24 +854,26 @@
     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<FakeNetworkPipe>(
-                     Clock::GetRealTimeClock(),
-                     absl::make_unique<SimulatedNetwork>(
-                         GetFakeNetworkPipeConfig())));
+      auto network =
+          absl::make_unique<SimulatedNetwork>(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<FakeNetworkPipe>(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<FakeNetworkPipe>(
-                     Clock::GetRealTimeClock(),
-                     absl::make_unique<SimulatedNetwork>(
-                         GetFakeNetworkPipeConfig())));
+      auto network =
+          absl::make_unique<SimulatedNetwork>(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<FakeNetworkPipe>(Clock::GetRealTimeClock(),
+                                             std::move(network)));
     }
 
     void PerformTest() override {
@@ -883,8 +885,8 @@
            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 @@
     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 a71ba4d..232ed9a 100644
--- a/call/fake_network_pipe.cc
+++ b/call/fake_network_pipe.cc
@@ -185,11 +185,6 @@
   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 fd540fb..d71e25c 100644
--- a/call/fake_network_pipe.h
+++ b/call/fake_network_pipe.h
@@ -138,11 +138,6 @@
 
   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 21caf17..47cb7e4 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 @@
       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 @@
 test::PacketTransport* RampUpTester::CreateSendTransport(
     test::SingleThreadedTaskQueueForTesting* task_queue,
     Call* sender_call) {
+  auto network = absl::make_unique<SimulatedNetwork>(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<FakeNetworkPipe>(
-          Clock::GetRealTimeClock(),
-          absl::make_unique<SimulatedNetwork>(forward_transport_config_)));
+      absl::make_unique<FakeNetworkPipe>(Clock::GetRealTimeClock(),
+                                         std::move(network)));
   return send_transport_;
 }
 
@@ -551,7 +552,7 @@
         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 5fd089f..6cc65ce 100644
--- a/call/rampup_tests.h
+++ b/call/rampup_tests.h
@@ -13,10 +13,12 @@
 
 #include <map>
 #include <string>
+#include <utility>
 #include <vector>
 
 #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 @@
   Call* sender_call_;
   VideoSendStream* send_stream_;
   test::PacketTransport* send_transport_;
+  SimulatedNetwork* send_simulated_network_;
 
  private:
   typedef std::map<uint32_t, uint32_t> SsrcMap;
diff --git a/call/simulated_packet_receiver.h b/call/simulated_packet_receiver.h
index 3137ba1..03d7e96 100644
--- a/call/simulated_packet_receiver.h
+++ b/call/simulated_packet_receiver.h
@@ -27,11 +27,6 @@
 
   // 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 16416ef..fe463e9 100644
--- a/test/direct_transport.cc
+++ b/test/direct_transport.cc
@@ -78,10 +78,6 @@
   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 f47f1b9..a2d79c0 100644
--- a/test/direct_transport.h
+++ b/test/direct_transport.h
@@ -66,8 +66,6 @@
 
   ~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 36f1c58..985d917 100644
--- a/video/end_to_end_tests/probing_tests.cc
+++ b/video/end_to_end_tests/probing_tests.cc
@@ -221,14 +221,14 @@
     test::PacketTransport* CreateSendTransport(
         test::SingleThreadedTaskQueueForTesting* task_queue,
         Call* sender_call) override {
-      send_transport_ = new test::PacketTransport(
+      auto network =
+          absl::make_unique<SimulatedNetwork>(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<FakeNetworkPipe>(
-              Clock::GetRealTimeClock(),
-              absl::make_unique<SimulatedNetwork>(
-                  DefaultNetworkSimulationConfig())));
-      return send_transport_;
+          absl::make_unique<FakeNetworkPipe>(Clock::GetRealTimeClock(),
+                                             std::move(network)));
     }
 
     void PerformTest() override {
@@ -248,7 +248,7 @@
                 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 @@
             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 @@
     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_;