mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Add ADAPTER_TYPE_ANY in AdapterType.
ADAPTER_TYPE_ANY can be used to set the network ignore mask if an application does not want candidates from the any address ports, the underlying network interface types of which are not determined in gathering. The ADAPTER_TYPE_ANY is also given the maximum network cost so that when there are candidates from explicit network interfaces, these candidates from the any address ports as backups, if they ever surface, are not preferred if the other candidates have at least the same network condition. Bug: webrtc:9468 Change-Id: I20c3a40e9a75b8fb34fad741ba5f835ecc3b0d92 Reviewed-on: https://webrtc-review.googlesource.com/85880 Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Reviewed-by: Tommi <tommi@webrtc.org> Commit-Queue: Qingsi Wang <qingsi@google.com> Cr-Commit-Position: refs/heads/master@{#23807}
This commit is contained in:
parent
6b33e60213
commit
9f1de69008
5 changed files with 25 additions and 4 deletions
|
@ -168,6 +168,7 @@ const char* NetworkAdapterTypeToStatsType(rtc::AdapterType type) {
|
|||
return RTCNetworkType::kVpn;
|
||||
case rtc::ADAPTER_TYPE_UNKNOWN:
|
||||
case rtc::ADAPTER_TYPE_LOOPBACK:
|
||||
case rtc::ADAPTER_TYPE_ANY:
|
||||
return RTCNetworkType::kUnknown;
|
||||
}
|
||||
RTC_NOTREACHED();
|
||||
|
|
|
@ -414,6 +414,7 @@ const char* IceCandidateTypeToStatsType(const std::string& candidate_type) {
|
|||
|
||||
const char* AdapterTypeToStatsType(rtc::AdapterType type) {
|
||||
switch (type) {
|
||||
case rtc::ADAPTER_TYPE_ANY:
|
||||
case rtc::ADAPTER_TYPE_UNKNOWN:
|
||||
return "unknown";
|
||||
case rtc::ADAPTER_TYPE_ETHERNET:
|
||||
|
|
|
@ -94,6 +94,7 @@ bool SortNetworks(const Network* a, const Network* b) {
|
|||
|
||||
std::string AdapterTypeToString(AdapterType type) {
|
||||
switch (type) {
|
||||
case ADAPTER_TYPE_ANY:
|
||||
case ADAPTER_TYPE_UNKNOWN:
|
||||
return "Unknown";
|
||||
case ADAPTER_TYPE_ETHERNET:
|
||||
|
@ -121,6 +122,17 @@ uint16_t ComputeNetworkCostByType(int type) {
|
|||
return kNetworkCostLow;
|
||||
case rtc::ADAPTER_TYPE_CELLULAR:
|
||||
return kNetworkCostHigh;
|
||||
case rtc::ADAPTER_TYPE_ANY:
|
||||
// Candidates gathered from the any-address/wildcard ports, as backups,
|
||||
// are given the maximum cost so that if there are other candidates with
|
||||
// known interface types, we would not select candidate pairs using these
|
||||
// backup candidates if other selection criteria with higher precedence
|
||||
// (network conditions over the route) are the same. Note that setting the
|
||||
// cost to kNetworkCostUnknown would be problematic since
|
||||
// ADAPTER_TYPE_CELLULAR would then have a higher cost. See
|
||||
// P2PTransportChannel::SortConnectionsAndUpdateState for how we rank and
|
||||
// select candidate pairs, where the network cost is among the criteria.
|
||||
return kNetworkCostMax;
|
||||
case rtc::ADAPTER_TYPE_VPN:
|
||||
// The cost of a VPN should be computed using its underlying network type.
|
||||
RTC_NOTREACHED();
|
||||
|
@ -265,7 +277,7 @@ void NetworkManagerBase::GetAnyAddressNetworks(NetworkList* networks) {
|
|||
if (!ipv4_any_address_network_) {
|
||||
const rtc::IPAddress ipv4_any_address(INADDR_ANY);
|
||||
ipv4_any_address_network_.reset(
|
||||
new rtc::Network("any", "any", ipv4_any_address, 0));
|
||||
new rtc::Network("any", "any", ipv4_any_address, 0, ADAPTER_TYPE_ANY));
|
||||
ipv4_any_address_network_->set_default_local_address_provider(this);
|
||||
ipv4_any_address_network_->AddIP(ipv4_any_address);
|
||||
}
|
||||
|
@ -274,8 +286,8 @@ void NetworkManagerBase::GetAnyAddressNetworks(NetworkList* networks) {
|
|||
if (ipv6_enabled()) {
|
||||
if (!ipv6_any_address_network_) {
|
||||
const rtc::IPAddress ipv6_any_address(in6addr_any);
|
||||
ipv6_any_address_network_.reset(
|
||||
new rtc::Network("any", "any", ipv6_any_address, 0));
|
||||
ipv6_any_address_network_.reset(new rtc::Network(
|
||||
"any", "any", ipv6_any_address, 0, ADAPTER_TYPE_ANY));
|
||||
ipv6_any_address_network_->set_default_local_address_provider(this);
|
||||
ipv6_any_address_network_->AddIP(ipv6_any_address);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,13 @@ enum AdapterType {
|
|||
ADAPTER_TYPE_WIFI = 1 << 1,
|
||||
ADAPTER_TYPE_CELLULAR = 1 << 2,
|
||||
ADAPTER_TYPE_VPN = 1 << 3,
|
||||
ADAPTER_TYPE_LOOPBACK = 1 << 4
|
||||
ADAPTER_TYPE_LOOPBACK = 1 << 4,
|
||||
// ADAPTER_TYPE_ANY is used for a network, which only contains a single "any
|
||||
// address" IP address (INADDR_ANY for IPv4 or in6addr_any for IPv6), and can
|
||||
// use any/all network interfaces. Whereas ADAPTER_TYPE_UNKNOWN is used
|
||||
// when the network uses a specific interface/IP, but its interface type can
|
||||
// not be determined or not fit in this enum.
|
||||
ADAPTER_TYPE_ANY = 1 << 5,
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
|
|
@ -127,6 +127,7 @@ public class PeerConnectionFactory {
|
|||
static final int ADAPTER_TYPE_CELLULAR = 1 << 2;
|
||||
static final int ADAPTER_TYPE_VPN = 1 << 3;
|
||||
static final int ADAPTER_TYPE_LOOPBACK = 1 << 4;
|
||||
static final int ADAPTER_TYPE_ANY = 1 << 5;
|
||||
|
||||
public int networkIgnoreMask;
|
||||
public boolean disableEncryption;
|
||||
|
|
Loading…
Reference in a new issue