Use StreamStatistician::BitrateReceived to produce total_bitrate_bps for GetStats.
Bug: webrtc:10679 Change-Id: I15d1b6d50cf61718de21554da4c676f352d5422c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/148522 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28819}
This commit is contained in:
parent
6685b328b9
commit
a52e9bd913
@ -105,7 +105,6 @@ ReceiveStatisticsProxy::ReceiveStatisticsProxy(
|
||||
renders_fps_estimator_(1000, 1000),
|
||||
render_fps_tracker_(100, 10u),
|
||||
render_pixel_tracker_(100, 10u),
|
||||
total_byte_tracker_(100, 10u), // bucket_interval_ms, bucket_count
|
||||
video_quality_observer_(
|
||||
new VideoQualityObserver(VideoContentType::UNSPECIFIED)),
|
||||
interframe_delay_max_moving_(kMovingMaxWindowMs),
|
||||
@ -571,8 +570,6 @@ VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const {
|
||||
UpdateFramerate(now_ms);
|
||||
stats_.render_frame_rate = renders_fps_estimator_.Rate(now_ms).value_or(0);
|
||||
stats_.decode_frame_rate = decode_fps_estimator_.Rate(now_ms).value_or(0);
|
||||
stats_.total_bitrate_bps =
|
||||
static_cast<int>(total_byte_tracker_.ComputeRate() * 8);
|
||||
stats_.interframe_delay_max_ms =
|
||||
interframe_delay_max_moving_.Max(now_ms).value_or(-1);
|
||||
stats_.freeze_count = video_quality_observer_->NumFreezes();
|
||||
@ -673,25 +670,17 @@ void ReceiveStatisticsProxy::OnCname(uint32_t ssrc, absl::string_view cname) {
|
||||
void ReceiveStatisticsProxy::DataCountersUpdated(
|
||||
const webrtc::StreamDataCounters& counters,
|
||||
uint32_t ssrc) {
|
||||
size_t last_total_bytes = 0;
|
||||
size_t total_bytes = 0;
|
||||
rtc::CritScope lock(&crit_);
|
||||
if (ssrc == stats_.ssrc) {
|
||||
last_total_bytes = stats_.rtp_stats.transmitted.TotalBytes();
|
||||
total_bytes = counters.transmitted.TotalBytes();
|
||||
stats_.rtp_stats = counters;
|
||||
} else {
|
||||
auto it = rtx_stats_.find(ssrc);
|
||||
if (it != rtx_stats_.end()) {
|
||||
last_total_bytes = it->second.transmitted.TotalBytes();
|
||||
total_bytes = counters.transmitted.TotalBytes();
|
||||
it->second = counters;
|
||||
} else {
|
||||
RTC_NOTREACHED() << "Unexpected stream ssrc: " << ssrc;
|
||||
}
|
||||
}
|
||||
if (total_bytes > last_total_bytes)
|
||||
total_byte_tracker_.AddSamples(total_bytes - last_total_bytes);
|
||||
}
|
||||
|
||||
void ReceiveStatisticsProxy::OnDecodedFrame(const VideoFrame& frame,
|
||||
|
||||
@ -152,7 +152,6 @@ class ReceiveStatisticsProxy : public VCMReceiveStatisticsCallback,
|
||||
RateStatistics renders_fps_estimator_ RTC_GUARDED_BY(crit_);
|
||||
rtc::RateTracker render_fps_tracker_ RTC_GUARDED_BY(crit_);
|
||||
rtc::RateTracker render_pixel_tracker_ RTC_GUARDED_BY(crit_);
|
||||
rtc::RateTracker total_byte_tracker_ RTC_GUARDED_BY(crit_);
|
||||
rtc::SampleCounter sync_offset_counter_ RTC_GUARDED_BY(crit_);
|
||||
rtc::SampleCounter decode_time_counter_ RTC_GUARDED_BY(crit_);
|
||||
rtc::SampleCounter jitter_buffer_delay_counter_ RTC_GUARDED_BY(crit_);
|
||||
|
||||
@ -459,10 +459,19 @@ void VideoReceiveStream::Stop() {
|
||||
|
||||
VideoReceiveStream::Stats VideoReceiveStream::GetStats() const {
|
||||
VideoReceiveStream::Stats stats = stats_proxy_.GetStats();
|
||||
stats.total_bitrate_bps = 0;
|
||||
StreamStatistician* statistician =
|
||||
rtp_receive_statistics_->GetStatistician(stats.ssrc);
|
||||
if (statistician)
|
||||
if (statistician) {
|
||||
statistician->GetStatistics(&stats.rtcp_stats, /*reset=*/false);
|
||||
stats.total_bitrate_bps = statistician->BitrateReceived();
|
||||
}
|
||||
if (config_.rtp.rtx_ssrc) {
|
||||
StreamStatistician* rtx_statistician =
|
||||
rtp_receive_statistics_->GetStatistician(config_.rtp.rtx_ssrc);
|
||||
if (rtx_statistician)
|
||||
stats.total_bitrate_bps += rtx_statistician->BitrateReceived();
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user