Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Unified Diff: webrtc/api/peerconnectionfactory.cc

Issue 1888903003: Network thread (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/api/peerconnectionfactory.h ('k') | webrtc/api/peerconnectionfactory_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/peerconnectionfactory.cc
diff --git a/webrtc/api/peerconnectionfactory.cc b/webrtc/api/peerconnectionfactory.cc
index ff8098cd57a277235a9cd72e01823503c740efda..f737df641b1fcfdd64c67e3bf4e9de8bf167a943 100644
--- a/webrtc/api/peerconnectionfactory.cc
+++ b/webrtc/api/peerconnectionfactory.cc
@@ -74,19 +74,17 @@ CreatePeerConnectionFactory() {
pc_factory);
}
-rtc::scoped_refptr<PeerConnectionFactoryInterface>
-CreatePeerConnectionFactory(
+rtc::scoped_refptr<PeerConnectionFactoryInterface> CreatePeerConnectionFactory(
+ rtc::Thread* network_thread,
rtc::Thread* worker_thread,
rtc::Thread* signaling_thread,
AudioDeviceModule* default_adm,
cricket::WebRtcVideoEncoderFactory* encoder_factory,
cricket::WebRtcVideoDecoderFactory* decoder_factory) {
rtc::scoped_refptr<PeerConnectionFactory> pc_factory(
- new rtc::RefCountedObject<PeerConnectionFactory>(worker_thread,
- signaling_thread,
- default_adm,
- encoder_factory,
- decoder_factory));
+ new rtc::RefCountedObject<PeerConnectionFactory>(
+ network_thread, worker_thread, signaling_thread, default_adm,
+ encoder_factory, decoder_factory));
// Call Initialize synchronously but make sure its executed on
// |signaling_thread|.
@@ -104,16 +102,19 @@ CreatePeerConnectionFactory(
PeerConnectionFactory::PeerConnectionFactory()
: owns_ptrs_(true),
wraps_current_thread_(false),
- signaling_thread_(rtc::ThreadManager::Instance()->CurrentThread()),
- worker_thread_(new rtc::Thread) {
+ signaling_thread_(rtc::Thread::Current()),
+ network_thread_(rtc::Thread::CreateWithSocketServer().release()),
+ worker_thread_(rtc::Thread::Create().release()) {
if (!signaling_thread_) {
signaling_thread_ = rtc::ThreadManager::Instance()->WrapCurrentThread();
wraps_current_thread_ = true;
}
+ network_thread_->Start();
worker_thread_->Start();
}
PeerConnectionFactory::PeerConnectionFactory(
+ rtc::Thread* network_thread,
rtc::Thread* worker_thread,
rtc::Thread* signaling_thread,
AudioDeviceModule* default_adm,
@@ -122,12 +123,14 @@ PeerConnectionFactory::PeerConnectionFactory(
: owns_ptrs_(false),
wraps_current_thread_(false),
signaling_thread_(signaling_thread),
+ network_thread_(network_thread),
worker_thread_(worker_thread),
default_adm_(default_adm),
video_encoder_factory_(video_encoder_factory),
video_decoder_factory_(video_decoder_factory) {
- ASSERT(worker_thread != NULL);
- ASSERT(signaling_thread != NULL);
+ RTC_DCHECK(network_thread);
+ RTC_DCHECK(worker_thread);
+ RTC_DCHECK(signaling_thread);
// TODO: Currently there is no way creating an external adm in
// libjingle source tree. So we can 't currently assert if this is NULL.
// ASSERT(default_adm != NULL);
@@ -148,6 +151,7 @@ PeerConnectionFactory::~PeerConnectionFactory() {
if (wraps_current_thread_)
rtc::ThreadManager::Instance()->UnwrapCurrentThread();
delete worker_thread_;
+ delete network_thread_;
}
}
@@ -155,33 +159,31 @@ bool PeerConnectionFactory::Initialize() {
RTC_DCHECK(signaling_thread_->IsCurrent());
rtc::InitRandom(rtc::Time());
- default_network_manager_.reset(new rtc::BasicNetworkManager());
- if (!default_network_manager_) {
- return false;
- }
-
- default_socket_factory_.reset(
- new rtc::BasicPacketSocketFactory(worker_thread_));
- if (!default_socket_factory_) {
- return false;
- }
+ network_thread_->Invoke<void>([this] {
+ default_network_manager_.reset(new rtc::BasicNetworkManager());
+ default_socket_factory_.reset(
+ new rtc::BasicPacketSocketFactory(network_thread_));
+ });
// TODO: Need to make sure only one VoE is created inside
// WebRtcMediaEngine.
cricket::MediaEngineInterface* media_engine =
- worker_thread_->Invoke<cricket::MediaEngineInterface*>(rtc::Bind(
- &PeerConnectionFactory::CreateMediaEngine_w, this));
+ worker_thread_->Invoke<cricket::MediaEngineInterface*>([this] {
+ return cricket::WebRtcMediaEngineFactory::Create(
+ default_adm_.get(), video_encoder_factory_.get(),
+ video_decoder_factory_.get());
+ });
- channel_manager_.reset(
- new cricket::ChannelManager(media_engine, worker_thread_));
+ channel_manager_.reset(new cricket::ChannelManager(
+ media_engine, worker_thread_, network_thread_));
channel_manager_->SetVideoRtxEnabled(true);
if (!channel_manager_->Init()) {
return false;
}
- dtls_identity_store_ = new RefCountedDtlsIdentityStore(
- signaling_thread_, worker_thread_);
+ dtls_identity_store_ =
+ new RefCountedDtlsIdentityStore(signaling_thread_, network_thread_);
return true;
}
@@ -336,6 +338,10 @@ rtc::Thread* PeerConnectionFactory::worker_thread() {
return worker_thread_;
}
+rtc::Thread* PeerConnectionFactory::network_thread() {
+ return network_thread_;
+}
+
cricket::MediaEngineInterface* PeerConnectionFactory::CreateMediaEngine_w() {
ASSERT(worker_thread_ == rtc::Thread::Current());
return cricket::WebRtcMediaEngineFactory::Create(
« no previous file with comments | « webrtc/api/peerconnectionfactory.h ('k') | webrtc/api/peerconnectionfactory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698