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 "RTCAudioSource+Private.h" | 14 #import "RTCAudioSource+Private.h" |
15 #import "RTCAudioTrack+Private.h" | 15 #import "RTCAudioTrack+Private.h" |
16 #import "RTCMediaConstraints+Private.h" | 16 #import "RTCMediaConstraints+Private.h" |
17 #import "RTCMediaStream+Private.h" | 17 #import "RTCMediaStream+Private.h" |
18 #import "RTCPeerConnection+Private.h" | 18 #import "RTCPeerConnection+Private.h" |
19 #import "RTCVideoSource+Private.h" | 19 #import "RTCVideoSource+Private.h" |
20 #import "RTCVideoTrack+Private.h" | 20 #import "RTCVideoTrack+Private.h" |
21 #import "RTCAVFoundationVideoSource+Private.h" | 21 #import "RTCAVFoundationVideoSource+Private.h" |
22 #import "WebRTC/RTCLogging.h" | 22 #import "WebRTC/RTCLogging.h" |
23 | 23 |
24 #include "Video/objcvideotracksource.h" | 24 #include "Video/objcvideotracksource.h" |
25 #include "VideoToolbox/videocodecfactory.h" | 25 #include "VideoToolbox/videocodecfactory.h" |
26 #include "webrtc/api/videosourceproxy.h" | 26 #include "webrtc/api/videosourceproxy.h" |
27 // Adding the nogncheck to disable the including header check. | |
28 // The no-media version PeerConnectionFactory doesn't depend on media related C+ + target. | |
tommi
2017/06/28 15:06:45
please run |git cl format|
Zhi Huang
2017/06/28 19:47:10
This is what I got after git cl format. It seems t
| |
29 // TODO(zhihuang): Remove nogncheck once MediaEngineInterface is moved to C++ AP I layer. | |
30 #include "webrtc/media/engine/webrtcmediaengine.h" // nogncheck | |
27 | 31 |
28 @implementation RTCPeerConnectionFactory { | 32 @implementation RTCPeerConnectionFactory { |
29 std::unique_ptr<rtc::Thread> _networkThread; | 33 std::unique_ptr<rtc::Thread> _networkThread; |
30 std::unique_ptr<rtc::Thread> _workerThread; | 34 std::unique_ptr<rtc::Thread> _workerThread; |
31 std::unique_ptr<rtc::Thread> _signalingThread; | 35 std::unique_ptr<rtc::Thread> _signalingThread; |
32 BOOL _hasStartedAecDump; | 36 BOOL _hasStartedAecDump; |
33 } | 37 } |
34 | 38 |
35 @synthesize nativeFactory = _nativeFactory; | 39 @synthesize nativeFactory = _nativeFactory; |
36 | 40 |
37 - (instancetype)init { | 41 - (instancetype)init { |
38 if ((self = [super init])) { | 42 if ((self = [super init])) { |
39 _networkThread = rtc::Thread::CreateWithSocketServer(); | 43 _networkThread = rtc::Thread::CreateWithSocketServer(); |
40 BOOL result = _networkThread->Start(); | 44 BOOL result = _networkThread->Start(); |
41 NSAssert(result, @"Failed to start network thread."); | 45 NSAssert(result, @"Failed to start network thread."); |
42 | 46 |
43 _workerThread = rtc::Thread::Create(); | 47 _workerThread = rtc::Thread::Create(); |
44 result = _workerThread->Start(); | 48 result = _workerThread->Start(); |
45 NSAssert(result, @"Failed to start worker thread."); | 49 NSAssert(result, @"Failed to start worker thread."); |
46 | 50 |
47 _signalingThread = rtc::Thread::Create(); | 51 _signalingThread = rtc::Thread::Create(); |
48 result = _signalingThread->Start(); | 52 result = _signalingThread->Start(); |
49 NSAssert(result, @"Failed to start signaling thread."); | 53 NSAssert(result, @"Failed to start signaling thread."); |
50 | 54 #ifdef HAVE_NO_MEDIA |
55 _nativeFactory = webrtc::CreateModularPeerConnectionFactory( | |
56 _networkThread.get(), | |
57 _workerThread.get(), | |
58 _signalingThread.get(), | |
59 nullptr /*default_adm*/, | |
tommi
2017/06/28 15:06:45
can we use // comment style?
nullptr, // default
Zhi Huang
2017/06/28 19:47:10
Yeah, sure. Done.
| |
60 nullptr /*audio_encoder_factory*/, | |
61 nullptr /*audio_decoder_factory*/, | |
62 nullptr /*video_encoder_factory*/, | |
63 nullptr /*video_decoder_factory*/, | |
64 nullptr /*audio_mixer*/, | |
65 std::unique_ptr<cricket::MediaEngineInterface>(), | |
66 std::unique_ptr<webrtc::CallFactoryInterface>(), | |
67 std::unique_ptr<webrtc::RtcEventLogFactoryInterface>()); | |
68 #else | |
51 const auto encoder_factory = new webrtc::VideoToolboxVideoEncoderFactory(); | 69 const auto encoder_factory = new webrtc::VideoToolboxVideoEncoderFactory(); |
52 const auto decoder_factory = new webrtc::VideoToolboxVideoDecoderFactory(); | 70 const auto decoder_factory = new webrtc::VideoToolboxVideoDecoderFactory(); |
53 | 71 |
54 // Ownership of encoder/decoder factories is passed on to the | 72 // Ownership of encoder/decoder factories is passed on to the |
55 // peerconnectionfactory, that handles deleting them. | 73 // peerconnectionfactory, that handles deleting them. |
56 _nativeFactory = webrtc::CreatePeerConnectionFactory( | 74 _nativeFactory = webrtc::CreatePeerConnectionFactory( |
57 _networkThread.get(), _workerThread.get(), _signalingThread.get(), | 75 _networkThread.get(), _workerThread.get(), _signalingThread.get(), |
58 nullptr, encoder_factory, decoder_factory); | 76 nullptr, encoder_factory, decoder_factory); |
77 #endif | |
59 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); | 78 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); |
60 } | 79 } |
61 return self; | 80 return self; |
62 } | 81 } |
63 | 82 |
64 - (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)c onstraints { | 83 - (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)c onstraints { |
65 std::unique_ptr<webrtc::MediaConstraints> nativeConstraints; | 84 std::unique_ptr<webrtc::MediaConstraints> nativeConstraints; |
66 if (constraints) { | 85 if (constraints) { |
67 nativeConstraints = constraints.nativeConstraints; | 86 nativeConstraints = constraints.nativeConstraints; |
68 } | 87 } |
69 rtc::scoped_refptr<webrtc::AudioSourceInterface> source = | 88 rtc::scoped_refptr<webrtc::AudioSourceInterface> source = |
70 _nativeFactory->CreateAudioSource(nativeConstraints.get()); | 89 _nativeFactory->CreateAudioSource(nativeConstraints.get()); |
71 return [[RTCAudioSource alloc] initWithNativeAudioSource:source]; | 90 return [[RTCAudioSource alloc] initWithNativeAudioSource:source]; |
72 } | 91 } |
73 | 92 |
74 - (RTCAudioTrack *)audioTrackWithTrackId:(NSString *)trackId { | 93 - (RTCAudioTrack *)audioTrackWithTrackId:(NSString *)trackId { |
75 RTCAudioSource *audioSource = [self audioSourceWithConstraints:nil]; | 94 RTCAudioSource *audioSource = [self audioSourceWithConstraints:nil]; |
76 return [self audioTrackWithSource:audioSource trackId:trackId]; | 95 return [self audioTrackWithSource:audioSource trackId:trackId]; |
77 } | 96 } |
78 | 97 |
79 - (RTCAudioTrack *)audioTrackWithSource:(RTCAudioSource *)source | 98 - (RTCAudioTrack *)audioTrackWithSource:(RTCAudioSource *)source |
80 trackId:(NSString *)trackId { | 99 trackId:(NSString *)trackId { |
81 return [[RTCAudioTrack alloc] initWithFactory:self | 100 return [[RTCAudioTrack alloc] initWithFactory:self |
82 source:source | 101 source:source |
83 trackId:trackId]; | 102 trackId:trackId]; |
84 } | 103 } |
85 | 104 |
86 - (RTCAVFoundationVideoSource *)avFoundationVideoSourceWithConstraints: | 105 - (RTCAVFoundationVideoSource *)avFoundationVideoSourceWithConstraints: |
87 (nullable RTCMediaConstraints *)constraints { | 106 (nullable RTCMediaConstraints *)constraints { |
88 return [[RTCAVFoundationVideoSource alloc] initWithFactory:self | 107 #ifdef HAVE_NO_MEDIA |
89 constraints:constraints]; | 108 return nil; |
109 #else | |
110 return [[RTCAVFoundationVideoSource alloc] initWithFactory:self constraints:co nstraints]; | |
111 #endif | |
90 } | 112 } |
91 | 113 |
92 - (RTCVideoSource *)videoSource { | 114 - (RTCVideoSource *)videoSource { |
93 rtc::scoped_refptr<webrtc::ObjcVideoTrackSource> objcVideoTrackSource( | 115 rtc::scoped_refptr<webrtc::ObjcVideoTrackSource> objcVideoTrackSource( |
94 new rtc::RefCountedObject<webrtc::ObjcVideoTrackSource>()); | 116 new rtc::RefCountedObject<webrtc::ObjcVideoTrackSource>()); |
95 return [[RTCVideoSource alloc] | 117 return [[RTCVideoSource alloc] |
96 initWithNativeVideoSource:webrtc::VideoTrackSourceProxy::Create(_signaling Thread.get(), | 118 initWithNativeVideoSource:webrtc::VideoTrackSourceProxy::Create(_signaling Thread.get(), |
97 _workerThr ead.get(), | 119 _workerThr ead.get(), |
98 objcVideoT rackSource)]; | 120 objcVideoT rackSource)]; |
99 } | 121 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 _hasStartedAecDump = _nativeFactory->StartAecDump(fd, maxSizeInBytes); | 161 _hasStartedAecDump = _nativeFactory->StartAecDump(fd, maxSizeInBytes); |
140 return _hasStartedAecDump; | 162 return _hasStartedAecDump; |
141 } | 163 } |
142 | 164 |
143 - (void)stopAecDump { | 165 - (void)stopAecDump { |
144 _nativeFactory->StopAecDump(); | 166 _nativeFactory->StopAecDump(); |
145 _hasStartedAecDump = NO; | 167 _hasStartedAecDump = NO; |
146 } | 168 } |
147 | 169 |
148 @end | 170 @end |
OLD | NEW |