Index: talk/app/webrtc/statscollector.cc |
diff --git a/talk/app/webrtc/statscollector.cc b/talk/app/webrtc/statscollector.cc |
index 9ba7da808d995169cfc35f05c9806d6b2ed167dc..5b527ecc73d4ef1372dd28b30ccc347c096fc2c1 100644 |
--- a/talk/app/webrtc/statscollector.cc |
+++ b/talk/app/webrtc/statscollector.cc |
@@ -30,7 +30,6 @@ |
#include <utility> |
#include <vector> |
-#include "talk/app/webrtc/peerconnection.h" |
#include "talk/session/media/channel.h" |
#include "webrtc/base/base64.h" |
#include "webrtc/base/checks.h" |
@@ -357,13 +356,14 @@ |
} |
} |
-StatsCollector::StatsCollector(PeerConnection* pc) |
- : pc_(pc), stats_gathering_started_(0) { |
- RTC_DCHECK(pc_); |
+StatsCollector::StatsCollector(WebRtcSession* session) |
+ : session_(session), |
+ stats_gathering_started_(0) { |
+ RTC_DCHECK(session_); |
} |
StatsCollector::~StatsCollector() { |
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
+ RTC_DCHECK(session_->signaling_thread()->IsCurrent()); |
} |
double StatsCollector::GetTimeNow() { |
@@ -373,7 +373,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(session_->signaling_thread()->IsCurrent()); |
RTC_DCHECK(stream != NULL); |
CreateTrackReports<AudioTrackVector>(stream->GetAudioTracks(), |
@@ -384,7 +384,7 @@ |
void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track, |
uint32_t ssrc) { |
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
+ RTC_DCHECK(session_->signaling_thread()->IsCurrent()); |
RTC_DCHECK(audio_track != NULL); |
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) |
for (const auto& track : local_audio_tracks_) |
@@ -416,7 +416,7 @@ |
void StatsCollector::GetStats(MediaStreamTrackInterface* track, |
StatsReports* reports) { |
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
+ RTC_DCHECK(session_->signaling_thread()->IsCurrent()); |
RTC_DCHECK(reports != NULL); |
RTC_DCHECK(reports->empty()); |
@@ -430,7 +430,7 @@ |
} |
StatsReport* report = reports_.Find(StatsReport::NewTypedId( |
- StatsReport::kStatsReportTypeSession, pc_->session()->id())); |
+ StatsReport::kStatsReportTypeSession, session_->id())); |
if (report) |
reports->push_back(report); |
@@ -456,7 +456,7 @@ |
void |
StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) { |
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
+ RTC_DCHECK(session_->signaling_thread()->IsCurrent()); |
double time_now = GetTimeNow(); |
// Calls to UpdateStats() that occur less than kMinGatherStatsPeriod number of |
// ms apart will be ignored. |
@@ -467,7 +467,7 @@ |
} |
stats_gathering_started_ = time_now; |
- if (pc_->session()) { |
+ if (session_) { |
// 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 |
@@ -482,12 +482,11 @@ |
} |
} |
-StatsReport* StatsCollector::PrepareReport( |
- bool local, |
- uint32_t ssrc, |
- const StatsReport::Id& transport_id, |
- StatsReport::Direction direction) { |
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
+StatsReport* StatsCollector::PrepareReport(bool local, |
+ uint32_t ssrc, |
+ const StatsReport::Id& transport_id, |
+ StatsReport::Direction direction) { |
+ RTC_DCHECK(session_->signaling_thread()->IsCurrent()); |
StatsReport::Id id(StatsReport::NewIdWithDirection( |
local ? StatsReport::kStatsReportTypeSsrc |
: StatsReport::kStatsReportTypeRemoteSsrc, |
@@ -526,7 +525,7 @@ |
StatsReport* StatsCollector::AddOneCertificateReport( |
const rtc::SSLCertificate* cert, const StatsReport* issuer) { |
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
+ RTC_DCHECK(session_->signaling_thread()->IsCurrent()); |
// TODO(bemasc): Move this computation to a helper class that caches these |
// values to reduce CPU use in GetStats. This will require adding a fast |
@@ -569,7 +568,7 @@ |
StatsReport* StatsCollector::AddCertificateReports( |
const rtc::SSLCertificate* cert) { |
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
+ RTC_DCHECK(session_->signaling_thread()->IsCurrent()); |
// Produces a chain of StatsReports representing this certificate and the rest |
// of its chain, and adds those reports to |reports_|. The return value is |
// the id of the leaf report. The provided cert must be non-null, so at least |
@@ -669,18 +668,18 @@ |
} |
void StatsCollector::ExtractSessionInfo() { |
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
+ RTC_DCHECK(session_->signaling_thread()->IsCurrent()); |
// Extract information from the base session. |
StatsReport::Id id(StatsReport::NewTypedId( |
- StatsReport::kStatsReportTypeSession, pc_->session()->id())); |
+ StatsReport::kStatsReportTypeSession, session_->id())); |
StatsReport* report = reports_.ReplaceOrAddNew(id); |
report->set_timestamp(stats_gathering_started_); |
report->AddBoolean(StatsReport::kStatsValueNameInitiator, |
- pc_->session()->initiator()); |
+ session_->initiator()); |
cricket::SessionStats stats; |
- if (!pc_->session()->GetTransportStats(&stats)) { |
+ if (!session_->GetTransportStats(&stats)) { |
return; |
} |
@@ -699,16 +698,16 @@ |
// |
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 (session_->GetLocalCertificate(transport_iter.second.transport_name, |
+ &certificate)) { |
StatsReport* r = AddCertificateReports(&(certificate->ssl_certificate())); |
if (r) |
local_cert_report_id = r->id(); |
} |
rtc::scoped_ptr<rtc::SSLCertificate> cert; |
- if (pc_->session()->GetRemoteSSLCertificate( |
- transport_iter.second.transport_name, cert.accept())) { |
+ if (session_->GetRemoteSSLCertificate(transport_iter.second.transport_name, |
+ cert.accept())) { |
StatsReport* r = AddCertificateReports(cert.get()); |
if (r) |
remote_cert_report_id = r->id(); |
@@ -759,13 +758,13 @@ |
} |
void StatsCollector::ExtractVoiceInfo() { |
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
- |
- if (!pc_->session()->voice_channel()) { |
+ RTC_DCHECK(session_->signaling_thread()->IsCurrent()); |
+ |
+ if (!session_->voice_channel()) { |
return; |
} |
cricket::VoiceMediaInfo voice_info; |
- if (!pc_->session()->voice_channel()->GetStats(&voice_info)) { |
+ if (!session_->voice_channel()->GetStats(&voice_info)) { |
LOG(LS_ERROR) << "Failed to get voice channel stats."; |
return; |
} |
@@ -774,11 +773,11 @@ |
// results back to the signaling thread, where we can add data to the reports. |
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; |
- StatsReport::Id transport_id(GetTransportIdFromProxy( |
- proxy_to_transport_, pc_->session()->voice_channel()->content_name())); |
+ StatsReport::Id transport_id(GetTransportIdFromProxy(proxy_to_transport_, |
+ session_->voice_channel()->content_name())); |
if (!transport_id.get()) { |
LOG(LS_ERROR) << "Failed to get transport name for proxy " |
- << pc_->session()->voice_channel()->content_name(); |
+ << session_->voice_channel()->content_name(); |
return; |
} |
@@ -792,13 +791,13 @@ |
void StatsCollector::ExtractVideoInfo( |
PeerConnectionInterface::StatsOutputLevel level) { |
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
- |
- if (!pc_->session()->video_channel()) |
+ RTC_DCHECK(session_->signaling_thread()->IsCurrent()); |
+ |
+ if (!session_->video_channel()) |
return; |
cricket::VideoMediaInfo video_info; |
- if (!pc_->session()->video_channel()->GetStats(&video_info)) { |
+ if (!session_->video_channel()->GetStats(&video_info)) { |
LOG(LS_ERROR) << "Failed to get video channel stats."; |
return; |
} |
@@ -807,11 +806,11 @@ |
// results back to the signaling thread, where we can add data to the reports. |
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; |
- StatsReport::Id transport_id(GetTransportIdFromProxy( |
- proxy_to_transport_, pc_->session()->video_channel()->content_name())); |
+ StatsReport::Id transport_id(GetTransportIdFromProxy(proxy_to_transport_, |
+ session_->video_channel()->content_name())); |
if (!transport_id.get()) { |
LOG(LS_ERROR) << "Failed to get transport name for proxy " |
- << pc_->session()->video_channel()->content_name(); |
+ << session_->video_channel()->content_name(); |
return; |
} |
ExtractStatsFromList(video_info.receivers, transport_id, this, |
@@ -829,11 +828,12 @@ |
} |
void StatsCollector::ExtractDataInfo() { |
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
+ RTC_DCHECK(session_->signaling_thread()->IsCurrent()); |
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; |
- for (const auto& dc : pc_->sctp_data_channels()) { |
+ for (const auto& dc : |
+ session_->mediastream_signaling()->sctp_data_channels()) { |
StatsReport::Id id(StatsReport::NewTypedIntId( |
StatsReport::kStatsReportTypeDataChannel, dc->id())); |
StatsReport* report = reports_.ReplaceOrAddNew(id); |
@@ -849,14 +849,14 @@ |
StatsReport* StatsCollector::GetReport(const StatsReport::StatsType& type, |
const std::string& id, |
StatsReport::Direction direction) { |
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
+ RTC_DCHECK(session_->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(session_->signaling_thread()->IsCurrent()); |
// Loop through the existing local audio tracks. |
for (const auto& it : local_audio_tracks_) { |
AudioTrackInterface* track = it.first; |
@@ -884,7 +884,7 @@ |
void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track, |
StatsReport* report) { |
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
+ RTC_DCHECK(session_->signaling_thread()->IsCurrent()); |
RTC_DCHECK(track != NULL); |
int signal_level = 0; |
@@ -907,16 +907,16 @@ |
bool StatsCollector::GetTrackIdBySsrc(uint32_t ssrc, |
std::string* track_id, |
StatsReport::Direction direction) { |
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
+ RTC_DCHECK(session_->signaling_thread()->IsCurrent()); |
if (direction == StatsReport::kSend) { |
- if (!pc_->session()->GetLocalTrackIdBySsrc(ssrc, track_id)) { |
+ if (!session_->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 (!session_->GetRemoteTrackIdBySsrc(ssrc, track_id)) { |
LOG(LS_WARNING) << "The SSRC " << ssrc |
<< " is not associated with a receiving track"; |
return false; |
@@ -927,7 +927,7 @@ |
} |
void StatsCollector::UpdateTrackReports() { |
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); |
+ RTC_DCHECK(session_->signaling_thread()->IsCurrent()); |
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; |