Let NetEq stats getter provide time for each stats query.

Bug: webrtc:9147
Change-Id: Idb3677bfa41bac7c050361b2ade220a84bb399be
Reviewed-on: https://webrtc-review.googlesource.com/70401
Commit-Queue: Minyue Li <minyue@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22978}
This commit is contained in:
Minyue Li
2018-04-23 09:40:56 +02:00
committed by Commit Bot
parent d78f70514f
commit e999b3fdf7
2 changed files with 13 additions and 10 deletions

View File

@ -52,7 +52,7 @@ void NetEqStatsGetter::AfterGetAudio(int64_t time_now_ms,
stats_query_interval_ms_) {
NetEqNetworkStatistics stats;
RTC_CHECK_EQ(neteq->NetworkStatistics(&stats), 0);
stats_.push_back(stats);
stats_.push_back(std::make_pair(time_now_ms, stats));
last_stats_query_time_ms_ = time_now_ms;
}
const auto lifetime_stat = neteq->GetLifetimeStatistics();
@ -88,18 +88,19 @@ void NetEqStatsGetter::AfterGetAudio(int64_t time_now_ms,
}
double NetEqStatsGetter::AverageSpeechExpandRate() const {
double sum_speech_expand =
std::accumulate(stats_.begin(), stats_.end(), double{0.0},
[](double a, NetEqNetworkStatistics b) {
return a + static_cast<double>(b.speech_expand_rate);
});
double sum_speech_expand = std::accumulate(
stats_.begin(), stats_.end(), double{0.0},
[](double a, std::pair<int64_t, NetEqNetworkStatistics> b) {
return a + static_cast<double>(b.second.speech_expand_rate);
});
return sum_speech_expand / 16384.0 / stats_.size();
}
NetEqStatsGetter::Stats NetEqStatsGetter::AverageStats() const {
Stats sum_stats = std::accumulate(
stats_.begin(), stats_.end(), Stats(),
[](Stats a, NetEqNetworkStatistics b) {
[](Stats a, std::pair<int64_t, NetEqNetworkStatistics> bb) {
const auto& b = bb.second;
a.current_buffer_size_ms += b.current_buffer_size_ms;
a.preferred_buffer_size_ms += b.preferred_buffer_size_ms;
a.jitter_peaks_found += b.jitter_peaks_found;

View File

@ -56,8 +56,6 @@ class NetEqStatsGetter : public NetEqGetAudioCallback {
// valid value.
explicit NetEqStatsGetter(std::unique_ptr<NetEqDelayAnalyzer> delay_analyzer);
int64_t stats_query_interval_ms() const { return stats_query_interval_ms_; }
void set_stats_query_interval_ms(int64_t stats_query_interval_ms) {
stats_query_interval_ms_ = stats_query_interval_ms;
}
@ -81,13 +79,17 @@ class NetEqStatsGetter : public NetEqGetAudioCallback {
return concealment_events_;
}
const std::vector<std::pair<int64_t, NetEqNetworkStatistics>>& stats() const {
return stats_;
}
Stats AverageStats() const;
private:
std::unique_ptr<NetEqDelayAnalyzer> delay_analyzer_;
int64_t stats_query_interval_ms_ = 1000;
int64_t last_stats_query_time_ms_ = 0;
std::vector<NetEqNetworkStatistics> stats_;
std::vector<std::pair<int64_t, NetEqNetworkStatistics>> stats_;
size_t current_concealment_event_ = 1;
uint64_t voice_concealed_samples_until_last_event_ = 0;
std::vector<ConcealmentEvent> concealment_events_;