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 12 matching lines...) Expand all Loading... | |
23 std::unique_ptr<rtc::Thread> _workerThread; | 23 std::unique_ptr<rtc::Thread> _workerThread; |
24 std::unique_ptr<rtc::Thread> _signalingThread; | 24 std::unique_ptr<rtc::Thread> _signalingThread; |
25 } | 25 } |
26 | 26 |
27 @synthesize nativeFactory = _nativeFactory; | 27 @synthesize nativeFactory = _nativeFactory; |
28 | 28 |
29 - (instancetype)init { | 29 - (instancetype)init { |
30 if ((self = [super init])) { | 30 if ((self = [super init])) { |
31 _networkThread = rtc::Thread::CreateWithSocketServer(); | 31 _networkThread = rtc::Thread::CreateWithSocketServer(); |
32 BOOL result = _networkThread->Start(); | 32 BOOL result = _networkThread->Start(); |
33 NSAssert(result, @"Failed to start network thread."); | 33 NSAssert(result, @"Failed to start network thread."); |
tkchin_webrtc
2016/08/19 17:31:42
These should probably be updated to return nil if
peah-webrtc
2016/08/23 11:45:15
Acknowledged.
| |
34 | 34 |
35 _workerThread = rtc::Thread::Create(); | 35 _workerThread = rtc::Thread::Create(); |
36 result = _workerThread->Start(); | 36 result = _workerThread->Start(); |
37 NSAssert(result, @"Failed to start worker thread."); | 37 NSAssert(result, @"Failed to start worker thread."); |
38 | 38 |
39 _signalingThread = rtc::Thread::Create(); | 39 _signalingThread = rtc::Thread::Create(); |
40 result = _signalingThread->Start(); | 40 result = _signalingThread->Start(); |
41 NSAssert(result, @"Failed to start signaling thread."); | 41 NSAssert(result, @"Failed to start signaling thread."); |
42 | 42 |
43 _nativeFactory = webrtc::CreatePeerConnectionFactory( | 43 _nativeFactory = webrtc::CreatePeerConnectionFactory( |
44 _networkThread.get(), _workerThread.get(), _signalingThread.get(), | 44 _networkThread.get(), _workerThread.get(), _signalingThread.get(), |
45 nullptr, nullptr, nullptr); | 45 nullptr, nullptr, nullptr); |
46 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); | 46 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); |
47 } | 47 } |
48 return self; | 48 return self; |
49 } | 49 } |
50 | 50 |
51 | |
52 - (BOOL) startAecDump:(NSString *)filename { | |
53 int fd = open(filename.UTF8String, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_I WUSR); | |
54 if (fd < 0) { | |
55 NSAssert(_nativeFactory, @"Failed to create the aecdump file!"); | |
tkchin_webrtc
2016/08/19 17:31:42
Why is there an assert on the factory here? Should
peah-webrtc
2016/08/23 11:45:15
That would definitely make sense. I moved this cod
| |
56 return false; | |
tkchin_webrtc
2016/08/19 17:31:42
BOOL is YES or NO.
return NO;
peah-webrtc
2016/08/23 11:45:15
Done.
| |
57 } | |
58 | |
59 // Pass the file to the recorder. The file ownership | |
60 // is passed to the recorder, and the recorder | |
61 // closes the file when needed. | |
62 return _nativeFactory->StartAecDump(fd, -1); | |
63 } | |
64 | |
65 - (void)stopAecDump { | |
66 // The file is closed by the call below. | |
67 _nativeFactory->StopAecDump(); | |
68 } | |
69 | |
51 - (RTCAVFoundationVideoSource *)avFoundationVideoSourceWithConstraints: | 70 - (RTCAVFoundationVideoSource *)avFoundationVideoSourceWithConstraints: |
52 (nullable RTCMediaConstraints *)constraints { | 71 (nullable RTCMediaConstraints *)constraints { |
53 return [[RTCAVFoundationVideoSource alloc] initWithFactory:self | 72 return [[RTCAVFoundationVideoSource alloc] initWithFactory:self |
54 constraints:constraints]; | 73 constraints:constraints]; |
55 } | 74 } |
56 | 75 |
57 - (RTCAudioTrack *)audioTrackWithTrackId:(NSString *)trackId { | 76 - (RTCAudioTrack *)audioTrackWithTrackId:(NSString *)trackId { |
58 return [[RTCAudioTrack alloc] initWithFactory:self | 77 return [[RTCAudioTrack alloc] initWithFactory:self |
59 trackId:trackId]; | 78 trackId:trackId]; |
60 } | 79 } |
(...skipping 16 matching lines...) Expand all Loading... | |
77 (RTCMediaConstraints *)constraints | 96 (RTCMediaConstraints *)constraints |
78 delegate: | 97 delegate: |
79 (nullable id<RTCPeerConnectionDelegate>)delegate { | 98 (nullable id<RTCPeerConnectionDelegate>)delegate { |
80 return [[RTCPeerConnection alloc] initWithFactory:self | 99 return [[RTCPeerConnection alloc] initWithFactory:self |
81 configuration:configuration | 100 configuration:configuration |
82 constraints:constraints | 101 constraints:constraints |
83 delegate:delegate]; | 102 delegate:delegate]; |
84 } | 103 } |
85 | 104 |
86 @end | 105 @end |
OLD | NEW |