Add more IceCandidatePairType for host-host CandidatePair
This is to help to differentiate endpoints which are behind NAT or on the public internet. BUG=520101 R=pthatcher@webrtc.org Review URL: https://codereview.webrtc.org/1328453003 . Cr-Commit-Position: refs/heads/master@{#9864}
This commit is contained in:
@ -95,6 +95,8 @@ typedef PeerConnectionMetricsName PeerConnectionUMAMetricsName;
|
||||
// type of candidate pair used when the PeerConnection first goes to a completed
|
||||
// state. When BUNDLE is enabled, only the first transport gets recorded.
|
||||
enum IceCandidatePairType {
|
||||
// HostHost is deprecated. It was replaced with the set of types at the bottom
|
||||
// to report private or public host IP address.
|
||||
kIceCandidatePairHostHost,
|
||||
kIceCandidatePairHostSrflx,
|
||||
kIceCandidatePairHostRelay,
|
||||
@ -110,6 +112,13 @@ enum IceCandidatePairType {
|
||||
kIceCandidatePairPrflxHost,
|
||||
kIceCandidatePairPrflxSrflx,
|
||||
kIceCandidatePairPrflxRelay,
|
||||
|
||||
// The following 4 types tell whether local and remote hosts have private or
|
||||
// public IP addresses.
|
||||
kIceCandidatePairHostPrivateHostPrivate,
|
||||
kIceCandidatePairHostPrivateHostPublic,
|
||||
kIceCandidatePairHostPublicHostPrivate,
|
||||
kIceCandidatePairHostPublicHostPublic,
|
||||
kIceCandidatePairMax
|
||||
};
|
||||
|
||||
|
@ -97,8 +97,23 @@ IceCandidatePairType GetIceCandidatePairCounter(
|
||||
const auto& srflx = STUN_PORT_TYPE;
|
||||
const auto& relay = RELAY_PORT_TYPE;
|
||||
const auto& prflx = PRFLX_PORT_TYPE;
|
||||
if (l == host && r == host)
|
||||
return kIceCandidatePairHostHost;
|
||||
if (l == host && r == host) {
|
||||
bool local_private = IPIsPrivate(local.address().ipaddr());
|
||||
bool remote_private = IPIsPrivate(remote.address().ipaddr());
|
||||
if (local_private) {
|
||||
if (remote_private) {
|
||||
return kIceCandidatePairHostPrivateHostPrivate;
|
||||
} else {
|
||||
return kIceCandidatePairHostPrivateHostPublic;
|
||||
}
|
||||
} else {
|
||||
if (remote_private) {
|
||||
return kIceCandidatePairHostPublicHostPrivate;
|
||||
} else {
|
||||
return kIceCandidatePairHostPublicHostPublic;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (l == host && r == srflx)
|
||||
return kIceCandidatePairHostSrflx;
|
||||
if (l == host && r == relay)
|
||||
|
@ -1043,6 +1043,10 @@ class WebRtcSessionTest
|
||||
EXPECT_EQ(metrics_observer->GetEnumCounter(
|
||||
webrtc::kEnumCounterIceCandidatePairTypeUdp,
|
||||
webrtc::kIceCandidatePairHostHost),
|
||||
0);
|
||||
EXPECT_EQ(metrics_observer->GetEnumCounter(
|
||||
webrtc::kEnumCounterIceCandidatePairTypeUdp,
|
||||
webrtc::kIceCandidatePairHostPublicHostPublic),
|
||||
1);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user