Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/PeerConnection/RTCPeerConnection.mm

Issue 2890733003: Reland of Split iOS sdk in to separate targets (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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+Private.h"
12
13 #import "NSString+StdString.h"
14 #import "RTCConfiguration+Private.h"
15 #import "RTCDataChannel+Private.h"
16 #import "RTCIceCandidate+Private.h"
17 #import "RTCLegacyStatsReport+Private.h"
18 #import "RTCMediaConstraints+Private.h"
19 #import "RTCMediaStream+Private.h"
20 #import "RTCPeerConnectionFactory+Private.h"
21 #import "RTCRtpReceiver+Private.h"
22 #import "RTCRtpSender+Private.h"
23 #import "RTCSessionDescription+Private.h"
24 #import "WebRTC/RTCLogging.h"
25
26 #include <memory>
27
28 #include "webrtc/api/jsepicecandidate.h"
29 #include "webrtc/base/checks.h"
30
31 NSString * const kRTCPeerConnectionErrorDomain =
32 @"org.webrtc.RTCPeerConnection";
33 int const kRTCPeerConnnectionSessionDescriptionError = -1;
34
35 namespace webrtc {
36
37 class CreateSessionDescriptionObserverAdapter
38 : public CreateSessionDescriptionObserver {
39 public:
40 CreateSessionDescriptionObserverAdapter(
41 void (^completionHandler)(RTCSessionDescription *sessionDescription,
42 NSError *error)) {
43 completion_handler_ = completionHandler;
44 }
45
46 ~CreateSessionDescriptionObserverAdapter() {
47 completion_handler_ = nil;
48 }
49
50 void OnSuccess(SessionDescriptionInterface *desc) override {
51 RTC_DCHECK(completion_handler_);
52 std::unique_ptr<webrtc::SessionDescriptionInterface> description =
53 std::unique_ptr<webrtc::SessionDescriptionInterface>(desc);
54 RTCSessionDescription* session =
55 [[RTCSessionDescription alloc] initWithNativeDescription:
56 description.get()];
57 completion_handler_(session, nil);
58 completion_handler_ = nil;
59 }
60
61 void OnFailure(const std::string& error) override {
62 RTC_DCHECK(completion_handler_);
63 NSString* str = [NSString stringForStdString:error];
64 NSError* err =
65 [NSError errorWithDomain:kRTCPeerConnectionErrorDomain
66 code:kRTCPeerConnnectionSessionDescriptionError
67 userInfo:@{ NSLocalizedDescriptionKey : str }];
68 completion_handler_(nil, err);
69 completion_handler_ = nil;
70 }
71
72 private:
73 void (^completion_handler_)
74 (RTCSessionDescription *sessionDescription, NSError *error);
75 };
76
77 class SetSessionDescriptionObserverAdapter :
78 public SetSessionDescriptionObserver {
79 public:
80 SetSessionDescriptionObserverAdapter(void (^completionHandler)
81 (NSError *error)) {
82 completion_handler_ = completionHandler;
83 }
84
85 ~SetSessionDescriptionObserverAdapter() {
86 completion_handler_ = nil;
87 }
88
89 void OnSuccess() override {
90 RTC_DCHECK(completion_handler_);
91 completion_handler_(nil);
92 completion_handler_ = nil;
93 }
94
95 void OnFailure(const std::string& error) override {
96 RTC_DCHECK(completion_handler_);
97 NSString* str = [NSString stringForStdString:error];
98 NSError* err =
99 [NSError errorWithDomain:kRTCPeerConnectionErrorDomain
100 code:kRTCPeerConnnectionSessionDescriptionError
101 userInfo:@{ NSLocalizedDescriptionKey : str }];
102 completion_handler_(err);
103 completion_handler_ = nil;
104 }
105
106 private:
107 void (^completion_handler_)(NSError *error);
108 };
109
110 PeerConnectionDelegateAdapter::PeerConnectionDelegateAdapter(
111 RTCPeerConnection *peerConnection) {
112 peer_connection_ = peerConnection;
113 }
114
115 PeerConnectionDelegateAdapter::~PeerConnectionDelegateAdapter() {
116 peer_connection_ = nil;
117 }
118
119 void PeerConnectionDelegateAdapter::OnSignalingChange(
120 PeerConnectionInterface::SignalingState new_state) {
121 RTCSignalingState state =
122 [[RTCPeerConnection class] signalingStateForNativeState:new_state];
123 RTCPeerConnection *peer_connection = peer_connection_;
124 [peer_connection.delegate peerConnection:peer_connection
125 didChangeSignalingState:state];
126 }
127
128 void PeerConnectionDelegateAdapter::OnAddStream(
129 rtc::scoped_refptr<MediaStreamInterface> stream) {
130 RTCMediaStream *mediaStream =
131 [[RTCMediaStream alloc] initWithNativeMediaStream:stream];
132 RTCPeerConnection *peer_connection = peer_connection_;
133 [peer_connection.delegate peerConnection:peer_connection
134 didAddStream:mediaStream];
135 }
136
137 void PeerConnectionDelegateAdapter::OnRemoveStream(
138 rtc::scoped_refptr<MediaStreamInterface> stream) {
139 RTCMediaStream *mediaStream =
140 [[RTCMediaStream alloc] initWithNativeMediaStream:stream];
141 RTCPeerConnection *peer_connection = peer_connection_;
142 [peer_connection.delegate peerConnection:peer_connection
143 didRemoveStream:mediaStream];
144 }
145
146 void PeerConnectionDelegateAdapter::OnDataChannel(
147 rtc::scoped_refptr<DataChannelInterface> data_channel) {
148 RTCDataChannel *dataChannel =
149 [[RTCDataChannel alloc] initWithNativeDataChannel:data_channel];
150 RTCPeerConnection *peer_connection = peer_connection_;
151 [peer_connection.delegate peerConnection:peer_connection
152 didOpenDataChannel:dataChannel];
153 }
154
155 void PeerConnectionDelegateAdapter::OnRenegotiationNeeded() {
156 RTCPeerConnection *peer_connection = peer_connection_;
157 [peer_connection.delegate peerConnectionShouldNegotiate:peer_connection];
158 }
159
160 void PeerConnectionDelegateAdapter::OnIceConnectionChange(
161 PeerConnectionInterface::IceConnectionState new_state) {
162 RTCIceConnectionState state =
163 [[RTCPeerConnection class] iceConnectionStateForNativeState:new_state];
164 RTCPeerConnection *peer_connection = peer_connection_;
165 [peer_connection.delegate peerConnection:peer_connection
166 didChangeIceConnectionState:state];
167 }
168
169 void PeerConnectionDelegateAdapter::OnIceGatheringChange(
170 PeerConnectionInterface::IceGatheringState new_state) {
171 RTCIceGatheringState state =
172 [[RTCPeerConnection class] iceGatheringStateForNativeState:new_state];
173 RTCPeerConnection *peer_connection = peer_connection_;
174 [peer_connection.delegate peerConnection:peer_connection
175 didChangeIceGatheringState:state];
176 }
177
178 void PeerConnectionDelegateAdapter::OnIceCandidate(
179 const IceCandidateInterface *candidate) {
180 RTCIceCandidate *iceCandidate =
181 [[RTCIceCandidate alloc] initWithNativeCandidate:candidate];
182 RTCPeerConnection *peer_connection = peer_connection_;
183 [peer_connection.delegate peerConnection:peer_connection
184 didGenerateIceCandidate:iceCandidate];
185 }
186
187 void PeerConnectionDelegateAdapter::OnIceCandidatesRemoved(
188 const std::vector<cricket::Candidate>& candidates) {
189 NSMutableArray* ice_candidates =
190 [NSMutableArray arrayWithCapacity:candidates.size()];
191 for (const auto& candidate : candidates) {
192 std::unique_ptr<JsepIceCandidate> candidate_wrapper(
193 new JsepIceCandidate(candidate.transport_name(), -1, candidate));
194 RTCIceCandidate* ice_candidate = [[RTCIceCandidate alloc]
195 initWithNativeCandidate:candidate_wrapper.get()];
196 [ice_candidates addObject:ice_candidate];
197 }
198 RTCPeerConnection* peer_connection = peer_connection_;
199 [peer_connection.delegate peerConnection:peer_connection
200 didRemoveIceCandidates:ice_candidates];
201 }
202
203 } // namespace webrtc
204
205
206 @implementation RTCPeerConnection {
207 NSMutableArray<RTCMediaStream *> *_localStreams;
208 std::unique_ptr<webrtc::PeerConnectionDelegateAdapter> _observer;
209 rtc::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection;
210 std::unique_ptr<webrtc::MediaConstraints> _nativeConstraints;
211 BOOL _hasStartedRtcEventLog;
212 }
213
214 @synthesize delegate = _delegate;
215
216 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
217 configuration:(RTCConfiguration *)configuration
218 constraints:(RTCMediaConstraints *)constraints
219 delegate:(id<RTCPeerConnectionDelegate>)delegate {
220 NSParameterAssert(factory);
221 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> config(
222 [configuration createNativeConfiguration]);
223 if (!config) {
224 return nil;
225 }
226 if (self = [super init]) {
227 _observer.reset(new webrtc::PeerConnectionDelegateAdapter(self));
228 _nativeConstraints = constraints.nativeConstraints;
229 CopyConstraintsIntoRtcConfiguration(_nativeConstraints.get(),
230 config.get());
231 _peerConnection =
232 factory.nativeFactory->CreatePeerConnection(*config,
233 nullptr,
234 nullptr,
235 _observer.get());
236 if (!_peerConnection) {
237 return nil;
238 }
239 _localStreams = [[NSMutableArray alloc] init];
240 _delegate = delegate;
241 }
242 return self;
243 }
244
245 - (NSArray<RTCMediaStream *> *)localStreams {
246 return [_localStreams copy];
247 }
248
249 - (RTCSessionDescription *)localDescription {
250 const webrtc::SessionDescriptionInterface *description =
251 _peerConnection->local_description();
252 return description ?
253 [[RTCSessionDescription alloc] initWithNativeDescription:description]
254 : nil;
255 }
256
257 - (RTCSessionDescription *)remoteDescription {
258 const webrtc::SessionDescriptionInterface *description =
259 _peerConnection->remote_description();
260 return description ?
261 [[RTCSessionDescription alloc] initWithNativeDescription:description]
262 : nil;
263 }
264
265 - (RTCSignalingState)signalingState {
266 return [[self class]
267 signalingStateForNativeState:_peerConnection->signaling_state()];
268 }
269
270 - (RTCIceConnectionState)iceConnectionState {
271 return [[self class] iceConnectionStateForNativeState:
272 _peerConnection->ice_connection_state()];
273 }
274
275 - (RTCIceGatheringState)iceGatheringState {
276 return [[self class] iceGatheringStateForNativeState:
277 _peerConnection->ice_gathering_state()];
278 }
279
280 - (BOOL)setConfiguration:(RTCConfiguration *)configuration {
281 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> config(
282 [configuration createNativeConfiguration]);
283 if (!config) {
284 return NO;
285 }
286 CopyConstraintsIntoRtcConfiguration(_nativeConstraints.get(),
287 config.get());
288 return _peerConnection->SetConfiguration(*config);
289 }
290
291 - (RTCConfiguration *)configuration {
292 webrtc::PeerConnectionInterface::RTCConfiguration config =
293 _peerConnection->GetConfiguration();
294 return [[RTCConfiguration alloc] initWithNativeConfiguration:config];
295 }
296
297 - (void)close {
298 _peerConnection->Close();
299 }
300
301 - (void)addIceCandidate:(RTCIceCandidate *)candidate {
302 std::unique_ptr<const webrtc::IceCandidateInterface> iceCandidate(
303 candidate.nativeCandidate);
304 _peerConnection->AddIceCandidate(iceCandidate.get());
305 }
306
307 - (void)removeIceCandidates:(NSArray<RTCIceCandidate *> *)iceCandidates {
308 std::vector<cricket::Candidate> candidates;
309 for (RTCIceCandidate *iceCandidate in iceCandidates) {
310 std::unique_ptr<const webrtc::IceCandidateInterface> candidate(
311 iceCandidate.nativeCandidate);
312 if (candidate) {
313 candidates.push_back(candidate->candidate());
314 // Need to fill the transport name from the sdp_mid.
315 candidates.back().set_transport_name(candidate->sdp_mid());
316 }
317 }
318 if (!candidates.empty()) {
319 _peerConnection->RemoveIceCandidates(candidates);
320 }
321 }
322
323 - (void)addStream:(RTCMediaStream *)stream {
324 if (!_peerConnection->AddStream(stream.nativeMediaStream)) {
325 RTCLogError(@"Failed to add stream: %@", stream);
326 return;
327 }
328 [_localStreams addObject:stream];
329 }
330
331 - (void)removeStream:(RTCMediaStream *)stream {
332 _peerConnection->RemoveStream(stream.nativeMediaStream);
333 [_localStreams removeObject:stream];
334 }
335
336 - (void)offerForConstraints:(RTCMediaConstraints *)constraints
337 completionHandler:
338 (void (^)(RTCSessionDescription *sessionDescription,
339 NSError *error))completionHandler {
340 rtc::scoped_refptr<webrtc::CreateSessionDescriptionObserverAdapter>
341 observer(new rtc::RefCountedObject
342 <webrtc::CreateSessionDescriptionObserverAdapter>(completionHandler));
343 _peerConnection->CreateOffer(observer, constraints.nativeConstraints.get());
344 }
345
346 - (void)answerForConstraints:(RTCMediaConstraints *)constraints
347 completionHandler:
348 (void (^)(RTCSessionDescription *sessionDescription,
349 NSError *error))completionHandler {
350 rtc::scoped_refptr<webrtc::CreateSessionDescriptionObserverAdapter>
351 observer(new rtc::RefCountedObject
352 <webrtc::CreateSessionDescriptionObserverAdapter>(completionHandler));
353 _peerConnection->CreateAnswer(observer, constraints.nativeConstraints.get());
354 }
355
356 - (void)setLocalDescription:(RTCSessionDescription *)sdp
357 completionHandler:(void (^)(NSError *error))completionHandler {
358 rtc::scoped_refptr<webrtc::SetSessionDescriptionObserverAdapter> observer(
359 new rtc::RefCountedObject<webrtc::SetSessionDescriptionObserverAdapter>(
360 completionHandler));
361 _peerConnection->SetLocalDescription(observer, sdp.nativeDescription);
362 }
363
364 - (void)setRemoteDescription:(RTCSessionDescription *)sdp
365 completionHandler:(void (^)(NSError *error))completionHandler {
366 rtc::scoped_refptr<webrtc::SetSessionDescriptionObserverAdapter> observer(
367 new rtc::RefCountedObject<webrtc::SetSessionDescriptionObserverAdapter>(
368 completionHandler));
369 _peerConnection->SetRemoteDescription(observer, sdp.nativeDescription);
370 }
371
372 - (BOOL)startRtcEventLogWithFilePath:(NSString *)filePath
373 maxSizeInBytes:(int64_t)maxSizeInBytes {
374 RTC_DCHECK(filePath.length);
375 RTC_DCHECK_GT(maxSizeInBytes, 0);
376 RTC_DCHECK(!_hasStartedRtcEventLog);
377 if (_hasStartedRtcEventLog) {
378 RTCLogError(@"Event logging already started.");
379 return NO;
380 }
381 int fd = open(filePath.UTF8String, O_WRONLY | O_CREAT | O_TRUNC,
382 S_IRUSR | S_IWUSR);
383 if (fd < 0) {
384 RTCLogError(@"Error opening file: %@. Error: %d", filePath, errno);
385 return NO;
386 }
387 _hasStartedRtcEventLog =
388 _peerConnection->StartRtcEventLog(fd, maxSizeInBytes);
389 return _hasStartedRtcEventLog;
390 }
391
392 - (void)stopRtcEventLog {
393 _peerConnection->StopRtcEventLog();
394 _hasStartedRtcEventLog = NO;
395 }
396
397 - (RTCRtpSender *)senderWithKind:(NSString *)kind
398 streamId:(NSString *)streamId {
399 std::string nativeKind = [NSString stdStringForString:kind];
400 std::string nativeStreamId = [NSString stdStringForString:streamId];
401 rtc::scoped_refptr<webrtc::RtpSenderInterface> nativeSender(
402 _peerConnection->CreateSender(nativeKind, nativeStreamId));
403 return nativeSender ?
404 [[RTCRtpSender alloc] initWithNativeRtpSender:nativeSender]
405 : nil;
406 }
407
408 - (NSArray<RTCRtpSender *> *)senders {
409 std::vector<rtc::scoped_refptr<webrtc::RtpSenderInterface>> nativeSenders(
410 _peerConnection->GetSenders());
411 NSMutableArray *senders = [[NSMutableArray alloc] init];
412 for (const auto &nativeSender : nativeSenders) {
413 RTCRtpSender *sender =
414 [[RTCRtpSender alloc] initWithNativeRtpSender:nativeSender];
415 [senders addObject:sender];
416 }
417 return senders;
418 }
419
420 - (NSArray<RTCRtpReceiver *> *)receivers {
421 std::vector<rtc::scoped_refptr<webrtc::RtpReceiverInterface>> nativeReceivers(
422 _peerConnection->GetReceivers());
423 NSMutableArray *receivers = [[NSMutableArray alloc] init];
424 for (const auto &nativeReceiver : nativeReceivers) {
425 RTCRtpReceiver *receiver =
426 [[RTCRtpReceiver alloc] initWithNativeRtpReceiver:nativeReceiver];
427 [receivers addObject:receiver];
428 }
429 return receivers;
430 }
431
432 #pragma mark - Private
433
434 + (webrtc::PeerConnectionInterface::SignalingState)nativeSignalingStateForState:
435 (RTCSignalingState)state {
436 switch (state) {
437 case RTCSignalingStateStable:
438 return webrtc::PeerConnectionInterface::kStable;
439 case RTCSignalingStateHaveLocalOffer:
440 return webrtc::PeerConnectionInterface::kHaveLocalOffer;
441 case RTCSignalingStateHaveLocalPrAnswer:
442 return webrtc::PeerConnectionInterface::kHaveLocalPrAnswer;
443 case RTCSignalingStateHaveRemoteOffer:
444 return webrtc::PeerConnectionInterface::kHaveRemoteOffer;
445 case RTCSignalingStateHaveRemotePrAnswer:
446 return webrtc::PeerConnectionInterface::kHaveRemotePrAnswer;
447 case RTCSignalingStateClosed:
448 return webrtc::PeerConnectionInterface::kClosed;
449 }
450 }
451
452 + (RTCSignalingState)signalingStateForNativeState:
453 (webrtc::PeerConnectionInterface::SignalingState)nativeState {
454 switch (nativeState) {
455 case webrtc::PeerConnectionInterface::kStable:
456 return RTCSignalingStateStable;
457 case webrtc::PeerConnectionInterface::kHaveLocalOffer:
458 return RTCSignalingStateHaveLocalOffer;
459 case webrtc::PeerConnectionInterface::kHaveLocalPrAnswer:
460 return RTCSignalingStateHaveLocalPrAnswer;
461 case webrtc::PeerConnectionInterface::kHaveRemoteOffer:
462 return RTCSignalingStateHaveRemoteOffer;
463 case webrtc::PeerConnectionInterface::kHaveRemotePrAnswer:
464 return RTCSignalingStateHaveRemotePrAnswer;
465 case webrtc::PeerConnectionInterface::kClosed:
466 return RTCSignalingStateClosed;
467 }
468 }
469
470 + (NSString *)stringForSignalingState:(RTCSignalingState)state {
471 switch (state) {
472 case RTCSignalingStateStable:
473 return @"STABLE";
474 case RTCSignalingStateHaveLocalOffer:
475 return @"HAVE_LOCAL_OFFER";
476 case RTCSignalingStateHaveLocalPrAnswer:
477 return @"HAVE_LOCAL_PRANSWER";
478 case RTCSignalingStateHaveRemoteOffer:
479 return @"HAVE_REMOTE_OFFER";
480 case RTCSignalingStateHaveRemotePrAnswer:
481 return @"HAVE_REMOTE_PRANSWER";
482 case RTCSignalingStateClosed:
483 return @"CLOSED";
484 }
485 }
486
487 + (webrtc::PeerConnectionInterface::IceConnectionState)
488 nativeIceConnectionStateForState:(RTCIceConnectionState)state {
489 switch (state) {
490 case RTCIceConnectionStateNew:
491 return webrtc::PeerConnectionInterface::kIceConnectionNew;
492 case RTCIceConnectionStateChecking:
493 return webrtc::PeerConnectionInterface::kIceConnectionChecking;
494 case RTCIceConnectionStateConnected:
495 return webrtc::PeerConnectionInterface::kIceConnectionConnected;
496 case RTCIceConnectionStateCompleted:
497 return webrtc::PeerConnectionInterface::kIceConnectionCompleted;
498 case RTCIceConnectionStateFailed:
499 return webrtc::PeerConnectionInterface::kIceConnectionFailed;
500 case RTCIceConnectionStateDisconnected:
501 return webrtc::PeerConnectionInterface::kIceConnectionDisconnected;
502 case RTCIceConnectionStateClosed:
503 return webrtc::PeerConnectionInterface::kIceConnectionClosed;
504 case RTCIceConnectionStateCount:
505 return webrtc::PeerConnectionInterface::kIceConnectionMax;
506 }
507 }
508
509 + (RTCIceConnectionState)iceConnectionStateForNativeState:
510 (webrtc::PeerConnectionInterface::IceConnectionState)nativeState {
511 switch (nativeState) {
512 case webrtc::PeerConnectionInterface::kIceConnectionNew:
513 return RTCIceConnectionStateNew;
514 case webrtc::PeerConnectionInterface::kIceConnectionChecking:
515 return RTCIceConnectionStateChecking;
516 case webrtc::PeerConnectionInterface::kIceConnectionConnected:
517 return RTCIceConnectionStateConnected;
518 case webrtc::PeerConnectionInterface::kIceConnectionCompleted:
519 return RTCIceConnectionStateCompleted;
520 case webrtc::PeerConnectionInterface::kIceConnectionFailed:
521 return RTCIceConnectionStateFailed;
522 case webrtc::PeerConnectionInterface::kIceConnectionDisconnected:
523 return RTCIceConnectionStateDisconnected;
524 case webrtc::PeerConnectionInterface::kIceConnectionClosed:
525 return RTCIceConnectionStateClosed;
526 case webrtc::PeerConnectionInterface::kIceConnectionMax:
527 return RTCIceConnectionStateCount;
528 }
529 }
530
531 + (NSString *)stringForIceConnectionState:(RTCIceConnectionState)state {
532 switch (state) {
533 case RTCIceConnectionStateNew:
534 return @"NEW";
535 case RTCIceConnectionStateChecking:
536 return @"CHECKING";
537 case RTCIceConnectionStateConnected:
538 return @"CONNECTED";
539 case RTCIceConnectionStateCompleted:
540 return @"COMPLETED";
541 case RTCIceConnectionStateFailed:
542 return @"FAILED";
543 case RTCIceConnectionStateDisconnected:
544 return @"DISCONNECTED";
545 case RTCIceConnectionStateClosed:
546 return @"CLOSED";
547 case RTCIceConnectionStateCount:
548 return @"COUNT";
549 }
550 }
551
552 + (webrtc::PeerConnectionInterface::IceGatheringState)
553 nativeIceGatheringStateForState:(RTCIceGatheringState)state {
554 switch (state) {
555 case RTCIceGatheringStateNew:
556 return webrtc::PeerConnectionInterface::kIceGatheringNew;
557 case RTCIceGatheringStateGathering:
558 return webrtc::PeerConnectionInterface::kIceGatheringGathering;
559 case RTCIceGatheringStateComplete:
560 return webrtc::PeerConnectionInterface::kIceGatheringComplete;
561 }
562 }
563
564 + (RTCIceGatheringState)iceGatheringStateForNativeState:
565 (webrtc::PeerConnectionInterface::IceGatheringState)nativeState {
566 switch (nativeState) {
567 case webrtc::PeerConnectionInterface::kIceGatheringNew:
568 return RTCIceGatheringStateNew;
569 case webrtc::PeerConnectionInterface::kIceGatheringGathering:
570 return RTCIceGatheringStateGathering;
571 case webrtc::PeerConnectionInterface::kIceGatheringComplete:
572 return RTCIceGatheringStateComplete;
573 }
574 }
575
576 + (NSString *)stringForIceGatheringState:(RTCIceGatheringState)state {
577 switch (state) {
578 case RTCIceGatheringStateNew:
579 return @"NEW";
580 case RTCIceGatheringStateGathering:
581 return @"GATHERING";
582 case RTCIceGatheringStateComplete:
583 return @"COMPLETE";
584 }
585 }
586
587 + (webrtc::PeerConnectionInterface::StatsOutputLevel)
588 nativeStatsOutputLevelForLevel:(RTCStatsOutputLevel)level {
589 switch (level) {
590 case RTCStatsOutputLevelStandard:
591 return webrtc::PeerConnectionInterface::kStatsOutputLevelStandard;
592 case RTCStatsOutputLevelDebug:
593 return webrtc::PeerConnectionInterface::kStatsOutputLevelDebug;
594 }
595 }
596
597 - (rtc::scoped_refptr<webrtc::PeerConnectionInterface>)nativePeerConnection {
598 return _peerConnection;
599 }
600
601 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698