1/* 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11#import "RTCPeerConnectionFactoryOptions+Private.h" 12 13#include "rtc_base/network_constants.h" 14 15namespace { 16 17void setNetworkBit(webrtc::PeerConnectionFactoryInterface::Options* options, 18 rtc::AdapterType type, 19 bool ignore) { 20 if (ignore) { 21 options->network_ignore_mask |= type; 22 } else { 23 options->network_ignore_mask &= ~type; 24 } 25} 26} // namespace 27 28@implementation RTC_OBJC_TYPE (RTCPeerConnectionFactoryOptions) 29 30@synthesize disableEncryption = _disableEncryption; 31@synthesize disableNetworkMonitor = _disableNetworkMonitor; 32@synthesize ignoreLoopbackNetworkAdapter = _ignoreLoopbackNetworkAdapter; 33@synthesize ignoreVPNNetworkAdapter = _ignoreVPNNetworkAdapter; 34@synthesize ignoreCellularNetworkAdapter = _ignoreCellularNetworkAdapter; 35@synthesize ignoreWiFiNetworkAdapter = _ignoreWiFiNetworkAdapter; 36@synthesize ignoreEthernetNetworkAdapter = _ignoreEthernetNetworkAdapter; 37 38- (instancetype)init { 39 return [super init]; 40} 41 42- (webrtc::PeerConnectionFactoryInterface::Options)nativeOptions { 43 webrtc::PeerConnectionFactoryInterface::Options options; 44 options.disable_encryption = self.disableEncryption; 45 options.disable_network_monitor = self.disableNetworkMonitor; 46 47 setNetworkBit(&options, rtc::ADAPTER_TYPE_LOOPBACK, self.ignoreLoopbackNetworkAdapter); 48 setNetworkBit(&options, rtc::ADAPTER_TYPE_VPN, self.ignoreVPNNetworkAdapter); 49 setNetworkBit(&options, rtc::ADAPTER_TYPE_CELLULAR, self.ignoreCellularNetworkAdapter); 50 setNetworkBit(&options, rtc::ADAPTER_TYPE_WIFI, self.ignoreWiFiNetworkAdapter); 51 setNetworkBit(&options, rtc::ADAPTER_TYPE_ETHERNET, self.ignoreEthernetNetworkAdapter); 52 53 return options; 54} 55 56@end 57