diff --git a/api/umametrics.h b/api/umametrics.h index 88ab08c1be..239eff3869 100644 --- a/api/umametrics.h +++ b/api/umametrics.h @@ -79,12 +79,17 @@ enum IceCandidatePairType { kIceCandidatePairPrflxSrflx, kIceCandidatePairPrflxRelay, - // The following 4 types tell whether local and remote hosts have private or - // public IP addresses. + // The following 9 types tell whether local and remote hosts have hostname, + // private or public IP addresses. kIceCandidatePairHostPrivateHostPrivate, kIceCandidatePairHostPrivateHostPublic, kIceCandidatePairHostPublicHostPrivate, kIceCandidatePairHostPublicHostPublic, + kIceCandidatePairHostNameHostName, + kIceCandidatePairHostNameHostPrivate, + kIceCandidatePairHostNameHostPublic, + kIceCandidatePairHostPrivateHostName, + kIceCandidatePairHostPublicHostName, kIceCandidatePairMax }; diff --git a/pc/peerconnection.cc b/pc/peerconnection.cc index c9f23020e8..6c92816f83 100644 --- a/pc/peerconnection.cc +++ b/pc/peerconnection.cc @@ -277,16 +277,32 @@ IceCandidatePairType GetIceCandidatePairCounter( const auto& relay = RELAY_PORT_TYPE; const auto& prflx = PRFLX_PORT_TYPE; if (l == host && r == host) { + bool local_hostname = + !local.address().hostname().empty() && local.address().IsUnresolvedIP(); + bool remote_hostname = !remote.address().hostname().empty() && + remote.address().IsUnresolvedIP(); bool local_private = IPIsPrivate(local.address().ipaddr()); bool remote_private = IPIsPrivate(remote.address().ipaddr()); - if (local_private) { - if (remote_private) { + if (local_hostname) { + if (remote_hostname) { + return kIceCandidatePairHostNameHostName; + } else if (remote_private) { + return kIceCandidatePairHostNameHostPrivate; + } else { + return kIceCandidatePairHostNameHostPublic; + } + } else if (local_private) { + if (remote_hostname) { + return kIceCandidatePairHostPrivateHostName; + } else if (remote_private) { return kIceCandidatePairHostPrivateHostPrivate; } else { return kIceCandidatePairHostPrivateHostPublic; } } else { - if (remote_private) { + if (remote_hostname) { + return kIceCandidatePairHostPublicHostName; + } else if (remote_private) { return kIceCandidatePairHostPublicHostPrivate; } else { return kIceCandidatePairHostPublicHostPublic; diff --git a/pc/peerconnection_integrationtest.cc b/pc/peerconnection_integrationtest.cc index fa1fb23486..c296e4c7d7 100644 --- a/pc/peerconnection_integrationtest.cc +++ b/pc/peerconnection_integrationtest.cc @@ -3674,6 +3674,10 @@ TEST_P(PeerConnectionIntegrationTest, caller()->ice_connection_state(), kDefaultTimeout); EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionConnected, callee()->ice_connection_state(), kDefaultTimeout); + + EXPECT_EQ(1, webrtc::metrics::NumEvents( + "WebRTC.PeerConnection.CandidatePairType_UDP", + webrtc::kIceCandidatePairHostNameHostName)); } // Test that firewalling the ICE connection causes the clients to identify the