Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: webrtc/api/statscollector.cc

Issue 1713043002: Late initialize MediaController, for less resource i.e. ProcessThread, usage by PeerConnection. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: some comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« webrtc/api/peerconnection.cc ('K') | « webrtc/api/statscollector.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/statscollector.cc
diff --git a/webrtc/api/statscollector.cc b/webrtc/api/statscollector.cc
index ca1548fa0d53531a6af4ea4c2a5b69d4f2a4b8f9..73f32fdcc700c796c87558909f8d6637996545d0 100644
--- a/webrtc/api/statscollector.cc
+++ b/webrtc/api/statscollector.cc
@@ -358,17 +358,18 @@ StatsCollector::StatsCollector(PeerConnection* pc)
}
StatsCollector::~StatsCollector() {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
}
double StatsCollector::GetTimeNow() {
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
return rtc::Timing::WallTimeNow() * rtc::kNumMillisecsPerSec;
}
// 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(signal_thread_checker_.CalledOnValidThread());
RTC_DCHECK(stream != NULL);
CreateTrackReports<AudioTrackVector>(stream->GetAudioTracks(),
@@ -379,7 +380,7 @@ void StatsCollector::AddStream(MediaStreamInterface* stream) {
void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
uint32_t ssrc) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
RTC_DCHECK(audio_track != NULL);
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
for (const auto& track : local_audio_tracks_)
@@ -401,6 +402,7 @@ void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
void StatsCollector::RemoveLocalAudioTrack(AudioTrackInterface* audio_track,
uint32_t ssrc) {
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
RTC_DCHECK(audio_track != NULL);
local_audio_tracks_.erase(std::remove_if(local_audio_tracks_.begin(),
local_audio_tracks_.end(),
@@ -411,7 +413,7 @@ void StatsCollector::RemoveLocalAudioTrack(AudioTrackInterface* audio_track,
void StatsCollector::GetStats(MediaStreamTrackInterface* track,
StatsReports* reports) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
RTC_DCHECK(reports != NULL);
RTC_DCHECK(reports->empty());
@@ -424,6 +426,8 @@ void StatsCollector::GetStats(MediaStreamTrackInterface* track,
return;
}
+ // TODO(solenberg): Need to pull out session id so we have that even when
+ // there is no session.
StatsReport* report = reports_.Find(StatsReport::NewTypedId(
StatsReport::kStatsReportTypeSession, pc_->session()->id()));
if (report)
@@ -451,7 +455,7 @@ void StatsCollector::GetStats(MediaStreamTrackInterface* track,
void
StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
double time_now = GetTimeNow();
// Calls to UpdateStats() that occur less than kMinGatherStatsPeriod number of
// ms apart will be ignored.
@@ -462,6 +466,10 @@ StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) {
}
stats_gathering_started_ = time_now;
+ // TODO(solenberg): Need to use a call which won't auto-create the session!
+ // Likely, this condition needs to go (PC always used to have a WebRtcSession)
+ // and some of the info at the beginning of ExtractSessionInfo is added even
+ // when there isn't a session.
pthatcher1 2016/02/26 21:51:20 I think we can just make this: TODO(pthatcher): M
the sun 2016/02/29 15:58:22 Done.
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
@@ -482,7 +490,7 @@ StatsReport* StatsCollector::PrepareReport(
uint32_t ssrc,
const StatsReport::Id& transport_id,
StatsReport::Direction direction) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
StatsReport::Id id(StatsReport::NewIdWithDirection(
local ? StatsReport::kStatsReportTypeSsrc
: StatsReport::kStatsReportTypeRemoteSsrc,
@@ -521,7 +529,7 @@ StatsReport* StatsCollector::PrepareReport(
StatsReport* StatsCollector::AddOneCertificateReport(
const rtc::SSLCertificate* cert, const StatsReport* issuer) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
// 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
@@ -564,7 +572,7 @@ StatsReport* StatsCollector::AddOneCertificateReport(
StatsReport* StatsCollector::AddCertificateReports(
const rtc::SSLCertificate* cert) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
// 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
@@ -592,6 +600,7 @@ StatsReport* StatsCollector::AddConnectionInfoReport(
const std::string& content_name, int component, int connection_id,
const StatsReport::Id& channel_report_id,
const cricket::ConnectionInfo& info) {
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
StatsReport::Id id(StatsReport::NewCandidatePairId(content_name, component,
connection_id));
StatsReport* report = reports_.ReplaceOrAddNew(id);
@@ -639,6 +648,7 @@ StatsReport* StatsCollector::AddConnectionInfoReport(
StatsReport* StatsCollector::AddCandidateReport(
const cricket::Candidate& candidate,
bool local) {
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
StatsReport::Id id(StatsReport::NewCandidateId(local, candidate.id()));
StatsReport* report = reports_.Find(id);
if (!report) {
@@ -664,7 +674,7 @@ StatsReport* StatsCollector::AddCandidateReport(
}
void StatsCollector::ExtractSessionInfo() {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
// Extract information from the base session.
StatsReport::Id id(StatsReport::NewTypedId(
@@ -757,7 +767,7 @@ void StatsCollector::ExtractSessionInfo() {
}
void StatsCollector::ExtractVoiceInfo() {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
if (!pc_->session()->voice_channel()) {
return;
@@ -790,7 +800,7 @@ void StatsCollector::ExtractVoiceInfo() {
void StatsCollector::ExtractVideoInfo(
PeerConnectionInterface::StatsOutputLevel level) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
if (!pc_->session()->video_channel())
return;
@@ -827,7 +837,7 @@ void StatsCollector::ExtractVideoInfo(
}
void StatsCollector::ExtractDataInfo() {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
@@ -847,14 +857,14 @@ void StatsCollector::ExtractDataInfo() {
StatsReport* StatsCollector::GetReport(const StatsReport::StatsType& type,
const std::string& id,
StatsReport::Direction direction) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
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(signal_thread_checker_.CalledOnValidThread());
// Loop through the existing local audio tracks.
for (const auto& it : local_audio_tracks_) {
AudioTrackInterface* track = it.first;
@@ -882,7 +892,7 @@ void StatsCollector::UpdateStatsFromExistingLocalAudioTracks() {
void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
StatsReport* report) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
RTC_DCHECK(track != NULL);
// Don't overwrite report values if they're not available.
@@ -908,7 +918,7 @@ void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
bool StatsCollector::GetTrackIdBySsrc(uint32_t ssrc,
std::string* track_id,
StatsReport::Direction direction) {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
if (direction == StatsReport::kSend) {
if (!pc_->session()->GetLocalTrackIdBySsrc(ssrc, track_id)) {
LOG(LS_WARNING) << "The SSRC " << ssrc
@@ -928,7 +938,7 @@ bool StatsCollector::GetTrackIdBySsrc(uint32_t ssrc,
}
void StatsCollector::UpdateTrackReports() {
- RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
@@ -939,6 +949,7 @@ void StatsCollector::UpdateTrackReports() {
}
void StatsCollector::ClearUpdateStatsCacheForTest() {
+ RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
stats_gathering_started_ = 0;
}
« webrtc/api/peerconnection.cc ('K') | « webrtc/api/statscollector.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698