Remove deprecated API for emulated network stats
Bug: None
Change-Id: Ib70a117d67002d108474214490ed1a8bb61da463
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/283140
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38619}
diff --git a/api/test/network_emulation_manager.h b/api/test/network_emulation_manager.h
index 4df5461..bc9279d 100644
--- a/api/test/network_emulation_manager.h
+++ b/api/test/network_emulation_manager.h
@@ -144,10 +144,6 @@
// Passes summarized network stats for endpoints for this manager into
// specified `stats_callback`. Callback will be executed on network emulation
// internal task queue.
- // Deprecated.
- virtual void GetStats(
- std::function<void(std::unique_ptr<EmulatedNetworkStats>)> stats_callback)
- const = 0;
virtual void GetStats(
std::function<void(EmulatedNetworkStats)> stats_callback) const = 0;
};
@@ -332,11 +328,6 @@
// Passes combined network stats for all specified `endpoints` into specified
// `stats_callback`. Callback will be executed on network emulation
// internal task queue.
- // Deprecated.
- virtual void GetStats(
- rtc::ArrayView<EmulatedEndpoint* const> endpoints,
- std::function<void(std::unique_ptr<EmulatedNetworkStats>)>
- stats_callback) = 0;
virtual void GetStats(
rtc::ArrayView<EmulatedEndpoint* const> endpoints,
std::function<void(EmulatedNetworkStats)> stats_callback) = 0;
diff --git a/test/network/emulated_network_manager.cc b/test/network/emulated_network_manager.cc
index a540b9d..fa4037e 100644
--- a/test/network/emulated_network_manager.cc
+++ b/test/network/emulated_network_manager.cc
@@ -85,15 +85,6 @@
}
void EmulatedNetworkManager::GetStats(
- std::function<void(std::unique_ptr<EmulatedNetworkStats>)> stats_callback)
- const {
- task_queue_->PostTask([stats_callback, this]() {
- stats_callback(std::make_unique<EmulatedNetworkStats>(
- endpoints_container_->GetStats()));
- });
-}
-
-void EmulatedNetworkManager::GetStats(
std::function<void(EmulatedNetworkStats)> stats_callback) const {
task_queue_->PostTask([stats_callback, this]() {
stats_callback(endpoints_container_->GetStats());
diff --git a/test/network/emulated_network_manager.h b/test/network/emulated_network_manager.h
index a53cf47..fb4ee1e 100644
--- a/test/network/emulated_network_manager.h
+++ b/test/network/emulated_network_manager.h
@@ -58,8 +58,6 @@
std::vector<EmulatedEndpoint*> endpoints() const override {
return endpoints_container_->GetEndpoints();
}
- void GetStats(std::function<void(std::unique_ptr<EmulatedNetworkStats>)>
- stats_callback) const override;
void GetStats(
std::function<void(EmulatedNetworkStats)> stats_callback) const override;
diff --git a/test/network/network_emulation_manager.cc b/test/network/network_emulation_manager.cc
index eddc80c..97c0bc1 100644
--- a/test/network/network_emulation_manager.cc
+++ b/test/network/network_emulation_manager.cc
@@ -305,24 +305,6 @@
void NetworkEmulationManagerImpl::GetStats(
rtc::ArrayView<EmulatedEndpoint* const> endpoints,
- std::function<void(std::unique_ptr<EmulatedNetworkStats>)> stats_callback) {
- task_queue_.PostTask([endpoints, stats_callback,
- stats_gathering_mode = stats_gathering_mode_]() {
- EmulatedNetworkStatsBuilder stats_builder(stats_gathering_mode);
- for (auto* endpoint : endpoints) {
- // It's safe to cast here because EmulatedEndpointImpl can be the only
- // implementation of EmulatedEndpoint, because only it has access to
- // EmulatedEndpoint constructor.
- auto endpoint_impl = static_cast<EmulatedEndpointImpl*>(endpoint);
- stats_builder.AddEmulatedNetworkStats(endpoint_impl->stats());
- }
- stats_callback(
- std::make_unique<EmulatedNetworkStats>(stats_builder.Build()));
- });
-}
-
-void NetworkEmulationManagerImpl::GetStats(
- rtc::ArrayView<EmulatedEndpoint* const> endpoints,
std::function<void(EmulatedNetworkStats)> stats_callback) {
task_queue_.PostTask([endpoints, stats_callback,
stats_gathering_mode = stats_gathering_mode_]() {
diff --git a/test/network/network_emulation_manager.h b/test/network/network_emulation_manager.h
index 7e16dc4..29debca 100644
--- a/test/network/network_emulation_manager.h
+++ b/test/network/network_emulation_manager.h
@@ -79,9 +79,6 @@
EmulatedNetworkManagerInterface* CreateEmulatedNetworkManagerInterface(
const std::vector<EmulatedEndpoint*>& endpoints) override;
- void GetStats(rtc::ArrayView<EmulatedEndpoint* const> endpoints,
- std::function<void(std::unique_ptr<EmulatedNetworkStats>)>
- stats_callback) override;
void GetStats(
rtc::ArrayView<EmulatedEndpoint* const> endpoints,
std::function<void(EmulatedNetworkStats)> stats_callback) override;
diff --git a/test/network/network_emulation_unittest.cc b/test/network/network_emulation_unittest.cc
index 6ed4602..2e67a5a 100644
--- a/test/network/network_emulation_unittest.cc
+++ b/test/network/network_emulation_unittest.cc
@@ -255,19 +255,19 @@
const int64_t single_packet_size = data.size() + kOverheadIpv4Udp;
std::atomic<int> received_stats_count{0};
- nt1->GetStats([&](std::unique_ptr<EmulatedNetworkStats> st) {
- EXPECT_EQ(st->PacketsSent(), 2000l);
- EXPECT_EQ(st->BytesSent().bytes(), single_packet_size * 2000l);
- EXPECT_THAT(st->local_addresses,
+ nt1->GetStats([&](EmulatedNetworkStats st) {
+ EXPECT_EQ(st.PacketsSent(), 2000l);
+ EXPECT_EQ(st.BytesSent().bytes(), single_packet_size * 2000l);
+ EXPECT_THAT(st.local_addresses,
ElementsAreArray({alice_endpoint->GetPeerLocalAddress()}));
- EXPECT_EQ(st->PacketsReceived(), 2000l);
- EXPECT_EQ(st->BytesReceived().bytes(), single_packet_size * 2000l);
- EXPECT_EQ(st->PacketsDiscardedNoReceiver(), 0l);
- EXPECT_EQ(st->BytesDiscardedNoReceiver().bytes(), 0l);
+ EXPECT_EQ(st.PacketsReceived(), 2000l);
+ EXPECT_EQ(st.BytesReceived().bytes(), single_packet_size * 2000l);
+ EXPECT_EQ(st.PacketsDiscardedNoReceiver(), 0l);
+ EXPECT_EQ(st.BytesDiscardedNoReceiver().bytes(), 0l);
rtc::IPAddress bob_ip = bob_endpoint->GetPeerLocalAddress();
std::map<rtc::IPAddress, EmulatedNetworkIncomingStats> source_st =
- st->incoming_stats_per_source;
+ st.incoming_stats_per_source;
ASSERT_EQ(source_st.size(), 1lu);
EXPECT_EQ(source_st.at(bob_ip).packets_received, 2000l);
EXPECT_EQ(source_st.at(bob_ip).bytes_received.bytes(),
@@ -276,17 +276,17 @@
EXPECT_EQ(source_st.at(bob_ip).bytes_discarded_no_receiver.bytes(), 0l);
std::map<rtc::IPAddress, EmulatedNetworkOutgoingStats> dest_st =
- st->outgoing_stats_per_destination;
+ st.outgoing_stats_per_destination;
ASSERT_EQ(dest_st.size(), 1lu);
EXPECT_EQ(dest_st.at(bob_ip).packets_sent, 2000l);
EXPECT_EQ(dest_st.at(bob_ip).bytes_sent.bytes(),
single_packet_size * 2000l);
// No debug stats are collected by default.
- EXPECT_TRUE(st->SentPacketsSizeCounter().IsEmpty());
- EXPECT_TRUE(st->sent_packets_queue_wait_time_us.IsEmpty());
- EXPECT_TRUE(st->ReceivedPacketsSizeCounter().IsEmpty());
- EXPECT_TRUE(st->PacketsDiscardedNoReceiverSizeCounter().IsEmpty());
+ EXPECT_TRUE(st.SentPacketsSizeCounter().IsEmpty());
+ EXPECT_TRUE(st.sent_packets_queue_wait_time_us.IsEmpty());
+ EXPECT_TRUE(st.ReceivedPacketsSizeCounter().IsEmpty());
+ EXPECT_TRUE(st.PacketsDiscardedNoReceiverSizeCounter().IsEmpty());
EXPECT_TRUE(dest_st.at(bob_ip).sent_packets_size.IsEmpty());
EXPECT_TRUE(source_st.at(bob_ip).received_packets_size.IsEmpty());
EXPECT_TRUE(
@@ -294,22 +294,22 @@
received_stats_count++;
});
- nt2->GetStats([&](std::unique_ptr<EmulatedNetworkStats> st) {
- EXPECT_EQ(st->PacketsSent(), 2000l);
- EXPECT_EQ(st->BytesSent().bytes(), single_packet_size * 2000l);
- EXPECT_THAT(st->local_addresses,
+ nt2->GetStats([&](EmulatedNetworkStats st) {
+ EXPECT_EQ(st.PacketsSent(), 2000l);
+ EXPECT_EQ(st.BytesSent().bytes(), single_packet_size * 2000l);
+ EXPECT_THAT(st.local_addresses,
ElementsAreArray({bob_endpoint->GetPeerLocalAddress()}));
- EXPECT_EQ(st->PacketsReceived(), 2000l);
- EXPECT_EQ(st->BytesReceived().bytes(), single_packet_size * 2000l);
- EXPECT_EQ(st->PacketsDiscardedNoReceiver(), 0l);
- EXPECT_EQ(st->BytesDiscardedNoReceiver().bytes(), 0l);
- EXPECT_GT(st->FirstReceivedPacketSize(), DataSize::Zero());
- EXPECT_TRUE(st->FirstPacketReceivedTime().IsFinite());
- EXPECT_TRUE(st->LastPacketReceivedTime().IsFinite());
+ EXPECT_EQ(st.PacketsReceived(), 2000l);
+ EXPECT_EQ(st.BytesReceived().bytes(), single_packet_size * 2000l);
+ EXPECT_EQ(st.PacketsDiscardedNoReceiver(), 0l);
+ EXPECT_EQ(st.BytesDiscardedNoReceiver().bytes(), 0l);
+ EXPECT_GT(st.FirstReceivedPacketSize(), DataSize::Zero());
+ EXPECT_TRUE(st.FirstPacketReceivedTime().IsFinite());
+ EXPECT_TRUE(st.LastPacketReceivedTime().IsFinite());
rtc::IPAddress alice_ip = alice_endpoint->GetPeerLocalAddress();
std::map<rtc::IPAddress, EmulatedNetworkIncomingStats> source_st =
- st->incoming_stats_per_source;
+ st.incoming_stats_per_source;
ASSERT_EQ(source_st.size(), 1lu);
EXPECT_EQ(source_st.at(alice_ip).packets_received, 2000l);
EXPECT_EQ(source_st.at(alice_ip).bytes_received.bytes(),
@@ -318,17 +318,17 @@
EXPECT_EQ(source_st.at(alice_ip).bytes_discarded_no_receiver.bytes(), 0l);
std::map<rtc::IPAddress, EmulatedNetworkOutgoingStats> dest_st =
- st->outgoing_stats_per_destination;
+ st.outgoing_stats_per_destination;
ASSERT_EQ(dest_st.size(), 1lu);
EXPECT_EQ(dest_st.at(alice_ip).packets_sent, 2000l);
EXPECT_EQ(dest_st.at(alice_ip).bytes_sent.bytes(),
single_packet_size * 2000l);
// No debug stats are collected by default.
- EXPECT_TRUE(st->SentPacketsSizeCounter().IsEmpty());
- EXPECT_TRUE(st->sent_packets_queue_wait_time_us.IsEmpty());
- EXPECT_TRUE(st->ReceivedPacketsSizeCounter().IsEmpty());
- EXPECT_TRUE(st->PacketsDiscardedNoReceiverSizeCounter().IsEmpty());
+ EXPECT_TRUE(st.SentPacketsSizeCounter().IsEmpty());
+ EXPECT_TRUE(st.sent_packets_queue_wait_time_us.IsEmpty());
+ EXPECT_TRUE(st.ReceivedPacketsSizeCounter().IsEmpty());
+ EXPECT_TRUE(st.PacketsDiscardedNoReceiverSizeCounter().IsEmpty());
EXPECT_TRUE(dest_st.at(alice_ip).sent_packets_size.IsEmpty());
EXPECT_TRUE(source_st.at(alice_ip).received_packets_size.IsEmpty());
EXPECT_TRUE(
@@ -409,23 +409,22 @@
const int64_t single_packet_size = data.size() + kOverheadIpv4Udp;
std::atomic<int> received_stats_count{0};
- nt1->GetStats([&](std::unique_ptr<EmulatedNetworkStats> st) {
+ nt1->GetStats([&](EmulatedNetworkStats st) {
rtc::IPAddress bob_ip = bob_endpoint->GetPeerLocalAddress();
std::map<rtc::IPAddress, EmulatedNetworkIncomingStats> source_st =
- st->incoming_stats_per_source;
+ st.incoming_stats_per_source;
ASSERT_EQ(source_st.size(), 1lu);
std::map<rtc::IPAddress, EmulatedNetworkOutgoingStats> dest_st =
- st->outgoing_stats_per_destination;
+ st.outgoing_stats_per_destination;
ASSERT_EQ(dest_st.size(), 1lu);
// No debug stats are collected by default.
- EXPECT_EQ(st->SentPacketsSizeCounter().NumSamples(), 2000l);
- EXPECT_EQ(st->ReceivedPacketsSizeCounter().GetAverage(),
- single_packet_size);
- EXPECT_EQ(st->sent_packets_queue_wait_time_us.NumSamples(), 2000l);
- EXPECT_LT(st->sent_packets_queue_wait_time_us.GetMax(), 1);
- EXPECT_TRUE(st->PacketsDiscardedNoReceiverSizeCounter().IsEmpty());
+ EXPECT_EQ(st.SentPacketsSizeCounter().NumSamples(), 2000l);
+ EXPECT_EQ(st.ReceivedPacketsSizeCounter().GetAverage(), single_packet_size);
+ EXPECT_EQ(st.sent_packets_queue_wait_time_us.NumSamples(), 2000l);
+ EXPECT_LT(st.sent_packets_queue_wait_time_us.GetMax(), 1);
+ EXPECT_TRUE(st.PacketsDiscardedNoReceiverSizeCounter().IsEmpty());
EXPECT_EQ(dest_st.at(bob_ip).sent_packets_size.NumSamples(), 2000l);
EXPECT_EQ(dest_st.at(bob_ip).sent_packets_size.GetAverage(),
single_packet_size);
@@ -504,14 +503,14 @@
}
std::atomic<int> received_stats_count{0};
- nt1->GetStats([&](std::unique_ptr<EmulatedNetworkStats> st) {
- EXPECT_EQ(st->PacketsSent(), kNumPacketsSent);
- EXPECT_EQ(st->BytesSent().bytes(), kSinglePacketSize * kNumPacketsSent);
+ nt1->GetStats([&](EmulatedNetworkStats st) {
+ EXPECT_EQ(st.PacketsSent(), kNumPacketsSent);
+ EXPECT_EQ(st.BytesSent().bytes(), kSinglePacketSize * kNumPacketsSent);
const double tolerance = 0.95; // Accept 5% tolerance for timing.
- EXPECT_GE(st->LastPacketSentTime() - st->FirstPacketSentTime(),
+ EXPECT_GE(st.LastPacketSentTime() - st.FirstPacketSentTime(),
(kNumPacketsSent - 1) * kDelay * tolerance);
- EXPECT_GT(st->AverageSendRate().bps(), 0);
+ EXPECT_GT(st.AverageSendRate().bps(), 0);
received_stats_count++;
});
diff --git a/test/pc/e2e/network_quality_metrics_reporter.cc b/test/pc/e2e/network_quality_metrics_reporter.cc
index 10d1695..0bb28f0 100644
--- a/test/pc/e2e/network_quality_metrics_reporter.cc
+++ b/test/pc/e2e/network_quality_metrics_reporter.cc
@@ -110,8 +110,8 @@
EmulatedNetworkManagerInterface* network) {
rtc::Event wait;
EmulatedNetworkStats stats;
- network->GetStats([&](std::unique_ptr<EmulatedNetworkStats> s) {
- stats = *s;
+ network->GetStats([&](EmulatedNetworkStats s) {
+ stats = std::move(s);
wait.Set();
});
bool stats_received = wait.Wait(kStatsWaitTimeout);
diff --git a/test/pc/e2e/stats_based_network_quality_metrics_reporter.cc b/test/pc/e2e/stats_based_network_quality_metrics_reporter.cc
index 063d142..d4c2f93 100644
--- a/test/pc/e2e/stats_based_network_quality_metrics_reporter.cc
+++ b/test/pc/e2e/stats_based_network_quality_metrics_reporter.cc
@@ -55,11 +55,10 @@
NetworkEmulationManager* network_emulation) {
rtc::Event stats_loaded;
EmulatedNetworkStats stats;
- network_emulation->GetStats(endpoints,
- [&](std::unique_ptr<EmulatedNetworkStats> s) {
- stats = *s;
- stats_loaded.Set();
- });
+ network_emulation->GetStats(endpoints, [&](EmulatedNetworkStats s) {
+ stats = std::move(s);
+ stats_loaded.Set();
+ });
bool stats_received = stats_loaded.Wait(kStatsWaitTimeout);
RTC_CHECK(stats_received);
return stats;