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