From bc7dd7e02353556a4206849ae72beb9b3f256706 Mon Sep 17 00:00:00 2001 From: Zeke Chin Date: Fri, 29 May 2015 14:59:14 -0700 Subject: [PATCH] Add RTCConfiguration constructor to RTCPeerConnection wrapper. BUG=4658 R=jiayl@webrtc.org Review URL: https://webrtc-codereview.appspot.com/56419004 Cr-Commit-Position: refs/heads/master@{#9335} --- talk/app/webrtc/objc/.clang-format | 10 ++ talk/app/webrtc/objc/RTCEnumConverter.h | 32 ++++++- talk/app/webrtc/objc/RTCEnumConverter.mm | 92 +++++++++++++++++++ .../webrtc/objc/RTCPeerConnection+Internal.h | 11 ++- talk/app/webrtc/objc/RTCPeerConnection.mm | 15 +++ .../webrtc/objc/RTCPeerConnectionFactory.mm | 10 ++ .../RTCPeerConnectionInterface+Internal.h | 37 ++++++++ .../webrtc/objc/RTCPeerConnectionInterface.mm | 87 ++++++++++++++++++ .../objc/public/RTCPeerConnectionFactory.h | 8 +- .../objc/public/RTCPeerConnectionInterface.h | 73 +++++++++++++++ talk/examples/objc/AppRTCDemo/ARDAppClient.m | 9 +- talk/examples/objc/AppRTCDemo/ios/Info.plist | 2 - talk/libjingle.gyp | 3 + 13 files changed, 377 insertions(+), 12 deletions(-) create mode 100644 talk/app/webrtc/objc/.clang-format create mode 100644 talk/app/webrtc/objc/RTCPeerConnectionInterface+Internal.h create mode 100644 talk/app/webrtc/objc/RTCPeerConnectionInterface.mm create mode 100644 talk/app/webrtc/objc/public/RTCPeerConnectionInterface.h diff --git a/talk/app/webrtc/objc/.clang-format b/talk/app/webrtc/objc/.clang-format new file mode 100644 index 000000000..34694e57d --- /dev/null +++ b/talk/app/webrtc/objc/.clang-format @@ -0,0 +1,10 @@ +BasedOnStyle: Chromium +ColumnLimit: 100 +BinPackParameters: false +AllowAllParametersOfDeclarationOnNextLine: true +DerivePointerAlignment: false +PointerAlignment: Right +SpacesBeforeTrailingComments: 1 +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true diff --git a/talk/app/webrtc/objc/RTCEnumConverter.h b/talk/app/webrtc/objc/RTCEnumConverter.h index 42ea45bdc..eb06c1864 100644 --- a/talk/app/webrtc/objc/RTCEnumConverter.h +++ b/talk/app/webrtc/objc/RTCEnumConverter.h @@ -25,14 +25,16 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#import - +// TODO(tkchin): remove this in favor of having objc headers mirror their C++ counterparts. +// TODO(tkchin): see if we can move C++ enums into their own file so we can avoid all this +// conversion code. #import "RTCTypes.h" -#include "talk/app/webrtc/peerconnectioninterface.h" +#import "talk/app/webrtc/objc/RTCPeerConnectionInterface+Internal.h" @interface RTCEnumConverter : NSObject +// TODO(tkchin): rename these. + (RTCICEConnectionState)convertIceConnectionStateToObjC: (webrtc::PeerConnectionInterface::IceConnectionState)nativeState; @@ -54,4 +56,28 @@ + (RTCTrackState)convertTrackStateToObjC: (webrtc::MediaStreamTrackInterface::TrackState)nativeState; ++ (RTCIceTransportsType)iceTransportsTypeForNativeEnum: + (webrtc::PeerConnectionInterface::IceTransportsType)nativeEnum; + ++ (webrtc::PeerConnectionInterface::IceTransportsType)nativeEnumForIceTransportsType: + (RTCIceTransportsType)iceTransportsType; + ++ (RTCBundlePolicy)bundlePolicyForNativeEnum: + (webrtc::PeerConnectionInterface::BundlePolicy)nativeEnum; + ++ (webrtc::PeerConnectionInterface::BundlePolicy)nativeEnumForBundlePolicy: + (RTCBundlePolicy)bundlePolicy; + ++ (RTCRtcpMuxPolicy)rtcpMuxPolicyForNativeEnum: + (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeEnum; + ++ (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeEnumForRtcpMuxPolicy: + (RTCRtcpMuxPolicy)rtcpMuxPolicy; + ++ (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativeEnum: + (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativeEnum; + ++ (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativeEnumForTcpCandidatePolicy: + (RTCTcpCandidatePolicy)tcpCandidatePolicy; + @end diff --git a/talk/app/webrtc/objc/RTCEnumConverter.mm b/talk/app/webrtc/objc/RTCEnumConverter.mm index f893fc871..6254b95e8 100644 --- a/talk/app/webrtc/objc/RTCEnumConverter.mm +++ b/talk/app/webrtc/objc/RTCEnumConverter.mm @@ -133,4 +133,96 @@ } } ++ (RTCIceTransportsType)iceTransportsTypeForNativeEnum: + (webrtc::PeerConnectionInterface::IceTransportsType)nativeEnum { + switch (nativeEnum) { + case webrtc::PeerConnectionInterface::kNone: + return kRTCIceTransportsTypeNone; + case webrtc::PeerConnectionInterface::kRelay: + return kRTCIceTransportsTypeRelay; + case webrtc::PeerConnectionInterface::kNoHost: + return kRTCIceTransportsTypeNoHost; + case webrtc::PeerConnectionInterface::kAll: + return kRTCIceTransportsTypeAll; + } +} + ++ (webrtc::PeerConnectionInterface::IceTransportsType)nativeEnumForIceTransportsType: + (RTCIceTransportsType)iceTransportsType { + switch (iceTransportsType) { + case kRTCIceTransportsTypeNone: + return webrtc::PeerConnectionInterface::kNone; + case kRTCIceTransportsTypeRelay: + return webrtc::PeerConnectionInterface::kRelay; + case kRTCIceTransportsTypeNoHost: + return webrtc::PeerConnectionInterface::kNoHost; + case kRTCIceTransportsTypeAll: + return webrtc::PeerConnectionInterface::kAll; + } +} + ++ (RTCBundlePolicy)bundlePolicyForNativeEnum: + (webrtc::PeerConnectionInterface::BundlePolicy)nativeEnum { + switch (nativeEnum) { + case webrtc::PeerConnectionInterface::kBundlePolicyBalanced: + return kRTCBundlePolicyBalanced; + case webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle: + return kRTCBundlePolicyMaxBundle; + case webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat: + return kRTCBundlePolicyMaxCompat; + } +} + ++ (webrtc::PeerConnectionInterface::BundlePolicy)nativeEnumForBundlePolicy: + (RTCBundlePolicy)bundlePolicy { + switch (bundlePolicy) { + case kRTCBundlePolicyBalanced: + return webrtc::PeerConnectionInterface::kBundlePolicyBalanced; + case kRTCBundlePolicyMaxBundle: + return webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle; + case kRTCBundlePolicyMaxCompat: + return webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat; + } +} + ++ (RTCRtcpMuxPolicy)rtcpMuxPolicyForNativeEnum: + (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeEnum { + switch (nativeEnum) { + case webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate: + return kRTCRtcpMuxPolicyNegotiate; + case webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire: + return kRTCRtcpMuxPolicyRequire; + } +} + ++ (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeEnumForRtcpMuxPolicy: + (RTCRtcpMuxPolicy)rtcpMuxPolicy { + switch (rtcpMuxPolicy) { + case kRTCRtcpMuxPolicyNegotiate: + return webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate; + case kRTCRtcpMuxPolicyRequire: + return webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire; + } +} + ++ (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativeEnum: + (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativeEnum { + switch (nativeEnum) { + case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled: + return kRTCTcpCandidatePolicyEnabled; + case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled: + return kRTCTcpCandidatePolicyDisabled; + } +} + ++ (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativeEnumForTcpCandidatePolicy: + (RTCTcpCandidatePolicy)tcpCandidatePolicy { + switch (tcpCandidatePolicy) { + case kRTCTcpCandidatePolicyEnabled: + return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled; + case kRTCTcpCandidatePolicyDisabled: + return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled; + } +} + @end diff --git a/talk/app/webrtc/objc/RTCPeerConnection+Internal.h b/talk/app/webrtc/objc/RTCPeerConnection+Internal.h index 8d7201f81..96d63ab41 100644 --- a/talk/app/webrtc/objc/RTCPeerConnection+Internal.h +++ b/talk/app/webrtc/objc/RTCPeerConnection+Internal.h @@ -36,8 +36,13 @@ @property(nonatomic, assign, readonly) rtc::scoped_refptr peerConnection; -- (instancetype)initWithFactory:(webrtc::PeerConnectionFactoryInterface*)factory - iceServers:(const webrtc::PeerConnectionInterface::IceServers&)iceServers - constraints:(const webrtc::MediaConstraintsInterface*)constraints; +- (instancetype)initWithFactory:(webrtc::PeerConnectionFactoryInterface *)factory + iceServers:(const webrtc::PeerConnectionInterface::IceServers &)iceServers + constraints:(const webrtc::MediaConstraintsInterface *)constraints; + +- (instancetype)initWithFactory:(webrtc::PeerConnectionFactoryInterface *)factory + config:(const webrtc::PeerConnectionInterface::RTCConfiguration &)config + constraints:(const webrtc::MediaConstraintsInterface *)constraints + delegate:(id)delegate; @end diff --git a/talk/app/webrtc/objc/RTCPeerConnection.mm b/talk/app/webrtc/objc/RTCPeerConnection.mm index 769219e1e..0d30acc0e 100644 --- a/talk/app/webrtc/objc/RTCPeerConnection.mm +++ b/talk/app/webrtc/objc/RTCPeerConnection.mm @@ -285,6 +285,21 @@ class RTCStatsObserver : public StatsObserver { return self; } +- (instancetype)initWithFactory:(webrtc::PeerConnectionFactoryInterface *)factory + config:(const webrtc::PeerConnectionInterface::RTCConfiguration &)config + constraints:(const webrtc::MediaConstraintsInterface *)constraints + delegate:(id)delegate { + NSParameterAssert(factory); + if (self = [super init]) { + _observer.reset(new webrtc::RTCPeerConnectionObserver(self)); + _peerConnection = + factory->CreatePeerConnection(config, constraints, nullptr, nullptr, _observer.get()); + _localStreams = [[NSMutableArray alloc] init]; + _delegate = delegate; + } + return self; +} + - (rtc::scoped_refptr)peerConnection { return _peerConnection; } diff --git a/talk/app/webrtc/objc/RTCPeerConnectionFactory.mm b/talk/app/webrtc/objc/RTCPeerConnectionFactory.mm index a4a12addd..50ea47dc6 100644 --- a/talk/app/webrtc/objc/RTCPeerConnectionFactory.mm +++ b/talk/app/webrtc/objc/RTCPeerConnectionFactory.mm @@ -41,6 +41,7 @@ #import "RTCMediaStreamTrack+Internal.h" #import "RTCPeerConnection+Internal.h" #import "RTCPeerConnectionDelegate.h" +#import "RTCPeerConnectionInterface+Internal.h" #import "RTCVideoCapturer+Internal.h" #import "RTCVideoSource+Internal.h" #import "RTCVideoTrack+Internal.h" @@ -88,6 +89,15 @@ return self; } +- (RTCPeerConnection *)peerConnectionWithConfiguration:(RTCConfiguration *)configuration + constraints:(RTCMediaConstraints *)constraints + delegate:(id)delegate { + return [[RTCPeerConnection alloc] initWithFactory:self.nativeFactory.get() + config:configuration.nativeConfiguration + constraints:constraints.constraints + delegate:delegate]; +} + - (RTCPeerConnection*) peerConnectionWithICEServers:(NSArray*)servers constraints:(RTCMediaConstraints*)constraints diff --git a/talk/app/webrtc/objc/RTCPeerConnectionInterface+Internal.h b/talk/app/webrtc/objc/RTCPeerConnectionInterface+Internal.h new file mode 100644 index 000000000..5e8dbbf60 --- /dev/null +++ b/talk/app/webrtc/objc/RTCPeerConnectionInterface+Internal.h @@ -0,0 +1,37 @@ +/* + * libjingle + * Copyright 2015 Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "talk/app/webrtc/objc/public/RTCPeerConnectionInterface.h" + +#include "talk/app/webrtc/peerconnectioninterface.h" + +@interface RTCConfiguration () + +@property(nonatomic, readonly) + webrtc::PeerConnectionInterface::RTCConfiguration nativeConfiguration; + +@end diff --git a/talk/app/webrtc/objc/RTCPeerConnectionInterface.mm b/talk/app/webrtc/objc/RTCPeerConnectionInterface.mm new file mode 100644 index 000000000..32298c8d7 --- /dev/null +++ b/talk/app/webrtc/objc/RTCPeerConnectionInterface.mm @@ -0,0 +1,87 @@ +/* + * libjingle + * Copyright 2015 Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "talk/app/webrtc/objc/RTCPeerConnectionInterface+Internal.h" + +#import "talk/app/webrtc/objc/RTCEnumConverter.h" +#import "talk/app/webrtc/objc/RTCICEServer+Internal.h" + +@implementation RTCConfiguration + +@synthesize iceTransportsType = _iceTransportsType; +@synthesize iceServers = _iceServers; +@synthesize bundlePolicy = _bundlePolicy; +@synthesize rtcpMuxPolicy = _rtcpMuxPolicy; +@synthesize tcpCandidatePolicy = _tcpCandidatePolicy; +@synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets; + +- (instancetype)init { + if (self = [super init]) { + // Copy defaults. + webrtc::PeerConnectionInterface::RTCConfiguration config; + _iceTransportsType = [RTCEnumConverter iceTransportsTypeForNativeEnum:config.type]; + _bundlePolicy = [RTCEnumConverter bundlePolicyForNativeEnum:config.bundle_policy]; + _rtcpMuxPolicy = [RTCEnumConverter rtcpMuxPolicyForNativeEnum:config.rtcp_mux_policy]; + _tcpCandidatePolicy = + [RTCEnumConverter tcpCandidatePolicyForNativeEnum:config.tcp_candidate_policy]; + _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets; + } + return self; +} + +- (instancetype)initWithIceTransportsType:(RTCIceTransportsType)iceTransportsType + bundlePolicy:(RTCBundlePolicy)bundlePolicy + rtcpMuxPolicy:(RTCRtcpMuxPolicy)rtcpMuxPolicy + tcpCandidatePolicy:(RTCTcpCandidatePolicy)tcpCandidatePolicy + audioJitterBufferMaxPackets:(int)audioJitterBufferMaxPackets { + if (self = [super init]) { + _iceTransportsType = iceTransportsType; + _bundlePolicy = bundlePolicy; + _rtcpMuxPolicy = rtcpMuxPolicy; + _tcpCandidatePolicy = tcpCandidatePolicy; + _audioJitterBufferMaxPackets = audioJitterBufferMaxPackets; + } + return self; +} + +#pragma mark - Private + +- (webrtc::PeerConnectionInterface::RTCConfiguration)nativeConfiguration { + webrtc::PeerConnectionInterface::RTCConfiguration nativeConfig; + nativeConfig.type = [RTCEnumConverter nativeEnumForIceTransportsType:_iceTransportsType]; + for (RTCICEServer *iceServer : _iceServers) { + nativeConfig.servers.push_back(iceServer.iceServer); + } + nativeConfig.bundle_policy = [RTCEnumConverter nativeEnumForBundlePolicy:_bundlePolicy]; + nativeConfig.rtcp_mux_policy = [RTCEnumConverter nativeEnumForRtcpMuxPolicy:_rtcpMuxPolicy]; + nativeConfig.tcp_candidate_policy = + [RTCEnumConverter nativeEnumForTcpCandidatePolicy:_tcpCandidatePolicy]; + nativeConfig.audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; + return nativeConfig; +} + +@end diff --git a/talk/app/webrtc/objc/public/RTCPeerConnectionFactory.h b/talk/app/webrtc/objc/public/RTCPeerConnectionFactory.h index f0b2e3ad9..e1e69b4b7 100644 --- a/talk/app/webrtc/objc/public/RTCPeerConnectionFactory.h +++ b/talk/app/webrtc/objc/public/RTCPeerConnectionFactory.h @@ -28,6 +28,7 @@ #import @class RTCAudioTrack; +@class RTCConfiguration; @class RTCMediaConstraints; @class RTCMediaStream; @class RTCPeerConnection; @@ -44,7 +45,7 @@ + (void)initializeSSL; + (void)deinitializeSSL; -// Create an RTCPeerConnection object. RTCPeerConnectionFactory will create +// Create an RTCPeerConnection object. RTCPeerConnectionFactory will create // required libjingle threads, socket and network manager factory classes for // networking. - (RTCPeerConnection *) @@ -52,6 +53,11 @@ constraints:(RTCMediaConstraints *)constraints delegate:(id)delegate; +// Creates a peer connection using the default port allocator factory and identity service. +- (RTCPeerConnection *)peerConnectionWithConfiguration:(RTCConfiguration *)configuration + constraints:(RTCMediaConstraints *)constraints + delegate:(id)delegate; + // Create an RTCMediaStream named |label|. - (RTCMediaStream *)mediaStreamWithLabel:(NSString *)label; diff --git a/talk/app/webrtc/objc/public/RTCPeerConnectionInterface.h b/talk/app/webrtc/objc/public/RTCPeerConnectionInterface.h new file mode 100644 index 000000000..fd7af620d --- /dev/null +++ b/talk/app/webrtc/objc/public/RTCPeerConnectionInterface.h @@ -0,0 +1,73 @@ +/* + * libjingle + * Copyright 2015 Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// See talk/app/webrtc/peerconnectioninterface.h. + +#import + +typedef NS_ENUM(NSInteger, RTCIceTransportsType) { + kRTCIceTransportsTypeNone, + kRTCIceTransportsTypeRelay, + kRTCIceTransportsTypeNoHost, + kRTCIceTransportsTypeAll, +}; + +// https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-08#section-4.1.1 +typedef NS_ENUM(NSInteger, RTCBundlePolicy) { + kRTCBundlePolicyBalanced, + kRTCBundlePolicyMaxBundle, + kRTCBundlePolicyMaxCompat, +}; + +// https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-09#section-4.1.1 +typedef NS_ENUM(NSInteger, RTCRtcpMuxPolicy) { + kRTCRtcpMuxPolicyNegotiate, + kRTCRtcpMuxPolicyRequire, +}; + +typedef NS_ENUM(NSInteger, RTCTcpCandidatePolicy) { + kRTCTcpCandidatePolicyEnabled, + kRTCTcpCandidatePolicyDisabled, +}; + +// Configuration object used for creating a peer connection. +@interface RTCConfiguration : NSObject + +@property(nonatomic, assign) RTCIceTransportsType iceTransportsType; +@property(nonatomic, copy) NSArray *iceServers; +@property(nonatomic, assign) RTCBundlePolicy bundlePolicy; +@property(nonatomic, assign) RTCRtcpMuxPolicy rtcpMuxPolicy; +@property(nonatomic, assign) RTCTcpCandidatePolicy tcpCandidatePolicy; +@property(nonatomic, assign) int audioJitterBufferMaxPackets; + +- (instancetype)initWithIceTransportsType:(RTCIceTransportsType)iceTransportsType + bundlePolicy:(RTCBundlePolicy)bundlePolicy + rtcpMuxPolicy:(RTCRtcpMuxPolicy)rtcpMuxPolicy + tcpCandidatePolicy:(RTCTcpCandidatePolicy)tcpCandidatePolicy + audioJitterBufferMaxPackets:(int)audioJitterBufferMaxPackets; + +@end diff --git a/talk/examples/objc/AppRTCDemo/ARDAppClient.m b/talk/examples/objc/AppRTCDemo/ARDAppClient.m index e4c2f81b4..0f3c423c4 100644 --- a/talk/examples/objc/AppRTCDemo/ARDAppClient.m +++ b/talk/examples/objc/AppRTCDemo/ARDAppClient.m @@ -34,6 +34,7 @@ #import "RTCMediaConstraints.h" #import "RTCMediaStream.h" #import "RTCPair.h" +#import "RTCPeerConnectionInterface.h" #import "RTCVideoCapturer.h" #import "RTCAVFoundationVideoSource.h" @@ -397,9 +398,11 @@ static NSInteger const kARDAppClientErrorInvalidRoom = -6; // Create peer connection. RTCMediaConstraints *constraints = [self defaultPeerConnectionConstraints]; - _peerConnection = [_factory peerConnectionWithICEServers:_iceServers - constraints:constraints - delegate:self]; + RTCConfiguration *config = [[RTCConfiguration alloc] init]; + config.iceServers = _iceServers; + _peerConnection = [_factory peerConnectionWithConfiguration:config + constraints:constraints + delegate:self]; // Create AV media stream and add it to the peer connection. RTCMediaStream *localStream = [self createLocalMediaStream]; [_peerConnection addStream:localStream]; diff --git a/talk/examples/objc/AppRTCDemo/ios/Info.plist b/talk/examples/objc/AppRTCDemo/ios/Info.plist index 0b66b1c68..21ee35500 100644 --- a/talk/examples/objc/AppRTCDemo/ios/Info.plist +++ b/talk/examples/objc/AppRTCDemo/ios/Info.plist @@ -28,8 +28,6 @@ AppRTCDemo CFBundlePackageType APPL - CFBundleResourceSpecification - ResourceRules.plist CFBundleShortVersionString 1.0 CFBundleSignature diff --git a/talk/libjingle.gyp b/talk/libjingle.gyp index 74b567ae1..19808be28 100755 --- a/talk/libjingle.gyp +++ b/talk/libjingle.gyp @@ -257,6 +257,8 @@ 'app/webrtc/objc/RTCPeerConnection+Internal.h', 'app/webrtc/objc/RTCPeerConnection.mm', 'app/webrtc/objc/RTCPeerConnectionFactory.mm', + 'app/webrtc/objc/RTCPeerConnectionInterface+Internal.h', + 'app/webrtc/objc/RTCPeerConnectionInterface.mm', 'app/webrtc/objc/RTCPeerConnectionObserver.h', 'app/webrtc/objc/RTCPeerConnectionObserver.mm', 'app/webrtc/objc/RTCSessionDescription+Internal.h', @@ -286,6 +288,7 @@ 'app/webrtc/objc/public/RTCPeerConnection.h', 'app/webrtc/objc/public/RTCPeerConnectionDelegate.h', 'app/webrtc/objc/public/RTCPeerConnectionFactory.h', + 'app/webrtc/objc/public/RTCPeerConnectionInterface.h', 'app/webrtc/objc/public/RTCSessionDescription.h', 'app/webrtc/objc/public/RTCSessionDescriptionDelegate.h', 'app/webrtc/objc/public/RTCStatsDelegate.h',