Allow NetEq stats getter to config stats query interval.
Bug: webrtc:9147 Change-Id: I42164dd784535ca31dd345ac4e199d6b6c802974 Reviewed-on: https://webrtc-review.googlesource.com/70200 Commit-Queue: Minyue Li <minyue@webrtc.org> Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22973}
This commit is contained in:
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/strings/string_builder.h"
|
#include "rtc_base/strings/string_builder.h"
|
||||||
|
#include "rtc_base/timeutils.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace test {
|
namespace test {
|
||||||
@ -44,11 +45,15 @@ void NetEqStatsGetter::AfterGetAudio(int64_t time_now_ms,
|
|||||||
const AudioFrame& audio_frame,
|
const AudioFrame& audio_frame,
|
||||||
bool muted,
|
bool muted,
|
||||||
NetEq* neteq) {
|
NetEq* neteq) {
|
||||||
if (++counter_ >= 100) {
|
// TODO(minyue): Get stats should better not be called as a call back after
|
||||||
counter_ = 0;
|
// get audio. It is called independently from get audio in practice.
|
||||||
|
if (last_stats_query_time_ms_ == 0 ||
|
||||||
|
rtc::TimeDiff(time_now_ms, last_stats_query_time_ms_) >=
|
||||||
|
stats_query_interval_ms_) {
|
||||||
NetEqNetworkStatistics stats;
|
NetEqNetworkStatistics stats;
|
||||||
RTC_CHECK_EQ(neteq->NetworkStatistics(&stats), 0);
|
RTC_CHECK_EQ(neteq->NetworkStatistics(&stats), 0);
|
||||||
stats_.push_back(stats);
|
stats_.push_back(stats);
|
||||||
|
last_stats_query_time_ms_ = time_now_ms;
|
||||||
}
|
}
|
||||||
const auto lifetime_stat = neteq->GetLifetimeStatistics();
|
const auto lifetime_stat = neteq->GetLifetimeStatistics();
|
||||||
if (current_concealment_event_ != lifetime_stat.concealment_events &&
|
if (current_concealment_event_ != lifetime_stat.concealment_events &&
|
||||||
|
@ -56,6 +56,12 @@ class NetEqStatsGetter : public NetEqGetAudioCallback {
|
|||||||
// valid value.
|
// valid value.
|
||||||
explicit NetEqStatsGetter(std::unique_ptr<NetEqDelayAnalyzer> delay_analyzer);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
void BeforeGetAudio(NetEq* neteq) override;
|
void BeforeGetAudio(NetEq* neteq) override;
|
||||||
|
|
||||||
void AfterGetAudio(int64_t time_now_ms,
|
void AfterGetAudio(int64_t time_now_ms,
|
||||||
@ -79,7 +85,8 @@ class NetEqStatsGetter : public NetEqGetAudioCallback {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<NetEqDelayAnalyzer> delay_analyzer_;
|
std::unique_ptr<NetEqDelayAnalyzer> delay_analyzer_;
|
||||||
size_t counter_ = 0;
|
int64_t stats_query_interval_ms_ = 1000;
|
||||||
|
int64_t last_stats_query_time_ms_ = 0;
|
||||||
std::vector<NetEqNetworkStatistics> stats_;
|
std::vector<NetEqNetworkStatistics> stats_;
|
||||||
size_t current_concealment_event_ = 1;
|
size_t current_concealment_event_ = 1;
|
||||||
uint64_t voice_concealed_samples_until_last_event_ = 0;
|
uint64_t voice_concealed_samples_until_last_event_ = 0;
|
||||||
|
Reference in New Issue
Block a user