Move histograms for rtp receive counters to ReceiveStatisticsProxy
BUG=
Review URL: https://codereview.webrtc.org/1726503003
Cr-Commit-Position: refs/heads/master@{#11735}
diff --git a/webrtc/video/receive_statistics_proxy.cc b/webrtc/video/receive_statistics_proxy.cc
index 649ea0c..d42721b 100644
--- a/webrtc/video/receive_statistics_proxy.cc
+++ b/webrtc/video/receive_statistics_proxy.cc
@@ -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 @@
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 @@
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() {
diff --git a/webrtc/video/receive_statistics_proxy.h b/webrtc/video/receive_statistics_proxy.h
index 4a71ebd..043a0a2 100644
--- a/webrtc/video/receive_statistics_proxy.h
+++ b/webrtc/video/receive_statistics_proxy.h
@@ -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 @@
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 @@
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 @@
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
diff --git a/webrtc/video/video_receive_stream.cc b/webrtc/video/video_receive_stream.cc
index f3bab1c..d6cb6bd 100644
--- a/webrtc/video/video_receive_stream.cc
+++ b/webrtc/video/video_receive_stream.cc
@@ -162,7 +162,7 @@
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,
diff --git a/webrtc/video/vie_channel.cc b/webrtc/video/vie_channel.cc
index 5d4b100..4890874 100644
--- a/webrtc/video/vie_channel.cc
+++ b/webrtc/video/vie_channel.cc
@@ -259,42 +259,6 @@
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::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 =
diff --git a/webrtc/video/vie_channel.h b/webrtc/video/vie_channel.h
index 850c974..c18d44c 100644
--- a/webrtc/video/vie_channel.h
+++ b/webrtc/video/vie_channel.h
@@ -99,10 +99,6 @@
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;