Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2004 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 #include "webrtc/pc/peerconnectionfactory.h" | 11 #include "webrtc/pc/peerconnectionfactory.h" |
| 12 | 12 |
| 13 #include <utility> | 13 #include <utility> |
| 14 | 14 |
| 15 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" | |
| 16 #include "webrtc/api/audio_codecs/builtin_audio_encoder_factory.h" | |
| 17 #include "webrtc/api/mediaconstraintsinterface.h" | 15 #include "webrtc/api/mediaconstraintsinterface.h" |
| 18 #include "webrtc/api/mediastreamproxy.h" | 16 #include "webrtc/api/mediastreamproxy.h" |
| 19 #include "webrtc/api/mediastreamtrackproxy.h" | 17 #include "webrtc/api/mediastreamtrackproxy.h" |
| 20 #include "webrtc/api/peerconnectionfactoryproxy.h" | 18 #include "webrtc/api/peerconnectionfactoryproxy.h" |
| 21 #include "webrtc/api/peerconnectionproxy.h" | 19 #include "webrtc/api/peerconnectionproxy.h" |
| 22 #include "webrtc/api/videosourceproxy.h" | 20 #include "webrtc/api/videosourceproxy.h" |
| 23 #include "webrtc/base/bind.h" | 21 #include "webrtc/base/bind.h" |
| 24 #include "webrtc/base/checks.h" | 22 #include "webrtc/base/checks.h" |
| 25 #include "webrtc/media/engine/webrtcmediaengine.h" | 23 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
| 26 #include "webrtc/media/engine/webrtcvideodecoderfactory.h" | 24 // Adding 'nogncheck' to disable the gn include headers check to support modular |
| 27 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" | 25 // WebRTC build targets. |
| 28 #include "webrtc/modules/audio_device/include/audio_device.h" | 26 #include "webrtc/media/engine/webrtcmediaengine.h" // nogncheck |
| 27 #include "webrtc/media/engine/webrtcvideodecoderfactory.h" // nogncheck | |
| 28 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" // nogncheck | |
| 29 #include "webrtc/modules/audio_device/include/audio_device.h" // nogncheck | |
| 29 #include "webrtc/p2p/base/basicpacketsocketfactory.h" | 30 #include "webrtc/p2p/base/basicpacketsocketfactory.h" |
| 30 #include "webrtc/p2p/client/basicportallocator.h" | 31 #include "webrtc/p2p/client/basicportallocator.h" |
| 31 #include "webrtc/pc/audiotrack.h" | 32 #include "webrtc/pc/audiotrack.h" |
| 32 #include "webrtc/pc/localaudiosource.h" | 33 #include "webrtc/pc/localaudiosource.h" |
| 33 #include "webrtc/pc/mediastream.h" | 34 #include "webrtc/pc/mediastream.h" |
| 34 #include "webrtc/pc/peerconnection.h" | 35 #include "webrtc/pc/peerconnection.h" |
| 35 #include "webrtc/pc/videocapturertracksource.h" | 36 #include "webrtc/pc/videocapturertracksource.h" |
| 36 #include "webrtc/pc/videotrack.h" | 37 #include "webrtc/pc/videotrack.h" |
| 37 | 38 |
| 38 namespace webrtc { | 39 namespace webrtc { |
| 39 | 40 |
| 40 rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( | 41 rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( |
|
the sun
2017/06/12 20:58:41
Does this need to be here? I find it odd that it c
Zhi Huang
2017/06/12 22:18:58
I'll move these impl to createpeerconnectionfacto
| |
| 41 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory, | 42 rtc::Thread* network_thread, |
| 42 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory) { | 43 rtc::Thread* worker_thread, |
| 43 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( | 44 rtc::Thread* signaling_thread, |
| 44 new rtc::RefCountedObject<PeerConnectionFactory>(audio_encoder_factory, | 45 AudioDeviceModule* default_adm, |
| 45 audio_decoder_factory)); | 46 cricket::WebRtcVideoEncoderFactory* encoder_factory, |
| 46 | 47 cricket::WebRtcVideoDecoderFactory* decoder_factory) { |
| 47 RTC_CHECK(rtc::Thread::Current() == pc_factory->signaling_thread()); | 48 return CreatePeerConnectionFactoryWithAudioMixer( |
| 48 // The signaling thread is the current thread so we can | 49 network_thread, worker_thread, signaling_thread, default_adm, |
| 49 // safely call Initialize directly. | 50 encoder_factory, decoder_factory, nullptr); |
| 50 if (!pc_factory->Initialize()) { | |
| 51 return nullptr; | |
| 52 } | |
| 53 return PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(), | |
| 54 pc_factory); | |
| 55 } | |
| 56 | |
| 57 rtc::scoped_refptr<PeerConnectionFactoryInterface> | |
| 58 CreatePeerConnectionFactory() { | |
| 59 return CreatePeerConnectionFactory(CreateBuiltinAudioEncoderFactory(), | |
| 60 CreateBuiltinAudioDecoderFactory()); | |
| 61 } | 51 } |
| 62 | 52 |
| 63 rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( | 53 rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( |
| 64 rtc::Thread* network_thread, | 54 rtc::Thread* network_thread, |
| 65 rtc::Thread* worker_thread, | 55 rtc::Thread* worker_thread, |
| 66 rtc::Thread* signaling_thread, | 56 rtc::Thread* signaling_thread, |
| 67 AudioDeviceModule* default_adm, | 57 AudioDeviceModule* default_adm, |
| 68 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory, | 58 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory, |
| 69 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory, | 59 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory, |
| 70 cricket::WebRtcVideoEncoderFactory* video_encoder_factory, | 60 cricket::WebRtcVideoEncoderFactory* video_encoder_factory, |
| 71 cricket::WebRtcVideoDecoderFactory* video_decoder_factory) { | 61 cricket::WebRtcVideoDecoderFactory* video_decoder_factory) { |
| 72 return CreatePeerConnectionFactoryWithAudioMixer( | 62 return CreatePeerConnectionFactoryWithAudioMixer( |
| 73 network_thread, worker_thread, signaling_thread, default_adm, | 63 network_thread, worker_thread, signaling_thread, default_adm, |
| 74 audio_encoder_factory, audio_decoder_factory, video_encoder_factory, | 64 audio_encoder_factory, audio_decoder_factory, video_encoder_factory, |
| 75 video_decoder_factory, nullptr); | 65 video_decoder_factory, nullptr); |
| 76 } | 66 } |
| 77 | 67 |
| 78 rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory( | 68 rtc::scoped_refptr<PeerConnectionFactoryInterface> |
| 69 CreateModularPeerConnectionFactory( | |
| 70 rtc::Thread* worker_thread, | |
| 71 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory, | |
| 72 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory, | |
| 73 std::unique_ptr<cricket::MediaEngineInterface> media_engine, | |
| 74 std::unique_ptr<CallFactoryInterface> call_factory, | |
| 75 std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory) { | |
| 76 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( | |
| 77 new rtc::RefCountedObject<PeerConnectionFactory>( | |
| 78 worker_thread, audio_encoder_factory, audio_decoder_factory, | |
| 79 std::move(media_engine), std::move(call_factory), | |
| 80 std::move(event_log_factory))); | |
| 81 | |
| 82 RTC_CHECK(rtc::Thread::Current() == pc_factory->signaling_thread()); | |
| 83 // The signaling thread is the current thread so we can | |
| 84 // safely call Initialize directly. | |
| 85 if (!pc_factory->Initialize()) { | |
| 86 return nullptr; | |
| 87 } | |
| 88 return PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(), | |
| 89 pc_factory); | |
| 90 } | |
| 91 | |
| 92 rtc::scoped_refptr<PeerConnectionFactoryInterface> | |
| 93 CreateModularPeerConnectionFactory( | |
| 79 rtc::Thread* network_thread, | 94 rtc::Thread* network_thread, |
| 80 rtc::Thread* worker_thread, | 95 rtc::Thread* worker_thread, |
| 81 rtc::Thread* signaling_thread, | 96 rtc::Thread* signaling_thread, |
| 82 AudioDeviceModule* default_adm, | |
| 83 cricket::WebRtcVideoEncoderFactory* encoder_factory, | |
| 84 cricket::WebRtcVideoDecoderFactory* decoder_factory) { | |
| 85 return CreatePeerConnectionFactoryWithAudioMixer( | |
| 86 network_thread, worker_thread, signaling_thread, default_adm, | |
| 87 encoder_factory, decoder_factory, nullptr); | |
| 88 } | |
| 89 | |
| 90 rtc::scoped_refptr<PeerConnectionFactoryInterface> | |
| 91 CreatePeerConnectionFactoryWithAudioMixer( | |
| 92 rtc::Thread* network_thread, | |
| 93 rtc::Thread* worker_thread, | |
| 94 rtc::Thread* signaling_thread, | |
| 95 AudioDeviceModule* default_adm, | 97 AudioDeviceModule* default_adm, |
| 96 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory, | 98 rtc::scoped_refptr<AudioEncoderFactory> audio_encoder_factory, |
| 97 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory, | 99 rtc::scoped_refptr<AudioDecoderFactory> audio_decoder_factory, |
| 98 cricket::WebRtcVideoEncoderFactory* video_encoder_factory, | 100 cricket::WebRtcVideoEncoderFactory* video_encoder_factory, |
| 99 cricket::WebRtcVideoDecoderFactory* video_decoder_factory, | 101 cricket::WebRtcVideoDecoderFactory* video_decoder_factory, |
| 100 rtc::scoped_refptr<AudioMixer> audio_mixer) { | 102 rtc::scoped_refptr<AudioMixer> audio_mixer, |
| 103 std::unique_ptr<cricket::MediaEngineInterface> media_engine, | |
| 104 std::unique_ptr<CallFactoryInterface> call_factory, | |
| 105 std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory) { | |
| 101 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( | 106 rtc::scoped_refptr<PeerConnectionFactory> pc_factory( |
| 102 new rtc::RefCountedObject<PeerConnectionFactory>( | 107 new rtc::RefCountedObject<PeerConnectionFactory>( |
| 103 network_thread, worker_thread, signaling_thread, default_adm, | 108 network_thread, worker_thread, signaling_thread, default_adm, |
| 104 audio_encoder_factory, audio_decoder_factory, video_encoder_factory, | 109 audio_encoder_factory, audio_decoder_factory, video_encoder_factory, |
| 105 video_decoder_factory, audio_mixer)); | 110 video_decoder_factory, audio_mixer, std::move(media_engine), |
| 111 std::move(call_factory), std::move(event_log_factory))); | |
| 106 | 112 |
| 107 // Call Initialize synchronously but make sure it is executed on | 113 // Call Initialize synchronously but make sure it is executed on |
| 108 // |signaling_thread|. | 114 // |signaling_thread|. |
| 109 MethodCall0<PeerConnectionFactory, bool> call( | 115 MethodCall0<PeerConnectionFactory, bool> call( |
| 110 pc_factory.get(), &PeerConnectionFactory::Initialize); | 116 pc_factory.get(), &PeerConnectionFactory::Initialize); |
| 111 bool result = call.Marshal(RTC_FROM_HERE, signaling_thread); | 117 bool result = call.Marshal(RTC_FROM_HERE, signaling_thread); |
| 112 | 118 |
| 113 if (!result) { | 119 if (!result) { |
| 114 return nullptr; | 120 return nullptr; |
| 115 } | 121 } |
| 116 return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory); | 122 return PeerConnectionFactoryProxy::Create(signaling_thread, pc_factory); |
| 117 } | 123 } |
| 118 | 124 |
| 119 rtc::scoped_refptr<PeerConnectionFactoryInterface> | |
| 120 CreatePeerConnectionFactoryWithAudioMixer( | |
| 121 rtc::Thread* network_thread, | |
| 122 rtc::Thread* worker_thread, | |
| 123 rtc::Thread* signaling_thread, | |
| 124 AudioDeviceModule* default_adm, | |
| 125 cricket::WebRtcVideoEncoderFactory* encoder_factory, | |
| 126 cricket::WebRtcVideoDecoderFactory* decoder_factory, | |
| 127 rtc::scoped_refptr<AudioMixer> audio_mixer) { | |
| 128 return CreatePeerConnectionFactoryWithAudioMixer( | |
| 129 network_thread, worker_thread, signaling_thread, default_adm, | |
| 130 CreateBuiltinAudioEncoderFactory(), CreateBuiltinAudioDecoderFactory(), | |
| 131 encoder_factory, decoder_factory, audio_mixer); | |
| 132 } | |
| 133 | |
| 134 PeerConnectionFactory::PeerConnectionFactory( | 125 PeerConnectionFactory::PeerConnectionFactory( |
| 135 rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory, | 126 rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory, |
| 136 rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory) | 127 rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory) |
| 128 : PeerConnectionFactory(rtc::Thread::Create().release(), | |
| 129 audio_encoder_factory, | |
| 130 audio_decoder_factory, | |
| 131 std::unique_ptr<cricket::MediaEngineInterface>(), | |
| 132 std::unique_ptr<webrtc::CallFactoryInterface>(), | |
| 133 std::unique_ptr<RtcEventLogFactoryInterface>()) { | |
| 134 worker_thread_->Start(); | |
| 135 } | |
| 136 | |
| 137 PeerConnectionFactory::PeerConnectionFactory( | |
| 138 rtc::Thread* worker_thread, | |
| 139 rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory, | |
| 140 rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory, | |
| 141 std::unique_ptr<cricket::MediaEngineInterface> media_engine, | |
| 142 std::unique_ptr<webrtc::CallFactoryInterface> call_factory, | |
| 143 std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory) | |
| 137 : owns_ptrs_(true), | 144 : owns_ptrs_(true), |
| 138 wraps_current_thread_(false), | 145 wraps_current_thread_(false), |
| 139 network_thread_(rtc::Thread::CreateWithSocketServer().release()), | 146 network_thread_(rtc::Thread::CreateWithSocketServer().release()), |
| 140 worker_thread_(rtc::Thread::Create().release()), | 147 worker_thread_(worker_thread), |
| 141 signaling_thread_(rtc::Thread::Current()), | 148 signaling_thread_(rtc::Thread::Current()), |
| 142 audio_encoder_factory_(audio_encoder_factory), | 149 audio_encoder_factory_(audio_encoder_factory), |
| 143 audio_decoder_factory_(audio_decoder_factory) { | 150 audio_decoder_factory_(audio_decoder_factory), |
| 151 media_engine_(std::move(media_engine)), | |
| 152 call_factory_(std::move(call_factory)), | |
| 153 event_log_factory_(std::move(event_log_factory)) { | |
| 144 if (!signaling_thread_) { | 154 if (!signaling_thread_) { |
| 145 signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread(); | 155 signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread(); |
| 146 wraps_current_thread_ = true; | 156 wraps_current_thread_ = true; |
| 147 } | 157 } |
| 148 network_thread_->Start(); | 158 network_thread_->Start(); |
| 149 worker_thread_->Start(); | |
| 150 } | 159 } |
| 151 | 160 |
| 152 PeerConnectionFactory::PeerConnectionFactory( | 161 PeerConnectionFactory::PeerConnectionFactory( |
| 153 rtc::Thread* network_thread, | 162 rtc::Thread* network_thread, |
| 154 rtc::Thread* worker_thread, | 163 rtc::Thread* worker_thread, |
| 155 rtc::Thread* signaling_thread, | 164 rtc::Thread* signaling_thread, |
| 156 AudioDeviceModule* default_adm, | 165 AudioDeviceModule* default_adm, |
| 157 rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory, | 166 rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory, |
| 158 rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory, | 167 rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory, |
| 159 cricket::WebRtcVideoEncoderFactory* video_encoder_factory, | 168 cricket::WebRtcVideoEncoderFactory* video_encoder_factory, |
| 160 cricket::WebRtcVideoDecoderFactory* video_decoder_factory, | 169 cricket::WebRtcVideoDecoderFactory* video_decoder_factory, |
| 161 rtc::scoped_refptr<AudioMixer> audio_mixer) | 170 rtc::scoped_refptr<AudioMixer> audio_mixer) |
| 171 : PeerConnectionFactory(network_thread, | |
| 172 worker_thread, | |
| 173 signaling_thread, | |
| 174 default_adm, | |
| 175 audio_encoder_factory, | |
| 176 audio_decoder_factory, | |
| 177 video_encoder_factory, | |
| 178 video_decoder_factory, | |
| 179 audio_mixer, | |
| 180 std::unique_ptr<cricket::MediaEngineInterface>(), | |
| 181 std::unique_ptr<webrtc::CallFactoryInterface>(), | |
| 182 std::unique_ptr<RtcEventLogFactoryInterface>()) {} | |
| 183 | |
| 184 PeerConnectionFactory::PeerConnectionFactory( | |
| 185 rtc::Thread* network_thread, | |
| 186 rtc::Thread* worker_thread, | |
| 187 rtc::Thread* signaling_thread, | |
| 188 AudioDeviceModule* default_adm, | |
| 189 rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory, | |
| 190 rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory, | |
| 191 cricket::WebRtcVideoEncoderFactory* video_encoder_factory, | |
| 192 cricket::WebRtcVideoDecoderFactory* video_decoder_factory, | |
| 193 rtc::scoped_refptr<AudioMixer> audio_mixer, | |
| 194 std::unique_ptr<cricket::MediaEngineInterface> media_engine, | |
| 195 std::unique_ptr<webrtc::CallFactoryInterface> call_factory, | |
| 196 std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory) | |
| 162 : owns_ptrs_(false), | 197 : owns_ptrs_(false), |
| 163 wraps_current_thread_(false), | 198 wraps_current_thread_(false), |
| 164 network_thread_(network_thread), | 199 network_thread_(network_thread), |
| 165 worker_thread_(worker_thread), | 200 worker_thread_(worker_thread), |
| 166 signaling_thread_(signaling_thread), | 201 signaling_thread_(signaling_thread), |
| 167 default_adm_(default_adm), | 202 default_adm_(default_adm), |
| 168 audio_encoder_factory_(audio_encoder_factory), | 203 audio_encoder_factory_(audio_encoder_factory), |
| 169 audio_decoder_factory_(audio_decoder_factory), | 204 audio_decoder_factory_(audio_decoder_factory), |
| 170 video_encoder_factory_(video_encoder_factory), | 205 video_encoder_factory_(video_encoder_factory), |
| 171 video_decoder_factory_(video_decoder_factory), | 206 video_decoder_factory_(video_decoder_factory), |
| 172 external_audio_mixer_(audio_mixer) { | 207 external_audio_mixer_(audio_mixer), |
| 208 media_engine_(std::move(media_engine)), | |
| 209 call_factory_(std::move(call_factory)), | |
| 210 event_log_factory_(std::move(event_log_factory)) { | |
| 173 RTC_DCHECK(network_thread); | 211 RTC_DCHECK(network_thread); |
| 174 RTC_DCHECK(worker_thread); | 212 RTC_DCHECK(worker_thread); |
| 175 RTC_DCHECK(signaling_thread); | 213 RTC_DCHECK(signaling_thread); |
| 176 // TODO: Currently there is no way creating an external adm in | 214 // TODO: Currently there is no way creating an external adm in |
| 177 // libjingle source tree. So we can 't currently assert if this is NULL. | 215 // libjingle source tree. So we can 't currently assert if this is NULL. |
| 178 // RTC_DCHECK(default_adm != NULL); | 216 // RTC_DCHECK(default_adm != NULL); |
| 179 } | 217 } |
| 180 | 218 |
| 181 PeerConnectionFactory::~PeerConnectionFactory() { | 219 PeerConnectionFactory::~PeerConnectionFactory() { |
| 182 RTC_DCHECK(signaling_thread_->IsCurrent()); | 220 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 203 if (!default_network_manager_) { | 241 if (!default_network_manager_) { |
| 204 return false; | 242 return false; |
| 205 } | 243 } |
| 206 | 244 |
| 207 default_socket_factory_.reset( | 245 default_socket_factory_.reset( |
| 208 new rtc::BasicPacketSocketFactory(network_thread_)); | 246 new rtc::BasicPacketSocketFactory(network_thread_)); |
| 209 if (!default_socket_factory_) { | 247 if (!default_socket_factory_) { |
| 210 return false; | 248 return false; |
| 211 } | 249 } |
| 212 | 250 |
| 213 std::unique_ptr<cricket::MediaEngineInterface> media_engine = | |
| 214 worker_thread_->Invoke<std::unique_ptr<cricket::MediaEngineInterface>>( | |
| 215 RTC_FROM_HERE, | |
| 216 rtc::Bind(&PeerConnectionFactory::CreateMediaEngine_w, this)); | |
| 217 | |
| 218 channel_manager_.reset(new cricket::ChannelManager( | 251 channel_manager_.reset(new cricket::ChannelManager( |
| 219 std::move(media_engine), worker_thread_, network_thread_)); | 252 std::move(media_engine_), worker_thread_, network_thread_)); |
| 220 | 253 |
| 221 channel_manager_->SetVideoRtxEnabled(true); | 254 channel_manager_->SetVideoRtxEnabled(true); |
| 222 if (!channel_manager_->Init()) { | 255 if (!channel_manager_->Init()) { |
| 223 return false; | 256 return false; |
| 224 } | 257 } |
| 225 | 258 |
| 226 return true; | 259 return true; |
| 227 } | 260 } |
| 228 | 261 |
| 229 void PeerConnectionFactory::SetOptions(const Options& options) { | 262 void PeerConnectionFactory::SetOptions(const Options& options) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 } | 346 } |
| 314 | 347 |
| 315 if (!allocator) { | 348 if (!allocator) { |
| 316 allocator.reset(new cricket::BasicPortAllocator( | 349 allocator.reset(new cricket::BasicPortAllocator( |
| 317 default_network_manager_.get(), default_socket_factory_.get())); | 350 default_network_manager_.get(), default_socket_factory_.get())); |
| 318 } | 351 } |
| 319 network_thread_->Invoke<void>( | 352 network_thread_->Invoke<void>( |
| 320 RTC_FROM_HERE, rtc::Bind(&cricket::PortAllocator::SetNetworkIgnoreMask, | 353 RTC_FROM_HERE, rtc::Bind(&cricket::PortAllocator::SetNetworkIgnoreMask, |
| 321 allocator.get(), options_.network_ignore_mask)); | 354 allocator.get(), options_.network_ignore_mask)); |
| 322 | 355 |
| 356 std::unique_ptr<RtcEventLog> event_log(new RtcEventLogNullImpl()); | |
|
the sun
2017/06/12 20:58:41
Could you send in the event log directly instead o
Zhi Huang
2017/06/12 22:18:58
I think the peerconnectionfactory need a RtcEventL
| |
| 357 if (event_log_factory_) { | |
| 358 event_log = event_log_factory_->CreateRtcEventLog(); | |
| 359 } | |
| 360 | |
| 361 Call* call = worker_thread_->Invoke<Call*>( | |
| 362 RTC_FROM_HERE, | |
| 363 rtc::Bind(&PeerConnectionFactory::CreateCall_w, this, event_log.get())); | |
| 364 | |
| 323 rtc::scoped_refptr<PeerConnection> pc( | 365 rtc::scoped_refptr<PeerConnection> pc( |
| 324 new rtc::RefCountedObject<PeerConnection>(this)); | 366 new rtc::RefCountedObject<PeerConnection>(this, std::move(event_log), |
| 367 call)); | |
| 325 | 368 |
| 326 if (!pc->Initialize(configuration, std::move(allocator), | 369 if (!pc->Initialize(configuration, std::move(allocator), |
| 327 std::move(cert_generator), observer)) { | 370 std::move(cert_generator), observer)) { |
| 328 return nullptr; | 371 return nullptr; |
| 329 } | 372 } |
| 330 return PeerConnectionProxy::Create(signaling_thread(), pc); | 373 return PeerConnectionProxy::Create(signaling_thread(), pc); |
| 331 } | 374 } |
| 332 | 375 |
| 333 rtc::scoped_refptr<MediaStreamInterface> | 376 rtc::scoped_refptr<MediaStreamInterface> |
| 334 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { | 377 PeerConnectionFactory::CreateLocalMediaStream(const std::string& label) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 | 418 |
| 376 rtc::Thread* PeerConnectionFactory::worker_thread() { | 419 rtc::Thread* PeerConnectionFactory::worker_thread() { |
| 377 RTC_DCHECK(signaling_thread_->IsCurrent()); | 420 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 378 return worker_thread_; | 421 return worker_thread_; |
| 379 } | 422 } |
| 380 | 423 |
| 381 rtc::Thread* PeerConnectionFactory::network_thread() { | 424 rtc::Thread* PeerConnectionFactory::network_thread() { |
| 382 return network_thread_; | 425 return network_thread_; |
| 383 } | 426 } |
| 384 | 427 |
| 385 std::unique_ptr<cricket::MediaEngineInterface> | 428 Call* PeerConnectionFactory::CreateCall_w(RtcEventLog* event_log) { |
| 386 PeerConnectionFactory::CreateMediaEngine_w() { | 429 const int kMinBandwidthBps = 30000; |
| 387 RTC_DCHECK(worker_thread_ == rtc::Thread::Current()); | 430 const int kStartBandwidthBps = 300000; |
| 388 return std::unique_ptr<cricket::MediaEngineInterface>( | 431 const int kMaxBandwidthBps = 2000000; |
| 389 cricket::WebRtcMediaEngineFactory::Create( | 432 |
| 390 default_adm_.get(), audio_encoder_factory_, | 433 webrtc::Call::Config call_config(event_log); |
| 391 audio_decoder_factory_, | 434 if (!channel_manager_->media_engine() || !call_factory_) { |
| 392 video_encoder_factory_.get(), video_decoder_factory_.get(), | 435 return nullptr; |
| 393 external_audio_mixer_)); | 436 } |
| 437 call_config.audio_state = channel_manager_->media_engine()->GetAudioState(); | |
| 438 call_config.bitrate_config.min_bitrate_bps = kMinBandwidthBps; | |
| 439 call_config.bitrate_config.start_bitrate_bps = kStartBandwidthBps; | |
| 440 call_config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps; | |
| 441 | |
| 442 return call_factory_->CreateCall(call_config); | |
| 394 } | 443 } |
| 395 | 444 |
| 396 } // namespace webrtc | 445 } // namespace webrtc |
| OLD | NEW |