From 05b29c77014588747027dd9b1435bfab9da75fde Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Wed, 2 Feb 2022 12:06:15 +0100 Subject: [PATCH] stats: collect RTCIceCandidate url MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG=webrtc:13652 Change-Id: I80eaa11eb9c6ff3523cbd48d47dd68beb39d5188 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250200 Reviewed-by: Henrik Boström Reviewed-by: Harald Alvestrand Commit-Queue: Philipp Hancke Cr-Commit-Position: refs/heads/main@{#35900} --- api/stats/rtcstats_objects.h | 1 - pc/rtc_stats_collector.cc | 8 ++++++++ pc/rtc_stats_collector_unittest.cc | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/api/stats/rtcstats_objects.h b/api/stats/rtcstats_objects.h index dec3094b45..f38d962e15 100644 --- a/api/stats/rtcstats_objects.h +++ b/api/stats/rtcstats_objects.h @@ -225,7 +225,6 @@ class RTC_EXPORT RTCIceCandidateStats : public RTCStats { // TODO(hbos): Support enum types? "RTCStatsMember"? RTCStatsMember candidate_type; RTCStatsMember priority; - // TODO(hbos): Not collected by `RTCStatsCollector`. crbug.com/632723 RTCStatsMember url; protected: diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc index a60972a68e..7e9807e449 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc @@ -733,6 +733,7 @@ const std::string& ProduceIceCandidateStats(int64_t timestamp_us, NetworkAdapterTypeToStatsType(candidate.network_type()); const std::string& candidate_type = candidate.type(); const std::string& relay_protocol = candidate.relay_protocol(); + const std::string& url = candidate.url(); if (candidate_type == cricket::RELAY_PORT_TYPE || (candidate_type == cricket::PRFLX_PORT_TYPE && !relay_protocol.empty())) { @@ -740,6 +741,13 @@ const std::string& ProduceIceCandidateStats(int64_t timestamp_us, relay_protocol.compare("tcp") == 0 || relay_protocol.compare("tls") == 0); candidate_stats->relay_protocol = relay_protocol; + if (!url.empty()) { + candidate_stats->url = url; + } + } else if (candidate_type == cricket::STUN_PORT_TYPE) { + if (!url.empty()) { + candidate_stats->url = url; + } } } else { // We don't expect to know the adapter type of remote candidates. diff --git a/pc/rtc_stats_collector_unittest.cc b/pc/rtc_stats_collector_unittest.cc index 93a408093d..8f0936c26c 100644 --- a/pc/rtc_stats_collector_unittest.cc +++ b/pc/rtc_stats_collector_unittest.cc @@ -1284,6 +1284,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { "16.17.18.19", 21, "a_local_relay's protocol", rtc::ADAPTER_TYPE_UNKNOWN, cricket::RELAY_PORT_TYPE, 1); a_local_relay->set_relay_protocol("tcp"); + a_local_relay->set_url("turn:url1"); RTCLocalIceCandidateStats expected_a_local_relay( "RTCIceCandidate_" + a_local_relay->id(), 0); @@ -1296,6 +1297,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { expected_a_local_relay.relay_protocol = "tcp"; expected_a_local_relay.candidate_type = "relay"; expected_a_local_relay.priority = 1; + expected_a_local_relay.url = "turn:url1"; std::unique_ptr a_local_relay_prflx = CreateFakeCandidate( "11.12.13.20", 22, "a_local_relay_prflx's protocol",