Add replacements for all FakeNetworkPipe ctors.
Add replacements for all FakeNetworkPipe constructos, that will accept instance of NetworkSimulationInterface instead of config to be able to use any implmentation of network simulation. Bug: webrtc:9630 Change-Id: Ifceb2f0d028faf255648891ce695b3742f866044 Reviewed-on: https://webrtc-review.googlesource.com/94541 Commit-Queue: Artem Titov <titovartem@webrtc.org> Reviewed-by: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24320}
This commit is contained in:
parent
6b1985de95
commit
b005087a8c
@ -88,20 +88,6 @@ FakeNetworkPipe::FakeNetworkPipe(Clock* clock,
|
||||
const FakeNetworkPipe::Config& config)
|
||||
: FakeNetworkPipe(clock, config, nullptr, 1) {}
|
||||
|
||||
FakeNetworkPipe::FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation)
|
||||
: clock_(clock),
|
||||
network_simulation_(std::move(network_simulation)),
|
||||
receiver_(nullptr),
|
||||
transport_(nullptr),
|
||||
clock_offset_ms_(0),
|
||||
dropped_packets_(0),
|
||||
sent_packets_(0),
|
||||
total_packet_delay_us_(0),
|
||||
next_process_time_us_(clock_->TimeInMicroseconds()),
|
||||
last_log_time_us_(clock_->TimeInMicroseconds()) {}
|
||||
|
||||
FakeNetworkPipe::FakeNetworkPipe(Clock* clock,
|
||||
const FakeNetworkPipe::Config& config,
|
||||
PacketReceiver* receiver)
|
||||
@ -136,6 +122,48 @@ FakeNetworkPipe::FakeNetworkPipe(Clock* clock,
|
||||
next_process_time_us_(clock_->TimeInMicroseconds()),
|
||||
last_log_time_us_(clock_->TimeInMicroseconds()) {}
|
||||
|
||||
FakeNetworkPipe::FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation)
|
||||
: FakeNetworkPipe(clock, std::move(network_simulation), nullptr, 1) {}
|
||||
|
||||
FakeNetworkPipe::FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||
PacketReceiver* receiver)
|
||||
: FakeNetworkPipe(clock, std::move(network_simulation), receiver, 1) {}
|
||||
|
||||
FakeNetworkPipe::FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||
PacketReceiver* receiver,
|
||||
uint64_t seed)
|
||||
: clock_(clock),
|
||||
network_simulation_(std::move(network_simulation)),
|
||||
receiver_(receiver),
|
||||
transport_(nullptr),
|
||||
clock_offset_ms_(0),
|
||||
dropped_packets_(0),
|
||||
sent_packets_(0),
|
||||
total_packet_delay_us_(0),
|
||||
next_process_time_us_(clock_->TimeInMicroseconds()),
|
||||
last_log_time_us_(clock_->TimeInMicroseconds()) {}
|
||||
|
||||
FakeNetworkPipe::FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||
Transport* transport)
|
||||
: clock_(clock),
|
||||
network_simulation_(std::move(network_simulation)),
|
||||
receiver_(nullptr),
|
||||
transport_(transport),
|
||||
clock_offset_ms_(0),
|
||||
dropped_packets_(0),
|
||||
sent_packets_(0),
|
||||
total_packet_delay_us_(0),
|
||||
next_process_time_us_(clock_->TimeInMicroseconds()),
|
||||
last_log_time_us_(clock_->TimeInMicroseconds()) {}
|
||||
|
||||
FakeNetworkPipe::~FakeNetworkPipe() = default;
|
||||
|
||||
void FakeNetworkPipe::SetReceiver(PacketReceiver* receiver) {
|
||||
|
||||
@ -103,31 +103,54 @@ class FakeNetworkPipe : public Transport, public PacketReceiver, public Module {
|
||||
public:
|
||||
using Config = NetworkSimulationInterface::SimulatedNetworkConfig;
|
||||
|
||||
// Deprecated. DO NOT USE. To be removed. Use corresponding version with
|
||||
// NetworkSimulationInterface instance instead.
|
||||
// Use these constructors if you plan to insert packets using DeliverPacket().
|
||||
FakeNetworkPipe(Clock* clock, const FakeNetworkPipe::Config& config);
|
||||
// Will keep |network_simulation| alive while pipe is alive itself.
|
||||
// Use these constructors if you plan to insert packets using DeliverPacket().
|
||||
FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation);
|
||||
// Deprecated. DO NOT USE. To be removed. Use corresponding version with
|
||||
// NetworkSimulationInterface instance instead.
|
||||
FakeNetworkPipe(Clock* clock,
|
||||
const FakeNetworkPipe::Config& config,
|
||||
PacketReceiver* receiver);
|
||||
FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||
PacketReceiver* receiver);
|
||||
// Deprecated. DO NOT USE. To be removed. Use corresponding version with
|
||||
// NetworkSimulationInterface instance instead.
|
||||
FakeNetworkPipe(Clock* clock,
|
||||
const FakeNetworkPipe::Config& config,
|
||||
PacketReceiver* receiver,
|
||||
uint64_t seed);
|
||||
FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||
PacketReceiver* receiver,
|
||||
uint64_t seed);
|
||||
|
||||
// Deprecated. DO NOT USE. To be removed. Use corresponding version with
|
||||
// NetworkSimulationInterface instance instead.
|
||||
// Use this constructor if you plan to insert packets using SendRt[c?]p().
|
||||
FakeNetworkPipe(Clock* clock,
|
||||
const FakeNetworkPipe::Config& config,
|
||||
Transport* transport);
|
||||
// Use this constructor if you plan to insert packets using SendRt[c?]p().
|
||||
FakeNetworkPipe(
|
||||
Clock* clock,
|
||||
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||
Transport* transport);
|
||||
|
||||
~FakeNetworkPipe() override;
|
||||
|
||||
void SetClockOffset(int64_t offset_ms);
|
||||
|
||||
// DO NOT USE. Hold direct reference on NetworkSimulationInterface instead
|
||||
// and call SetConfig on that object directly. Will be removed soon.
|
||||
// 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 FakeNetworkPipe::Config& config);
|
||||
|
||||
|
||||
@ -208,8 +208,7 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithEmptyPipeTest) {
|
||||
std::unique_ptr<SimulatedNetwork> network(new SimulatedNetwork(config));
|
||||
SimulatedNetwork* simulated_network = network.get();
|
||||
std::unique_ptr<FakeNetworkPipe> pipe(
|
||||
new FakeNetworkPipe(&fake_clock_, std::move(network)));
|
||||
pipe->SetReceiver(&receiver);
|
||||
new FakeNetworkPipe(&fake_clock_, std::move(network), &receiver));
|
||||
|
||||
// Add 10 packets of 1000 bytes, = 80 kb, and verify it takes one second to
|
||||
// get through the pipe.
|
||||
@ -270,8 +269,7 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithPacketsInPipeTest) {
|
||||
std::unique_ptr<SimulatedNetwork> network(new SimulatedNetwork(config));
|
||||
SimulatedNetwork* simulated_network = network.get();
|
||||
std::unique_ptr<FakeNetworkPipe> pipe(
|
||||
new FakeNetworkPipe(&fake_clock_, std::move(network)));
|
||||
pipe->SetReceiver(&receiver);
|
||||
new FakeNetworkPipe(&fake_clock_, std::move(network), &receiver));
|
||||
|
||||
// Add 10 packets of 1000 bytes, = 80 kb.
|
||||
const int kNumPackets = 10;
|
||||
@ -328,8 +326,7 @@ TEST_F(FakeNetworkPipeTest, DisallowReorderingThenAllowReordering) {
|
||||
std::unique_ptr<SimulatedNetwork> network(new SimulatedNetwork(config));
|
||||
SimulatedNetwork* simulated_network = network.get();
|
||||
std::unique_ptr<FakeNetworkPipe> pipe(
|
||||
new FakeNetworkPipe(&fake_clock_, std::move(network)));
|
||||
pipe->SetReceiver(&receiver);
|
||||
new FakeNetworkPipe(&fake_clock_, std::move(network), &receiver));
|
||||
|
||||
const uint32_t kNumPackets = 100;
|
||||
const int kPacketSize = 10;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user