Move histograms for rtp receive counters to ReceiveStatisticsProxy

BUG=

Review URL: https://codereview.webrtc.org/1726503003

Cr-Commit-Position: refs/heads/master@{#11735}
This commit is contained in:
sprang 2016-02-24 01:35:40 -08:00 committed by Commit bot
parent b7261fd3ae
commit 0ab8e81e12
5 changed files with 59 additions and 65 deletions

View File

@ -19,14 +19,19 @@
namespace webrtc {
ReceiveStatisticsProxy::ReceiveStatisticsProxy(uint32_t ssrc, Clock* clock)
ReceiveStatisticsProxy::ReceiveStatisticsProxy(
const VideoReceiveStream::Config& config,
Clock* clock)
: clock_(clock),
config_(config),
// 1000ms window, scale 1000 for ms to s.
decode_fps_estimator_(1000, 1000),
renders_fps_estimator_(1000, 1000),
render_fps_tracker_(100u, 10u),
render_pixel_tracker_(100u, 10u) {
stats_.ssrc = ssrc;
stats_.ssrc = config.rtp.remote_ssrc;
for (auto it : config.rtp.rtx)
rtx_stats_[it.second.ssrc] = StreamDataCounters();
}
ReceiveStatisticsProxy::~ReceiveStatisticsProxy() {
@ -68,6 +73,42 @@ void ReceiveStatisticsProxy::UpdateHistograms() {
int delay_ms = delay_counter_.Avg(kMinRequiredDecodeSamples);
if (delay_ms != -1)
RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.OnewayDelayInMs", delay_ms);
StreamDataCounters rtp = stats_.rtp_stats;
StreamDataCounters rtx;
for (auto it : rtx_stats_)
rtx.Add(it.second);
StreamDataCounters rtp_rtx = rtp;
rtp_rtx.Add(rtx);
int64_t elapsed_sec =
rtp_rtx.TimeSinceFirstPacketInMs(clock_->TimeInMilliseconds()) / 1000;
if (elapsed_sec > metrics::kMinRunTimeInSeconds) {
RTC_HISTOGRAM_COUNTS_10000(
"WebRTC.Video.BitrateReceivedInKbps",
static_cast<int>(rtp_rtx.transmitted.TotalBytes() * 8 / elapsed_sec /
1000));
RTC_HISTOGRAM_COUNTS_10000(
"WebRTC.Video.MediaBitrateReceivedInKbps",
static_cast<int>(rtp.MediaPayloadBytes() * 8 / elapsed_sec / 1000));
RTC_HISTOGRAM_COUNTS_10000(
"WebRTC.Video.PaddingBitrateReceivedInKbps",
static_cast<int>(rtp_rtx.transmitted.padding_bytes * 8 / elapsed_sec /
1000));
RTC_HISTOGRAM_COUNTS_10000(
"WebRTC.Video.RetransmittedBitrateReceivedInKbps",
static_cast<int>(rtp_rtx.retransmitted.TotalBytes() * 8 / elapsed_sec /
1000));
if (!rtx_stats_.empty()) {
RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.RtxBitrateReceivedInKbps",
static_cast<int>(rtx.transmitted.TotalBytes() *
8 / elapsed_sec / 1000));
}
if (config_.rtp.fec.ulpfec_payload_type != -1) {
RTC_HISTOGRAM_COUNTS_10000(
"WebRTC.Video.FecBitrateReceivedInKbps",
static_cast<int>(rtp_rtx.fec.TotalBytes() * 8 / elapsed_sec / 1000));
}
}
}
VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const {
@ -148,9 +189,16 @@ void ReceiveStatisticsProxy::DataCountersUpdated(
const webrtc::StreamDataCounters& counters,
uint32_t ssrc) {
rtc::CritScope lock(&crit_);
if (stats_.ssrc != ssrc)
return;
stats_.rtp_stats = counters;
if (ssrc == stats_.ssrc) {
stats_.rtp_stats = counters;
} else {
auto it = rtx_stats_.find(ssrc);
if (it != rtx_stats_.end()) {
it->second = counters;
} else {
RTC_NOTREACHED() << "Unexpected stream ssrc: " << ssrc;
}
}
}
void ReceiveStatisticsProxy::OnDecodedFrame() {

View File

@ -11,6 +11,7 @@
#ifndef WEBRTC_VIDEO_RECEIVE_STATISTICS_PROXY_H_
#define WEBRTC_VIDEO_RECEIVE_STATISTICS_PROXY_H_
#include <map>
#include <string>
#include "webrtc/base/criticalsection.h"
@ -37,7 +38,8 @@ class ReceiveStatisticsProxy : public VCMReceiveStatisticsCallback,
public RtcpPacketTypeCounterObserver,
public StreamDataCountersCallback {
public:
ReceiveStatisticsProxy(uint32_t ssrc, Clock* clock);
ReceiveStatisticsProxy(const VideoReceiveStream::Config& config,
Clock* clock);
virtual ~ReceiveStatisticsProxy();
VideoReceiveStream::Stats GetStats() const;
@ -94,6 +96,7 @@ class ReceiveStatisticsProxy : public VCMReceiveStatisticsCallback,
void UpdateHistograms() EXCLUSIVE_LOCKS_REQUIRED(crit_);
Clock* const clock_;
const VideoReceiveStream::Config config_;
rtc::CriticalSection crit_;
VideoReceiveStream::Stats stats_ GUARDED_BY(crit_);
@ -107,6 +110,7 @@ class ReceiveStatisticsProxy : public VCMReceiveStatisticsCallback,
SampleCounter delay_counter_ GUARDED_BY(crit_);
ReportBlockStats report_block_stats_ GUARDED_BY(crit_);
QpCounters qp_counters_; // Only accessed on the decoding thread.
std::map<uint32_t, StreamDataCounters> rtx_stats_ GUARDED_BY(crit_);
};
} // namespace webrtc

View File

@ -162,7 +162,7 @@ VideoReceiveStream::VideoReceiveStream(
incoming_video_stream_(
0,
config.renderer ? config.renderer->SmoothsRenderedFrames() : false),
stats_proxy_(config_.rtp.remote_ssrc, clock_),
stats_proxy_(config_, clock_),
vie_channel_(&transport_adapter_,
process_thread,
nullptr,

View File

@ -259,42 +259,6 @@ void ViEChannel::UpdateHistograms() {
rtcp_counter.UniqueNackRequestsInPercent());
}
}
StreamDataCounters rtp;
StreamDataCounters rtx;
GetReceiveStreamDataCounters(&rtp, &rtx);
StreamDataCounters rtp_rtx = rtp;
rtp_rtx.Add(rtx);
elapsed_sec = rtp_rtx.TimeSinceFirstPacketInMs(now) / 1000;
if (elapsed_sec > metrics::kMinRunTimeInSeconds) {
RTC_HISTOGRAM_COUNTS_10000(
"WebRTC.Video.BitrateReceivedInKbps",
static_cast<int>(rtp_rtx.transmitted.TotalBytes() * 8 / elapsed_sec /
1000));
RTC_HISTOGRAM_COUNTS_10000(
"WebRTC.Video.MediaBitrateReceivedInKbps",
static_cast<int>(rtp.MediaPayloadBytes() * 8 / elapsed_sec / 1000));
RTC_HISTOGRAM_COUNTS_10000(
"WebRTC.Video.PaddingBitrateReceivedInKbps",
static_cast<int>(rtp_rtx.transmitted.padding_bytes * 8 / elapsed_sec /
1000));
RTC_HISTOGRAM_COUNTS_10000(
"WebRTC.Video.RetransmittedBitrateReceivedInKbps",
static_cast<int>(rtp_rtx.retransmitted.TotalBytes() * 8 /
elapsed_sec / 1000));
uint32_t ssrc = 0;
if (vie_receiver_.GetRtxSsrc(&ssrc)) {
RTC_HISTOGRAM_COUNTS_10000(
"WebRTC.Video.RtxBitrateReceivedInKbps",
static_cast<int>(rtx.transmitted.TotalBytes() * 8 / elapsed_sec /
1000));
}
if (vie_receiver_.IsFecEnabled()) {
RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.FecBitrateReceivedInKbps",
static_cast<int>(rtp_rtx.fec.TotalBytes() *
8 / elapsed_sec / 1000));
}
}
}
}
@ -549,24 +513,6 @@ void ViEChannel::GetSendStreamDataCounters(
}
}
void ViEChannel::GetReceiveStreamDataCounters(
StreamDataCounters* rtp_counters,
StreamDataCounters* rtx_counters) const {
StreamStatistician* statistician = vie_receiver_.GetReceiveStatistics()->
GetStatistician(vie_receiver_.GetRemoteSsrc());
if (statistician) {
statistician->GetReceiveStreamDataCounters(rtp_counters);
}
uint32_t rtx_ssrc = 0;
if (vie_receiver_.GetRtxSsrc(&rtx_ssrc)) {
StreamStatistician* statistician =
vie_receiver_.GetReceiveStatistics()->GetStatistician(rtx_ssrc);
if (statistician) {
statistician->GetReceiveStreamDataCounters(rtx_counters);
}
}
}
void ViEChannel::GetSendRtcpPacketTypeCounter(
RtcpPacketTypeCounter* packet_counter) const {
std::map<uint32_t, RtcpPacketTypeCounter> counter_map =

View File

@ -99,10 +99,6 @@ class ViEChannel : public VCMFrameTypeCallback,
void GetSendStreamDataCounters(StreamDataCounters* rtp_counters,
StreamDataCounters* rtx_counters) const;
// Gets received stream data counters.
void GetReceiveStreamDataCounters(StreamDataCounters* rtp_counters,
StreamDataCounters* rtx_counters) const;
void GetSendRtcpPacketTypeCounter(
RtcpPacketTypeCounter* packet_counter) const;