From 847a9c70c2f952470a418e5b0eee30f91046d151 Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Tue, 14 Aug 2018 15:44:31 +0200 Subject: [PATCH] Use NetworkSimulationInterface instead of SimulatedNetwork. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switch on using NetworkSimulatedInterface in FakeNetwork pipe to be able to inject different implementations in future. Also temporary add SetConfig(...) method to NetworkSimulationInterface to make it possible to use it in FakeNetworkPipe. This method will be removed by futher refactoring. Bug: webrtc:9630 Change-Id: I2ce2219f523b4121e46643699ab87b37da09d95b Reviewed-on: https://webrtc-review.googlesource.com/94145 Reviewed-by: Patrik Höglund Reviewed-by: Sebastian Jansson Commit-Queue: Artem Titov Cr-Commit-Position: refs/heads/master@{#24289} --- api/test/simulated_network.h | 5 +++++ call/fake_network_pipe.cc | 1 + call/fake_network_pipe.h | 5 ++--- call/simulated_network.h | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/api/test/simulated_network.h b/api/test/simulated_network.h index 4ddc4377d1..89345f539a 100644 --- a/api/test/simulated_network.h +++ b/api/test/simulated_network.h @@ -64,6 +64,11 @@ class NetworkSimulationInterface { int avg_burst_loss_length = -1; }; + // DO NOT USE. Method added temporary for further refactoring and will be + // removed soon. + // Sets a new configuration. This won't affect packets already in the pipe. + virtual void SetConfig(const SimulatedNetworkConfig& config) = 0; + virtual bool EnqueuePacket(PacketInFlightInfo packet_info) = 0; // Retrieves all packets that should be delivered by the given receive time. virtual std::vector DequeueDeliverablePackets( diff --git a/call/fake_network_pipe.cc b/call/fake_network_pipe.cc index 21ee652b09..e2fa2f4e99 100644 --- a/call/fake_network_pipe.cc +++ b/call/fake_network_pipe.cc @@ -18,6 +18,7 @@ #include "absl/memory/memory.h" #include "call/call.h" #include "call/fake_network_pipe.h" +#include "call/simulated_network.h" #include "rtc_base/logging.h" #include "system_wrappers/include/clock.h" diff --git a/call/fake_network_pipe.h b/call/fake_network_pipe.h index 6e2bc11c6e..531329ee72 100644 --- a/call/fake_network_pipe.h +++ b/call/fake_network_pipe.h @@ -22,7 +22,6 @@ #include "api/call/transport.h" #include "api/test/simulated_network.h" #include "call/call.h" -#include "call/simulated_network.h" #include "common_types.h" // NOLINT(build/include) #include "modules/include/module.h" #include "rtc_base/constructormagic.h" @@ -102,7 +101,7 @@ class NetworkPacket { // SimulatedNetworkInterface to simulate network behavior. class FakeNetworkPipe : public Transport, public PacketReceiver, public Module { public: - using Config = SimulatedNetwork::Config; + using Config = NetworkSimulationInterface::SimulatedNetworkConfig; // Use these constructors if you plan to insert packets using DeliverPacket(). FakeNetworkPipe(Clock* clock, const FakeNetworkPipe::Config& config); @@ -212,7 +211,7 @@ class FakeNetworkPipe : public Transport, public PacketReceiver, public Module { Clock* const clock_; // |config_lock| guards the mostly constant things like the callbacks. rtc::CriticalSection config_lock_; - const std::unique_ptr network_simulation_; + const std::unique_ptr network_simulation_; PacketReceiver* receiver_ RTC_GUARDED_BY(config_lock_); Transport* const transport_ RTC_GUARDED_BY(config_lock_); diff --git a/call/simulated_network.h b/call/simulated_network.h index 53283bfb16..0ddd1f85fc 100644 --- a/call/simulated_network.h +++ b/call/simulated_network.h @@ -33,7 +33,7 @@ class SimulatedNetwork : public NetworkSimulationInterface { ~SimulatedNetwork() override; // Sets a new configuration. This won't affect packets already in the pipe. - void SetConfig(const Config& config); + void SetConfig(const Config& config) override; void PauseTransmissionUntil(int64_t until_us); // NetworkSimulationInterface