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 "webrtc/base/base64.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/timing.h"
|
||||
|
||||
@ -248,7 +249,7 @@ void ExtractStats(const cricket::BandwidthEstimationInfo& info,
|
||||
double stats_gathering_started,
|
||||
PeerConnectionInterface::StatsOutputLevel level,
|
||||
StatsReport* report) {
|
||||
ASSERT(report->type() == StatsReport::kStatsReportTypeBwe);
|
||||
DCHECK(report->type() == StatsReport::kStatsReportTypeBwe);
|
||||
|
||||
report->set_timestamp(stats_gathering_started);
|
||||
const IntForAdd ints[] = {
|
||||
@ -319,7 +320,7 @@ const char* IceCandidateTypeToStatsType(const std::string& candidate_type) {
|
||||
if (candidate_type == cricket::RELAY_PORT_TYPE) {
|
||||
return STATSREPORT_RELAY_PORT_TYPE;
|
||||
}
|
||||
ASSERT(false);
|
||||
DCHECK(false);
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
@ -338,7 +339,7 @@ const char* AdapterTypeToStatsType(rtc::AdapterType type) {
|
||||
case rtc::ADAPTER_TYPE_LOOPBACK:
|
||||
return STATSREPORT_ADAPTER_TYPE_LOOPBACK;
|
||||
default:
|
||||
ASSERT(false);
|
||||
DCHECK(false);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@ -346,11 +347,11 @@ const char* AdapterTypeToStatsType(rtc::AdapterType type) {
|
||||
StatsCollector::StatsCollector(WebRtcSession* session)
|
||||
: session_(session),
|
||||
stats_gathering_started_(0) {
|
||||
ASSERT(session_);
|
||||
DCHECK(session_);
|
||||
}
|
||||
|
||||
StatsCollector::~StatsCollector() {
|
||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
||||
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||
}
|
||||
|
||||
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
|
||||
// to GetStats.
|
||||
void StatsCollector::AddStream(MediaStreamInterface* stream) {
|
||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
||||
ASSERT(stream != NULL);
|
||||
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||
DCHECK(stream != NULL);
|
||||
|
||||
CreateTrackReports<AudioTrackVector>(stream->GetAudioTracks(),
|
||||
&reports_);
|
||||
@ -371,11 +372,11 @@ void StatsCollector::AddStream(MediaStreamInterface* stream) {
|
||||
|
||||
void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
|
||||
uint32 ssrc) {
|
||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
||||
ASSERT(audio_track != NULL);
|
||||
#if ENABLE_DEBUG
|
||||
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||
DCHECK(audio_track != NULL);
|
||||
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
|
||||
for (const auto& track : local_audio_tracks_)
|
||||
ASSERT(track.first != audio_track || track.second != ssrc);
|
||||
DCHECK(track.first != audio_track || track.second != ssrc);
|
||||
#endif
|
||||
|
||||
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,
|
||||
uint32 ssrc) {
|
||||
ASSERT(audio_track != NULL);
|
||||
DCHECK(audio_track != NULL);
|
||||
local_audio_tracks_.erase(std::remove_if(local_audio_tracks_.begin(),
|
||||
local_audio_tracks_.end(),
|
||||
[audio_track, ssrc](const LocalAudioTrackVector::value_type& track) {
|
||||
@ -403,9 +404,9 @@ void StatsCollector::RemoveLocalAudioTrack(AudioTrackInterface* audio_track,
|
||||
|
||||
void StatsCollector::GetStats(MediaStreamTrackInterface* track,
|
||||
StatsReports* reports) {
|
||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
||||
ASSERT(reports != NULL);
|
||||
ASSERT(reports->empty());
|
||||
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||
DCHECK(reports != NULL);
|
||||
DCHECK(reports->empty());
|
||||
|
||||
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
|
||||
|
||||
@ -443,7 +444,7 @@ void StatsCollector::GetStats(MediaStreamTrackInterface* track,
|
||||
|
||||
void
|
||||
StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) {
|
||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
||||
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||
double time_now = GetTimeNow();
|
||||
// Calls to UpdateStats() that occur less than kMinGatherStatsPeriod number of
|
||||
// ms apart will be ignored.
|
||||
@ -473,7 +474,7 @@ StatsReport* StatsCollector::PrepareReport(
|
||||
uint32 ssrc,
|
||||
const StatsReport::Id& transport_id,
|
||||
StatsReport::Direction direction) {
|
||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
||||
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||
StatsReport::Id id(StatsReport::NewIdWithDirection(
|
||||
local ? StatsReport::kStatsReportTypeSsrc :
|
||||
StatsReport::kStatsReportTypeRemoteSsrc,
|
||||
@ -512,7 +513,7 @@ StatsReport* StatsCollector::PrepareReport(
|
||||
|
||||
StatsReport* StatsCollector::AddOneCertificateReport(
|
||||
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
|
||||
// values to reduce CPU use in GetStats. This will require adding a fast
|
||||
@ -555,13 +556,13 @@ StatsReport* StatsCollector::AddOneCertificateReport(
|
||||
|
||||
StatsReport* StatsCollector::AddCertificateReports(
|
||||
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
|
||||
// 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
|
||||
// one report will always be provided and the returned string will never be
|
||||
// empty.
|
||||
ASSERT(cert != NULL);
|
||||
DCHECK(cert != NULL);
|
||||
|
||||
StatsReport* issuer = nullptr;
|
||||
rtc::scoped_ptr<rtc::SSLCertChain> chain;
|
||||
@ -655,7 +656,7 @@ StatsReport* StatsCollector::AddCandidateReport(
|
||||
}
|
||||
|
||||
void StatsCollector::ExtractSessionInfo() {
|
||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
||||
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||
|
||||
// Extract information from the base session.
|
||||
StatsReport::Id id(StatsReport::NewTypedId(
|
||||
@ -747,7 +748,7 @@ void StatsCollector::ExtractSessionInfo() {
|
||||
}
|
||||
|
||||
void StatsCollector::ExtractVoiceInfo() {
|
||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
||||
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||
|
||||
if (!session_->voice_channel()) {
|
||||
return;
|
||||
@ -780,7 +781,7 @@ void StatsCollector::ExtractVoiceInfo() {
|
||||
|
||||
void StatsCollector::ExtractVideoInfo(
|
||||
PeerConnectionInterface::StatsOutputLevel level) {
|
||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
||||
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||
|
||||
if (!session_->video_channel())
|
||||
return;
|
||||
@ -817,7 +818,7 @@ void StatsCollector::ExtractVideoInfo(
|
||||
}
|
||||
|
||||
void StatsCollector::ExtractDataInfo() {
|
||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
||||
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||
|
||||
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
|
||||
|
||||
@ -838,14 +839,14 @@ void StatsCollector::ExtractDataInfo() {
|
||||
StatsReport* StatsCollector::GetReport(const StatsReport::StatsType& type,
|
||||
const std::string& id,
|
||||
StatsReport::Direction direction) {
|
||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
||||
ASSERT(type == StatsReport::kStatsReportTypeSsrc ||
|
||||
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||
DCHECK(type == StatsReport::kStatsReportTypeSsrc ||
|
||||
type == StatsReport::kStatsReportTypeRemoteSsrc);
|
||||
return reports_.Find(StatsReport::NewIdWithDirection(type, id, direction));
|
||||
}
|
||||
|
||||
void StatsCollector::UpdateStatsFromExistingLocalAudioTracks() {
|
||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
||||
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||
// Loop through the existing local audio tracks.
|
||||
for (const auto& it : local_audio_tracks_) {
|
||||
AudioTrackInterface* track = it.first;
|
||||
@ -872,8 +873,8 @@ void StatsCollector::UpdateStatsFromExistingLocalAudioTracks() {
|
||||
|
||||
void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
|
||||
StatsReport* report) {
|
||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
||||
ASSERT(track != NULL);
|
||||
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||
DCHECK(track != NULL);
|
||||
|
||||
int signal_level = 0;
|
||||
if (!track->GetSignalLevel(&signal_level))
|
||||
@ -894,7 +895,7 @@ void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
|
||||
|
||||
bool StatsCollector::GetTrackIdBySsrc(uint32 ssrc, std::string* track_id,
|
||||
StatsReport::Direction direction) {
|
||||
ASSERT(session_->signaling_thread()->IsCurrent());
|
||||
DCHECK(session_->signaling_thread()->IsCurrent());
|
||||
if (direction == StatsReport::kSend) {
|
||||
if (!session_->GetLocalTrackIdBySsrc(ssrc, track_id)) {
|
||||
LOG(LS_WARNING) << "The SSRC " << ssrc
|
||||
@ -902,7 +903,7 @@ bool StatsCollector::GetTrackIdBySsrc(uint32 ssrc, std::string* track_id,
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
ASSERT(direction == StatsReport::kReceive);
|
||||
DCHECK(direction == StatsReport::kReceive);
|
||||
if (!session_->GetRemoteTrackIdBySsrc(ssrc, track_id)) {
|
||||
LOG(LS_WARNING) << "The SSRC " << ssrc
|
||||
<< " is not associated with a receiving track";
|
||||
|
@ -37,7 +37,7 @@
|
||||
// generate strongly typed inline C++ code that forces the correct type to be
|
||||
// used for a given name at compile time.
|
||||
|
||||
using rtc::RefCountedObject;
|
||||
using rtc::RefCountedObject;
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
Loading…
Reference in New Issue
Block a user