diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index 95ba7563dd..60dbe0523f 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -431,6 +431,8 @@ if (is_ios || is_mac) { "objc/Framework/Classes/PeerConnection/RTCPeerConnection+Private.h", "objc/Framework/Classes/PeerConnection/RTCPeerConnection+Stats.mm", "objc/Framework/Classes/PeerConnection/RTCPeerConnection.mm", + "objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactoryOptions+Private.h", + "objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactoryOptions.mm", "objc/Framework/Classes/PeerConnection/RTCRtpCodecParameters+Private.h", "objc/Framework/Classes/PeerConnection/RTCRtpCodecParameters.mm", "objc/Framework/Classes/PeerConnection/RTCRtpEncodingParameters+Private.h", @@ -481,6 +483,7 @@ if (is_ios || is_mac) { "objc/Framework/Headers/WebRTC/RTCMetricsSampleInfo.h", "objc/Framework/Headers/WebRTC/RTCPeerConnection.h", "objc/Framework/Headers/WebRTC/RTCPeerConnectionFactory.h", + "objc/Framework/Headers/WebRTC/RTCPeerConnectionFactoryOptions.h", "objc/Framework/Headers/WebRTC/RTCRtpCodecParameters.h", "objc/Framework/Headers/WebRTC/RTCRtpEncodingParameters.h", "objc/Framework/Headers/WebRTC/RTCRtpParameters.h", @@ -687,6 +690,7 @@ if (is_ios || is_mac) { "objc/Framework/Headers/WebRTC/RTCMetricsSampleInfo.h", "objc/Framework/Headers/WebRTC/RTCPeerConnection.h", "objc/Framework/Headers/WebRTC/RTCPeerConnectionFactory.h", + "objc/Framework/Headers/WebRTC/RTCPeerConnectionFactoryOptions.h", "objc/Framework/Headers/WebRTC/RTCRtpCodecParameters.h", "objc/Framework/Headers/WebRTC/RTCRtpEncodingParameters.h", "objc/Framework/Headers/WebRTC/RTCRtpParameters.h", diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm b/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm index 7a102c45f1..31d5695478 100644 --- a/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactory.mm @@ -10,6 +10,7 @@ #import "RTCPeerConnectionFactory+Native.h" #import "RTCPeerConnectionFactory+Private.h" +#import "RTCPeerConnectionFactoryOptions+Private.h" #import "NSString+StdString.h" #import "RTCAVFoundationVideoSource+Private.h" @@ -242,6 +243,11 @@ delegate:delegate]; } +- (void)setOptions:(nonnull RTCPeerConnectionFactoryOptions *)options { + RTC_DCHECK(options != nil); + _nativeFactory->SetOptions(options.nativeOptions); +} + - (BOOL)startAecDumpWithFilePath:(NSString *)filePath maxSizeInBytes:(int64_t)maxSizeInBytes { RTC_DCHECK(filePath.length); diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactoryOptions+Private.h b/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactoryOptions+Private.h new file mode 100644 index 0000000000..131e8ffda7 --- /dev/null +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactoryOptions+Private.h @@ -0,0 +1,26 @@ +/* + * Copyright 2017 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#import "WebRTC/RTCPeerConnectionFactoryOptions.h" + +#include "api/peerconnectioninterface.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface RTCPeerConnectionFactoryOptions () + +/** Returns the equivalent native PeerConnectionFactoryInterface::Options + * structure. */ +@property(nonatomic, readonly) + webrtc::PeerConnectionFactoryInterface::Options nativeOptions; + +@end + +NS_ASSUME_NONNULL_END diff --git a/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactoryOptions.mm b/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactoryOptions.mm new file mode 100644 index 0000000000..f0cc6a6c81 --- /dev/null +++ b/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnectionFactoryOptions.mm @@ -0,0 +1,56 @@ +/* + * Copyright 2017 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#import "RTCPeerConnectionFactoryOptions+Private.h" + +#include "rtc_base/network_constants.h" + +namespace { + +void setNetworkBit(webrtc::PeerConnectionFactoryInterface::Options* options, + rtc::AdapterType type, + bool ignore) { + if (ignore) { + options->network_ignore_mask |= type; + } else { + options->network_ignore_mask &= ~type; + } +} +} // namespace + +@implementation RTCPeerConnectionFactoryOptions + +@synthesize disableEncryption = _disableEncryption; +@synthesize disableNetworkMonitor = _disableNetworkMonitor; +@synthesize ignoreLoopbackNetworkAdapter = _ignoreLoopbackNetworkAdapter; +@synthesize ignoreVPNNetworkAdapter = _ignoreVPNNetworkAdapter; +@synthesize ignoreCellularNetworkAdapter = _ignoreCellularNetworkAdapter; +@synthesize ignoreWiFiNetworkAdapter = _ignoreWiFiNetworkAdapter; +@synthesize ignoreEthernetNetworkAdapter = _ignoreEthernetNetworkAdapter; + +- (instancetype)init { + return [super init]; +} + +- (webrtc::PeerConnectionFactoryInterface::Options)nativeOptions { + webrtc::PeerConnectionFactoryInterface::Options options; + options.disable_encryption = self.disableEncryption; + options.disable_network_monitor = self.disableNetworkMonitor; + + setNetworkBit(&options, rtc::ADAPTER_TYPE_LOOPBACK, self.ignoreLoopbackNetworkAdapter); + setNetworkBit(&options, rtc::ADAPTER_TYPE_VPN, self.ignoreVPNNetworkAdapter); + setNetworkBit(&options, rtc::ADAPTER_TYPE_CELLULAR, self.ignoreCellularNetworkAdapter); + setNetworkBit(&options, rtc::ADAPTER_TYPE_WIFI, self.ignoreWiFiNetworkAdapter); + setNetworkBit(&options, rtc::ADAPTER_TYPE_ETHERNET, self.ignoreEthernetNetworkAdapter); + + return options; +} + +@end diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnectionFactory.h b/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnectionFactory.h index 42acbfcd7e..56c399e27a 100644 --- a/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnectionFactory.h +++ b/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnectionFactory.h @@ -23,6 +23,7 @@ NS_ASSUME_NONNULL_BEGIN @class RTCPeerConnection; @class RTCVideoSource; @class RTCVideoTrack; +@class RTCPeerConnectionFactoryOptions; @protocol RTCPeerConnectionDelegate; @protocol RTCVideoDecoderFactory; @protocol RTCVideoEncoderFactory; @@ -75,6 +76,9 @@ RTC_EXPORT delegate: (nullable id)delegate; +/** Set the options to be used for subsequently created RTCPeerConnections */ +- (void)setOptions:(nonnull RTCPeerConnectionFactoryOptions *)options; + /** Start an AecDump recording. This API call will likely change in the future. */ - (BOOL)startAecDumpWithFilePath:(NSString *)filePath maxSizeInBytes:(int64_t)maxSizeInBytes; diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnectionFactoryOptions.h b/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnectionFactoryOptions.h new file mode 100644 index 0000000000..a65abc6c8b --- /dev/null +++ b/sdk/objc/Framework/Headers/WebRTC/RTCPeerConnectionFactoryOptions.h @@ -0,0 +1,38 @@ +/* + * Copyright 2017 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#import + +#import + +NS_ASSUME_NONNULL_BEGIN + +RTC_EXPORT +@interface RTCPeerConnectionFactoryOptions : NSObject + +@property(nonatomic, assign) BOOL disableEncryption; + +@property(nonatomic, assign) BOOL disableNetworkMonitor; + +@property(nonatomic, assign) BOOL ignoreLoopbackNetworkAdapter; + +@property(nonatomic, assign) BOOL ignoreVPNNetworkAdapter; + +@property(nonatomic, assign) BOOL ignoreCellularNetworkAdapter; + +@property(nonatomic, assign) BOOL ignoreWiFiNetworkAdapter; + +@property(nonatomic, assign) BOOL ignoreEthernetNetworkAdapter; + +- (instancetype)init NS_DESIGNATED_INITIALIZER; + +@end + +NS_ASSUME_NONNULL_END diff --git a/sdk/objc/Framework/Headers/WebRTC/WebRTC.h b/sdk/objc/Framework/Headers/WebRTC/WebRTC.h index 64ca544288..b9e0149e99 100644 --- a/sdk/objc/Framework/Headers/WebRTC/WebRTC.h +++ b/sdk/objc/Framework/Headers/WebRTC/WebRTC.h @@ -45,6 +45,7 @@ #import #import #import +#import #import #import #import