henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
| 3 | * Copyright 2013, Google Inc. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 29 | #error "This file requires ARC support." |
| 30 | #endif |
| 31 | |
fischman@webrtc.org | c693a2a | 2014-03-24 18:56:37 +0000 | [diff] [blame] | 32 | #import "RTCPeerConnection+Internal.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 33 | |
tkchin@webrtc.org | ff27332 | 2014-04-30 18:32:33 +0000 | [diff] [blame] | 34 | #import "RTCDataChannel+Internal.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 35 | #import "RTCEnumConverter.h" |
fischman@webrtc.org | c693a2a | 2014-03-24 18:56:37 +0000 | [diff] [blame] | 36 | #import "RTCICECandidate+Internal.h" |
| 37 | #import "RTCICEServer+Internal.h" |
| 38 | #import "RTCMediaConstraints+Internal.h" |
| 39 | #import "RTCMediaStream+Internal.h" |
tkchin@webrtc.org | 19b1be1 | 2014-04-22 21:05:38 +0000 | [diff] [blame] | 40 | #import "RTCMediaStreamTrack+Internal.h" |
tkchin@webrtc.org | acca675 | 2014-05-30 22:26:06 +0000 | [diff] [blame] | 41 | #import "RTCPeerConnectionObserver.h" |
fischman@webrtc.org | c693a2a | 2014-03-24 18:56:37 +0000 | [diff] [blame] | 42 | #import "RTCSessionDescription+Internal.h" |
tkchin@webrtc.org | ec3d8ec | 2014-04-21 18:47:24 +0000 | [diff] [blame] | 43 | #import "RTCSessionDescriptionDelegate.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 44 | #import "RTCSessionDescription.h" |
tkchin@webrtc.org | 19b1be1 | 2014-04-22 21:05:38 +0000 | [diff] [blame] | 45 | #import "RTCStatsDelegate.h" |
| 46 | #import "RTCStatsReport+Internal.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 47 | |
| 48 | #include "talk/app/webrtc/jsep.h" |
| 49 | |
| 50 | NSString* const kRTCSessionDescriptionDelegateErrorDomain = @"RTCSDPError"; |
| 51 | int const kRTCSessionDescriptionDelegateErrorCode = -1; |
| 52 | |
| 53 | namespace webrtc { |
| 54 | |
| 55 | class RTCCreateSessionDescriptionObserver |
| 56 | : public CreateSessionDescriptionObserver { |
| 57 | public: |
tkchin@webrtc.org | ec3d8ec | 2014-04-21 18:47:24 +0000 | [diff] [blame] | 58 | RTCCreateSessionDescriptionObserver( |
| 59 | id<RTCSessionDescriptionDelegate> delegate, |
| 60 | RTCPeerConnection* peerConnection) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 61 | _delegate = delegate; |
| 62 | _peerConnection = peerConnection; |
| 63 | } |
| 64 | |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 65 | virtual void OnSuccess(SessionDescriptionInterface* desc) OVERRIDE { |
| 66 | RTCSessionDescription* session = |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 67 | [[RTCSessionDescription alloc] initWithSessionDescription:desc]; |
| 68 | [_delegate peerConnection:_peerConnection |
| 69 | didCreateSessionDescription:session |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 70 | error:nil]; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 71 | } |
| 72 | |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 73 | virtual void OnFailure(const std::string& error) OVERRIDE { |
| 74 | NSString* str = @(error.c_str()); |
| 75 | NSError* err = |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 76 | [NSError errorWithDomain:kRTCSessionDescriptionDelegateErrorDomain |
| 77 | code:kRTCSessionDescriptionDelegateErrorCode |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 78 | userInfo:@{@"error" : str}]; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 79 | [_delegate peerConnection:_peerConnection |
| 80 | didCreateSessionDescription:nil |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 81 | error:err]; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | private: |
tkchin@webrtc.org | ec3d8ec | 2014-04-21 18:47:24 +0000 | [diff] [blame] | 85 | id<RTCSessionDescriptionDelegate> _delegate; |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 86 | RTCPeerConnection* _peerConnection; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | class RTCSetSessionDescriptionObserver : public SetSessionDescriptionObserver { |
| 90 | public: |
tkchin@webrtc.org | ec3d8ec | 2014-04-21 18:47:24 +0000 | [diff] [blame] | 91 | RTCSetSessionDescriptionObserver(id<RTCSessionDescriptionDelegate> delegate, |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 92 | RTCPeerConnection* peerConnection) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 93 | _delegate = delegate; |
| 94 | _peerConnection = peerConnection; |
| 95 | } |
| 96 | |
| 97 | virtual void OnSuccess() OVERRIDE { |
| 98 | [_delegate peerConnection:_peerConnection |
| 99 | didSetSessionDescriptionWithError:nil]; |
| 100 | } |
| 101 | |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 102 | virtual void OnFailure(const std::string& error) OVERRIDE { |
| 103 | NSString* str = @(error.c_str()); |
| 104 | NSError* err = |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 105 | [NSError errorWithDomain:kRTCSessionDescriptionDelegateErrorDomain |
| 106 | code:kRTCSessionDescriptionDelegateErrorCode |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 107 | userInfo:@{@"error" : str}]; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 108 | [_delegate peerConnection:_peerConnection |
| 109 | didSetSessionDescriptionWithError:err]; |
| 110 | } |
| 111 | |
| 112 | private: |
tkchin@webrtc.org | ec3d8ec | 2014-04-21 18:47:24 +0000 | [diff] [blame] | 113 | id<RTCSessionDescriptionDelegate> _delegate; |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 114 | RTCPeerConnection* _peerConnection; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 115 | }; |
tkchin@webrtc.org | 19b1be1 | 2014-04-22 21:05:38 +0000 | [diff] [blame] | 116 | |
| 117 | class RTCStatsObserver : public StatsObserver { |
| 118 | public: |
| 119 | RTCStatsObserver(id<RTCStatsDelegate> delegate, |
| 120 | RTCPeerConnection* peerConnection) { |
| 121 | _delegate = delegate; |
| 122 | _peerConnection = peerConnection; |
| 123 | } |
| 124 | |
| 125 | virtual void OnComplete(const std::vector<StatsReport>& reports) OVERRIDE { |
| 126 | NSMutableArray* stats = [NSMutableArray arrayWithCapacity:reports.size()]; |
| 127 | std::vector<StatsReport>::const_iterator it = reports.begin(); |
| 128 | for (; it != reports.end(); ++it) { |
| 129 | RTCStatsReport* statsReport = |
| 130 | [[RTCStatsReport alloc] initWithStatsReport:*it]; |
| 131 | [stats addObject:statsReport]; |
| 132 | } |
| 133 | [_delegate peerConnection:_peerConnection didGetStats:stats]; |
| 134 | } |
| 135 | |
| 136 | private: |
| 137 | id<RTCStatsDelegate> _delegate; |
| 138 | RTCPeerConnection* _peerConnection; |
| 139 | }; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | @implementation RTCPeerConnection { |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 143 | NSMutableArray* _localStreams; |
| 144 | talk_base::scoped_ptr<webrtc::RTCPeerConnectionObserver> _observer; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 145 | talk_base::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection; |
| 146 | } |
| 147 | |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 148 | - (BOOL)addICECandidate:(RTCICECandidate*)candidate { |
fischman@webrtc.org | e003455 | 2013-12-02 18:49:54 +0000 | [diff] [blame] | 149 | talk_base::scoped_ptr<const webrtc::IceCandidateInterface> iceCandidate( |
| 150 | candidate.candidate); |
| 151 | return self.peerConnection->AddIceCandidate(iceCandidate.get()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 152 | } |
| 153 | |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 154 | - (BOOL)addStream:(RTCMediaStream*)stream |
| 155 | constraints:(RTCMediaConstraints*)constraints { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 156 | BOOL ret = self.peerConnection->AddStream(stream.mediaStream, |
| 157 | constraints.constraints); |
| 158 | if (!ret) { |
| 159 | return NO; |
| 160 | } |
| 161 | [_localStreams addObject:stream]; |
| 162 | return YES; |
| 163 | } |
| 164 | |
tkchin@webrtc.org | ff27332 | 2014-04-30 18:32:33 +0000 | [diff] [blame] | 165 | - (RTCDataChannel*)createDataChannelWithLabel:(NSString*)label |
| 166 | config:(RTCDataChannelInit*)config { |
| 167 | std::string labelString([label UTF8String]); |
| 168 | talk_base::scoped_refptr<webrtc::DataChannelInterface> dataChannel = |
| 169 | self.peerConnection->CreateDataChannel(labelString, |
| 170 | config.dataChannelInit); |
| 171 | return [[RTCDataChannel alloc] initWithDataChannel:dataChannel]; |
| 172 | } |
| 173 | |
tkchin@webrtc.org | ec3d8ec | 2014-04-21 18:47:24 +0000 | [diff] [blame] | 174 | - (void)createAnswerWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 175 | constraints:(RTCMediaConstraints*)constraints { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 176 | talk_base::scoped_refptr<webrtc::RTCCreateSessionDescriptionObserver> |
| 177 | observer(new talk_base::RefCountedObject< |
| 178 | webrtc::RTCCreateSessionDescriptionObserver>(delegate, self)); |
| 179 | self.peerConnection->CreateAnswer(observer, constraints.constraints); |
| 180 | } |
| 181 | |
tkchin@webrtc.org | ec3d8ec | 2014-04-21 18:47:24 +0000 | [diff] [blame] | 182 | - (void)createOfferWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 183 | constraints:(RTCMediaConstraints*)constraints { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 184 | talk_base::scoped_refptr<webrtc::RTCCreateSessionDescriptionObserver> |
| 185 | observer(new talk_base::RefCountedObject< |
| 186 | webrtc::RTCCreateSessionDescriptionObserver>(delegate, self)); |
| 187 | self.peerConnection->CreateOffer(observer, constraints.constraints); |
| 188 | } |
| 189 | |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 190 | - (void)removeStream:(RTCMediaStream*)stream { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 191 | self.peerConnection->RemoveStream(stream.mediaStream); |
| 192 | [_localStreams removeObject:stream]; |
| 193 | } |
| 194 | |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 195 | - (void)setLocalDescriptionWithDelegate: |
tkchin@webrtc.org | ec3d8ec | 2014-04-21 18:47:24 +0000 | [diff] [blame] | 196 | (id<RTCSessionDescriptionDelegate>)delegate |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 197 | sessionDescription:(RTCSessionDescription*)sdp { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 198 | talk_base::scoped_refptr<webrtc::RTCSetSessionDescriptionObserver> observer( |
| 199 | new talk_base::RefCountedObject<webrtc::RTCSetSessionDescriptionObserver>( |
| 200 | delegate, self)); |
| 201 | self.peerConnection->SetLocalDescription(observer, sdp.sessionDescription); |
| 202 | } |
| 203 | |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 204 | - (void)setRemoteDescriptionWithDelegate: |
tkchin@webrtc.org | ec3d8ec | 2014-04-21 18:47:24 +0000 | [diff] [blame] | 205 | (id<RTCSessionDescriptionDelegate>)delegate |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 206 | sessionDescription:(RTCSessionDescription*)sdp { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 207 | talk_base::scoped_refptr<webrtc::RTCSetSessionDescriptionObserver> observer( |
| 208 | new talk_base::RefCountedObject<webrtc::RTCSetSessionDescriptionObserver>( |
| 209 | delegate, self)); |
| 210 | self.peerConnection->SetRemoteDescription(observer, sdp.sessionDescription); |
| 211 | } |
| 212 | |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 213 | - (BOOL)updateICEServers:(NSArray*)servers |
| 214 | constraints:(RTCMediaConstraints*)constraints { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 215 | webrtc::PeerConnectionInterface::IceServers iceServers; |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 216 | for (RTCICEServer* server in servers) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 217 | iceServers.push_back(server.iceServer); |
| 218 | } |
| 219 | return self.peerConnection->UpdateIce(iceServers, constraints.constraints); |
| 220 | } |
| 221 | |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 222 | - (RTCSessionDescription*)localDescription { |
| 223 | const webrtc::SessionDescriptionInterface* sdi = |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 224 | self.peerConnection->local_description(); |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 225 | return sdi ? [[RTCSessionDescription alloc] initWithSessionDescription:sdi] |
| 226 | : nil; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 227 | } |
| 228 | |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 229 | - (NSArray*)localStreams { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 230 | return [_localStreams copy]; |
| 231 | } |
| 232 | |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 233 | - (RTCSessionDescription*)remoteDescription { |
| 234 | const webrtc::SessionDescriptionInterface* sdi = |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 235 | self.peerConnection->remote_description(); |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 236 | return sdi ? [[RTCSessionDescription alloc] initWithSessionDescription:sdi] |
| 237 | : nil; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | - (RTCICEConnectionState)iceConnectionState { |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 241 | return [RTCEnumConverter |
| 242 | convertIceConnectionStateToObjC:self.peerConnection |
| 243 | ->ice_connection_state()]; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | - (RTCICEGatheringState)iceGatheringState { |
fischman@webrtc.org | 7fa1fcb | 2014-03-25 00:11:56 +0000 | [diff] [blame] | 247 | return [RTCEnumConverter |
| 248 | convertIceGatheringStateToObjC:self.peerConnection |
| 249 | ->ice_gathering_state()]; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | - (RTCSignalingState)signalingState { |
| 253 | return [RTCEnumConverter |
| 254 | convertSignalingStateToObjC:self.peerConnection->signaling_state()]; |
| 255 | } |
| 256 | |
| 257 | - (void)close { |
| 258 | self.peerConnection->Close(); |
| 259 | } |
| 260 | |
tkchin@webrtc.org | 19b1be1 | 2014-04-22 21:05:38 +0000 | [diff] [blame] | 261 | - (BOOL)getStatsWithDelegate:(id<RTCStatsDelegate>)delegate |
| 262 | mediaStreamTrack:(RTCMediaStreamTrack*)mediaStreamTrack |
| 263 | statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel { |
| 264 | talk_base::scoped_refptr<webrtc::RTCStatsObserver> observer( |
| 265 | new talk_base::RefCountedObject<webrtc::RTCStatsObserver>(delegate, |
| 266 | self)); |
| 267 | webrtc::PeerConnectionInterface::StatsOutputLevel nativeOutputLevel = |
| 268 | [RTCEnumConverter convertStatsOutputLevelToNative:statsOutputLevel]; |
| 269 | return self.peerConnection->GetStats( |
| 270 | observer, mediaStreamTrack.mediaTrack, nativeOutputLevel); |
| 271 | } |
| 272 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 273 | @end |
| 274 | |
| 275 | @implementation RTCPeerConnection (Internal) |
| 276 | |
tkchin@webrtc.org | acca675 | 2014-05-30 22:26:06 +0000 | [diff] [blame] | 277 | - (instancetype)initWithFactory:(webrtc::PeerConnectionFactoryInterface*)factory |
| 278 | iceServers:(const webrtc::PeerConnectionInterface::IceServers&)iceServers |
| 279 | constraints:(const webrtc::MediaConstraintsInterface*)constraints { |
| 280 | NSParameterAssert(factory != NULL); |
| 281 | if (self = [super init]) { |
| 282 | _observer.reset(new webrtc::RTCPeerConnectionObserver(self)); |
| 283 | _peerConnection = factory->CreatePeerConnection( |
| 284 | iceServers, constraints, NULL, NULL, _observer.get()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 285 | _localStreams = [[NSMutableArray alloc] init]; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 286 | } |
| 287 | return self; |
| 288 | } |
| 289 | |
| 290 | - (talk_base::scoped_refptr<webrtc::PeerConnectionInterface>)peerConnection { |
| 291 | return _peerConnection; |
| 292 | } |
| 293 | |
| 294 | @end |