| Index: talk/app/webrtc/statscollector.cc
|
| diff --git a/talk/app/webrtc/statscollector.cc b/talk/app/webrtc/statscollector.cc
|
| index 5b527ecc73d4ef1372dd28b30ccc347c096fc2c1..9ba7da808d995169cfc35f05c9806d6b2ed167dc 100644
|
| --- a/talk/app/webrtc/statscollector.cc
|
| +++ b/talk/app/webrtc/statscollector.cc
|
| @@ -30,6 +30,7 @@
|
| #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"
|
| @@ -356,14 +357,13 @@ const char* AdapterTypeToStatsType(rtc::AdapterType type) {
|
| }
|
| }
|
|
|
| -StatsCollector::StatsCollector(WebRtcSession* session)
|
| - : session_(session),
|
| - stats_gathering_started_(0) {
|
| - RTC_DCHECK(session_);
|
| +StatsCollector::StatsCollector(PeerConnection* pc)
|
| + : pc_(pc), stats_gathering_started_(0) {
|
| + RTC_DCHECK(pc_);
|
| }
|
|
|
| StatsCollector::~StatsCollector() {
|
| - RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
| + RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
| }
|
|
|
| double StatsCollector::GetTimeNow() {
|
| @@ -373,7 +373,7 @@ double StatsCollector::GetTimeNow() {
|
| // Adds a MediaStream with tracks that can be used as a |selector| in a call
|
| // to GetStats.
|
| void StatsCollector::AddStream(MediaStreamInterface* stream) {
|
| - RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
| + RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
| RTC_DCHECK(stream != NULL);
|
|
|
| CreateTrackReports<AudioTrackVector>(stream->GetAudioTracks(),
|
| @@ -384,7 +384,7 @@ void StatsCollector::AddStream(MediaStreamInterface* stream) {
|
|
|
| void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
|
| uint32_t ssrc) {
|
| - RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
| + RTC_DCHECK(pc_->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::RemoveLocalAudioTrack(AudioTrackInterface* audio_track,
|
|
|
| void StatsCollector::GetStats(MediaStreamTrackInterface* track,
|
| StatsReports* reports) {
|
| - RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
| + RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
| RTC_DCHECK(reports != NULL);
|
| RTC_DCHECK(reports->empty());
|
|
|
| @@ -430,7 +430,7 @@ void StatsCollector::GetStats(MediaStreamTrackInterface* track,
|
| }
|
|
|
| StatsReport* report = reports_.Find(StatsReport::NewTypedId(
|
| - StatsReport::kStatsReportTypeSession, session_->id()));
|
| + StatsReport::kStatsReportTypeSession, pc_->session()->id()));
|
| if (report)
|
| reports->push_back(report);
|
|
|
| @@ -456,7 +456,7 @@ void StatsCollector::GetStats(MediaStreamTrackInterface* track,
|
|
|
| void
|
| StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) {
|
| - RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
| + RTC_DCHECK(pc_->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 @@ StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) {
|
| }
|
| stats_gathering_started_ = time_now;
|
|
|
| - if (session_) {
|
| + if (pc_->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,11 +482,12 @@ StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) {
|
| }
|
| }
|
|
|
| -StatsReport* StatsCollector::PrepareReport(bool local,
|
| - uint32_t ssrc,
|
| - const StatsReport::Id& transport_id,
|
| - StatsReport::Direction direction) {
|
| - RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
| +StatsReport* StatsCollector::PrepareReport(
|
| + bool local,
|
| + uint32_t ssrc,
|
| + const StatsReport::Id& transport_id,
|
| + StatsReport::Direction direction) {
|
| + RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
| StatsReport::Id id(StatsReport::NewIdWithDirection(
|
| local ? StatsReport::kStatsReportTypeSsrc
|
| : StatsReport::kStatsReportTypeRemoteSsrc,
|
| @@ -525,7 +526,7 @@ StatsReport* StatsCollector::PrepareReport(bool local,
|
|
|
| StatsReport* StatsCollector::AddOneCertificateReport(
|
| const rtc::SSLCertificate* cert, const StatsReport* issuer) {
|
| - RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
| + RTC_DCHECK(pc_->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
|
| @@ -568,7 +569,7 @@ StatsReport* StatsCollector::AddOneCertificateReport(
|
|
|
| StatsReport* StatsCollector::AddCertificateReports(
|
| const rtc::SSLCertificate* cert) {
|
| - RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
| + RTC_DCHECK(pc_->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
|
| @@ -668,18 +669,18 @@ StatsReport* StatsCollector::AddCandidateReport(
|
| }
|
|
|
| void StatsCollector::ExtractSessionInfo() {
|
| - RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
| + RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
|
|
| // Extract information from the base session.
|
| StatsReport::Id id(StatsReport::NewTypedId(
|
| - StatsReport::kStatsReportTypeSession, session_->id()));
|
| + StatsReport::kStatsReportTypeSession, pc_->session()->id()));
|
| StatsReport* report = reports_.ReplaceOrAddNew(id);
|
| report->set_timestamp(stats_gathering_started_);
|
| report->AddBoolean(StatsReport::kStatsValueNameInitiator,
|
| - session_->initiator());
|
| + pc_->session()->initiator());
|
|
|
| cricket::SessionStats stats;
|
| - if (!session_->GetTransportStats(&stats)) {
|
| + if (!pc_->session()->GetTransportStats(&stats)) {
|
| return;
|
| }
|
|
|
| @@ -698,16 +699,16 @@ void StatsCollector::ExtractSessionInfo() {
|
| //
|
| StatsReport::Id local_cert_report_id, remote_cert_report_id;
|
| rtc::scoped_refptr<rtc::RTCCertificate> certificate;
|
| - if (session_->GetLocalCertificate(transport_iter.second.transport_name,
|
| - &certificate)) {
|
| + if (pc_->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 (session_->GetRemoteSSLCertificate(transport_iter.second.transport_name,
|
| - cert.accept())) {
|
| + if (pc_->session()->GetRemoteSSLCertificate(
|
| + transport_iter.second.transport_name, cert.accept())) {
|
| StatsReport* r = AddCertificateReports(cert.get());
|
| if (r)
|
| remote_cert_report_id = r->id();
|
| @@ -758,13 +759,13 @@ void StatsCollector::ExtractSessionInfo() {
|
| }
|
|
|
| void StatsCollector::ExtractVoiceInfo() {
|
| - RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
| + RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
|
|
| - if (!session_->voice_channel()) {
|
| + if (!pc_->session()->voice_channel()) {
|
| return;
|
| }
|
| cricket::VoiceMediaInfo voice_info;
|
| - if (!session_->voice_channel()->GetStats(&voice_info)) {
|
| + if (!pc_->session()->voice_channel()->GetStats(&voice_info)) {
|
| LOG(LS_ERROR) << "Failed to get voice channel stats.";
|
| return;
|
| }
|
| @@ -773,11 +774,11 @@ void StatsCollector::ExtractVoiceInfo() {
|
| // 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_,
|
| - session_->voice_channel()->content_name()));
|
| + StatsReport::Id transport_id(GetTransportIdFromProxy(
|
| + proxy_to_transport_, pc_->session()->voice_channel()->content_name()));
|
| if (!transport_id.get()) {
|
| LOG(LS_ERROR) << "Failed to get transport name for proxy "
|
| - << session_->voice_channel()->content_name();
|
| + << pc_->session()->voice_channel()->content_name();
|
| return;
|
| }
|
|
|
| @@ -791,13 +792,13 @@ void StatsCollector::ExtractVoiceInfo() {
|
|
|
| void StatsCollector::ExtractVideoInfo(
|
| PeerConnectionInterface::StatsOutputLevel level) {
|
| - RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
| + RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
|
|
| - if (!session_->video_channel())
|
| + if (!pc_->session()->video_channel())
|
| return;
|
|
|
| cricket::VideoMediaInfo video_info;
|
| - if (!session_->video_channel()->GetStats(&video_info)) {
|
| + if (!pc_->session()->video_channel()->GetStats(&video_info)) {
|
| LOG(LS_ERROR) << "Failed to get video channel stats.";
|
| return;
|
| }
|
| @@ -806,11 +807,11 @@ void StatsCollector::ExtractVideoInfo(
|
| // 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_,
|
| - session_->video_channel()->content_name()));
|
| + StatsReport::Id transport_id(GetTransportIdFromProxy(
|
| + proxy_to_transport_, pc_->session()->video_channel()->content_name()));
|
| if (!transport_id.get()) {
|
| LOG(LS_ERROR) << "Failed to get transport name for proxy "
|
| - << session_->video_channel()->content_name();
|
| + << pc_->session()->video_channel()->content_name();
|
| return;
|
| }
|
| ExtractStatsFromList(video_info.receivers, transport_id, this,
|
| @@ -828,12 +829,11 @@ void StatsCollector::ExtractVideoInfo(
|
| }
|
|
|
| void StatsCollector::ExtractDataInfo() {
|
| - RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
| + RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
|
|
| rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
|
|
|
| - for (const auto& dc :
|
| - session_->mediastream_signaling()->sctp_data_channels()) {
|
| + for (const auto& dc : pc_->sctp_data_channels()) {
|
| StatsReport::Id id(StatsReport::NewTypedIntId(
|
| StatsReport::kStatsReportTypeDataChannel, dc->id()));
|
| StatsReport* report = reports_.ReplaceOrAddNew(id);
|
| @@ -849,14 +849,14 @@ void StatsCollector::ExtractDataInfo() {
|
| StatsReport* StatsCollector::GetReport(const StatsReport::StatsType& type,
|
| const std::string& id,
|
| StatsReport::Direction direction) {
|
| - RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
| + RTC_DCHECK(pc_->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(session_->signaling_thread()->IsCurrent());
|
| + RTC_DCHECK(pc_->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::UpdateStatsFromExistingLocalAudioTracks() {
|
|
|
| void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
|
| StatsReport* report) {
|
| - RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
| + RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
| RTC_DCHECK(track != NULL);
|
|
|
| int signal_level = 0;
|
| @@ -907,16 +907,16 @@ void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
|
| bool StatsCollector::GetTrackIdBySsrc(uint32_t ssrc,
|
| std::string* track_id,
|
| StatsReport::Direction direction) {
|
| - RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
| + RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
| if (direction == StatsReport::kSend) {
|
| - if (!session_->GetLocalTrackIdBySsrc(ssrc, track_id)) {
|
| + if (!pc_->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 (!session_->GetRemoteTrackIdBySsrc(ssrc, track_id)) {
|
| + if (!pc_->session()->GetRemoteTrackIdBySsrc(ssrc, track_id)) {
|
| LOG(LS_WARNING) << "The SSRC " << ssrc
|
| << " is not associated with a receiving track";
|
| return false;
|
| @@ -927,7 +927,7 @@ bool StatsCollector::GetTrackIdBySsrc(uint32_t ssrc,
|
| }
|
|
|
| void StatsCollector::UpdateTrackReports() {
|
| - RTC_DCHECK(session_->signaling_thread()->IsCurrent());
|
| + RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
|
|
|
| rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
|
|
|
|
|