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

Unified Diff: webrtc/call/call.cc

Issue 2303763002: Use RateCounter for received bitrate stats. (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 | no next file » | no next file with comments »
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..bc336157478bf06794e3afdb5703a673af1c1d75 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"
@@ -182,6 +183,7 @@ class Call : public webrtc::Call,
int64_t first_rtp_packet_received_ms_;
int64_t last_rtp_packet_received_ms_;
int64_t first_packet_sent_ms_;
+ RateCounter received_bytes_per_second_counter_;
// TODO(holmer): Remove this lock once BitrateController no longer calls
// OnNetworkChanged from multiple threads.
@@ -240,6 +242,7 @@ Call::Call(const Call::Config& config)
first_rtp_packet_received_ms_(-1),
last_rtp_packet_received_ms_(-1),
first_packet_sent_ms_(-1),
+ received_bytes_per_second_counter_(clock_, nullptr, false),
estimated_send_bitrate_sum_kbits_(0),
pacer_bitrate_sum_kbits_(0),
min_allocated_send_bitrate_bps_(0),
@@ -352,9 +355,13 @@ void Call::UpdateReceiveHistograms() {
RTC_LOGGED_HISTOGRAM_COUNTS_100000("WebRTC.Call.RtcpBitrateReceivedInBps",
rtcp_bitrate_bps);
}
- RTC_LOGGED_HISTOGRAM_COUNTS_100000(
- "WebRTC.Call.BitrateReceivedInKbps",
- audio_bitrate_kbps + video_bitrate_kbps + rtcp_bitrate_bps / 1000);
+ const int kMinRequiredPeriodicSamples = 5;
+ AggregatedStats recv_bytes_per_sec =
+ received_bytes_per_second_counter_.GetStats();
+ if (recv_bytes_per_sec.num_samples >= kMinRequiredPeriodicSamples) {
+ RTC_LOGGED_HISTOGRAM_COUNTS_100000("WebRTC.Call.BitrateReceivedInKbps",
+ recv_bytes_per_sec.average * 8 / 1000);
+ }
}
PacketReceiver* Call::Receiver() {
@@ -819,6 +826,7 @@ PacketReceiver::DeliveryStatus Call::DeliverRtcp(MediaType media_type,
// Return DELIVERY_UNKNOWN_SSRC if it can be determined that
// there's no receiver of the packet.
received_rtcp_bytes_ += length;
+ received_bytes_per_second_counter_.Add(length);
bool rtcp_delivered = false;
if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) {
ReadLockScoped read_lock(*receive_crit_);
@@ -874,6 +882,7 @@ PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type,
auto it = audio_receive_ssrcs_.find(ssrc);
if (it != audio_receive_ssrcs_.end()) {
received_audio_bytes_ += length;
+ received_bytes_per_second_counter_.Add(length);
auto status = it->second->DeliverRtp(packet, length, packet_time)
? DELIVERY_OK
: DELIVERY_PACKET_ERROR;
@@ -886,6 +895,7 @@ PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type,
auto it = video_receive_ssrcs_.find(ssrc);
if (it != video_receive_ssrcs_.end()) {
received_video_bytes_ += length;
+ received_bytes_per_second_counter_.Add(length);
auto status = it->second->DeliverRtp(packet, length, packet_time)
? DELIVERY_OK
: DELIVERY_PACKET_ERROR;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698