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
|
// type of candidate pair used when the PeerConnection first goes to a completed
|
||||||
// state. When BUNDLE is enabled, only the first transport gets recorded.
|
// state. When BUNDLE is enabled, only the first transport gets recorded.
|
||||||
enum IceCandidatePairType {
|
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,
|
kIceCandidatePairHostHost,
|
||||||
kIceCandidatePairHostSrflx,
|
kIceCandidatePairHostSrflx,
|
||||||
kIceCandidatePairHostRelay,
|
kIceCandidatePairHostRelay,
|
||||||
@ -110,6 +112,13 @@ enum IceCandidatePairType {
|
|||||||
kIceCandidatePairPrflxHost,
|
kIceCandidatePairPrflxHost,
|
||||||
kIceCandidatePairPrflxSrflx,
|
kIceCandidatePairPrflxSrflx,
|
||||||
kIceCandidatePairPrflxRelay,
|
kIceCandidatePairPrflxRelay,
|
||||||
|
|
||||||
|
// The following 4 types tell whether local and remote hosts have private or
|
||||||
|
// public IP addresses.
|
||||||
|
kIceCandidatePairHostPrivateHostPrivate,
|
||||||
|
kIceCandidatePairHostPrivateHostPublic,
|
||||||
|
kIceCandidatePairHostPublicHostPrivate,
|
||||||
|
kIceCandidatePairHostPublicHostPublic,
|
||||||
kIceCandidatePairMax
|
kIceCandidatePairMax
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -97,8 +97,23 @@ IceCandidatePairType GetIceCandidatePairCounter(
|
|||||||
const auto& srflx = STUN_PORT_TYPE;
|
const auto& srflx = STUN_PORT_TYPE;
|
||||||
const auto& relay = RELAY_PORT_TYPE;
|
const auto& relay = RELAY_PORT_TYPE;
|
||||||
const auto& prflx = PRFLX_PORT_TYPE;
|
const auto& prflx = PRFLX_PORT_TYPE;
|
||||||
if (l == host && r == host)
|
if (l == host && r == host) {
|
||||||
return kIceCandidatePairHostHost;
|
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)
|
if (l == host && r == srflx)
|
||||||
return kIceCandidatePairHostSrflx;
|
return kIceCandidatePairHostSrflx;
|
||||||
if (l == host && r == relay)
|
if (l == host && r == relay)
|
||||||
|
@ -1043,6 +1043,10 @@ class WebRtcSessionTest
|
|||||||
EXPECT_EQ(metrics_observer->GetEnumCounter(
|
EXPECT_EQ(metrics_observer->GetEnumCounter(
|
||||||
webrtc::kEnumCounterIceCandidatePairTypeUdp,
|
webrtc::kEnumCounterIceCandidatePairTypeUdp,
|
||||||
webrtc::kIceCandidatePairHostHost),
|
webrtc::kIceCandidatePairHostHost),
|
||||||
|
0);
|
||||||
|
EXPECT_EQ(metrics_observer->GetEnumCounter(
|
||||||
|
webrtc::kEnumCounterIceCandidatePairTypeUdp,
|
||||||
|
webrtc::kIceCandidatePairHostPublicHostPublic),
|
||||||
1);
|
1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user