From 8ea1e9def1afcc78bab6d05b2956ddf8b11972cd Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Thu, 4 Oct 2018 14:46:31 +0200 Subject: [PATCH] Switch webrtc from deprecated usages of NetworkSimulationInterface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:9630 Change-Id: I42222261676b0c260c1aab81523a23988d3cd1c1 Reviewed-on: https://webrtc-review.googlesource.com/c/103780 Reviewed-by: Patrik Höglund Commit-Queue: Artem Titov Cr-Commit-Position: refs/heads/master@{#25011} --- api/test/video_quality_test_fixture.h | 4 ++-- call/fake_network_pipe.cc | 23 +++++++++---------- call/fake_network_pipe.h | 32 ++++++++++++--------------- call/simulated_network.h | 4 ++-- test/scenario/network_node.cc | 12 +++++----- test/scenario/network_node.h | 6 ++--- test/scenario/scenario.cc | 4 ++-- test/scenario/scenario.h | 2 +- video/video_quality_test.cc | 16 +++++++------- 9 files changed, 49 insertions(+), 54 deletions(-) diff --git a/api/test/video_quality_test_fixture.h b/api/test/video_quality_test_fixture.h index 5ec77137ae..ff1472e9a5 100644 --- a/api/test/video_quality_test_fixture.h +++ b/api/test/video_quality_test_fixture.h @@ -118,8 +118,8 @@ class VideoQualityTestFixtureInterface { // Simulations of sender and receiver networks. They must either both be // null (in which case `config` from Params is used), or both be non-null // (in which case `config` from Params must be nullopt). - std::unique_ptr sender_network; - std::unique_ptr receiver_network; + std::unique_ptr sender_network; + std::unique_ptr receiver_network; std::unique_ptr fec_controller_factory; }; diff --git a/call/fake_network_pipe.cc b/call/fake_network_pipe.cc index 0e0366695e..e702c1b6f5 100644 --- a/call/fake_network_pipe.cc +++ b/call/fake_network_pipe.cc @@ -68,22 +68,22 @@ NetworkPacket& NetworkPacket::operator=(NetworkPacket&& o) { FakeNetworkPipe::FakeNetworkPipe( Clock* clock, - std::unique_ptr network_simulation) - : FakeNetworkPipe(clock, std::move(network_simulation), nullptr, 1) {} + std::unique_ptr network_behavior) + : FakeNetworkPipe(clock, std::move(network_behavior), nullptr, 1) {} FakeNetworkPipe::FakeNetworkPipe( Clock* clock, - std::unique_ptr network_simulation, + std::unique_ptr network_behavior, PacketReceiver* receiver) - : FakeNetworkPipe(clock, std::move(network_simulation), receiver, 1) {} + : FakeNetworkPipe(clock, std::move(network_behavior), receiver, 1) {} FakeNetworkPipe::FakeNetworkPipe( Clock* clock, - std::unique_ptr network_simulation, + std::unique_ptr network_behavior, PacketReceiver* receiver, uint64_t seed) : clock_(clock), - network_simulation_(std::move(network_simulation)), + network_behavior_(std::move(network_behavior)), receiver_(receiver), transport_(nullptr), clock_offset_ms_(0), @@ -95,10 +95,10 @@ FakeNetworkPipe::FakeNetworkPipe( FakeNetworkPipe::FakeNetworkPipe( Clock* clock, - std::unique_ptr network_simulation, + std::unique_ptr network_behavior, Transport* transport) : clock_(clock), - network_simulation_(std::move(network_simulation)), + network_behavior_(std::move(network_behavior)), receiver_(nullptr), transport_(transport), clock_offset_ms_(0), @@ -162,7 +162,7 @@ bool FakeNetworkPipe::EnqueuePacket(rtc::CopyOnWriteBuffer packet, packets_in_flight_.emplace_back(StoredPacket(std::move(net_packet))); int64_t packet_id = reinterpret_cast(&packets_in_flight_.back()); - bool sent = network_simulation_->EnqueuePacket( + bool sent = network_behavior_->EnqueuePacket( PacketInFlightInfo(packet_size, time_now_us, packet_id)); if (!sent) { @@ -217,7 +217,7 @@ void FakeNetworkPipe::Process() { } std::vector delivery_infos = - network_simulation_->DequeueDeliverablePackets(time_now_us); + network_behavior_->DequeueDeliverablePackets(time_now_us); for (auto& delivery_info : delivery_infos) { // In the common case where no reordering happens, find will return early // as the first packet will be a match. @@ -261,8 +261,7 @@ void FakeNetworkPipe::Process() { packets_to_deliver.pop(); DeliverNetworkPacket(&packet); } - absl::optional delivery_us = - network_simulation_->NextDeliveryTimeUs(); + absl::optional delivery_us = network_behavior_->NextDeliveryTimeUs(); next_process_time_us_ = delivery_us ? *delivery_us : time_now_us + kDefaultProcessIntervalMs * 1000; diff --git a/call/fake_network_pipe.h b/call/fake_network_pipe.h index 579e1fb18b..f85e82efc5 100644 --- a/call/fake_network_pipe.h +++ b/call/fake_network_pipe.h @@ -90,26 +90,22 @@ class NetworkPacket { class FakeNetworkPipe : public webrtc::SimulatedPacketReceiverInterface, public Transport { public: - // Will keep |network_simulation| alive while pipe is alive itself. + // Will keep |network_behavior| alive while pipe is alive itself. // Use these constructors if you plan to insert packets using DeliverPacket(). - FakeNetworkPipe( - Clock* clock, - std::unique_ptr network_simulation); - FakeNetworkPipe( - Clock* clock, - std::unique_ptr network_simulation, - PacketReceiver* receiver); - FakeNetworkPipe( - Clock* clock, - std::unique_ptr network_simulation, - PacketReceiver* receiver, - uint64_t seed); + FakeNetworkPipe(Clock* clock, + std::unique_ptr network_behavior); + FakeNetworkPipe(Clock* clock, + std::unique_ptr network_behavior, + PacketReceiver* receiver); + FakeNetworkPipe(Clock* clock, + std::unique_ptr network_behavior, + PacketReceiver* receiver, + uint64_t seed); // Use this constructor if you plan to insert packets using SendRt[c?]p(). - FakeNetworkPipe( - Clock* clock, - std::unique_ptr network_simulation, - Transport* transport); + FakeNetworkPipe(Clock* clock, + std::unique_ptr network_behavior, + Transport* transport); ~FakeNetworkPipe() override; @@ -193,7 +189,7 @@ class FakeNetworkPipe : public webrtc::SimulatedPacketReceiverInterface, 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_behavior_; 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 9646a8990f..0f8453283a 100644 --- a/call/simulated_network.h +++ b/call/simulated_network.h @@ -26,7 +26,7 @@ namespace webrtc { // Class simulating a network link. This is a simple and naive solution just // faking capacity and adding an extra transport delay in addition to the // capacity introduced delay. -class SimulatedNetwork : public NetworkSimulationInterface { +class SimulatedNetwork : public NetworkBehaviorInterface { public: using Config = DefaultNetworkSimulationConfig; explicit SimulatedNetwork(Config config, uint64_t random_seed = 1); @@ -36,7 +36,7 @@ class SimulatedNetwork : public NetworkSimulationInterface { void SetConfig(const Config& config); void PauseTransmissionUntil(int64_t until_us); - // NetworkSimulationInterface + // NetworkBehaviorInterface bool EnqueuePacket(PacketInFlightInfo packet) override; std::vector DequeueDeliverablePackets( int64_t receive_time_us) override; diff --git a/test/scenario/network_node.cc b/test/scenario/network_node.cc index 6fec9eb659..ff138939ab 100644 --- a/test/scenario/network_node.cc +++ b/test/scenario/network_node.cc @@ -44,9 +44,9 @@ bool ActionReceiver::TryDeliverPacket(rtc::CopyOnWriteBuffer packet, NetworkNode::~NetworkNode() = default; NetworkNode::NetworkNode(NetworkNodeConfig config, - std::unique_ptr simulation) + std::unique_ptr behavior) : packet_overhead_(config.packet_overhead.bytes()), - simulation_(std::move(simulation)) {} + behavior_(std::move(behavior)) {} void NetworkNode::SetRoute(uint64_t receiver, NetworkReceiverInterface* node) { rtc::CritScope crit(&crit_sect_); @@ -66,7 +66,7 @@ bool NetworkNode::TryDeliverPacket(rtc::CopyOnWriteBuffer packet, if (routing_.find(receiver) == routing_.end()) return false; uint64_t packet_id = next_packet_id_++; - bool sent = simulation_->EnqueuePacket(PacketInFlightInfo( + bool sent = behavior_->EnqueuePacket(PacketInFlightInfo( packet.size() + packet_overhead_, at_time.us(), packet_id)); if (sent) { packets_.emplace_back(StoredPacket{packet, receiver, packet_id, false}); @@ -78,11 +78,11 @@ void NetworkNode::Process(Timestamp at_time) { std::vector delivery_infos; { rtc::CritScope crit(&crit_sect_); - absl::optional delivery_us = simulation_->NextDeliveryTimeUs(); + absl::optional delivery_us = behavior_->NextDeliveryTimeUs(); if (delivery_us && *delivery_us > at_time.us()) return; - delivery_infos = simulation_->DequeueDeliverablePackets(at_time.us()); + delivery_infos = behavior_->DequeueDeliverablePackets(at_time.us()); } for (PacketDeliveryInfo& delivery_info : delivery_infos) { StoredPacket* packet = nullptr; @@ -162,7 +162,7 @@ ColumnPrinter SimulationNode::ConfigPrinter() const { SimulationNode::SimulationNode( NetworkNodeConfig config, - std::unique_ptr behavior, + std::unique_ptr behavior, SimulatedNetwork* simulation) : NetworkNode(config, std::move(behavior)), simulated_network_(simulation), diff --git a/test/scenario/network_node.h b/test/scenario/network_node.h index a94df1b34b..af6db0a009 100644 --- a/test/scenario/network_node.h +++ b/test/scenario/network_node.h @@ -75,7 +75,7 @@ class NetworkNode : public NetworkReceiverInterface { friend class VideoStreamPair; NetworkNode(NetworkNodeConfig config, - std::unique_ptr simulation); + std::unique_ptr simulation); static void ClearRoute(int64_t receiver_id, std::vector nodes); void Process(Timestamp at_time); @@ -90,7 +90,7 @@ class NetworkNode : public NetworkReceiverInterface { void ClearRoute(uint64_t receiver_id); rtc::CriticalSection crit_sect_; size_t packet_overhead_ RTC_GUARDED_BY(crit_sect_); - const std::unique_ptr simulation_ + const std::unique_ptr behavior_ RTC_GUARDED_BY(crit_sect_); std::map routing_ RTC_GUARDED_BY(crit_sect_); @@ -110,7 +110,7 @@ class SimulationNode : public NetworkNode { friend class Scenario; SimulationNode(NetworkNodeConfig config, - std::unique_ptr behavior, + std::unique_ptr behavior, SimulatedNetwork* simulation); static std::unique_ptr Create(NetworkNodeConfig config); SimulatedNetwork* const simulated_network_; diff --git a/test/scenario/scenario.cc b/test/scenario/scenario.cc index 107365f42f..7eb09e8bb7 100644 --- a/test/scenario/scenario.cc +++ b/test/scenario/scenario.cc @@ -167,9 +167,9 @@ SimulationNode* Scenario::CreateSimulationNode(NetworkNodeConfig config) { NetworkNode* Scenario::CreateNetworkNode( NetworkNodeConfig config, - std::unique_ptr simulation) { + std::unique_ptr behavior) { RTC_DCHECK(config.mode == NetworkNodeConfig::TrafficMode::kCustom); - network_nodes_.emplace_back(new NetworkNode(config, std::move(simulation))); + network_nodes_.emplace_back(new NetworkNode(config, std::move(behavior))); NetworkNode* network_node = network_nodes_.back().get(); Every(config.update_frequency, [this, network_node] { network_node->Process(Now()); }); diff --git a/test/scenario/scenario.h b/test/scenario/scenario.h index 9390b0670e..05876ac49c 100644 --- a/test/scenario/scenario.h +++ b/test/scenario/scenario.h @@ -71,7 +71,7 @@ class Scenario { std::function config_modifier); NetworkNode* CreateNetworkNode( NetworkNodeConfig config, - std::unique_ptr simulation); + std::unique_ptr behavior); CallClient* CreateClient(std::string name, CallClientConfig config); CallClient* CreateClient( diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc index 224e4a8a81..2a3be672d7 100644 --- a/video/video_quality_test.cc +++ b/video/video_quality_test.cc @@ -1006,16 +1006,16 @@ void VideoQualityTest::StopThumbnails() { std::unique_ptr VideoQualityTest::CreateSendTransport() { - std::unique_ptr simulated_network = nullptr; + std::unique_ptr network_behavior = nullptr; if (injection_components_->sender_network == nullptr) { - simulated_network = absl::make_unique(*params_.config); + network_behavior = absl::make_unique(*params_.config); } else { - simulated_network = std::move(injection_components_->sender_network); + network_behavior = std::move(injection_components_->sender_network); } return absl::make_unique( &task_queue_, absl::make_unique(Clock::GetRealTimeClock(), - std::move(simulated_network)), + std::move(network_behavior)), sender_call_.get(), kPayloadTypeVP8, kPayloadTypeVP9, params_.video[0].selected_tl, params_.ss[0].selected_sl, payload_type_map_, kVideoSendSsrcs[0], @@ -1025,16 +1025,16 @@ VideoQualityTest::CreateSendTransport() { std::unique_ptr VideoQualityTest::CreateReceiveTransport() { - std::unique_ptr simulated_network = nullptr; + std::unique_ptr network_behavior = nullptr; if (injection_components_->receiver_network == nullptr) { - simulated_network = absl::make_unique(*params_.config); + network_behavior = absl::make_unique(*params_.config); } else { - simulated_network = std::move(injection_components_->receiver_network); + network_behavior = std::move(injection_components_->receiver_network); } return absl::make_unique( &task_queue_, absl::make_unique(Clock::GetRealTimeClock(), - std::move(simulated_network)), + std::move(network_behavior)), receiver_call_.get(), payload_type_map_); }