diff --git a/call/fake_network_pipe.cc b/call/fake_network_pipe.cc index 9bbde61377..b9bf4e7398 100644 --- a/call/fake_network_pipe.cc +++ b/call/fake_network_pipe.cc @@ -194,6 +194,11 @@ void SimulatedNetwork::SetConfig(const SimulatedNetwork::Config& config) { } } +void SimulatedNetwork::PauseTransmissionUntil(int64_t until_us) { + rtc::CritScope crit(&config_lock_); + pause_transmission_until_us_ = until_us; +} + bool SimulatedNetwork::EnqueuePacket(PacketInFlightInfo packet) { Config config; { @@ -222,6 +227,14 @@ bool SimulatedNetwork::EnqueuePacket(PacketInFlightInfo packet) { } int64_t network_start_time_us = packet.send_time_us; + { + rtc::CritScope crit(&config_lock_); + if (pause_transmission_until_us_) { + network_start_time_us = + std::max(network_start_time_us, *pause_transmission_until_us_); + pause_transmission_until_us_.reset(); + } + } // Check if there already are packets on the link and change network start // time forward if there is. if (!capacity_link_.empty() && diff --git a/call/fake_network_pipe.h b/call/fake_network_pipe.h index b7d5e2e6a2..ea9c60b047 100644 --- a/call/fake_network_pipe.h +++ b/call/fake_network_pipe.h @@ -109,6 +109,7 @@ class SimulatedNetwork : public NetworkSimulationInterface { // Sets a new configuration. This won't affect packets already in the pipe. void SetConfig(const Config& config); + void PauseTransmissionUntil(int64_t until_us); // NetworkSimulationInterface bool EnqueuePacket(PacketInFlightInfo packet) override; @@ -134,6 +135,8 @@ class SimulatedNetwork : public NetworkSimulationInterface { // Link configuration. Config config_ RTC_GUARDED_BY(config_lock_); + absl::optional pause_transmission_until_us_ + RTC_GUARDED_BY(config_lock_); // Are we currently dropping a burst of packets? bool bursting_;