OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2015 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 "RTCPeerConnection.h" | |
12 | |
13 #import "webrtc/api/objc/RTCPeerConnection+Private.h" | |
14 #import "webrtc/api/objc/RTCConfiguration+Private.h" | |
15 #import "webrtc/api/objc/RTCDataChannel+Private.h" | |
16 #import "webrtc/api/objc/RTCDataChannelConfiguration+Private.h" | |
17 #import "webrtc/api/objc/RTCIceCandidate+Private.h" | |
18 #import "webrtc/api/objc/RTCMediaConstraints+Private.h" | |
19 #import "webrtc/api/objc/RTCMediaStream+Private.h" | |
20 #import "webrtc/api/objc/RTCMediaStreamTrack+Private.h" | |
21 #import "webrtc/api/objc/RTCPeerConnectionFactory+Private.h" | |
22 #import "webrtc/api/objc/RTCSessionDescription+Private.h" | |
23 #import "webrtc/api/objc/RTCStatsReport+Private.h" | |
24 #import "webrtc/base/objc/RTCLogging.h" | |
25 #import "webrtc/base/objc/NSString+StdString.h" | |
26 | |
27 NSString * const kRTCPeerConnectionErrorDomain = | |
28 @"org.webrtc.RTCPeerConnection"; | |
29 int const kRTCSessionDescriptionErrorCode = -1; | |
tkchin_webrtc
2016/02/05 16:15:16
kRTCPeerConnnectionSessionDescriptionError = -1;
hjon_webrtc
2016/02/09 00:59:54
Done.
| |
30 | |
31 namespace webrtc { | |
32 | |
33 class CreateSessionDescriptionObserverAdapter | |
34 : public CreateSessionDescriptionObserver { | |
35 public: | |
36 CreateSessionDescriptionObserverAdapter(void (^completionHandler) | |
37 (RTCSessionDescription *sessionDescription, NSError *error)) { | |
38 completion_handler_ = completionHandler; | |
39 } | |
40 | |
41 ~CreateSessionDescriptionObserverAdapter() { | |
42 completion_handler_ = nil; | |
43 } | |
44 | |
45 void OnSuccess(SessionDescriptionInterface *desc) override { | |
46 rtc::scoped_ptr<webrtc::SessionDescriptionInterface> description = | |
47 rtc::scoped_ptr<webrtc::SessionDescriptionInterface>(desc); | |
48 RTCSessionDescription *session = | |
49 [[RTCSessionDescription alloc] initWithNativeDescription: | |
50 description.get()]; | |
51 if (completion_handler_) { | |
52 completion_handler_(session, nil); | |
53 } | |
54 Block_release(completion_handler_); | |
tkchin_webrtc
2016/02/05 16:15:16
? ARC should be releasing for you. Set it to nil.
hjon_webrtc
2016/02/09 00:59:54
Done.
Do you have a preference between setting to
| |
55 } | |
56 | |
57 void OnFailure(const std::string& error) override { | |
58 NSString *str = [NSString stringForStdString:error]; | |
59 NSError *err = | |
60 [NSError errorWithDomain:kRTCPeerConnectionErrorDomain | |
61 code:kRTCSessionDescriptionErrorCode | |
62 userInfo:@{NSLocalizedDescriptionKey : str}]; | |
63 if (completion_handler_) { | |
64 completion_handler_(nil, err); | |
65 } | |
66 Block_release(completion_handler_); | |
tkchin_webrtc
2016/02/05 16:15:16
ditto
hjon_webrtc
2016/02/09 00:59:54
Done.
| |
67 } | |
68 | |
69 private: | |
70 void (^completion_handler_) | |
71 (RTCSessionDescription *sessionDescription, NSError *error); | |
72 }; | |
73 | |
74 PeerConnectionDelegateAdapter::PeerConnectionDelegateAdapter( | |
tkchin_webrtc
2016/02/05 16:15:16
dedent entire section?
hjon_webrtc
2016/02/09 00:59:54
Done.
| |
75 RTCPeerConnection *peerConnection) { | |
76 peer_connection_ = peerConnection; | |
77 } | |
78 | |
79 PeerConnectionDelegateAdapter::~PeerConnectionDelegateAdapter() { | |
80 } | |
81 | |
82 void PeerConnectionDelegateAdapter::OnSignalingChange( | |
83 PeerConnectionInterface::SignalingState new_state) { | |
84 RTCSignalingState state = | |
85 [[RTCPeerConnection class] signalingStateForNativeState:new_state]; | |
86 RTCPeerConnection *strong_pc = peer_connection_; | |
tkchin_webrtc
2016/02/05 16:15:16
nit: just peer_connection = peer_connection_ will
hjon_webrtc
2016/02/09 00:59:54
Done.
| |
87 [strong_pc.delegate peerConnection:strong_pc | |
88 signalingStateChanged:state]; | |
89 } | |
90 | |
91 void PeerConnectionDelegateAdapter::OnAddStream( | |
92 MediaStreamInterface *stream) { | |
93 RTCMediaStream *mediaStream = | |
94 [[RTCMediaStream alloc] initWithNativeMediaStream:stream]; | |
95 RTCPeerConnection *strong_pc = peer_connection_; | |
96 [strong_pc.delegate peerConnection:strong_pc | |
97 addedStream:mediaStream]; | |
98 } | |
99 | |
100 void PeerConnectionDelegateAdapter::OnRemoveStream( | |
101 MediaStreamInterface *stream) { | |
102 RTCMediaStream *mediaStream = | |
103 [[RTCMediaStream alloc] initWithNativeMediaStream:stream]; | |
104 RTCPeerConnection *strong_pc = peer_connection_; | |
105 [strong_pc.delegate peerConnection:strong_pc | |
106 removedStream:mediaStream]; | |
107 } | |
108 | |
109 void PeerConnectionDelegateAdapter::OnDataChannel( | |
110 DataChannelInterface *data_channel) { | |
111 RTCDataChannel *dataChannel = | |
112 [[RTCDataChannel alloc] initWithNativeDataChannel:data_channel]; | |
113 RTCPeerConnection *strong_pc = peer_connection_; | |
114 [strong_pc.delegate peerConnection:strong_pc | |
115 didOpenDataChannel:dataChannel]; | |
116 } | |
117 | |
118 void PeerConnectionDelegateAdapter::OnRenegotiationNeeded() { | |
119 RTCPeerConnection *strong_pc = peer_connection_; | |
120 [strong_pc.delegate peerConnectionNeedsRenegotiation:strong_pc]; | |
121 } | |
122 | |
123 void PeerConnectionDelegateAdapter::OnIceConnectionChange( | |
124 PeerConnectionInterface::IceConnectionState new_state) { | |
125 RTCIceConnectionState state = | |
126 [[RTCPeerConnection class] iceConnectionStateForNativeState:new_state]; | |
127 RTCPeerConnection *strong_pc = peer_connection_; | |
128 [strong_pc.delegate peerConnection:strong_pc | |
129 iceConnectionStateChanged:state]; | |
130 } | |
131 | |
132 void PeerConnectionDelegateAdapter::OnIceGatheringChange( | |
133 PeerConnectionInterface::IceGatheringState new_state) { | |
134 RTCIceGatheringState state = | |
135 [[RTCPeerConnection class] iceGatheringStateForNativeState:new_state]; | |
136 RTCPeerConnection *strong_pc = peer_connection_; | |
137 [strong_pc.delegate peerConnection:strong_pc | |
138 iceGatheringStateChanged:state]; | |
139 } | |
140 | |
141 void PeerConnectionDelegateAdapter::OnIceCandidate( | |
142 const IceCandidateInterface *candidate) { | |
143 RTCIceCandidate *iceCandidate = | |
144 [[RTCIceCandidate alloc] initWithNativeCandidate:candidate]; | |
145 RTCPeerConnection *strong_pc = peer_connection_; | |
146 [strong_pc.delegate peerConnection:strong_pc | |
147 receivedIceCandidate:iceCandidate]; | |
148 } | |
149 | |
150 class SetSessionDescriptionObserverAdapter : | |
tkchin_webrtc
2016/02/05 16:15:16
Can we keep the session description bits together?
hjon_webrtc
2016/02/09 00:59:54
Done.
| |
151 public SetSessionDescriptionObserver { | |
152 public: | |
153 SetSessionDescriptionObserverAdapter(void (^completionHandler) | |
154 (NSError *error)) { | |
155 completion_handler_ = completionHandler; | |
156 } | |
157 | |
158 ~SetSessionDescriptionObserverAdapter() { | |
159 completion_handler_ = nil; | |
160 } | |
161 | |
162 void OnSuccess() override { | |
163 if (completion_handler_) { | |
164 completion_handler_(nil); | |
165 } | |
166 Block_release(completion_handler_); | |
tkchin_webrtc
2016/02/05 16:15:16
ditto. here and elsewhere
hjon_webrtc
2016/02/09 00:59:54
Done.
| |
167 } | |
168 | |
169 void OnFailure(const std::string& error) override { | |
170 NSString *str = [NSString stringForStdString:error]; | |
171 NSError *err = | |
172 [NSError errorWithDomain:kRTCPeerConnectionErrorDomain | |
173 code:kRTCSessionDescriptionErrorCode | |
174 userInfo:@{NSLocalizedDescriptionKey : str}]; | |
175 if (completion_handler_) { | |
176 completion_handler_(err); | |
177 } | |
178 Block_release(completion_handler_); | |
tkchin_webrtc
2016/02/05 16:15:16
ditto
hjon_webrtc
2016/02/09 00:59:54
Done.
| |
179 } | |
180 | |
181 private: | |
182 void (^completion_handler_)(NSError *error); | |
183 }; | |
184 | |
185 class StatsObserverAdapter : public StatsObserver { | |
186 public: | |
187 StatsObserverAdapter(void (^completionHandler) | |
188 (NSArray<RTCStatsReport *> *stats)) { | |
189 completion_handler_ = completionHandler; | |
190 } | |
191 | |
192 ~StatsObserverAdapter() { | |
193 completion_handler_ = nil; | |
194 } | |
195 | |
196 void OnComplete(const StatsReports& reports) override { | |
197 NSMutableArray *stats = [NSMutableArray arrayWithCapacity:reports.size()]; | |
198 for (const auto* report : reports) { | |
199 RTCStatsReport *statsReport = | |
200 [[RTCStatsReport alloc] initWithNativeReport:*report]; | |
201 [stats addObject:statsReport]; | |
202 } | |
203 if (completion_handler_) { | |
204 completion_handler_(stats); | |
205 } | |
206 Block_release(completion_handler_); | |
207 } | |
208 | |
209 private: | |
210 void (^completion_handler_)(NSArray *stats); | |
211 }; | |
212 } // namespace webrtc | |
213 | |
214 | |
215 @implementation RTCPeerConnection { | |
216 NSMutableArray *_localStreams; | |
217 rtc::scoped_ptr<webrtc::PeerConnectionDelegateAdapter> _observer; | |
218 rtc::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection; | |
219 } | |
220 | |
221 @synthesize delegate = _delegate; | |
222 | |
223 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory | |
224 configuration:(RTCConfiguration *)configuration | |
225 constraints:(RTCMediaConstraints *)constraints | |
226 delegate:(id<RTCPeerConnectionDelegate>)delegate { | |
227 NSParameterAssert(factory); | |
228 if (self = [super init]) { | |
229 _observer.reset(new webrtc::PeerConnectionDelegateAdapter(self)); | |
230 webrtc::PeerConnectionInterface::RTCConfiguration config = | |
231 configuration.nativeConfiguration; | |
232 webrtc::MediaConstraints *nativeConstraints = | |
233 constraints.nativeConstraints.get(); | |
234 _peerConnection = | |
235 factory.nativeFactory->CreatePeerConnection(config, | |
236 nativeConstraints, | |
237 nullptr, | |
238 nullptr, | |
239 _observer.get()); | |
240 _localStreams = [[NSMutableArray alloc] init]; | |
241 _delegate = delegate; | |
242 } | |
243 return self; | |
244 } | |
245 | |
246 - (NSArray *)localStreams { | |
247 return [_localStreams copy]; | |
248 } | |
249 | |
250 - (RTCSessionDescription *)localDescription { | |
251 const webrtc::SessionDescriptionInterface *description = | |
252 _peerConnection->local_description(); | |
253 return description ? | |
254 [[RTCSessionDescription alloc] initWithNativeDescription:description] | |
255 : nil; | |
256 } | |
257 | |
258 - (RTCSessionDescription *)remoteDescription { | |
259 const webrtc::SessionDescriptionInterface *description = | |
260 _peerConnection->remote_description(); | |
261 return description ? | |
262 [[RTCSessionDescription alloc] initWithNativeDescription:description] | |
263 : nil; | |
264 } | |
265 | |
266 - (RTCSignalingState)signalingState { | |
267 return [[self class] | |
268 signalingStateForNativeState:_peerConnection->signaling_state()]; | |
269 } | |
270 | |
271 - (RTCIceConnectionState)iceConnectionState { | |
272 return [[self class] iceConnectionStateForNativeState: | |
273 _peerConnection->ice_connection_state()]; | |
274 } | |
275 | |
276 - (RTCIceGatheringState)iceGatheringState { | |
277 return [[self class] iceGatheringStateForNativeState: | |
278 _peerConnection->ice_gathering_state()]; | |
279 } | |
280 | |
281 - (void)close { | |
282 _peerConnection->Close(); | |
283 } | |
284 | |
285 - (void)addIceCandidate:(RTCIceCandidate *)candidate { | |
286 rtc::scoped_ptr<const webrtc::IceCandidateInterface> iceCandidate( | |
287 candidate.nativeCandidate); | |
288 _peerConnection->AddIceCandidate(iceCandidate.get()); | |
289 } | |
290 | |
291 - (void)addStream:(RTCMediaStream *)stream { | |
292 if (_peerConnection->AddStream(stream.nativeMediaStream)) { | |
293 RTCLogError(@"Failed to create add stream: %@", stream); | |
294 return; | |
295 } | |
296 [_localStreams addObject:stream]; | |
297 } | |
298 | |
299 - (void)removeStream:(RTCMediaStream *)stream { | |
300 _peerConnection->RemoveStream(stream.nativeMediaStream); | |
301 [_localStreams removeObject:stream]; | |
302 } | |
303 | |
304 - (RTCDataChannel *)dataChannelWithLabel:(NSString *)label | |
305 configuration: | |
306 (RTCDataChannelConfiguration *)configuration { | |
307 std::string labelString = [NSString stdStringForString:label]; | |
308 const webrtc::DataChannelInit nativeInit = | |
309 configuration.nativeDataChannelInit; | |
310 rtc::scoped_refptr<webrtc::DataChannelInterface> dataChannel = | |
311 _peerConnection->CreateDataChannel(labelString, | |
312 &nativeInit); | |
313 return [[RTCDataChannel alloc] initWithNativeDataChannel:dataChannel]; | |
314 } | |
315 | |
316 - (void)offerWithConstraints:(RTCMediaConstraints *)constraints | |
317 completionHandler: | |
318 (void (^)(RTCSessionDescription *sessionDescription, NSError *error)) | |
319 completionHandler { | |
320 rtc::scoped_refptr<webrtc::CreateSessionDescriptionObserverAdapter> | |
321 observer(new rtc::RefCountedObject | |
322 <webrtc::CreateSessionDescriptionObserverAdapter>(completionHandler)); | |
323 _peerConnection->CreateOffer(observer, constraints.nativeConstraints.get()); | |
324 } | |
325 | |
326 - (void)answerWithConstraints:(RTCMediaConstraints *)constraints | |
327 completionHandler: | |
328 (void (^)(RTCSessionDescription *sessionDescription, NSError *error)) | |
329 completionHandler { | |
330 rtc::scoped_refptr<webrtc::CreateSessionDescriptionObserverAdapter> | |
331 observer(new rtc::RefCountedObject | |
332 <webrtc::CreateSessionDescriptionObserverAdapter>(completionHandler)); | |
333 _peerConnection->CreateAnswer(observer, constraints.nativeConstraints.get()); | |
334 } | |
335 | |
336 - (void)setLocalDescription:(RTCSessionDescription *)sdp | |
337 completionHandler:(void (^)(NSError *error))completionHandler { | |
338 rtc::scoped_refptr<webrtc::SetSessionDescriptionObserverAdapter> observer( | |
339 new rtc::RefCountedObject<webrtc::SetSessionDescriptionObserverAdapter> | |
340 (completionHandler)); | |
341 _peerConnection->SetLocalDescription(observer, sdp.nativeDescription); | |
342 } | |
343 | |
344 - (void)setRemoteDescription:(RTCSessionDescription *)sdp | |
345 completionHandler:(void (^)(NSError *error))completionHandler { | |
346 rtc::scoped_refptr<webrtc::SetSessionDescriptionObserverAdapter> observer( | |
347 new rtc::RefCountedObject<webrtc::SetSessionDescriptionObserverAdapter> | |
348 (completionHandler)); | |
349 _peerConnection->SetRemoteDescription(observer, sdp.nativeDescription); | |
350 } | |
351 | |
352 - (void)statsForMediaStreamTrack:(RTCMediaStreamTrack *)mediaStreamTrack | |
353 statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel | |
354 completionHandler: | |
355 (void (^)(NSArray<RTCStatsReport *> *stats))completionHandler { | |
356 rtc::scoped_refptr<webrtc::StatsObserverAdapter> observer( | |
357 new rtc::RefCountedObject<webrtc::StatsObserverAdapter> | |
358 (completionHandler)); | |
359 webrtc::PeerConnectionInterface::StatsOutputLevel nativeOutputLevel = | |
360 [[self class] nativeStatsOutputLevelForLevel:statsOutputLevel]; | |
361 _peerConnection->GetStats( | |
362 observer, mediaStreamTrack.nativeTrack, nativeOutputLevel); | |
363 } | |
364 | |
365 #pragma mark - Private | |
366 | |
367 - (rtc::scoped_refptr<webrtc::PeerConnectionInterface>)nativePeerConnection { | |
368 return _peerConnection; | |
369 } | |
370 | |
371 + (webrtc::PeerConnectionInterface::SignalingState)nativeSignalingStateForState: | |
372 (RTCSignalingState)state { | |
373 switch (state) { | |
374 case RTCSignalingStateStable: | |
375 return webrtc::PeerConnectionInterface::kStable; | |
376 case RTCSignalingStateHaveLocalOffer: | |
377 return webrtc::PeerConnectionInterface::kHaveLocalOffer; | |
378 case RTCSignalingStateHaveLocalPrAnswer: | |
379 return webrtc::PeerConnectionInterface::kHaveLocalPrAnswer; | |
380 case RTCSignalingStateHaveRemoteOffer: | |
381 return webrtc::PeerConnectionInterface::kHaveRemoteOffer; | |
382 case RTCSignalingStateHaveRemotePrAnswer: | |
383 return webrtc::PeerConnectionInterface::kHaveRemotePrAnswer; | |
384 case RTCSignalingStateClosed: | |
385 return webrtc::PeerConnectionInterface::kClosed; | |
386 } | |
387 } | |
388 | |
389 + (RTCSignalingState)signalingStateForNativeState: | |
390 (webrtc::PeerConnectionInterface::SignalingState)nativeState { | |
391 switch (nativeState) { | |
392 case webrtc::PeerConnectionInterface::kStable: | |
393 return RTCSignalingStateStable; | |
394 case webrtc::PeerConnectionInterface::kHaveLocalOffer: | |
395 return RTCSignalingStateHaveLocalOffer; | |
396 case webrtc::PeerConnectionInterface::kHaveLocalPrAnswer: | |
397 return RTCSignalingStateHaveLocalPrAnswer; | |
398 case webrtc::PeerConnectionInterface::kHaveRemoteOffer: | |
399 return RTCSignalingStateHaveRemoteOffer; | |
400 case webrtc::PeerConnectionInterface::kHaveRemotePrAnswer: | |
401 return RTCSignalingStateHaveRemotePrAnswer; | |
402 case webrtc::PeerConnectionInterface::kClosed: | |
403 return RTCSignalingStateClosed; | |
404 } | |
405 } | |
406 | |
407 + (NSString *)stringForSignalingState:(RTCSignalingState)state { | |
408 switch (state) { | |
409 case RTCSignalingStateStable: | |
410 return @"STABLE"; | |
411 case RTCSignalingStateHaveLocalOffer: | |
412 return @"HAVE_LOCAL_OFFER"; | |
413 case RTCSignalingStateHaveLocalPrAnswer: | |
414 return @"HAVE_LOCAL_PRANSWER"; | |
415 case RTCSignalingStateHaveRemoteOffer: | |
416 return @"HAVE_REMOTE_OFFER"; | |
417 case RTCSignalingStateHaveRemotePrAnswer: | |
418 return @"HAVE_REMOTE_PRANSWER"; | |
419 case RTCSignalingStateClosed: | |
420 return @"CLOSED"; | |
421 } | |
422 } | |
423 | |
424 + (webrtc::PeerConnectionInterface::IceConnectionState) | |
425 nativeIceConnectionStateForState:(RTCIceConnectionState)state { | |
426 switch (state) { | |
427 case RTCIceConnectionStateNew: | |
428 return webrtc::PeerConnectionInterface::kIceConnectionNew; | |
429 case RTCIceConnectionStateChecking: | |
430 return webrtc::PeerConnectionInterface::kIceConnectionChecking; | |
431 case RTCIceConnectionStateConnected: | |
432 return webrtc::PeerConnectionInterface::kIceConnectionConnected; | |
433 case RTCIceConnectionStateCompleted: | |
434 return webrtc::PeerConnectionInterface::kIceConnectionCompleted; | |
435 case RTCIceConnectionStateFailed: | |
436 return webrtc::PeerConnectionInterface::kIceConnectionFailed; | |
437 case RTCIceConnectionStateDisconnected: | |
438 return webrtc::PeerConnectionInterface::kIceConnectionDisconnected; | |
439 case RTCIceConnectionStateClosed: | |
440 return webrtc::PeerConnectionInterface::kIceConnectionClosed; | |
441 case RTCIceConnectionStateMax: | |
442 return webrtc::PeerConnectionInterface::kIceConnectionMax; | |
443 } | |
444 } | |
445 | |
446 + (RTCIceConnectionState)iceConnectionStateForNativeState: | |
447 (webrtc::PeerConnectionInterface::IceConnectionState)nativeState { | |
448 switch (nativeState) { | |
449 case webrtc::PeerConnectionInterface::kIceConnectionNew: | |
450 return RTCIceConnectionStateNew; | |
451 case webrtc::PeerConnectionInterface::kIceConnectionChecking: | |
452 return RTCIceConnectionStateChecking; | |
453 case webrtc::PeerConnectionInterface::kIceConnectionConnected: | |
454 return RTCIceConnectionStateConnected; | |
455 case webrtc::PeerConnectionInterface::kIceConnectionCompleted: | |
456 return RTCIceConnectionStateCompleted; | |
457 case webrtc::PeerConnectionInterface::kIceConnectionFailed: | |
458 return RTCIceConnectionStateFailed; | |
459 case webrtc::PeerConnectionInterface::kIceConnectionDisconnected: | |
460 return RTCIceConnectionStateDisconnected; | |
461 case webrtc::PeerConnectionInterface::kIceConnectionClosed: | |
462 return RTCIceConnectionStateClosed; | |
463 case webrtc::PeerConnectionInterface::kIceConnectionMax: | |
464 return RTCIceConnectionStateMax; | |
465 } | |
466 } | |
467 | |
468 + (NSString *)stringForIceConnectionState:(RTCIceConnectionState)state { | |
469 switch (state) { | |
470 case RTCIceConnectionStateNew: | |
471 return @"NEW"; | |
472 case RTCIceConnectionStateChecking: | |
473 return @"CHECKING"; | |
474 case RTCIceConnectionStateConnected: | |
475 return @"CONNECTED"; | |
476 case RTCIceConnectionStateCompleted: | |
477 return @"COMPLETED"; | |
478 case RTCIceConnectionStateFailed: | |
479 return @"FAILED"; | |
480 case RTCIceConnectionStateDisconnected: | |
481 return @"DISCONNECTED"; | |
482 case RTCIceConnectionStateClosed: | |
483 return @"CLOSED"; | |
484 case RTCIceConnectionStateMax: | |
485 return @"MAX"; | |
486 } | |
487 } | |
488 | |
489 + (webrtc::PeerConnectionInterface::IceGatheringState) | |
490 nativeIceGatheringStateForState:(RTCIceGatheringState)state { | |
491 switch (state) { | |
492 case RTCIceGatheringStateNew: | |
493 return webrtc::PeerConnectionInterface::kIceGatheringNew; | |
494 case RTCIceGatheringStateGathering: | |
495 return webrtc::PeerConnectionInterface::kIceGatheringGathering; | |
496 case RTCIceGatheringStateComplete: | |
497 return webrtc::PeerConnectionInterface::kIceGatheringComplete; | |
498 } | |
499 } | |
500 | |
501 + (RTCIceGatheringState)iceGatheringStateForNativeState: | |
502 (webrtc::PeerConnectionInterface::IceGatheringState)nativeState { | |
503 switch (nativeState) { | |
504 case webrtc::PeerConnectionInterface::kIceGatheringNew: | |
505 return RTCIceGatheringStateNew; | |
506 case webrtc::PeerConnectionInterface::kIceGatheringGathering: | |
507 return RTCIceGatheringStateGathering; | |
508 case webrtc::PeerConnectionInterface::kIceGatheringComplete: | |
509 return RTCIceGatheringStateComplete; | |
510 } | |
511 } | |
512 | |
513 + (NSString *)stringForIceGatheringState:(RTCIceGatheringState)state { | |
514 switch (state) { | |
515 case RTCIceGatheringStateNew: | |
516 return @"NEW"; | |
517 case RTCIceGatheringStateGathering: | |
518 return @"GATHERING"; | |
519 case RTCIceGatheringStateComplete: | |
520 return @"COMPLETE"; | |
521 } | |
522 } | |
523 | |
524 + (webrtc::PeerConnectionInterface::StatsOutputLevel) | |
525 nativeStatsOutputLevelForLevel:(RTCStatsOutputLevel)level { | |
526 switch (level) { | |
527 case RTCStatsOutputLevelStandard: | |
528 return webrtc::PeerConnectionInterface::kStatsOutputLevelStandard; | |
529 case RTCStatsOutputLevelDebug: | |
530 return webrtc::PeerConnectionInterface::kStatsOutputLevelDebug; | |
531 } | |
532 } | |
533 | |
534 @end | |
OLD | NEW |