Index: webrtc/pc/webrtcsession.cc |
diff --git a/webrtc/pc/webrtcsession.cc b/webrtc/pc/webrtcsession.cc |
index c6046e905fd48e3a57b98315d49bebe091b56dfd..54ef1a923e7fb20cb37ffc9516238c3773d5da53 100644 |
--- a/webrtc/pc/webrtcsession.cc |
+++ b/webrtc/pc/webrtcsession.cc |
@@ -461,7 +461,9 @@ bool CheckForRemoteIceRestart(const SessionDescriptionInterface* old_desc, |
} |
WebRtcSession::WebRtcSession( |
- webrtc::MediaControllerInterface* media_controller, |
+ cricket::ChannelManager* channel_manager, |
+ const cricket::MediaConfig& media_config, |
+ RtcEventLog* event_log, |
rtc::Thread* network_thread, |
rtc::Thread* worker_thread, |
rtc::Thread* signaling_thread, |
@@ -477,8 +479,9 @@ WebRtcSession::WebRtcSession( |
sid_(rtc::ToString(rtc::CreateRandomId64() & LLONG_MAX)), |
transport_controller_(std::move(transport_controller)), |
sctp_factory_(std::move(sctp_factory)), |
- media_controller_(media_controller), |
- channel_manager_(media_controller_->channel_manager()), |
+ media_config_(media_config), |
+ event_log_(event_log), |
+ channel_manager_(channel_manager), |
ice_observer_(NULL), |
ice_connection_state_(PeerConnectionInterface::kIceConnectionNew), |
ice_connection_receiving_(true), |
@@ -525,6 +528,11 @@ WebRtcSession::~WebRtcSession() { |
} |
#endif |
+ // Make sure Call is destructed on the worker thread. |
+ if (state() != STATE_CLOSED) { |
+ worker_thread_->Invoke<void>(RTC_FROM_HERE, |
+ rtc::Bind(&WebRtcSession::Close_w, this)); |
+ } |
LOG(LS_INFO) << "Session: " << id() << " is destroyed."; |
} |
@@ -620,9 +628,29 @@ bool WebRtcSession::Initialize( |
webrtc_session_desc_factory_->SetSdesPolicy(cricket::SEC_DISABLED); |
} |
+ worker_thread_->Invoke<void>(RTC_FROM_HERE, |
+ rtc::Bind(&WebRtcSession::Init_w, this)); |
+ |
return true; |
} |
+void WebRtcSession::Init_w() { |
+ RTC_DCHECK(worker_thread_->IsCurrent()); |
+ RTC_DCHECK(!call_); |
+ |
+ const int kMinBandwidthBps = 30000; |
+ const int kStartBandwidthBps = 300000; |
+ const int kMaxBandwidthBps = 2000000; |
+ |
+ webrtc::Call::Config call_config(event_log_); |
+ call_config.audio_state = channel_manager_->media_engine()->GetAudioState(); |
+ call_config.bitrate_config.min_bitrate_bps = kMinBandwidthBps; |
+ call_config.bitrate_config.start_bitrate_bps = kStartBandwidthBps; |
+ call_config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps; |
+ |
+ call_.reset(webrtc::Call::Create(call_config)); |
+} |
+ |
void WebRtcSession::Close() { |
SetState(STATE_CLOSED); |
RemoveUnusedChannels(nullptr); |
@@ -630,7 +658,14 @@ void WebRtcSession::Close() { |
RTC_DCHECK(!video_channel_); |
RTC_DCHECK(!rtp_data_channel_); |
RTC_DCHECK(!sctp_transport_); |
- media_controller_->Close(); |
+ |
+ worker_thread_->Invoke<void>(RTC_FROM_HERE, |
+ rtc::Bind(&WebRtcSession::Close_w, this)); |
+} |
+ |
+void WebRtcSession::Close_w() { |
+ RTC_DCHECK(worker_thread_->IsCurrent()); |
+ call_.reset(); |
} |
cricket::BaseChannel* WebRtcSession::GetChannel( |
@@ -1757,7 +1792,7 @@ bool WebRtcSession::CreateVoiceChannel(const cricket::ContentInfo* content, |
} |
voice_channel_.reset(channel_manager_->CreateVoiceChannel( |
- media_controller_, rtp_dtls_transport, rtcp_dtls_transport, |
+ call(), media_config_, rtp_dtls_transport, rtcp_dtls_transport, |
transport_controller_->signaling_thread(), content->name, SrtpRequired(), |
audio_options_)); |
if (!voice_channel_) { |
@@ -1799,7 +1834,7 @@ bool WebRtcSession::CreateVideoChannel(const cricket::ContentInfo* content, |
} |
video_channel_.reset(channel_manager_->CreateVideoChannel( |
- media_controller_, rtp_dtls_transport, rtcp_dtls_transport, |
+ call(), media_config_, rtp_dtls_transport, rtcp_dtls_transport, |
transport_controller_->signaling_thread(), content->name, SrtpRequired(), |
video_options_)); |
@@ -1864,7 +1899,7 @@ bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content, |
} |
rtp_data_channel_.reset(channel_manager_->CreateRtpDataChannel( |
- media_controller_, rtp_dtls_transport, rtcp_dtls_transport, |
+ media_config_, rtp_dtls_transport, rtcp_dtls_transport, |
transport_controller_->signaling_thread(), content->name, |
SrtpRequired())); |
@@ -2313,7 +2348,7 @@ void WebRtcSession::ReportNegotiatedCiphers( |
void WebRtcSession::OnSentPacket_w(const rtc::SentPacket& sent_packet) { |
RTC_DCHECK(worker_thread()->IsCurrent()); |
- media_controller_->call_w()->OnSentPacket(sent_packet); |
+ call()->OnSentPacket(sent_packet); |
} |
const std::string WebRtcSession::GetTransportName( |