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+Private.h" | 11 #import "RTCPeerConnectionFactory+Private.h" |
12 | 12 |
13 #import "NSString+StdString.h" | 13 #import "NSString+StdString.h" |
14 #import "RTCAVFoundationVideoSource+Private.h" | 14 #import "RTCAVFoundationVideoSource+Private.h" |
15 #import "RTCAudioSource+Private.h" | 15 #import "RTCAudioSource+Private.h" |
16 #import "RTCAudioTrack+Private.h" | 16 #import "RTCAudioTrack+Private.h" |
17 #import "RTCMediaConstraints+Private.h" | 17 #import "RTCMediaConstraints+Private.h" |
18 #import "RTCMediaStream+Private.h" | 18 #import "RTCMediaStream+Private.h" |
19 #import "RTCPeerConnection+Private.h" | 19 #import "RTCPeerConnection+Private.h" |
20 #import "RTCVideoSource+Private.h" | 20 #import "RTCVideoSource+Private.h" |
21 #import "RTCVideoTrack+Private.h" | 21 #import "RTCVideoTrack+Private.h" |
22 #import "WebRTC/RTCLogging.h" | 22 #import "WebRTC/RTCLogging.h" |
23 | 23 |
24 #include "videotoolboxvideocodecfactory.h" | |
25 | |
26 @implementation RTCPeerConnectionFactory { | 24 @implementation RTCPeerConnectionFactory { |
27 std::unique_ptr<rtc::Thread> _networkThread; | 25 std::unique_ptr<rtc::Thread> _networkThread; |
28 std::unique_ptr<rtc::Thread> _workerThread; | 26 std::unique_ptr<rtc::Thread> _workerThread; |
29 std::unique_ptr<rtc::Thread> _signalingThread; | 27 std::unique_ptr<rtc::Thread> _signalingThread; |
30 BOOL _hasStartedAecDump; | 28 BOOL _hasStartedAecDump; |
31 } | 29 } |
32 | 30 |
33 @synthesize nativeFactory = _nativeFactory; | 31 @synthesize nativeFactory = _nativeFactory; |
34 | 32 |
35 - (instancetype)init { | 33 - (instancetype)init { |
36 if ((self = [super init])) { | 34 if ((self = [super init])) { |
37 _networkThread = rtc::Thread::CreateWithSocketServer(); | 35 _networkThread = rtc::Thread::CreateWithSocketServer(); |
38 BOOL result = _networkThread->Start(); | 36 BOOL result = _networkThread->Start(); |
39 NSAssert(result, @"Failed to start network thread."); | 37 NSAssert(result, @"Failed to start network thread."); |
40 | 38 |
41 _workerThread = rtc::Thread::Create(); | 39 _workerThread = rtc::Thread::Create(); |
42 result = _workerThread->Start(); | 40 result = _workerThread->Start(); |
43 NSAssert(result, @"Failed to start worker thread."); | 41 NSAssert(result, @"Failed to start worker thread."); |
44 | 42 |
45 _signalingThread = rtc::Thread::Create(); | 43 _signalingThread = rtc::Thread::Create(); |
46 result = _signalingThread->Start(); | 44 result = _signalingThread->Start(); |
47 NSAssert(result, @"Failed to start signaling thread."); | 45 NSAssert(result, @"Failed to start signaling thread."); |
48 | 46 |
49 const auto encoder_factory = new webrtc::VideoToolboxVideoEncoderFactory(); | |
50 const auto decoder_factory = new webrtc::VideoToolboxVideoDecoderFactory(); | |
51 | |
52 // Ownership of encoder/decoder factories is passed on to the | |
53 // peerconnectionfactory, that handles deleting them. | |
54 _nativeFactory = webrtc::CreatePeerConnectionFactory( | 47 _nativeFactory = webrtc::CreatePeerConnectionFactory( |
55 _networkThread.get(), _workerThread.get(), _signalingThread.get(), | 48 _networkThread.get(), _workerThread.get(), _signalingThread.get(), |
56 nullptr, encoder_factory, decoder_factory); | 49 nullptr, nullptr, nullptr); |
57 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); | 50 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); |
58 } | 51 } |
59 return self; | 52 return self; |
60 } | 53 } |
61 | 54 |
62 - (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)c
onstraints { | 55 - (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)c
onstraints { |
63 std::unique_ptr<webrtc::MediaConstraints> nativeConstraints; | 56 std::unique_ptr<webrtc::MediaConstraints> nativeConstraints; |
64 if (constraints) { | 57 if (constraints) { |
65 nativeConstraints = constraints.nativeConstraints; | 58 nativeConstraints = constraints.nativeConstraints; |
66 } | 59 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 _hasStartedAecDump = _nativeFactory->StartAecDump(fd, maxSizeInBytes); | 121 _hasStartedAecDump = _nativeFactory->StartAecDump(fd, maxSizeInBytes); |
129 return _hasStartedAecDump; | 122 return _hasStartedAecDump; |
130 } | 123 } |
131 | 124 |
132 - (void)stopAecDump { | 125 - (void)stopAecDump { |
133 _nativeFactory->StopAecDump(); | 126 _nativeFactory->StopAecDump(); |
134 _hasStartedAecDump = NO; | 127 _hasStartedAecDump = NO; |
135 } | 128 } |
136 | 129 |
137 @end | 130 @end |
OLD | NEW |