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

Unified Diff: webrtc/video/send_delay_stats.cc

Issue 2013403002: Start integrating StatsCounter class. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « webrtc/video/send_delay_stats.h ('k') | webrtc/video/send_delay_stats_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/video/send_delay_stats.cc
diff --git a/webrtc/video/send_delay_stats.cc b/webrtc/video/send_delay_stats.cc
index 8701066519807bc1cb2634dc5e3a03ed9c2a9584..e84bf10287afbab25cce5b68f2db268de96e815f 100644
--- a/webrtc/video/send_delay_stats.cc
+++ b/webrtc/video/send_delay_stats.cc
@@ -22,7 +22,7 @@ const size_t kMaxPacketMapSize = 2000;
// Limit for the maximum number of streams to calculate stats for.
const size_t kMaxSsrcMapSize = 50;
-const int kMinRequiredSamples = 200;
+const int kMinRequiredPeriodicSamples = 5;
} // namespace
SendDelayStats::SendDelayStats(Clock* clock)
@@ -40,10 +40,10 @@ SendDelayStats::~SendDelayStats() {
void SendDelayStats::UpdateHistograms() {
rtc::CritScope lock(&crit_);
for (const auto& it : send_delay_counters_) {
- int send_delay_ms = it.second.Avg(kMinRequiredSamples);
- if (send_delay_ms != -1) {
+ AggregatedStats stats = it.second->GetStats();
+ if (stats.num_samples >= kMinRequiredPeriodicSamples) {
RTC_LOGGED_HISTOGRAM_COUNTS_10000("WebRTC.Video.SendDelayInMs",
- send_delay_ms);
+ stats.average);
}
}
}
@@ -56,6 +56,16 @@ void SendDelayStats::AddSsrcs(const VideoSendStream::Config& config) {
ssrcs_.insert(ssrc);
}
+AvgCounter* SendDelayStats::GetSendDelayCounter(uint32_t ssrc) {
+ const auto& it = send_delay_counters_.find(ssrc);
+ if (it != send_delay_counters_.end())
+ return it->second.get();
+
+ AvgCounter* counter = new AvgCounter(clock_, nullptr);
+ send_delay_counters_[ssrc].reset(counter);
+ return counter;
+}
+
void SendDelayStats::OnSendPacket(uint16_t packet_id,
int64_t capture_time_ms,
uint32_t ssrc) {
@@ -88,7 +98,7 @@ bool SendDelayStats::OnSentPacket(int packet_id, int64_t time_ms) {
// TODO(asapersson): Remove SendSideDelayUpdated(), use capture -> sent.
// Elapsed time from send (to transport) -> sent (leaving socket).
int diff_ms = time_ms - it->second.send_time_ms;
- send_delay_counters_[it->second.ssrc].Add(diff_ms);
+ GetSendDelayCounter(it->second.ssrc)->Add(diff_ms);
packets_.erase(it);
return true;
}
@@ -104,15 +114,4 @@ void SendDelayStats::RemoveOld(int64_t now, PacketMap* packets) {
}
}
-void SendDelayStats::SampleCounter::Add(int sample) {
- sum += sample;
- ++num_samples;
-}
-
-int SendDelayStats::SampleCounter::Avg(int min_required_samples) const {
- if (num_samples < min_required_samples || num_samples == 0)
- return -1;
- return (sum + (num_samples / 2)) / num_samples;
-}
-
} // namespace webrtc
« no previous file with comments | « webrtc/video/send_delay_stats.h ('k') | webrtc/video/send_delay_stats_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698