Move clients of WebRtcSession to use PeerConnection
This change is part of the work to merge WebRtcSession into
PeerConnection. To make that work easier, this moves all clients
of WebRtcSession to use shims added to PeerConnection. That way
when the classes are merged they won't need to be modified.
Bug: webrtc:8183
Change-Id: I5758a5954b91d235faf810c8bf4bf9f6f31d83c1
Reviewed-on: https://webrtc-review.googlesource.com/5040
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20090}
diff --git a/pc/peerconnection.cc b/pc/peerconnection.cc
index 91d0c90..b232a26 100644
--- a/pc/peerconnection.cc
+++ b/pc/peerconnection.cc
@@ -421,12 +421,13 @@
// Now destroy session_ before destroying other members,
// because its destruction fires signals (such as VoiceChannelDestroyed)
// which will trigger some final actions in PeerConnection...
- session_.reset(nullptr);
+ owned_session_.reset(nullptr);
+ session_ = nullptr;
// port_allocator_ lives on the network thread and should be destroyed there.
network_thread()->Invoke<void>(RTC_FROM_HERE,
[this] { port_allocator_.reset(); });
// call_ and event_log_ must be destroyed on the worker thread.
- factory_->worker_thread()->Invoke<void>(RTC_FROM_HERE, [this] {
+ worker_thread()->Invoke<void>(RTC_FROM_HERE, [this] {
call_.reset();
event_log_.reset();
});
@@ -467,12 +468,9 @@
return false;
}
-
- session_.reset(new WebRtcSession(
+ owned_session_.reset(new WebRtcSession(
call_.get(), factory_->channel_manager(), configuration.media_config,
- event_log_.get(),
- factory_->network_thread(),
- factory_->worker_thread(), factory_->signaling_thread(),
+ event_log_.get(), network_thread(), worker_thread(), signaling_thread(),
port_allocator_.get(),
std::unique_ptr<cricket::TransportController>(
factory_->CreateTransportController(
@@ -480,11 +478,12 @@
configuration.redetermine_role_on_ice_restart)),
#ifdef HAVE_SCTP
std::unique_ptr<cricket::SctpTransportInternalFactory>(
- new cricket::SctpTransportFactory(factory_->network_thread()))
+ new cricket::SctpTransportFactory(network_thread()))
#else
nullptr
#endif
));
+ session_ = owned_session_.get();
stats_.reset(new StatsCollector(this));
stats_collector_ = RTCStatsCollector::Create(this);
@@ -1240,9 +1239,8 @@
}
RTCError PeerConnection::SetBitrate(const BitrateParameters& bitrate) {
- rtc::Thread* worker_thread = factory_->worker_thread();
- if (!worker_thread->IsCurrent()) {
- return worker_thread->Invoke<RTCError>(
+ if (!worker_thread()->IsCurrent()) {
+ return worker_thread()->Invoke<RTCError>(
RTC_FROM_HERE, rtc::Bind(&PeerConnection::SetBitrate, this, bitrate));
}
@@ -1289,13 +1287,13 @@
bool PeerConnection::StartRtcEventLog(rtc::PlatformFile file,
int64_t max_size_bytes) {
- return factory_->worker_thread()->Invoke<bool>(
+ return worker_thread()->Invoke<bool>(
RTC_FROM_HERE, rtc::Bind(&PeerConnection::StartRtcEventLog_w, this, file,
max_size_bytes));
}
void PeerConnection::StopRtcEventLog() {
- factory_->worker_thread()->Invoke<void>(
+ worker_thread()->Invoke<void>(
RTC_FROM_HERE, rtc::Bind(&PeerConnection::StopRtcEventLog_w, this));
}
@@ -1339,7 +1337,7 @@
rtc::Bind(&cricket::PortAllocator::DiscardCandidatePool,
port_allocator_.get()));
- factory_->worker_thread()->Invoke<void>(RTC_FROM_HERE, [this] {
+ worker_thread()->Invoke<void>(RTC_FROM_HERE, [this] {
call_.reset();
// The event log must outlive call (and any other object that uses it).
event_log_.reset();
@@ -1437,7 +1435,7 @@
rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>
receiver = RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create(
signaling_thread(),
- new VideoRtpReceiver(track_id, factory_->worker_thread(), ssrc,
+ new VideoRtpReceiver(track_id, worker_thread(), ssrc,
session_->video_channel()));
stream->AddTrack(
static_cast<VideoTrackInterface*>(receiver->internal()->track().get()));
@@ -2241,7 +2239,7 @@
}
rtc::scoped_refptr<DataChannel> channel(DataChannel::Create(
- session_.get(), session_->data_channel_type(), label, new_config));
+ session_, session_->data_channel_type(), label, new_config));
if (!channel) {
sid_allocator_.ReleaseSid(new_config.id);
return nullptr;