NetEq: Simplify the dependencies of GetNetworkStatistics
Adds a new method PopulateDelayManagerStats which takes care of the
fields that needed information from the DelayManager.
Also adds a new test for StatisticsCalculator made practically
feasible by the refactoring.
Bug: webrtc:7554
Change-Id: Iff5cb5e209c276bd2784f2ccf73be8f619b1d955
Reviewed-on: https://webrtc-review.googlesource.com/3181
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#19957}diff --git a/modules/audio_coding/neteq/statistics_calculator.cc b/modules/audio_coding/neteq/statistics_calculator.cc
index 09ced6a..4e034e6 100644
--- a/modules/audio_coding/neteq/statistics_calculator.cc
+++ b/modules/audio_coding/neteq/statistics_calculator.cc
@@ -14,7 +14,6 @@
#include <string.h> // memset
#include <algorithm>
-#include "modules/audio_coding/neteq/decision_logic.h"
#include "modules/audio_coding/neteq/delay_manager.h"
#include "rtc_base/checks.h"
#include "rtc_base/safe_conversions.h"
@@ -255,24 +254,13 @@
int fs_hz,
size_t num_samples_in_buffers,
size_t samples_per_packet,
- const DelayManager& delay_manager,
- const DecisionLogic& decision_logic,
NetEqNetworkStatistics *stats) {
- if (fs_hz <= 0 || !stats) {
- assert(false);
- return;
- }
+ RTC_DCHECK_GT(fs_hz, 0);
+ RTC_DCHECK(stats);
stats->added_zero_samples = added_zero_samples_;
stats->current_buffer_size_ms =
static_cast<uint16_t>(num_samples_in_buffers * 1000 / fs_hz);
- const int ms_per_packet = rtc::dchecked_cast<int>(
- decision_logic.packet_length_samples() / (fs_hz / 1000));
- stats->preferred_buffer_size_ms = (delay_manager.TargetLevel() >> 8) *
- ms_per_packet;
- stats->jitter_peaks_found = delay_manager.PeakFound();
- stats->clockdrift_ppm =
- rtc::saturated_cast<int32_t>(delay_manager.EstimatedClockDriftPpm());
stats->packet_loss_rate =
CalculateQ14Ratio(lost_timestamps_, timestamps_since_last_report_);
@@ -331,6 +319,18 @@
Reset();
}
+void StatisticsCalculator::PopulateDelayManagerStats(
+ int ms_per_packet,
+ const DelayManager& delay_manager,
+ NetEqNetworkStatistics* stats) {
+ RTC_DCHECK(stats);
+ stats->preferred_buffer_size_ms =
+ (delay_manager.TargetLevel() >> 8) * ms_per_packet;
+ stats->jitter_peaks_found = delay_manager.PeakFound();
+ stats->clockdrift_ppm =
+ rtc::saturated_cast<int32_t>(delay_manager.EstimatedClockDriftPpm());
+}
+
NetEqLifetimeStatistics StatisticsCalculator::GetLifetimeStatistics() const {
return lifetime_stats_;
}