OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 didRemoveIceCandidates:ice_candidates]; | 200 didRemoveIceCandidates:ice_candidates]; |
201 } | 201 } |
202 | 202 |
203 } // namespace webrtc | 203 } // namespace webrtc |
204 | 204 |
205 | 205 |
206 @implementation RTCPeerConnection { | 206 @implementation RTCPeerConnection { |
207 NSMutableArray *_localStreams; | 207 NSMutableArray *_localStreams; |
208 std::unique_ptr<webrtc::PeerConnectionDelegateAdapter> _observer; | 208 std::unique_ptr<webrtc::PeerConnectionDelegateAdapter> _observer; |
209 rtc::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection; | 209 rtc::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection; |
210 BOOL _hasStartedRtcEventLog; | |
211 } | 210 } |
212 | 211 |
213 @synthesize delegate = _delegate; | 212 @synthesize delegate = _delegate; |
214 | 213 |
215 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory | 214 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory |
216 configuration:(RTCConfiguration *)configuration | 215 configuration:(RTCConfiguration *)configuration |
217 constraints:(RTCMediaConstraints *)constraints | 216 constraints:(RTCMediaConstraints *)constraints |
218 delegate:(id<RTCPeerConnectionDelegate>)delegate { | 217 delegate:(id<RTCPeerConnectionDelegate>)delegate { |
219 NSParameterAssert(factory); | 218 NSParameterAssert(factory); |
220 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> config( | 219 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> config( |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 } | 349 } |
351 | 350 |
352 - (void)setRemoteDescription:(RTCSessionDescription *)sdp | 351 - (void)setRemoteDescription:(RTCSessionDescription *)sdp |
353 completionHandler:(void (^)(NSError *error))completionHandler { | 352 completionHandler:(void (^)(NSError *error))completionHandler { |
354 rtc::scoped_refptr<webrtc::SetSessionDescriptionObserverAdapter> observer( | 353 rtc::scoped_refptr<webrtc::SetSessionDescriptionObserverAdapter> observer( |
355 new rtc::RefCountedObject<webrtc::SetSessionDescriptionObserverAdapter>( | 354 new rtc::RefCountedObject<webrtc::SetSessionDescriptionObserverAdapter>( |
356 completionHandler)); | 355 completionHandler)); |
357 _peerConnection->SetRemoteDescription(observer, sdp.nativeDescription); | 356 _peerConnection->SetRemoteDescription(observer, sdp.nativeDescription); |
358 } | 357 } |
359 | 358 |
360 - (BOOL)startRtcEventLogWithFilePath:(NSString *)filePath | |
361 maxSizeInBytes:(int64_t)maxSizeInBytes { | |
362 RTC_DCHECK(filePath.length); | |
363 RTC_DCHECK_GT(maxSizeInBytes, 0); | |
364 RTC_DCHECK(!_hasStartedRtcEventLog); | |
365 if (_hasStartedRtcEventLog) { | |
366 RTCLogError(@"Event logging already started."); | |
367 return NO; | |
368 } | |
369 int fd = open(filePath.UTF8String, O_WRONLY | O_CREAT | O_TRUNC, | |
370 S_IRUSR | S_IWUSR); | |
371 if (fd < 0) { | |
372 RTCLogError(@"Error opening file: %@. Error: %d", filePath, errno); | |
373 return NO; | |
374 } | |
375 _hasStartedRtcEventLog = | |
376 _peerConnection->StartRtcEventLog(fd, maxSizeInBytes); | |
377 return _hasStartedRtcEventLog; | |
378 } | |
379 | |
380 - (void)stopRtcEventLog { | |
381 _peerConnection->StopRtcEventLog(); | |
382 _hasStartedRtcEventLog = NO; | |
383 } | |
384 | |
385 - (RTCRtpSender *)senderWithKind:(NSString *)kind | 359 - (RTCRtpSender *)senderWithKind:(NSString *)kind |
386 streamId:(NSString *)streamId { | 360 streamId:(NSString *)streamId { |
387 std::string nativeKind = [NSString stdStringForString:kind]; | 361 std::string nativeKind = [NSString stdStringForString:kind]; |
388 std::string nativeStreamId = [NSString stdStringForString:streamId]; | 362 std::string nativeStreamId = [NSString stdStringForString:streamId]; |
389 rtc::scoped_refptr<webrtc::RtpSenderInterface> nativeSender( | 363 rtc::scoped_refptr<webrtc::RtpSenderInterface> nativeSender( |
390 _peerConnection->CreateSender(nativeKind, nativeStreamId)); | 364 _peerConnection->CreateSender(nativeKind, nativeStreamId)); |
391 return nativeSender ? | 365 return nativeSender ? |
392 [[RTCRtpSender alloc] initWithNativeRtpSender:nativeSender] | 366 [[RTCRtpSender alloc] initWithNativeRtpSender:nativeSender] |
393 : nil; | 367 : nil; |
394 } | 368 } |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 case RTCStatsOutputLevelDebug: | 554 case RTCStatsOutputLevelDebug: |
581 return webrtc::PeerConnectionInterface::kStatsOutputLevelDebug; | 555 return webrtc::PeerConnectionInterface::kStatsOutputLevelDebug; |
582 } | 556 } |
583 } | 557 } |
584 | 558 |
585 - (rtc::scoped_refptr<webrtc::PeerConnectionInterface>)nativePeerConnection { | 559 - (rtc::scoped_refptr<webrtc::PeerConnectionInterface>)nativePeerConnection { |
586 return _peerConnection; | 560 return _peerConnection; |
587 } | 561 } |
588 | 562 |
589 @end | 563 @end |
OLD | NEW |