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

Unified Diff: webrtc/pc/channelmanager.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/pc/channelmanager.h ('k') | webrtc/pc/channelmanager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/pc/channelmanager.cc
diff --git a/webrtc/pc/channelmanager.cc b/webrtc/pc/channelmanager.cc
index f59a3df9c72f7059e0c1a66aed639a66e2dbe518..a7166efbdd12f09c38f3f00d1dd2322b59c40949 100644
--- a/webrtc/pc/channelmanager.cc
+++ b/webrtc/pc/channelmanager.cc
@@ -44,25 +44,26 @@ static DataEngineInterface* ConstructDataEngine() {
ChannelManager::ChannelManager(MediaEngineInterface* me,
DataEngineInterface* dme,
- rtc::Thread* worker_thread) {
- Construct(me, dme, worker_thread);
+ rtc::Thread* thread) {
+ Construct(me, dme, thread, thread);
}
ChannelManager::ChannelManager(MediaEngineInterface* me,
- rtc::Thread* worker_thread) {
- Construct(me,
- ConstructDataEngine(),
- worker_thread);
+ rtc::Thread* worker_thread,
+ rtc::Thread* network_thread) {
+ Construct(me, ConstructDataEngine(), worker_thread, network_thread);
}
void ChannelManager::Construct(MediaEngineInterface* me,
DataEngineInterface* dme,
- rtc::Thread* worker_thread) {
+ rtc::Thread* worker_thread,
+ rtc::Thread* network_thread) {
media_engine_.reset(me);
data_media_engine_.reset(dme);
initialized_ = false;
main_thread_ = rtc::Thread::Current();
worker_thread_ = worker_thread;
+ network_thread_ = network_thread;
audio_output_volume_ = kNotSetOutputVolume;
capturing_ = false;
enable_rtx_ = false;
@@ -144,22 +145,17 @@ bool ChannelManager::Init() {
if (initialized_) {
return false;
}
- ASSERT(worker_thread_ != NULL);
- if (!worker_thread_) {
- return false;
- }
- if (worker_thread_ != rtc::Thread::Current()) {
- // Do not allow invoking calls to other threads on the worker thread.
- worker_thread_->Invoke<bool>(rtc::Bind(
- &rtc::Thread::SetAllowBlockingCalls, worker_thread_, false));
+ RTC_DCHECK(network_thread_);
+ RTC_DCHECK(worker_thread_);
+ if (!network_thread_->IsCurrent()) {
+ // Do not allow invoking calls to other threads on the network thread.
+ network_thread_->Invoke<bool>(
+ rtc::Bind(&rtc::Thread::SetAllowBlockingCalls, network_thread_, false));
}
- initialized_ = worker_thread_->Invoke<bool>(Bind(
- &ChannelManager::InitMediaEngine_w, this));
- ASSERT(initialized_);
- if (!initialized_) {
- return false;
- }
+ initialized_ =
+ worker_thread_->Invoke<bool>([this] { return media_engine_->Init(); });
+ RTC_DCHECK(initialized_);
// If audio_output_volume_ has been set via SetOutputVolume(), set the
// audio output volume of the engine.
@@ -172,11 +168,6 @@ bool ChannelManager::Init() {
return initialized_;
}
-bool ChannelManager::InitMediaEngine_w() {
- ASSERT(worker_thread_ == rtc::Thread::Current());
- return media_engine_->Init();
-}
-
void ChannelManager::Terminate() {
ASSERT(initialized_);
if (!initialized_) {
@@ -223,13 +214,13 @@ VoiceChannel* ChannelManager::CreateVoiceChannel_w(
ASSERT(worker_thread_ == rtc::Thread::Current());
ASSERT(nullptr != media_controller);
VoiceMediaChannel* media_channel = media_engine_->CreateChannel(
- media_controller->call_w(), media_controller->config(), options);
+ media_controller->call(), media_controller->config(), options);
if (!media_channel)
return nullptr;
VoiceChannel* voice_channel =
- new VoiceChannel(worker_thread_, media_engine_.get(), media_channel,
- transport_controller, content_name, rtcp);
+ new VoiceChannel(worker_thread_, network_thread_, media_engine_.get(),
+ media_channel, transport_controller, content_name, rtcp);
if (!voice_channel->Init()) {
delete voice_channel;
return nullptr;
@@ -281,13 +272,14 @@ VideoChannel* ChannelManager::CreateVideoChannel_w(
ASSERT(worker_thread_ == rtc::Thread::Current());
ASSERT(nullptr != media_controller);
VideoMediaChannel* media_channel = media_engine_->CreateVideoChannel(
- media_controller->call_w(), media_controller->config(), options);
+ media_controller->call(), media_controller->config(), options);
if (media_channel == NULL) {
return NULL;
}
- VideoChannel* video_channel = new VideoChannel(
- worker_thread_, media_channel, transport_controller, content_name, rtcp);
+ VideoChannel* video_channel =
+ new VideoChannel(worker_thread_, network_thread_, media_channel,
+ transport_controller, content_name, rtcp);
if (!video_channel->Init()) {
delete video_channel;
return NULL;
@@ -344,8 +336,9 @@ DataChannel* ChannelManager::CreateDataChannel_w(
return NULL;
}
- DataChannel* data_channel = new DataChannel(
- worker_thread_, media_channel, transport_controller, content_name, rtcp);
+ DataChannel* data_channel =
+ new DataChannel(worker_thread_, network_thread_, media_channel,
+ transport_controller, content_name, rtcp);
if (!data_channel->Init()) {
LOG(LS_WARNING) << "Failed to init data channel.";
delete data_channel;
« no previous file with comments | « webrtc/pc/channelmanager.h ('k') | webrtc/pc/channelmanager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698