Change StatsCollector to use DCHECK instead of ASSERT.
R=henrika@webrtc.org Review URL: https://webrtc-codereview.appspot.com/46579004 Cr-Commit-Position: refs/heads/master@{#8729} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8729 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
eed2fcaa76
commit
4b89aa03bb
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "talk/session/media/channel.h"
|
#include "talk/session/media/channel.h"
|
||||||
#include "webrtc/base/base64.h"
|
#include "webrtc/base/base64.h"
|
||||||
|
#include "webrtc/base/checks.h"
|
||||||
#include "webrtc/base/scoped_ptr.h"
|
#include "webrtc/base/scoped_ptr.h"
|
||||||
#include "webrtc/base/timing.h"
|
#include "webrtc/base/timing.h"
|
||||||
|
|
||||||
@ -248,7 +249,7 @@ void ExtractStats(const cricket::BandwidthEstimationInfo& info,
|
|||||||
double stats_gathering_started,
|
double stats_gathering_started,
|
||||||
PeerConnectionInterface::StatsOutputLevel level,
|
PeerConnectionInterface::StatsOutputLevel level,
|
||||||
StatsReport* report) {
|
StatsReport* report) {
|
||||||
ASSERT(report->type() == StatsReport::kStatsReportTypeBwe);
|
DCHECK(report->type() == StatsReport::kStatsReportTypeBwe);
|
||||||
|
|
||||||
report->set_timestamp(stats_gathering_started);
|
report->set_timestamp(stats_gathering_started);
|
||||||
const IntForAdd ints[] = {
|
const IntForAdd ints[] = {
|
||||||
@ -319,7 +320,7 @@ const char* IceCandidateTypeToStatsType(const std::string& candidate_type) {
|
|||||||
if (candidate_type == cricket::RELAY_PORT_TYPE) {
|
if (candidate_type == cricket::RELAY_PORT_TYPE) {
|
||||||
return STATSREPORT_RELAY_PORT_TYPE;
|
return STATSREPORT_RELAY_PORT_TYPE;
|
||||||
}
|
}
|
||||||
ASSERT(false);
|
DCHECK(false);
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,7 +339,7 @@ const char* AdapterTypeToStatsType(rtc::AdapterType type) {
|
|||||||
case rtc::ADAPTER_TYPE_LOOPBACK:
|
case rtc::ADAPTER_TYPE_LOOPBACK:
|
||||||
return STATSREPORT_ADAPTER_TYPE_LOOPBACK;
|
return STATSREPORT_ADAPTER_TYPE_LOOPBACK;
|
||||||
default:
|
default:
|
||||||
ASSERT(false);
|
DCHECK(false);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -346,11 +347,11 @@ const char* AdapterTypeToStatsType(rtc::AdapterType type) {
|
|||||||
StatsCollector::StatsCollector(WebRtcSession* session)
|
StatsCollector::StatsCollector(WebRtcSession* session)
|
||||||
: session_(session),
|
: session_(session),
|
||||||
stats_gathering_started_(0) {
|
stats_gathering_started_(0) {
|
||||||
ASSERT(session_);
|
DCHECK(session_);
|
||||||
}
|
}
|
||||||
|
|
||||||
StatsCollector::~StatsCollector() {
|
StatsCollector::~StatsCollector() {
|
||||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||||
}
|
}
|
||||||
|
|
||||||
double StatsCollector::GetTimeNow() {
|
double StatsCollector::GetTimeNow() {
|
||||||
@ -360,8 +361,8 @@ double StatsCollector::GetTimeNow() {
|
|||||||
// Adds a MediaStream with tracks that can be used as a |selector| in a call
|
// Adds a MediaStream with tracks that can be used as a |selector| in a call
|
||||||
// to GetStats.
|
// to GetStats.
|
||||||
void StatsCollector::AddStream(MediaStreamInterface* stream) {
|
void StatsCollector::AddStream(MediaStreamInterface* stream) {
|
||||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||||
ASSERT(stream != NULL);
|
DCHECK(stream != NULL);
|
||||||
|
|
||||||
CreateTrackReports<AudioTrackVector>(stream->GetAudioTracks(),
|
CreateTrackReports<AudioTrackVector>(stream->GetAudioTracks(),
|
||||||
&reports_);
|
&reports_);
|
||||||
@ -371,11 +372,11 @@ void StatsCollector::AddStream(MediaStreamInterface* stream) {
|
|||||||
|
|
||||||
void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
|
void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
|
||||||
uint32 ssrc) {
|
uint32 ssrc) {
|
||||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||||
ASSERT(audio_track != NULL);
|
DCHECK(audio_track != NULL);
|
||||||
#if ENABLE_DEBUG
|
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
|
||||||
for (const auto& track : local_audio_tracks_)
|
for (const auto& track : local_audio_tracks_)
|
||||||
ASSERT(track.first != audio_track || track.second != ssrc);
|
DCHECK(track.first != audio_track || track.second != ssrc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
local_audio_tracks_.push_back(std::make_pair(audio_track, ssrc));
|
local_audio_tracks_.push_back(std::make_pair(audio_track, ssrc));
|
||||||
@ -393,7 +394,7 @@ void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
|
|||||||
|
|
||||||
void StatsCollector::RemoveLocalAudioTrack(AudioTrackInterface* audio_track,
|
void StatsCollector::RemoveLocalAudioTrack(AudioTrackInterface* audio_track,
|
||||||
uint32 ssrc) {
|
uint32 ssrc) {
|
||||||
ASSERT(audio_track != NULL);
|
DCHECK(audio_track != NULL);
|
||||||
local_audio_tracks_.erase(std::remove_if(local_audio_tracks_.begin(),
|
local_audio_tracks_.erase(std::remove_if(local_audio_tracks_.begin(),
|
||||||
local_audio_tracks_.end(),
|
local_audio_tracks_.end(),
|
||||||
[audio_track, ssrc](const LocalAudioTrackVector::value_type& track) {
|
[audio_track, ssrc](const LocalAudioTrackVector::value_type& track) {
|
||||||
@ -403,9 +404,9 @@ void StatsCollector::RemoveLocalAudioTrack(AudioTrackInterface* audio_track,
|
|||||||
|
|
||||||
void StatsCollector::GetStats(MediaStreamTrackInterface* track,
|
void StatsCollector::GetStats(MediaStreamTrackInterface* track,
|
||||||
StatsReports* reports) {
|
StatsReports* reports) {
|
||||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||||
ASSERT(reports != NULL);
|
DCHECK(reports != NULL);
|
||||||
ASSERT(reports->empty());
|
DCHECK(reports->empty());
|
||||||
|
|
||||||
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
|
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
|
||||||
|
|
||||||
@ -443,7 +444,7 @@ void StatsCollector::GetStats(MediaStreamTrackInterface* track,
|
|||||||
|
|
||||||
void
|
void
|
||||||
StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) {
|
StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) {
|
||||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||||
double time_now = GetTimeNow();
|
double time_now = GetTimeNow();
|
||||||
// Calls to UpdateStats() that occur less than kMinGatherStatsPeriod number of
|
// Calls to UpdateStats() that occur less than kMinGatherStatsPeriod number of
|
||||||
// ms apart will be ignored.
|
// ms apart will be ignored.
|
||||||
@ -473,7 +474,7 @@ StatsReport* StatsCollector::PrepareReport(
|
|||||||
uint32 ssrc,
|
uint32 ssrc,
|
||||||
const StatsReport::Id& transport_id,
|
const StatsReport::Id& transport_id,
|
||||||
StatsReport::Direction direction) {
|
StatsReport::Direction direction) {
|
||||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||||
StatsReport::Id id(StatsReport::NewIdWithDirection(
|
StatsReport::Id id(StatsReport::NewIdWithDirection(
|
||||||
local ? StatsReport::kStatsReportTypeSsrc :
|
local ? StatsReport::kStatsReportTypeSsrc :
|
||||||
StatsReport::kStatsReportTypeRemoteSsrc,
|
StatsReport::kStatsReportTypeRemoteSsrc,
|
||||||
@ -512,7 +513,7 @@ StatsReport* StatsCollector::PrepareReport(
|
|||||||
|
|
||||||
StatsReport* StatsCollector::AddOneCertificateReport(
|
StatsReport* StatsCollector::AddOneCertificateReport(
|
||||||
const rtc::SSLCertificate* cert, const StatsReport* issuer) {
|
const rtc::SSLCertificate* cert, const StatsReport* issuer) {
|
||||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||||
|
|
||||||
// TODO(bemasc): Move this computation to a helper class that caches these
|
// 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
|
// values to reduce CPU use in GetStats. This will require adding a fast
|
||||||
@ -555,13 +556,13 @@ StatsReport* StatsCollector::AddOneCertificateReport(
|
|||||||
|
|
||||||
StatsReport* StatsCollector::AddCertificateReports(
|
StatsReport* StatsCollector::AddCertificateReports(
|
||||||
const rtc::SSLCertificate* cert) {
|
const rtc::SSLCertificate* cert) {
|
||||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||||
// Produces a chain of StatsReports representing this certificate and the rest
|
// Produces a chain of StatsReports representing this certificate and the rest
|
||||||
// of its chain, and adds those reports to |reports_|. The return value is
|
// 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
|
// the id of the leaf report. The provided cert must be non-null, so at least
|
||||||
// one report will always be provided and the returned string will never be
|
// one report will always be provided and the returned string will never be
|
||||||
// empty.
|
// empty.
|
||||||
ASSERT(cert != NULL);
|
DCHECK(cert != NULL);
|
||||||
|
|
||||||
StatsReport* issuer = nullptr;
|
StatsReport* issuer = nullptr;
|
||||||
rtc::scoped_ptr<rtc::SSLCertChain> chain;
|
rtc::scoped_ptr<rtc::SSLCertChain> chain;
|
||||||
@ -655,7 +656,7 @@ StatsReport* StatsCollector::AddCandidateReport(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StatsCollector::ExtractSessionInfo() {
|
void StatsCollector::ExtractSessionInfo() {
|
||||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||||
|
|
||||||
// Extract information from the base session.
|
// Extract information from the base session.
|
||||||
StatsReport::Id id(StatsReport::NewTypedId(
|
StatsReport::Id id(StatsReport::NewTypedId(
|
||||||
@ -747,7 +748,7 @@ void StatsCollector::ExtractSessionInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StatsCollector::ExtractVoiceInfo() {
|
void StatsCollector::ExtractVoiceInfo() {
|
||||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||||
|
|
||||||
if (!session_->voice_channel()) {
|
if (!session_->voice_channel()) {
|
||||||
return;
|
return;
|
||||||
@ -780,7 +781,7 @@ void StatsCollector::ExtractVoiceInfo() {
|
|||||||
|
|
||||||
void StatsCollector::ExtractVideoInfo(
|
void StatsCollector::ExtractVideoInfo(
|
||||||
PeerConnectionInterface::StatsOutputLevel level) {
|
PeerConnectionInterface::StatsOutputLevel level) {
|
||||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||||
|
|
||||||
if (!session_->video_channel())
|
if (!session_->video_channel())
|
||||||
return;
|
return;
|
||||||
@ -817,7 +818,7 @@ void StatsCollector::ExtractVideoInfo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StatsCollector::ExtractDataInfo() {
|
void StatsCollector::ExtractDataInfo() {
|
||||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||||
|
|
||||||
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
|
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
|
||||||
|
|
||||||
@ -838,14 +839,14 @@ void StatsCollector::ExtractDataInfo() {
|
|||||||
StatsReport* StatsCollector::GetReport(const StatsReport::StatsType& type,
|
StatsReport* StatsCollector::GetReport(const StatsReport::StatsType& type,
|
||||||
const std::string& id,
|
const std::string& id,
|
||||||
StatsReport::Direction direction) {
|
StatsReport::Direction direction) {
|
||||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||||
ASSERT(type == StatsReport::kStatsReportTypeSsrc ||
|
DCHECK(type == StatsReport::kStatsReportTypeSsrc ||
|
||||||
type == StatsReport::kStatsReportTypeRemoteSsrc);
|
type == StatsReport::kStatsReportTypeRemoteSsrc);
|
||||||
return reports_.Find(StatsReport::NewIdWithDirection(type, id, direction));
|
return reports_.Find(StatsReport::NewIdWithDirection(type, id, direction));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsCollector::UpdateStatsFromExistingLocalAudioTracks() {
|
void StatsCollector::UpdateStatsFromExistingLocalAudioTracks() {
|
||||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||||
// Loop through the existing local audio tracks.
|
// Loop through the existing local audio tracks.
|
||||||
for (const auto& it : local_audio_tracks_) {
|
for (const auto& it : local_audio_tracks_) {
|
||||||
AudioTrackInterface* track = it.first;
|
AudioTrackInterface* track = it.first;
|
||||||
@ -872,8 +873,8 @@ void StatsCollector::UpdateStatsFromExistingLocalAudioTracks() {
|
|||||||
|
|
||||||
void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
|
void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
|
||||||
StatsReport* report) {
|
StatsReport* report) {
|
||||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||||
ASSERT(track != NULL);
|
DCHECK(track != NULL);
|
||||||
|
|
||||||
int signal_level = 0;
|
int signal_level = 0;
|
||||||
if (!track->GetSignalLevel(&signal_level))
|
if (!track->GetSignalLevel(&signal_level))
|
||||||
@ -894,7 +895,7 @@ void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
|
|||||||
|
|
||||||
bool StatsCollector::GetTrackIdBySsrc(uint32 ssrc, std::string* track_id,
|
bool StatsCollector::GetTrackIdBySsrc(uint32 ssrc, std::string* track_id,
|
||||||
StatsReport::Direction direction) {
|
StatsReport::Direction direction) {
|
||||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||||
if (direction == StatsReport::kSend) {
|
if (direction == StatsReport::kSend) {
|
||||||
if (!session_->GetLocalTrackIdBySsrc(ssrc, track_id)) {
|
if (!session_->GetLocalTrackIdBySsrc(ssrc, track_id)) {
|
||||||
LOG(LS_WARNING) << "The SSRC " << ssrc
|
LOG(LS_WARNING) << "The SSRC " << ssrc
|
||||||
@ -902,7 +903,7 @@ bool StatsCollector::GetTrackIdBySsrc(uint32 ssrc, std::string* track_id,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ASSERT(direction == StatsReport::kReceive);
|
DCHECK(direction == StatsReport::kReceive);
|
||||||
if (!session_->GetRemoteTrackIdBySsrc(ssrc, track_id)) {
|
if (!session_->GetRemoteTrackIdBySsrc(ssrc, track_id)) {
|
||||||
LOG(LS_WARNING) << "The SSRC " << ssrc
|
LOG(LS_WARNING) << "The SSRC " << ssrc
|
||||||
<< " is not associated with a receiving track";
|
<< " is not associated with a receiving track";
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
// generate strongly typed inline C++ code that forces the correct type to be
|
// generate strongly typed inline C++ code that forces the correct type to be
|
||||||
// used for a given name at compile time.
|
// used for a given name at compile time.
|
||||||
|
|
||||||
using rtc::RefCountedObject;
|
using rtc::RefCountedObject;
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace {
|
namespace {
|
||||||
|
Loading…
Reference in New Issue
Block a user