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 |
11 #import "RTCPeerConnectionFactory.h" | 11 #import "RTCPeerConnectionFactory.h" |
12 | 12 |
| 13 #if defined(WEBRTC_IOS) |
| 14 #import "webrtc/api/objc/RTCAVFoundationVideoSource+Private.h" |
| 15 #endif |
| 16 #import "webrtc/api/objc/RTCAudioTrack+Private.h" |
| 17 #import "webrtc/api/objc/RTCMediaStream+Private.h" |
| 18 #import "webrtc/api/objc/RTCPeerConnection+Private.h" |
13 #import "webrtc/api/objc/RTCPeerConnectionFactory+Private.h" | 19 #import "webrtc/api/objc/RTCPeerConnectionFactory+Private.h" |
| 20 #import "webrtc/api/objc/RTCVideoSource+Private.h" |
| 21 #import "webrtc/api/objc/RTCVideoTrack+Private.h" |
| 22 #import "webrtc/base/objc/NSString+StdString.h" |
14 | 23 |
15 @implementation RTCPeerConnectionFactory { | 24 @implementation RTCPeerConnectionFactory { |
16 rtc::scoped_ptr<rtc::Thread> _signalingThread; | 25 rtc::scoped_ptr<rtc::Thread> _signalingThread; |
17 rtc::scoped_ptr<rtc::Thread> _workerThread; | 26 rtc::scoped_ptr<rtc::Thread> _workerThread; |
18 } | 27 } |
19 | 28 |
20 @synthesize nativeFactory = _nativeFactory; | 29 @synthesize nativeFactory = _nativeFactory; |
21 | 30 |
22 - (instancetype)init { | 31 - (instancetype)init { |
23 if ((self = [super init])) { | 32 if ((self = [super init])) { |
24 _signalingThread.reset(new rtc::Thread()); | 33 _signalingThread.reset(new rtc::Thread()); |
25 BOOL result = _signalingThread->Start(); | 34 BOOL result = _signalingThread->Start(); |
26 NSAssert(result, @"Failed to start signaling thread."); | 35 NSAssert(result, @"Failed to start signaling thread."); |
27 _workerThread.reset(new rtc::Thread()); | 36 _workerThread.reset(new rtc::Thread()); |
28 result = _workerThread->Start(); | 37 result = _workerThread->Start(); |
29 NSAssert(result, @"Failed to start worker thread."); | 38 NSAssert(result, @"Failed to start worker thread."); |
30 | 39 |
31 _nativeFactory = webrtc::CreatePeerConnectionFactory( | 40 _nativeFactory = webrtc::CreatePeerConnectionFactory( |
32 _workerThread.get(), _signalingThread.get(), nullptr, nullptr, nullptr); | 41 _workerThread.get(), _signalingThread.get(), nullptr, nullptr, nullptr); |
33 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); | 42 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); |
34 } | 43 } |
35 return self; | 44 return self; |
36 } | 45 } |
37 | 46 |
| 47 #if defined(WEBRTC_IOS) |
| 48 - (RTCAVFoundationVideoSource *)avFoundationVideoSourceWithConstraints: |
| 49 (nullable RTCMediaConstraints *)constraints { |
| 50 return [[RTCAVFoundationVideoSource alloc] initWithFactory:self |
| 51 constraints:constraints]; |
| 52 } |
| 53 #endif |
| 54 |
| 55 - (RTCAudioTrack *)audioTrackWithTrackId:(NSString *)trackId { |
| 56 return [[RTCAudioTrack alloc] initWithFactory:self |
| 57 trackId:trackId]; |
| 58 } |
| 59 |
| 60 - (RTCVideoTrack *)videoTrackWithSource:(RTCVideoSource *)source |
| 61 trackId:(NSString *)trackId { |
| 62 return [[RTCVideoTrack alloc] initWithFactory:self |
| 63 source:source |
| 64 trackId:trackId]; |
| 65 } |
| 66 |
| 67 - (RTCMediaStream *)mediaStreamWithStreamId:(NSString *)streamId { |
| 68 return [[RTCMediaStream alloc] initWithFactory:self |
| 69 streamId:streamId]; |
| 70 } |
| 71 |
| 72 - (RTCPeerConnection *)peerConnectionWithConfiguration: |
| 73 (RTCConfiguration *)configuration |
| 74 constraints: |
| 75 (RTCMediaConstraints *)constraints |
| 76 delegate: |
| 77 (nullable id<RTCPeerConnectionDelegate>)delegate { |
| 78 return [[RTCPeerConnection alloc] initWithFactory:self |
| 79 configuration:configuration |
| 80 constraints:constraints |
| 81 delegate:delegate]; |
| 82 } |
| 83 |
38 @end | 84 @end |
OLD | NEW |