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

Unified Diff: webrtc/call/call.cc

Issue 1440603002: Add receive bitrate UMA stats. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: . Created 5 years, 1 month 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/end_to_end_tests.cc » ('j') | 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 11445067271071fb367d270a028354af0e7e6755..698661b24f360e001d91c5d8aaa36651f1ca76ce 100644
--- a/webrtc/call/call.cc
+++ b/webrtc/call/call.cc
@@ -33,6 +33,7 @@
#include "webrtc/system_wrappers/include/cpu_info.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/logging.h"
+#include "webrtc/system_wrappers/include/metrics.h"
#include "webrtc/system_wrappers/include/rw_lock_wrapper.h"
#include "webrtc/system_wrappers/include/trace.h"
#include "webrtc/video/video_receive_stream.h"
@@ -105,6 +106,10 @@ class Call : public webrtc::Call, public PacketReceiver {
return nullptr;
}
+ void UpdateHistograms();
+
+ const Clock* const clock_;
+
const int num_cpu_cores_;
const rtc::scoped_ptr<ProcessThread> module_process_thread_;
const rtc::scoped_ptr<CallStats> call_stats_;
@@ -135,6 +140,12 @@ class Call : public webrtc::Call, public PacketReceiver {
RtcEventLog* event_log_ = nullptr;
+ size_t received_video_bytes_;
pbos-webrtc 2015/11/11 14:56:57 Can you put notes on how these are synchronized?
stefan-webrtc 2015/11/11 15:49:25 Done.
+ size_t received_audio_bytes_;
+ size_t received_rtcp_bytes_;
+ int64_t first_rtp_received_ms_;
+ int64_t first_rtcp_received_ms_;
+
RTC_DISALLOW_COPY_AND_ASSIGN(Call);
};
} // namespace internal
@@ -146,15 +157,22 @@ Call* Call::Create(const Call::Config& config) {
namespace internal {
Call::Call(const Call::Config& config)
- : num_cpu_cores_(CpuInfo::DetectNumberOfCores()),
+ : clock_(Clock::GetRealTimeClock()),
+ num_cpu_cores_(CpuInfo::DetectNumberOfCores()),
module_process_thread_(ProcessThread::Create("ModuleProcessThread")),
call_stats_(new CallStats()),
- congestion_controller_(new CongestionController(
- module_process_thread_.get(), call_stats_.get())),
+ congestion_controller_(
+ new CongestionController(module_process_thread_.get(),
+ call_stats_.get())),
config_(config),
network_enabled_(true),
receive_crit_(RWLockWrapper::CreateRWLock()),
- send_crit_(RWLockWrapper::CreateRWLock()) {
+ send_crit_(RWLockWrapper::CreateRWLock()),
+ received_video_bytes_(0),
+ received_audio_bytes_(0),
+ received_rtcp_bytes_(0),
+ first_rtp_received_ms_(-1),
+ first_rtcp_received_ms_(-1) {
RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0);
RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps,
config.bitrate_config.min_bitrate_bps);
@@ -180,6 +198,7 @@ Call::Call(const Call::Config& config)
}
Call::~Call() {
+ UpdateHistograms();
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
RTC_CHECK(audio_send_ssrcs_.empty());
RTC_CHECK(video_send_ssrcs_.empty());
@@ -193,6 +212,49 @@ Call::~Call() {
Trace::ReturnTrace();
}
+void Call::UpdateHistograms() {
+ int64_t first_packet_received_ms = first_rtp_received_ms_;
+ if (first_rtcp_received_ms_ != -1) {
+ if (first_packet_received_ms != -1) {
+ first_packet_received_ms =
+ std::min(first_packet_received_ms, first_rtcp_received_ms_);
+ } else {
+ first_packet_received_ms = first_rtcp_received_ms_;
+ }
+ }
+ if (first_packet_received_ms == -1)
+ return;
+ int64_t elapsed_sec =
+ (clock_->TimeInMilliseconds() - first_packet_received_ms) / 1000;
+ if (elapsed_sec > metrics::kMinRunTimeInSeconds) {
åsapersson 2015/11/11 15:35:24 maybe early return
stefan-webrtc 2015/11/11 15:59:04 Done.
+ if (received_video_bytes_ > 0) {
+ RTC_HISTOGRAM_COUNTS_100000(
+ "WebRTC.Call.VideoBitrateReceivedInKbps",
+ static_cast<int>(received_video_bytes_ * 8 / elapsed_sec / 1000));
+ }
+ if (received_audio_bytes_ > 0) {
+ RTC_HISTOGRAM_COUNTS_100000(
+ "WebRTC.Call.AudioBitrateReceivedInKbps",
+ static_cast<int>(received_audio_bytes_ * 8 / elapsed_sec / 1000));
+ }
+ if (received_rtcp_bytes_ > 0) {
+ RTC_HISTOGRAM_COUNTS_100000(
+ "WebRTC.Call.RtcpBitrateReceivedInKbps",
+ static_cast<int>(received_rtcp_bytes_ * 8 / elapsed_sec / 1000));
+ }
+ // Only report the total bitrate received if we have been receiving audio or
+ // video packets. This is to avoid getting a huge spike close to zero for
+ // Calls which are only receiving RTCP.
+ if (received_video_bytes_ + received_audio_bytes_ > 0) {
+ RTC_HISTOGRAM_COUNTS_100000(
+ "WebRTC.Call.BitrateReceivedInKbps",
+ static_cast<int>((received_video_bytes_ + received_audio_bytes_ +
+ received_rtcp_bytes_) *
+ 8 / elapsed_sec / 1000));
+ }
+ }
+}
+
PacketReceiver* Call::Receiver() {
// TODO(solenberg): Some test cases in EndToEndTest use this from a different
// thread. Re-enable once that is fixed.
@@ -527,6 +589,9 @@ PacketReceiver::DeliveryStatus Call::DeliverRtcp(MediaType media_type,
// Do NOT broadcast! Also make sure it's a valid packet.
// Return DELIVERY_UNKNOWN_SSRC if it can be determined that
// there's no receiver of the packet.
+ received_rtcp_bytes_ += length;
+ if (first_rtcp_received_ms_ == -1)
+ first_rtcp_received_ms_ = clock_->TimeInMilliseconds();
bool rtcp_delivered = false;
if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) {
ReadLockScoped read_lock(*receive_crit_);
@@ -559,10 +624,13 @@ PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type,
if (length < 12)
return DELIVERY_PACKET_ERROR;
- uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]);
+ if (first_rtp_received_ms_ == -1)
+ first_rtp_received_ms_ = clock_->TimeInMilliseconds();
+ uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]);
ReadLockScoped read_lock(*receive_crit_);
if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) {
+ received_audio_bytes_ += length;
auto it = audio_receive_ssrcs_.find(ssrc);
if (it != audio_receive_ssrcs_.end()) {
auto status = it->second->DeliverRtp(packet, length, packet_time)
@@ -574,6 +642,7 @@ PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type,
}
}
if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) {
+ received_video_bytes_ += length;
åsapersson 2015/11/11 15:35:24 Could media type any be counted twice?
stefan-webrtc 2015/11/11 15:59:04 Fixed.
auto it = video_receive_ssrcs_.find(ssrc);
if (it != video_receive_ssrcs_.end()) {
auto status = it->second->DeliverRtp(packet, length, packet_time)
« no previous file with comments | « no previous file | webrtc/video/end_to_end_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698