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

Unified Diff: webrtc/call/call.cc

Issue 2307913002: Update AvgCounter to have the ability to include last period metric for subsequent intervals withou… (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | webrtc/video/send_delay_stats.cc » ('j') | webrtc/video/stats_counter.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/call/call.cc
diff --git a/webrtc/call/call.cc b/webrtc/call/call.cc
index ceec963ee29a04b2f2f9f8f11dfa446d0861db86..4bb58ec0f677b0d880c501e19092e3ff8f7bcff0 100644
--- a/webrtc/call/call.cc
+++ b/webrtc/call/call.cc
@@ -43,6 +43,7 @@
#include "webrtc/system_wrappers/include/trace.h"
#include "webrtc/video/call_stats.h"
#include "webrtc/video/send_delay_stats.h"
+#include "webrtc/video/stats_counter.h"
#include "webrtc/video/video_receive_stream.h"
#include "webrtc/video/video_send_stream.h"
#include "webrtc/video/vie_remb.h"
@@ -186,11 +187,10 @@ class Call : public webrtc::Call,
// TODO(holmer): Remove this lock once BitrateController no longer calls
// OnNetworkChanged from multiple threads.
rtc::CriticalSection bitrate_crit_;
- int64_t estimated_send_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_);
- int64_t pacer_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_);
uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_);
- int64_t num_bitrate_updates_ GUARDED_BY(&bitrate_crit_);
uint32_t configured_max_padding_bitrate_bps_ GUARDED_BY(&bitrate_crit_);
+ AvgCounter estimated_send_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_);
+ AvgCounter pacer_bitrate_kbps_counter_ GUARDED_BY(&bitrate_crit_);
std::map<std::string, rtc::NetworkRoute> network_routes_;
@@ -240,11 +240,10 @@ Call::Call(const Call::Config& config)
first_rtp_packet_received_ms_(-1),
last_rtp_packet_received_ms_(-1),
first_packet_sent_ms_(-1),
- estimated_send_bitrate_sum_kbits_(0),
- pacer_bitrate_sum_kbits_(0),
min_allocated_send_bitrate_bps_(0),
- num_bitrate_updates_(0),
configured_max_padding_bitrate_bps_(0),
+ estimated_send_bitrate_kbps_counter_(clock_, nullptr, true),
+ pacer_bitrate_kbps_counter_(clock_, nullptr, true),
remb_(clock_),
congestion_controller_(
new CongestionController(clock_, this, &remb_, event_log_.get())),
@@ -311,22 +310,24 @@ void Call::UpdateHistograms() {
}
void Call::UpdateSendHistograms() {
- if (num_bitrate_updates_ == 0 || first_packet_sent_ms_ == -1)
+ if (first_packet_sent_ms_ == -1)
return;
int64_t elapsed_sec =
(clock_->TimeInMilliseconds() - first_packet_sent_ms_) / 1000;
if (elapsed_sec < metrics::kMinRunTimeInSeconds)
return;
- int send_bitrate_kbps =
- estimated_send_bitrate_sum_kbits_ / num_bitrate_updates_;
- int pacer_bitrate_kbps = pacer_bitrate_sum_kbits_ / num_bitrate_updates_;
- if (send_bitrate_kbps > 0) {
+ const int kMinRequiredPeriodicSamples = 5;
+ AggregatedStats send_bitrate_stats =
+ estimated_send_bitrate_kbps_counter_.ProcessAndGetStats();
+ if (send_bitrate_stats.num_samples >= kMinRequiredPeriodicSamples) {
RTC_LOGGED_HISTOGRAM_COUNTS_100000("WebRTC.Call.EstimatedSendBitrateInKbps",
- send_bitrate_kbps);
+ send_bitrate_stats.average);
}
- if (pacer_bitrate_kbps > 0) {
+ AggregatedStats pacer_bitrate_stats =
+ pacer_bitrate_kbps_counter_.ProcessAndGetStats();
+ if (pacer_bitrate_stats.num_samples >= kMinRequiredPeriodicSamples) {
RTC_LOGGED_HISTOGRAM_COUNTS_100000("WebRTC.Call.PacerBitrateInKbps",
- pacer_bitrate_kbps);
+ pacer_bitrate_stats.average);
}
}
@@ -732,26 +733,32 @@ void Call::OnNetworkChanged(uint32_t target_bitrate_bps, uint8_t fraction_loss,
bitrate_allocator_->OnNetworkChanged(target_bitrate_bps, fraction_loss,
rtt_ms);
- // Ignore updates where the bitrate is zero because the aggregate network
- // state is down.
- if (target_bitrate_bps > 0) {
- {
- ReadLockScoped read_lock(*send_crit_);
- // Do not update the stats if we are not sending video.
- if (video_send_streams_.empty())
- return;
- }
+ // Ignore updates if bitrate is zero (the aggregate network state is down).
+ if (target_bitrate_bps == 0) {
rtc::CritScope lock(&bitrate_crit_);
- // We only update these stats if we have send streams, and assume that
- // OnNetworkChanged is called roughly with a fixed frequency.
- estimated_send_bitrate_sum_kbits_ += target_bitrate_bps / 1000;
- // Pacer bitrate might be higher than bitrate estimate if enforcing min
- // bitrate.
- uint32_t pacer_bitrate_bps =
- std::max(target_bitrate_bps, min_allocated_send_bitrate_bps_);
- pacer_bitrate_sum_kbits_ += pacer_bitrate_bps / 1000;
- ++num_bitrate_updates_;
+ estimated_send_bitrate_kbps_counter_.ProcessAndPause();
+ pacer_bitrate_kbps_counter_.ProcessAndPause();
+ return;
+ }
+
+ bool sending_video;
+ {
+ ReadLockScoped read_lock(*send_crit_);
+ sending_video = !video_send_streams_.empty();
+ }
+
+ rtc::CritScope lock(&bitrate_crit_);
+ if (!sending_video) {
+ // Do not update the stats if we are not sending video.
+ estimated_send_bitrate_kbps_counter_.ProcessAndPause();
+ pacer_bitrate_kbps_counter_.ProcessAndPause();
+ return;
}
+ estimated_send_bitrate_kbps_counter_.Add(target_bitrate_bps / 1000);
+ // Pacer bitrate may be higher than bitrate estimate if enforcing min bitrate.
+ uint32_t pacer_bitrate_bps =
+ std::max(target_bitrate_bps, min_allocated_send_bitrate_bps_);
+ pacer_bitrate_kbps_counter_.Add(pacer_bitrate_bps / 1000);
}
void Call::OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps,
« no previous file with comments | « no previous file | webrtc/video/send_delay_stats.cc » ('j') | webrtc/video/stats_counter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698