Use NetworkSimulationInterface instead of SimulatedNetwork.

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 <phoglund@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24289}
This commit is contained in:
Artem Titov 2018-08-14 15:44:31 +02:00 committed by Commit Bot
parent b75d6b8dc3
commit 847a9c70c2
4 changed files with 9 additions and 4 deletions

View File

@ -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<PacketDeliveryInfo> DequeueDeliverablePackets(

View File

@ -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"

View File

@ -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<SimulatedNetwork> network_simulation_;
const std::unique_ptr<NetworkSimulationInterface> network_simulation_;
PacketReceiver* receiver_ RTC_GUARDED_BY(config_lock_);
Transport* const transport_ RTC_GUARDED_BY(config_lock_);

View File

@ -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