diff --git a/api/stats/rtcstats_objects.h b/api/stats/rtcstats_objects.h index a597d6f3ce..f377809ba3 100644 --- a/api/stats/rtcstats_objects.h +++ b/api/stats/rtcstats_objects.h @@ -199,6 +199,7 @@ class RTCIceCandidateStats : public RTCStats { RTCStatsMember ip; RTCStatsMember port; RTCStatsMember protocol; + RTCStatsMember relay_protocol; // TODO(hbos): Support enum types? "RTCStatsMember"? RTCStatsMember candidate_type; RTCStatsMember priority; diff --git a/pc/rtcstats_integrationtest.cc b/pc/rtcstats_integrationtest.cc index 38007405ba..3c07e38b5a 100644 --- a/pc/rtcstats_integrationtest.cc +++ b/pc/rtcstats_integrationtest.cc @@ -497,6 +497,7 @@ class RTCStatsReportVerifier { verifier.TestMemberIsNonNegative(candidate.priority); verifier.TestMemberIsUndefined(candidate.url); verifier.TestMemberIsDefined(candidate.deleted); + verifier.TestMemberIsUndefined(candidate.relay_protocol); return verifier.ExpectAllMembersSuccessfullyTested(); } diff --git a/pc/rtcstatscollector.cc b/pc/rtcstatscollector.cc index da2fef1946..d8839430eb 100644 --- a/pc/rtcstatscollector.cc +++ b/pc/rtcstatscollector.cc @@ -363,6 +363,13 @@ const std::string& ProduceIceCandidateStats( if (is_local) { candidate_stats->network_type = NetworkAdapterTypeToStatsType(candidate.network_type()); + if (candidate.type() == cricket::RELAY_PORT_TYPE) { + std::string relay_protocol = candidate.relay_protocol(); + RTC_DCHECK(relay_protocol.compare("udp") == 0 || + relay_protocol.compare("tcp") == 0 || + relay_protocol.compare("tls") == 0); + candidate_stats->relay_protocol = relay_protocol; + } } else { // We don't expect to know the adapter type of remote candidates. RTC_DCHECK_EQ(rtc::ADAPTER_TYPE_UNKNOWN, candidate.network_type()); diff --git a/pc/rtcstatscollector_unittest.cc b/pc/rtcstatscollector_unittest.cc index c14fecc025..7404d492ef 100644 --- a/pc/rtcstatscollector_unittest.cc +++ b/pc/rtcstatscollector_unittest.cc @@ -993,6 +993,23 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { expected_a_remote_relay.deleted = false; EXPECT_TRUE(*expected_a_remote_relay.is_remote); + std::unique_ptr a_local_relay = CreateFakeCandidate( + "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"); + + RTCRemoteIceCandidateStats expected_a_local_relay( + "RTCIceCandidate_" + a_local_relay->id(), 0); + expected_a_local_relay.transport_id = "RTCTransport_a_0"; + expected_a_local_relay.ip = "16.17.18.19"; + expected_a_local_relay.port = 21; + expected_a_local_relay.protocol = "a_local_relay's protocol"; + expected_a_local_relay.relay_protocol = "tcp"; + expected_a_local_relay.candidate_type = "relay"; + expected_a_local_relay.priority = 1; + expected_a_local_relay.deleted = false; + EXPECT_TRUE(*expected_a_local_relay.is_remote); + // Candidates in the second transport stats. std::unique_ptr b_local = CreateFakeCandidate("42.42.42.42", 42, "b_local's protocol", @@ -1023,6 +1040,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { expected_b_remote.deleted = false; EXPECT_TRUE(*expected_b_remote.is_remote); + // Add candidate pairs to connection. cricket::TransportChannelStats a_transport_channel_stats; a_transport_channel_stats.connection_infos.push_back( cricket::ConnectionInfo()); @@ -1036,6 +1054,12 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidateStats) { *a_local_prflx.get(); a_transport_channel_stats.connection_infos[1].remote_candidate = *a_remote_relay.get(); + a_transport_channel_stats.connection_infos.push_back( + cricket::ConnectionInfo()); + a_transport_channel_stats.connection_infos[2].local_candidate = + *a_local_relay.get(); + a_transport_channel_stats.connection_infos[2].remote_candidate = + *a_remote_relay.get(); pc_->AddVoiceChannel("audio", "a"); pc_->SetTransportStats("a", a_transport_channel_stats); diff --git a/stats/rtcstats_objects.cc b/stats/rtcstats_objects.cc index 9fc5d8bf14..dcc1180f16 100644 --- a/stats/rtcstats_objects.cc +++ b/stats/rtcstats_objects.cc @@ -246,6 +246,7 @@ WEBRTC_RTCSTATS_IMPL(RTCIceCandidateStats, RTCStats, "abstract-ice-candidate", &ip, &port, &protocol, + &relay_protocol, &candidate_type, &priority, &url, @@ -267,6 +268,7 @@ RTCIceCandidateStats::RTCIceCandidateStats(std::string&& id, ip("ip"), port("port"), protocol("protocol"), + relay_protocol("relayProtocol"), candidate_type("candidateType"), priority("priority"), url("url"), @@ -280,6 +282,7 @@ RTCIceCandidateStats::RTCIceCandidateStats(const RTCIceCandidateStats& other) ip(other.ip), port(other.port), protocol(other.protocol), + relay_protocol(other.relay_protocol), candidate_type(other.candidate_type), priority(other.priority), url(other.url),