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; |
210 } | 211 } |
211 | 212 |
212 @synthesize delegate = _delegate; | 213 @synthesize delegate = _delegate; |
213 | 214 |
214 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory | 215 - (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory |
215 configuration:(RTCConfiguration *)configuration | 216 configuration:(RTCConfiguration *)configuration |
216 constraints:(RTCMediaConstraints *)constraints | 217 constraints:(RTCMediaConstraints *)constraints |
217 delegate:(id<RTCPeerConnectionDelegate>)delegate { | 218 delegate:(id<RTCPeerConnectionDelegate>)delegate { |
218 NSParameterAssert(factory); | 219 NSParameterAssert(factory); |
219 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> config( | 220 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> config( |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 } | 350 } |
350 | 351 |
351 - (void)setRemoteDescription:(RTCSessionDescription *)sdp | 352 - (void)setRemoteDescription:(RTCSessionDescription *)sdp |
352 completionHandler:(void (^)(NSError *error))completionHandler { | 353 completionHandler:(void (^)(NSError *error))completionHandler { |
353 rtc::scoped_refptr<webrtc::SetSessionDescriptionObserverAdapter> observer( | 354 rtc::scoped_refptr<webrtc::SetSessionDescriptionObserverAdapter> observer( |
354 new rtc::RefCountedObject<webrtc::SetSessionDescriptionObserverAdapter>( | 355 new rtc::RefCountedObject<webrtc::SetSessionDescriptionObserverAdapter>( |
355 completionHandler)); | 356 completionHandler)); |
356 _peerConnection->SetRemoteDescription(observer, sdp.nativeDescription); | 357 _peerConnection->SetRemoteDescription(observer, sdp.nativeDescription); |
357 } | 358 } |
358 | 359 |
| 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 |
359 - (RTCRtpSender *)senderWithKind:(NSString *)kind | 385 - (RTCRtpSender *)senderWithKind:(NSString *)kind |
360 streamId:(NSString *)streamId { | 386 streamId:(NSString *)streamId { |
361 std::string nativeKind = [NSString stdStringForString:kind]; | 387 std::string nativeKind = [NSString stdStringForString:kind]; |
362 std::string nativeStreamId = [NSString stdStringForString:streamId]; | 388 std::string nativeStreamId = [NSString stdStringForString:streamId]; |
363 rtc::scoped_refptr<webrtc::RtpSenderInterface> nativeSender( | 389 rtc::scoped_refptr<webrtc::RtpSenderInterface> nativeSender( |
364 _peerConnection->CreateSender(nativeKind, nativeStreamId)); | 390 _peerConnection->CreateSender(nativeKind, nativeStreamId)); |
365 return nativeSender ? | 391 return nativeSender ? |
366 [[RTCRtpSender alloc] initWithNativeRtpSender:nativeSender] | 392 [[RTCRtpSender alloc] initWithNativeRtpSender:nativeSender] |
367 : nil; | 393 : nil; |
368 } | 394 } |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 case RTCStatsOutputLevelDebug: | 580 case RTCStatsOutputLevelDebug: |
555 return webrtc::PeerConnectionInterface::kStatsOutputLevelDebug; | 581 return webrtc::PeerConnectionInterface::kStatsOutputLevelDebug; |
556 } | 582 } |
557 } | 583 } |
558 | 584 |
559 - (rtc::scoped_refptr<webrtc::PeerConnectionInterface>)nativePeerConnection { | 585 - (rtc::scoped_refptr<webrtc::PeerConnectionInterface>)nativePeerConnection { |
560 return _peerConnection; | 586 return _peerConnection; |
561 } | 587 } |
562 | 588 |
563 @end | 589 @end |
OLD | NEW |