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;
diff --git a/pc/peerconnection.h b/pc/peerconnection.h
index 2d6be60..1913e60 100644
--- a/pc/peerconnection.h
+++ b/pc/peerconnection.h
@@ -65,7 +65,10 @@
std::vector<MediaStreamInterface*> streams) override;
bool RemoveTrack(RtpSenderInterface* sender) override;
- virtual WebRtcSession* session() { return session_.get(); }
+ // TODO(steveanton): Remove this once all clients have switched to using the
+ // PeerConnection shims for WebRtcSession methods instead of the methods
+ // directly via this getter.
+ virtual WebRtcSession* session() { return session_; }
rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender(
AudioTrackInterface* track) override;
@@ -146,6 +149,64 @@
return sctp_data_channels_;
}
+ // TODO(steveanton): These methods are temporarily added to facilitate work
+ // towards merging WebRtcSession into PeerConnection. To make this easier, we
+ // want only PeerConnection to interact with WebRtcSession so they can be
+ // merged easily. A few outside classes still access WebRtcSession methods
+ // directly, so these have been added to PeerConnection to remove the
+ // dependency from WebRtcSession.
+
+ rtc::Thread* network_thread() const { return factory_->network_thread(); }
+ rtc::Thread* worker_thread() const { return factory_->worker_thread(); }
+ rtc::Thread* signaling_thread() const { return factory_->signaling_thread(); }
+ virtual const std::string& session_id() const { return session_->id(); }
+ virtual bool session_created() const { return session_ != nullptr; }
+ virtual bool initial_offerer() const { return session_->initial_offerer(); }
+ virtual std::unique_ptr<SessionStats> GetSessionStats_s() {
+ return session_->GetStats_s();
+ }
+ virtual std::unique_ptr<SessionStats> GetSessionStats(
+ const ChannelNamePairs& channel_name_pairs) {
+ return session_->GetStats(channel_name_pairs);
+ }
+ virtual bool GetLocalCertificate(
+ const std::string& transport_name,
+ rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
+ return session_->GetLocalCertificate(transport_name, certificate);
+ }
+ virtual std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate(
+ const std::string& transport_name) {
+ return session_->GetRemoteSSLCertificate(transport_name);
+ }
+ virtual Call::Stats GetCallStats() { return session_->GetCallStats(); }
+ virtual cricket::VoiceChannel* voice_channel() {
+ return session_->voice_channel();
+ }
+ virtual cricket::VideoChannel* video_channel() {
+ return session_->video_channel();
+ }
+ virtual cricket::RtpDataChannel* rtp_data_channel() {
+ return session_->rtp_data_channel();
+ }
+ virtual rtc::Optional<std::string> sctp_content_name() const {
+ return session_->sctp_content_name();
+ }
+ virtual rtc::Optional<std::string> sctp_transport_name() const {
+ return session_->sctp_transport_name();
+ }
+ virtual bool GetLocalTrackIdBySsrc(uint32_t ssrc, std::string* track_id) {
+ return session_->GetLocalTrackIdBySsrc(ssrc, track_id);
+ }
+ virtual bool GetRemoteTrackIdBySsrc(uint32_t ssrc, std::string* track_id) {
+ return session_->GetRemoteTrackIdBySsrc(ssrc, track_id);
+ }
+
+ // This is needed for stats tests to inject a MockWebRtcSession. Once
+ // WebRtcSession has been merged in, this will no longer be needed.
+ void set_session_for_testing(WebRtcSession* session) {
+ session_ = session;
+ }
+
protected:
~PeerConnection() override;
@@ -210,12 +271,6 @@
void OnVideoTrackRemoved(VideoTrackInterface* track,
MediaStreamInterface* stream);
- rtc::Thread* signaling_thread() const {
- return factory_->signaling_thread();
- }
-
- rtc::Thread* network_thread() const { return factory_->network_thread(); }
-
void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer,
const std::string& error);
void PostCreateSessionDescriptionFailure(
@@ -433,7 +488,8 @@
bool remote_peer_supports_msid_ = false;
std::unique_ptr<Call> call_;
- std::unique_ptr<WebRtcSession> session_;
+ WebRtcSession* session_;
+ std::unique_ptr<WebRtcSession> owned_session_;
std::unique_ptr<StatsCollector> stats_; // A pointer is passed to senders_
rtc::scoped_refptr<RTCStatsCollector> stats_collector_;
diff --git a/pc/rtcstatscollector.cc b/pc/rtcstatscollector.cc
index 2fcb754..b282e7d 100644
--- a/pc/rtcstatscollector.cc
+++ b/pc/rtcstatscollector.cc
@@ -590,9 +590,9 @@
RTCStatsCollector::RTCStatsCollector(PeerConnection* pc,
int64_t cache_lifetime_us)
: pc_(pc),
- signaling_thread_(pc->session()->signaling_thread()),
- worker_thread_(pc->session()->worker_thread()),
- network_thread_(pc->session()->network_thread()),
+ signaling_thread_(pc->signaling_thread()),
+ worker_thread_(pc->worker_thread()),
+ network_thread_(pc->network_thread()),
num_pending_partial_reports_(0),
partial_report_timestamp_us_(0),
cache_timestamp_us_(0),
@@ -638,26 +638,25 @@
// Prepare |channel_name_pairs_| for use in
// |ProducePartialResultsOnNetworkThread|.
channel_name_pairs_.reset(new ChannelNamePairs());
- if (pc_->session()->voice_channel()) {
+ if (pc_->voice_channel()) {
channel_name_pairs_->voice = rtc::Optional<ChannelNamePair>(
- ChannelNamePair(pc_->session()->voice_channel()->content_name(),
- pc_->session()->voice_channel()->transport_name()));
+ ChannelNamePair(pc_->voice_channel()->content_name(),
+ pc_->voice_channel()->transport_name()));
}
- if (pc_->session()->video_channel()) {
+ if (pc_->video_channel()) {
channel_name_pairs_->video = rtc::Optional<ChannelNamePair>(
- ChannelNamePair(pc_->session()->video_channel()->content_name(),
- pc_->session()->video_channel()->transport_name()));
+ ChannelNamePair(pc_->video_channel()->content_name(),
+ pc_->video_channel()->transport_name()));
}
- if (pc_->session()->rtp_data_channel()) {
+ if (pc_->rtp_data_channel()) {
+ channel_name_pairs_->data = rtc::Optional<ChannelNamePair>(
+ ChannelNamePair(pc_->rtp_data_channel()->content_name(),
+ pc_->rtp_data_channel()->transport_name()));
+ }
+ if (pc_->sctp_content_name()) {
channel_name_pairs_->data =
rtc::Optional<ChannelNamePair>(ChannelNamePair(
- pc_->session()->rtp_data_channel()->content_name(),
- pc_->session()->rtp_data_channel()->transport_name()));
- }
- if (pc_->session()->sctp_content_name()) {
- channel_name_pairs_->data = rtc::Optional<ChannelNamePair>(
- ChannelNamePair(*pc_->session()->sctp_content_name(),
- *pc_->session()->sctp_transport_name()));
+ *pc_->sctp_content_name(), *pc_->sctp_transport_name()));
}
// Prepare |track_media_info_map_| for use in
// |ProducePartialResultsOnNetworkThread| and
@@ -672,7 +671,7 @@
// thread.
// TODO(holmer): To avoid the hop we could move BWE and BWE stats to the
// network thread, where it more naturally belongs.
- call_stats_ = pc_->session()->GetCallStats();
+ call_stats_ = pc_->GetCallStats();
invoker_.AsyncInvoke<void>(
RTC_FROM_HERE, network_thread_,
@@ -718,7 +717,7 @@
timestamp_us);
std::unique_ptr<SessionStats> session_stats =
- pc_->session()->GetStats(*channel_name_pairs_);
+ pc_->GetSessionStats(*channel_name_pairs_);
if (session_stats) {
std::map<std::string, CertificateStatsPair> transport_cert_stats =
PrepareTransportCertificateStats_n(*session_stats);
@@ -978,7 +977,7 @@
// Audio
if (track_media_info_map.voice_media_info()) {
std::string transport_id = RTCTransportStatsIDFromBaseChannel(
- session_stats.proxy_to_transport, *pc_->session()->voice_channel());
+ session_stats.proxy_to_transport, *pc_->voice_channel());
RTC_DCHECK(!transport_id.empty());
// Inbound
for (const cricket::VoiceReceiverInfo& voice_receiver_info :
@@ -1040,7 +1039,7 @@
// Video
if (track_media_info_map.video_media_info()) {
std::string transport_id = RTCTransportStatsIDFromBaseChannel(
- session_stats.proxy_to_transport, *pc_->session()->video_channel());
+ session_stats.proxy_to_transport, *pc_->video_channel());
RTC_DCHECK(!transport_id.empty());
// Inbound
for (const cricket::VideoReceiverInfo& video_receiver_info :
@@ -1175,14 +1174,13 @@
for (const auto& transport_stats : session_stats.transport_stats) {
CertificateStatsPair certificate_stats_pair;
rtc::scoped_refptr<rtc::RTCCertificate> local_certificate;
- if (pc_->session()->GetLocalCertificate(
- transport_stats.second.transport_name, &local_certificate)) {
+ if (pc_->GetLocalCertificate(transport_stats.second.transport_name,
+ &local_certificate)) {
certificate_stats_pair.local =
local_certificate->ssl_certificate().GetStats();
}
std::unique_ptr<rtc::SSLCertificate> remote_certificate =
- pc_->session()->GetRemoteSSLCertificate(
- transport_stats.second.transport_name);
+ pc_->GetRemoteSSLCertificate(transport_stats.second.transport_name);
if (remote_certificate) {
certificate_stats_pair.remote = remote_certificate->GetStats();
}
@@ -1197,16 +1195,16 @@
RTCStatsCollector::PrepareTrackMediaInfoMap_s() const {
RTC_DCHECK(signaling_thread_->IsCurrent());
std::unique_ptr<cricket::VoiceMediaInfo> voice_media_info;
- if (pc_->session()->voice_channel()) {
+ if (pc_->voice_channel()) {
voice_media_info.reset(new cricket::VoiceMediaInfo());
- if (!pc_->session()->voice_channel()->GetStats(voice_media_info.get())) {
+ if (!pc_->voice_channel()->GetStats(voice_media_info.get())) {
voice_media_info.reset();
}
}
std::unique_ptr<cricket::VideoMediaInfo> video_media_info;
- if (pc_->session()->video_channel()) {
+ if (pc_->video_channel()) {
video_media_info.reset(new cricket::VideoMediaInfo());
- if (!pc_->session()->video_channel()->GetStats(video_media_info.get())) {
+ if (!pc_->video_channel()->GetStats(video_media_info.get())) {
video_media_info.reset();
}
}
diff --git a/pc/rtcstatscollector_unittest.cc b/pc/rtcstatscollector_unittest.cc
index 0e573b1..a5c2ee1 100644
--- a/pc/rtcstatscollector_unittest.cc
+++ b/pc/rtcstatscollector_unittest.cc
@@ -286,10 +286,10 @@
network_thread_)),
session_(channel_manager_.get(), cricket::MediaConfig()),
pc_() {
+ pc_.set_session_for_testing(&session_);
// Default return values for mocks.
EXPECT_CALL(pc_, local_streams()).WillRepeatedly(Return(nullptr));
EXPECT_CALL(pc_, remote_streams()).WillRepeatedly(Return(nullptr));
- EXPECT_CALL(pc_, session()).WillRepeatedly(Return(&session_));
EXPECT_CALL(pc_, GetSenders()).WillRepeatedly(Return(
std::vector<rtc::scoped_refptr<RtpSenderInterface>>()));
EXPECT_CALL(pc_, GetReceivers()).WillRepeatedly(Return(
@@ -561,14 +561,11 @@
}
protected:
- FakeRTCStatsCollector(
- PeerConnection* pc,
- int64_t cache_lifetime)
+ FakeRTCStatsCollector(PeerConnection* pc, int64_t cache_lifetime)
: RTCStatsCollector(pc, cache_lifetime),
- signaling_thread_(pc->session()->signaling_thread()),
- worker_thread_(pc->session()->worker_thread()),
- network_thread_(pc->session()->network_thread()) {
- }
+ signaling_thread_(pc->signaling_thread()),
+ worker_thread_(pc->worker_thread()),
+ network_thread_(pc->network_thread()) {}
void ProducePartialResultsOnSignalingThread(int64_t timestamp_us) override {
EXPECT_TRUE(signaling_thread_->IsCurrent());
diff --git a/pc/statscollector.cc b/pc/statscollector.cc
index 070c942..eedd2286 100644
--- a/pc/statscollector.cc
+++ b/pc/statscollector.cc
@@ -447,7 +447,7 @@
}
StatsCollector::~StatsCollector() {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
}
// Wallclock time in ms.
@@ -459,7 +459,7 @@
// Adds a MediaStream with tracks that can be used as a |selector| in a call
// to GetStats.
void StatsCollector::AddStream(MediaStreamInterface* stream) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(stream != NULL);
CreateTrackReports<AudioTrackVector>(stream->GetAudioTracks(),
@@ -470,7 +470,7 @@
void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
uint32_t ssrc) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(audio_track != NULL);
#if RTC_DCHECK_IS_ON
for (const auto& track : local_audio_tracks_)
@@ -504,7 +504,7 @@
void StatsCollector::GetStats(MediaStreamTrackInterface* track,
StatsReports* reports) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(reports != NULL);
RTC_DCHECK(reports->empty());
@@ -518,7 +518,7 @@
}
StatsReport* report = reports_.Find(StatsReport::NewTypedId(
- StatsReport::kStatsReportTypeSession, pc_->session()->id()));
+ StatsReport::kStatsReportTypeSession, pc_->session_id()));
if (report)
reports->push_back(report);
@@ -544,7 +544,7 @@
void
StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
double time_now = GetTimeNow();
// Calls to UpdateStats() that occur less than kMinGatherStatsPeriod number of
// ms apart will be ignored.
@@ -557,7 +557,7 @@
// TODO(pthatcher): Merge PeerConnection and WebRtcSession so there is no
// pc_->session().
- if (pc_->session()) {
+ if (pc_->session_created()) {
// TODO(tommi): All of these hop over to the worker thread to fetch
// information. We could use an AsyncInvoker to run all of these and post
// the information back to the signaling thread where we can create and
@@ -579,7 +579,7 @@
uint32_t ssrc,
const StatsReport::Id& transport_id,
StatsReport::Direction direction) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
StatsReport::Id id(StatsReport::NewIdWithDirection(
local ? StatsReport::kStatsReportTypeSsrc
: StatsReport::kStatsReportTypeRemoteSsrc,
@@ -623,7 +623,7 @@
StatsReport* StatsCollector::AddCertificateReports(
const rtc::SSLCertificate* cert) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(cert != NULL);
std::unique_ptr<rtc::SSLCertificateStats> first_stats = cert->GetStats();
@@ -734,17 +734,17 @@
}
void StatsCollector::ExtractSessionInfo() {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
// Extract information from the base session.
StatsReport::Id id(StatsReport::NewTypedId(
- StatsReport::kStatsReportTypeSession, pc_->session()->id()));
+ StatsReport::kStatsReportTypeSession, pc_->session_id()));
StatsReport* report = reports_.ReplaceOrAddNew(id);
report->set_timestamp(stats_gathering_started_);
report->AddBoolean(StatsReport::kStatsValueNameInitiator,
- pc_->session()->initial_offerer());
+ pc_->initial_offerer());
- std::unique_ptr<SessionStats> stats = pc_->session()->GetStats_s();
+ std::unique_ptr<SessionStats> stats = pc_->GetSessionStats_s();
if (!stats) {
return;
}
@@ -764,16 +764,15 @@
//
StatsReport::Id local_cert_report_id, remote_cert_report_id;
rtc::scoped_refptr<rtc::RTCCertificate> certificate;
- if (pc_->session()->GetLocalCertificate(
- transport_iter.second.transport_name, &certificate)) {
+ if (pc_->GetLocalCertificate(transport_iter.second.transport_name,
+ &certificate)) {
StatsReport* r = AddCertificateReports(&(certificate->ssl_certificate()));
if (r)
local_cert_report_id = r->id();
}
std::unique_ptr<rtc::SSLCertificate> cert =
- pc_->session()->GetRemoteSSLCertificate(
- transport_iter.second.transport_name);
+ pc_->GetRemoteSSLCertificate(transport_iter.second.transport_name);
if (cert) {
StatsReport* r = AddCertificateReports(cert.get());
if (r)
@@ -828,20 +827,20 @@
}
void StatsCollector::ExtractBweInfo() {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
- if (pc_->session()->state() == WebRtcSession::State::STATE_CLOSED)
+ if (pc_->signaling_state() == PeerConnectionInterface::kClosed)
return;
- webrtc::Call::Stats call_stats = pc_->session()->GetCallStats();
+ webrtc::Call::Stats call_stats = pc_->GetCallStats();
cricket::BandwidthEstimationInfo bwe_info;
bwe_info.available_send_bandwidth = call_stats.send_bandwidth_bps;
bwe_info.available_recv_bandwidth = call_stats.recv_bandwidth_bps;
bwe_info.bucket_delay = call_stats.pacer_delay_ms;
// Fill in target encoder bitrate, actual encoder bitrate, rtx bitrate, etc.
// TODO(holmer): Also fill this in for audio.
- if (pc_->session()->video_channel()) {
- pc_->session()->video_channel()->FillBitrateInfo(&bwe_info);
+ if (pc_->video_channel()) {
+ pc_->video_channel()->FillBitrateInfo(&bwe_info);
}
StatsReport::Id report_id(StatsReport::NewBandwidthEstimationId());
StatsReport* report = reports_.FindOrAddNew(report_id);
@@ -849,13 +848,13 @@
}
void StatsCollector::ExtractVoiceInfo() {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
- if (!pc_->session()->voice_channel()) {
+ if (!pc_->voice_channel()) {
return;
}
cricket::VoiceMediaInfo voice_info;
- if (!pc_->session()->voice_channel()->GetStats(&voice_info)) {
+ if (!pc_->voice_channel()->GetStats(&voice_info)) {
LOG(LS_ERROR) << "Failed to get voice channel stats.";
return;
}
@@ -865,10 +864,10 @@
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
StatsReport::Id transport_id(GetTransportIdFromProxy(
- proxy_to_transport_, pc_->session()->voice_channel()->content_name()));
+ proxy_to_transport_, pc_->voice_channel()->content_name()));
if (!transport_id.get()) {
LOG(LS_ERROR) << "Failed to get transport name for proxy "
- << pc_->session()->voice_channel()->content_name();
+ << pc_->voice_channel()->content_name();
return;
}
@@ -882,13 +881,13 @@
void StatsCollector::ExtractVideoInfo(
PeerConnectionInterface::StatsOutputLevel level) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
- if (!pc_->session()->video_channel())
+ if (!pc_->video_channel())
return;
cricket::VideoMediaInfo video_info;
- if (!pc_->session()->video_channel()->GetStats(&video_info)) {
+ if (!pc_->video_channel()->GetStats(&video_info)) {
LOG(LS_ERROR) << "Failed to get video channel stats.";
return;
}
@@ -898,10 +897,10 @@
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
StatsReport::Id transport_id(GetTransportIdFromProxy(
- proxy_to_transport_, pc_->session()->video_channel()->content_name()));
+ proxy_to_transport_, pc_->video_channel()->content_name()));
if (!transport_id.get()) {
LOG(LS_ERROR) << "Failed to get transport name for proxy "
- << pc_->session()->video_channel()->content_name();
+ << pc_->video_channel()->content_name();
return;
}
ExtractStatsFromList(video_info.receivers, transport_id, this,
@@ -911,7 +910,7 @@
}
void StatsCollector::ExtractSenderInfo() {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
for (const auto& sender : pc_->GetSenders()) {
// TODO(nisse): SSRC == 0 currently means none. Delete check when
@@ -944,7 +943,7 @@
}
void StatsCollector::ExtractDataInfo() {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
@@ -967,14 +966,14 @@
StatsReport* StatsCollector::GetReport(const StatsReport::StatsType& type,
const std::string& id,
StatsReport::Direction direction) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(type == StatsReport::kStatsReportTypeSsrc ||
type == StatsReport::kStatsReportTypeRemoteSsrc);
return reports_.Find(StatsReport::NewIdWithDirection(type, id, direction));
}
void StatsCollector::UpdateStatsFromExistingLocalAudioTracks() {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
// Loop through the existing local audio tracks.
for (const auto& it : local_audio_tracks_) {
AudioTrackInterface* track = it.first;
@@ -1002,7 +1001,7 @@
void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
StatsReport* report) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(track != NULL);
// Don't overwrite report values if they're not available.
@@ -1033,16 +1032,16 @@
bool StatsCollector::GetTrackIdBySsrc(uint32_t ssrc,
std::string* track_id,
StatsReport::Direction direction) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
if (direction == StatsReport::kSend) {
- if (!pc_->session()->GetLocalTrackIdBySsrc(ssrc, track_id)) {
+ if (!pc_->GetLocalTrackIdBySsrc(ssrc, track_id)) {
LOG(LS_WARNING) << "The SSRC " << ssrc
<< " is not associated with a sending track";
return false;
}
} else {
RTC_DCHECK(direction == StatsReport::kReceive);
- if (!pc_->session()->GetRemoteTrackIdBySsrc(ssrc, track_id)) {
+ if (!pc_->GetRemoteTrackIdBySsrc(ssrc, track_id)) {
LOG(LS_WARNING) << "The SSRC " << ssrc
<< " is not associated with a receiving track";
return false;
@@ -1053,7 +1052,7 @@
}
void StatsCollector::UpdateTrackReports() {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
diff --git a/pc/statscollector_unittest.cc b/pc/statscollector_unittest.cc
index 6a1d827..5e34f7f 100644
--- a/pc/statscollector_unittest.cc
+++ b/pc/statscollector_unittest.cc
@@ -573,12 +573,12 @@
network_thread_)),
session_(channel_manager_.get(), cricket::MediaConfig()) {
+ pc_.set_session_for_testing(&session_);
// By default, we ignore session GetStats calls.
EXPECT_CALL(session_, GetStats(_)).WillRepeatedly(ReturnNull());
// Add default returns for mock classes.
EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull());
EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull());
- EXPECT_CALL(pc_, session()).WillRepeatedly(Return(&session_));
EXPECT_CALL(pc_, sctp_data_channels())
.WillRepeatedly(ReturnRef(data_channels_));
EXPECT_CALL(pc_, GetSenders()).WillRepeatedly(Return(
diff --git a/pc/test/mock_peerconnection.h b/pc/test/mock_peerconnection.h
index 73f4a4b..7944a4d 100644
--- a/pc/test/mock_peerconnection.h
+++ b/pc/test/mock_peerconnection.h
@@ -47,7 +47,6 @@
rtc::scoped_refptr<StreamCollectionInterface>());
MOCK_METHOD0(remote_streams,
rtc::scoped_refptr<StreamCollectionInterface>());
- MOCK_METHOD0(session, WebRtcSession*());
MOCK_CONST_METHOD0(GetSenders,
std::vector<rtc::scoped_refptr<RtpSenderInterface>>());
MOCK_CONST_METHOD0(GetReceivers,