Skip to content

Commit

Permalink
Allow NetEq stats getter to config stats query interval.
Browse files Browse the repository at this point in the history
Bug: webrtc:9147
Change-Id: I42164dd784535ca31dd345ac4e199d6b6c802974
Reviewed-on: https://webrtc-review.googlesource.com/70200
Commit-Queue: Minyue Li <[email protected]>
Reviewed-by: Henrik Lundin <[email protected]>
Cr-Commit-Position: refs/heads/master@{#22973}
  • Loading branch information
minyuel authored and Commit Bot committed Apr 23, 2018
1 parent df1fe11 commit 753f72e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 7 additions & 2 deletions modules/audio_coding/neteq/tools/neteq_stats_getter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "rtc_base/checks.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/timeutils.h"

namespace webrtc {
namespace test {
Expand Down Expand Up @@ -44,11 +45,15 @@ void NetEqStatsGetter::AfterGetAudio(int64_t time_now_ms,
const AudioFrame& audio_frame,
bool muted,
NetEq* neteq) {
if (++counter_ >= 100) {
counter_ = 0;
// TODO(minyue): Get stats should better not be called as a call back after
// 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;
RTC_CHECK_EQ(neteq->NetworkStatistics(&stats), 0);
stats_.push_back(stats);
last_stats_query_time_ms_ = time_now_ms;
}
const auto lifetime_stat = neteq->GetLifetimeStatistics();
if (current_concealment_event_ != lifetime_stat.concealment_events &&
Expand Down
9 changes: 8 additions & 1 deletion modules/audio_coding/neteq/tools/neteq_stats_getter.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ 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;
}

void BeforeGetAudio(NetEq* neteq) override;

void AfterGetAudio(int64_t time_now_ms,
Expand All @@ -79,7 +85,8 @@ class NetEqStatsGetter : public NetEqGetAudioCallback {

private:
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_;
size_t current_concealment_event_ = 1;
uint64_t voice_concealed_samples_until_last_event_ = 0;
Expand Down

0 comments on commit 753f72e

Please sign in to comment.