Move expand uma logger into statistics calculator.
Bug: webrtc:370424996 Change-Id: I525758eaa5430a4d1cf63cfd663de0079e7d3d68 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/364100 Commit-Queue: Jakob Ivarsson <jakobi@webrtc.org> Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org> Cr-Commit-Position: refs/heads/main@{#43106}
This commit is contained in:
parent
f5a547aa99
commit
a6e555648e
@ -30,7 +30,8 @@ TEST(Expand, CreateAndDestroy) {
|
|||||||
BackgroundNoise bgn(channels);
|
BackgroundNoise bgn(channels);
|
||||||
SyncBuffer sync_buffer(1, 1000);
|
SyncBuffer sync_buffer(1, 1000);
|
||||||
RandomVector random_vector;
|
RandomVector random_vector;
|
||||||
StatisticsCalculator statistics;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator statistics(&timer);
|
||||||
Expand expand(&bgn, &sync_buffer, &random_vector, &statistics, fs, channels);
|
Expand expand(&bgn, &sync_buffer, &random_vector, &statistics, fs, channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +41,8 @@ TEST(Expand, CreateUsingFactory) {
|
|||||||
BackgroundNoise bgn(channels);
|
BackgroundNoise bgn(channels);
|
||||||
SyncBuffer sync_buffer(1, 1000);
|
SyncBuffer sync_buffer(1, 1000);
|
||||||
RandomVector random_vector;
|
RandomVector random_vector;
|
||||||
StatisticsCalculator statistics;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator statistics(&timer);
|
||||||
ExpandFactory expand_factory;
|
ExpandFactory expand_factory;
|
||||||
Expand* expand = expand_factory.Create(&bgn, &sync_buffer, &random_vector,
|
Expand* expand = expand_factory.Create(&bgn, &sync_buffer, &random_vector,
|
||||||
&statistics, fs, channels);
|
&statistics, fs, channels);
|
||||||
@ -51,6 +53,9 @@ TEST(Expand, CreateUsingFactory) {
|
|||||||
namespace {
|
namespace {
|
||||||
class FakeStatisticsCalculator : public StatisticsCalculator {
|
class FakeStatisticsCalculator : public StatisticsCalculator {
|
||||||
public:
|
public:
|
||||||
|
FakeStatisticsCalculator(TickTimer* tick_timer)
|
||||||
|
: StatisticsCalculator(tick_timer) {}
|
||||||
|
|
||||||
void LogDelayedPacketOutageEvent(int num_samples, int fs_hz) override {
|
void LogDelayedPacketOutageEvent(int num_samples, int fs_hz) override {
|
||||||
last_outage_duration_samples_ = num_samples;
|
last_outage_duration_samples_ = num_samples;
|
||||||
}
|
}
|
||||||
@ -77,6 +82,7 @@ class ExpandTest : public ::testing::Test {
|
|||||||
background_noise_(num_channels_),
|
background_noise_(num_channels_),
|
||||||
sync_buffer_(num_channels_,
|
sync_buffer_(num_channels_,
|
||||||
kNetEqSyncBufferLengthMs * test_sample_rate_hz_ / 1000),
|
kNetEqSyncBufferLengthMs * test_sample_rate_hz_ / 1000),
|
||||||
|
statistics_(&tick_timer_),
|
||||||
expand_(&background_noise_,
|
expand_(&background_noise_,
|
||||||
&sync_buffer_,
|
&sync_buffer_,
|
||||||
&random_vector_,
|
&random_vector_,
|
||||||
@ -106,6 +112,7 @@ class ExpandTest : public ::testing::Test {
|
|||||||
BackgroundNoise background_noise_;
|
BackgroundNoise background_noise_;
|
||||||
SyncBuffer sync_buffer_;
|
SyncBuffer sync_buffer_;
|
||||||
RandomVector random_vector_;
|
RandomVector random_vector_;
|
||||||
|
TickTimer tick_timer_;
|
||||||
FakeStatisticsCalculator statistics_;
|
FakeStatisticsCalculator statistics_;
|
||||||
Expand expand_;
|
Expand expand_;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -32,7 +32,8 @@ TEST(Merge, CreateAndDestroy) {
|
|||||||
BackgroundNoise bgn(channels);
|
BackgroundNoise bgn(channels);
|
||||||
SyncBuffer sync_buffer(1, 1000);
|
SyncBuffer sync_buffer(1, 1000);
|
||||||
RandomVector random_vector;
|
RandomVector random_vector;
|
||||||
StatisticsCalculator statistics;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator statistics(&timer);
|
||||||
Expand expand(&bgn, &sync_buffer, &random_vector, &statistics, fs, channels);
|
Expand expand(&bgn, &sync_buffer, &random_vector, &statistics, fs, channels);
|
||||||
Merge merge(fs, channels, &expand, &sync_buffer);
|
Merge merge(fs, channels, &expand, &sync_buffer);
|
||||||
}
|
}
|
||||||
@ -52,6 +53,7 @@ class MergeTest : public testing::TestWithParam<size_t> {
|
|||||||
background_noise_(num_channels_),
|
background_noise_(num_channels_),
|
||||||
sync_buffer_(num_channels_,
|
sync_buffer_(num_channels_,
|
||||||
kNetEqSyncBufferLengthMs * test_sample_rate_hz_ / 1000),
|
kNetEqSyncBufferLengthMs * test_sample_rate_hz_ / 1000),
|
||||||
|
statistics_(&timer_),
|
||||||
expand_(&background_noise_,
|
expand_(&background_noise_,
|
||||||
&sync_buffer_,
|
&sync_buffer_,
|
||||||
&random_vector_,
|
&random_vector_,
|
||||||
@ -86,6 +88,7 @@ class MergeTest : public testing::TestWithParam<size_t> {
|
|||||||
BackgroundNoise background_noise_;
|
BackgroundNoise background_noise_;
|
||||||
SyncBuffer sync_buffer_;
|
SyncBuffer sync_buffer_;
|
||||||
RandomVector random_vector_;
|
RandomVector random_vector_;
|
||||||
|
TickTimer timer_;
|
||||||
StatisticsCalculator statistics_;
|
StatisticsCalculator statistics_;
|
||||||
Expand expand_;
|
Expand expand_;
|
||||||
Merge merge_;
|
Merge merge_;
|
||||||
|
|||||||
@ -18,6 +18,9 @@ namespace webrtc {
|
|||||||
|
|
||||||
class MockStatisticsCalculator : public StatisticsCalculator {
|
class MockStatisticsCalculator : public StatisticsCalculator {
|
||||||
public:
|
public:
|
||||||
|
MockStatisticsCalculator(TickTimer* tick_timer)
|
||||||
|
: StatisticsCalculator(tick_timer) {}
|
||||||
|
|
||||||
MOCK_METHOD(void, PacketsDiscarded, (size_t num_packets), (override));
|
MOCK_METHOD(void, PacketsDiscarded, (size_t num_packets), (override));
|
||||||
MOCK_METHOD(void,
|
MOCK_METHOD(void,
|
||||||
SecondaryPacketsDiscarded,
|
SecondaryPacketsDiscarded,
|
||||||
|
|||||||
@ -96,7 +96,7 @@ NetEqImpl::Dependencies::Dependencies(
|
|||||||
const NetEqControllerFactory& controller_factory)
|
const NetEqControllerFactory& controller_factory)
|
||||||
: env(env),
|
: env(env),
|
||||||
tick_timer(new TickTimer),
|
tick_timer(new TickTimer),
|
||||||
stats(new StatisticsCalculator),
|
stats(std::make_unique<StatisticsCalculator>(tick_timer.get())),
|
||||||
decoder_database(
|
decoder_database(
|
||||||
std::make_unique<DecoderDatabase>(env,
|
std::make_unique<DecoderDatabase>(env,
|
||||||
std::move(decoder_factory),
|
std::move(decoder_factory),
|
||||||
@ -148,12 +148,6 @@ NetEqImpl::NetEqImpl(const NetEq::Config& config,
|
|||||||
enable_fast_accelerate_(config.enable_fast_accelerate),
|
enable_fast_accelerate_(config.enable_fast_accelerate),
|
||||||
nack_enabled_(false),
|
nack_enabled_(false),
|
||||||
enable_muted_state_(config.enable_muted_state),
|
enable_muted_state_(config.enable_muted_state),
|
||||||
expand_uma_logger_("WebRTC.Audio.ExpandRatePercent",
|
|
||||||
10, // Report once every 10 s.
|
|
||||||
tick_timer_.get()),
|
|
||||||
speech_expand_uma_logger_("WebRTC.Audio.SpeechExpandRatePercent",
|
|
||||||
10, // Report once every 10 s.
|
|
||||||
tick_timer_.get()),
|
|
||||||
no_time_stretching_(config.for_test_no_time_stretching) {
|
no_time_stretching_(config.for_test_no_time_stretching) {
|
||||||
RTC_LOG(LS_INFO) << "NetEq config: " << config.ToString();
|
RTC_LOG(LS_INFO) << "NetEq config: " << config.ToString();
|
||||||
int fs = config.sample_rate_hz;
|
int fs = config.sample_rate_hz;
|
||||||
@ -740,13 +734,6 @@ int NetEqImpl::GetAudioInternal(AudioFrame* audio_frame,
|
|||||||
last_decoded_packet_infos_.clear();
|
last_decoded_packet_infos_.clear();
|
||||||
tick_timer_->Increment();
|
tick_timer_->Increment();
|
||||||
stats_->IncreaseCounter(output_size_samples_, fs_hz_);
|
stats_->IncreaseCounter(output_size_samples_, fs_hz_);
|
||||||
const auto lifetime_stats = stats_->GetLifetimeStatistics();
|
|
||||||
expand_uma_logger_.UpdateSampleCounter(lifetime_stats.concealed_samples,
|
|
||||||
fs_hz_);
|
|
||||||
speech_expand_uma_logger_.UpdateSampleCounter(
|
|
||||||
lifetime_stats.concealed_samples -
|
|
||||||
lifetime_stats.silent_concealed_samples,
|
|
||||||
fs_hz_);
|
|
||||||
|
|
||||||
// Check for muted state.
|
// Check for muted state.
|
||||||
if (enable_muted_state_ && expand_->Muted() && packet_buffer_->Empty()) {
|
if (enable_muted_state_ && expand_->Muted() && packet_buffer_->Empty()) {
|
||||||
|
|||||||
@ -27,7 +27,6 @@
|
|||||||
#include "api/rtp_packet_info.h"
|
#include "api/rtp_packet_info.h"
|
||||||
#include "api/units/timestamp.h"
|
#include "api/units/timestamp.h"
|
||||||
#include "modules/audio_coding/neteq/audio_multi_vector.h"
|
#include "modules/audio_coding/neteq/audio_multi_vector.h"
|
||||||
#include "modules/audio_coding/neteq/expand_uma_logger.h"
|
|
||||||
#include "modules/audio_coding/neteq/packet.h"
|
#include "modules/audio_coding/neteq/packet.h"
|
||||||
#include "modules/audio_coding/neteq/packet_buffer.h"
|
#include "modules/audio_coding/neteq/packet_buffer.h"
|
||||||
#include "modules/audio_coding/neteq/random_vector.h"
|
#include "modules/audio_coding/neteq/random_vector.h"
|
||||||
@ -395,8 +394,6 @@ class NetEqImpl : public webrtc::NetEq {
|
|||||||
std::unique_ptr<TickTimer::Stopwatch> generated_noise_stopwatch_
|
std::unique_ptr<TickTimer::Stopwatch> generated_noise_stopwatch_
|
||||||
RTC_GUARDED_BY(mutex_);
|
RTC_GUARDED_BY(mutex_);
|
||||||
std::vector<RtpPacketInfo> last_decoded_packet_infos_ RTC_GUARDED_BY(mutex_);
|
std::vector<RtpPacketInfo> last_decoded_packet_infos_ RTC_GUARDED_BY(mutex_);
|
||||||
ExpandUmaLogger expand_uma_logger_ RTC_GUARDED_BY(mutex_);
|
|
||||||
ExpandUmaLogger speech_expand_uma_logger_ RTC_GUARDED_BY(mutex_);
|
|
||||||
bool no_time_stretching_ RTC_GUARDED_BY(mutex_); // Only used for test.
|
bool no_time_stretching_ RTC_GUARDED_BY(mutex_); // Only used for test.
|
||||||
rtc::BufferT<int16_t> concealment_audio_ RTC_GUARDED_BY(mutex_);
|
rtc::BufferT<int16_t> concealment_audio_ RTC_GUARDED_BY(mutex_);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -48,7 +48,8 @@ TEST(Normal, CreateAndDestroy) {
|
|||||||
BackgroundNoise bgn(channels);
|
BackgroundNoise bgn(channels);
|
||||||
SyncBuffer sync_buffer(1, 1000);
|
SyncBuffer sync_buffer(1, 1000);
|
||||||
RandomVector random_vector;
|
RandomVector random_vector;
|
||||||
StatisticsCalculator statistics;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator statistics(&timer);
|
||||||
Expand expand(&bgn, &sync_buffer, &random_vector, &statistics, fs, channels);
|
Expand expand(&bgn, &sync_buffer, &random_vector, &statistics, fs, channels);
|
||||||
Normal normal(fs, &db, bgn, &expand, &statistics);
|
Normal normal(fs, &db, bgn, &expand, &statistics);
|
||||||
EXPECT_CALL(db, Die()); // Called when `db` goes out of scope.
|
EXPECT_CALL(db, Die()); // Called when `db` goes out of scope.
|
||||||
@ -61,7 +62,8 @@ TEST(Normal, AvoidDivideByZero) {
|
|||||||
BackgroundNoise bgn(channels);
|
BackgroundNoise bgn(channels);
|
||||||
SyncBuffer sync_buffer(1, 1000);
|
SyncBuffer sync_buffer(1, 1000);
|
||||||
RandomVector random_vector;
|
RandomVector random_vector;
|
||||||
StatisticsCalculator statistics;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator statistics(&timer);
|
||||||
MockExpand expand(&bgn, &sync_buffer, &random_vector, &statistics, fs,
|
MockExpand expand(&bgn, &sync_buffer, &random_vector, &statistics, fs,
|
||||||
channels);
|
channels);
|
||||||
Normal normal(fs, &db, bgn, &expand, &statistics);
|
Normal normal(fs, &db, bgn, &expand, &statistics);
|
||||||
@ -96,7 +98,8 @@ TEST(Normal, InputLengthAndChannelsDoNotMatch) {
|
|||||||
BackgroundNoise bgn(channels);
|
BackgroundNoise bgn(channels);
|
||||||
SyncBuffer sync_buffer(channels, 1000);
|
SyncBuffer sync_buffer(channels, 1000);
|
||||||
RandomVector random_vector;
|
RandomVector random_vector;
|
||||||
StatisticsCalculator statistics;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator statistics(&timer);
|
||||||
MockExpand expand(&bgn, &sync_buffer, &random_vector, &statistics, fs,
|
MockExpand expand(&bgn, &sync_buffer, &random_vector, &statistics, fs,
|
||||||
channels);
|
channels);
|
||||||
Normal normal(fs, &db, bgn, &expand, &statistics);
|
Normal normal(fs, &db, bgn, &expand, &statistics);
|
||||||
@ -121,7 +124,8 @@ TEST(Normal, LastModeExpand120msPacket) {
|
|||||||
BackgroundNoise bgn(kChannels);
|
BackgroundNoise bgn(kChannels);
|
||||||
SyncBuffer sync_buffer(kChannels, 1000);
|
SyncBuffer sync_buffer(kChannels, 1000);
|
||||||
RandomVector random_vector;
|
RandomVector random_vector;
|
||||||
StatisticsCalculator statistics;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator statistics(&timer);
|
||||||
MockExpand expand(&bgn, &sync_buffer, &random_vector, &statistics, kFs,
|
MockExpand expand(&bgn, &sync_buffer, &random_vector, &statistics, kFs,
|
||||||
kChannels);
|
kChannels);
|
||||||
Normal normal(kFs, &db, bgn, &expand, &statistics);
|
Normal normal(kFs, &db, bgn, &expand, &statistics);
|
||||||
|
|||||||
@ -108,7 +108,7 @@ namespace webrtc {
|
|||||||
|
|
||||||
TEST(PacketBuffer, CreateAndDestroy) {
|
TEST(PacketBuffer, CreateAndDestroy) {
|
||||||
TickTimer tick_timer;
|
TickTimer tick_timer;
|
||||||
StrictMock<MockStatisticsCalculator> mock_stats;
|
StrictMock<MockStatisticsCalculator> mock_stats(&tick_timer);
|
||||||
PacketBuffer* buffer =
|
PacketBuffer* buffer =
|
||||||
new PacketBuffer(10, &tick_timer, &mock_stats); // 10 packets.
|
new PacketBuffer(10, &tick_timer, &mock_stats); // 10 packets.
|
||||||
EXPECT_TRUE(buffer->Empty());
|
EXPECT_TRUE(buffer->Empty());
|
||||||
@ -117,7 +117,7 @@ TEST(PacketBuffer, CreateAndDestroy) {
|
|||||||
|
|
||||||
TEST(PacketBuffer, InsertPacket) {
|
TEST(PacketBuffer, InsertPacket) {
|
||||||
TickTimer tick_timer;
|
TickTimer tick_timer;
|
||||||
StrictMock<MockStatisticsCalculator> mock_stats;
|
StrictMock<MockStatisticsCalculator> mock_stats(&tick_timer);
|
||||||
PacketBuffer buffer(10, &tick_timer, &mock_stats); // 10 packets.
|
PacketBuffer buffer(10, &tick_timer, &mock_stats); // 10 packets.
|
||||||
PacketGenerator gen(17u, 4711u, 0, 10);
|
PacketGenerator gen(17u, 4711u, 0, 10);
|
||||||
MockDecoderDatabase decoder_database;
|
MockDecoderDatabase decoder_database;
|
||||||
@ -141,7 +141,7 @@ TEST(PacketBuffer, InsertPacket) {
|
|||||||
// Test to flush buffer.
|
// Test to flush buffer.
|
||||||
TEST(PacketBuffer, FlushBuffer) {
|
TEST(PacketBuffer, FlushBuffer) {
|
||||||
TickTimer tick_timer;
|
TickTimer tick_timer;
|
||||||
StrictMock<MockStatisticsCalculator> mock_stats;
|
StrictMock<MockStatisticsCalculator> mock_stats(&tick_timer);
|
||||||
PacketBuffer buffer(10, &tick_timer, &mock_stats); // 10 packets.
|
PacketBuffer buffer(10, &tick_timer, &mock_stats); // 10 packets.
|
||||||
PacketGenerator gen(0, 0, 0, 10);
|
PacketGenerator gen(0, 0, 0, 10);
|
||||||
const int payload_len = 10;
|
const int payload_len = 10;
|
||||||
@ -166,7 +166,7 @@ TEST(PacketBuffer, FlushBuffer) {
|
|||||||
// Test to fill the buffer over the limits, and verify that it flushes.
|
// Test to fill the buffer over the limits, and verify that it flushes.
|
||||||
TEST(PacketBuffer, OverfillBuffer) {
|
TEST(PacketBuffer, OverfillBuffer) {
|
||||||
TickTimer tick_timer;
|
TickTimer tick_timer;
|
||||||
StrictMock<MockStatisticsCalculator> mock_stats;
|
StrictMock<MockStatisticsCalculator> mock_stats(&tick_timer);
|
||||||
PacketBuffer buffer(10, &tick_timer, &mock_stats); // 10 packets.
|
PacketBuffer buffer(10, &tick_timer, &mock_stats); // 10 packets.
|
||||||
PacketGenerator gen(0, 0, 0, 10);
|
PacketGenerator gen(0, 0, 0, 10);
|
||||||
MockDecoderDatabase decoder_database;
|
MockDecoderDatabase decoder_database;
|
||||||
@ -199,7 +199,7 @@ TEST(PacketBuffer, OverfillBuffer) {
|
|||||||
|
|
||||||
TEST(PacketBuffer, ExtractOrderRedundancy) {
|
TEST(PacketBuffer, ExtractOrderRedundancy) {
|
||||||
TickTimer tick_timer;
|
TickTimer tick_timer;
|
||||||
StrictMock<MockStatisticsCalculator> mock_stats;
|
StrictMock<MockStatisticsCalculator> mock_stats(&tick_timer);
|
||||||
PacketBuffer buffer(100, &tick_timer, &mock_stats); // 100 packets.
|
PacketBuffer buffer(100, &tick_timer, &mock_stats); // 100 packets.
|
||||||
const int kPackets = 18;
|
const int kPackets = 18;
|
||||||
const int kFrameSize = 10;
|
const int kFrameSize = 10;
|
||||||
@ -262,7 +262,7 @@ TEST(PacketBuffer, ExtractOrderRedundancy) {
|
|||||||
|
|
||||||
TEST(PacketBuffer, DiscardPackets) {
|
TEST(PacketBuffer, DiscardPackets) {
|
||||||
TickTimer tick_timer;
|
TickTimer tick_timer;
|
||||||
StrictMock<MockStatisticsCalculator> mock_stats;
|
StrictMock<MockStatisticsCalculator> mock_stats(&tick_timer);
|
||||||
PacketBuffer buffer(100, &tick_timer, &mock_stats); // 100 packets.
|
PacketBuffer buffer(100, &tick_timer, &mock_stats); // 100 packets.
|
||||||
const uint16_t start_seq_no = 17;
|
const uint16_t start_seq_no = 17;
|
||||||
const uint32_t start_ts = 4711;
|
const uint32_t start_ts = 4711;
|
||||||
@ -327,7 +327,7 @@ TEST(PacketBuffer, DiscardPackets) {
|
|||||||
|
|
||||||
TEST(PacketBuffer, Reordering) {
|
TEST(PacketBuffer, Reordering) {
|
||||||
TickTimer tick_timer;
|
TickTimer tick_timer;
|
||||||
StrictMock<MockStatisticsCalculator> mock_stats;
|
StrictMock<MockStatisticsCalculator> mock_stats(&tick_timer);
|
||||||
PacketBuffer buffer(100, &tick_timer, &mock_stats); // 100 packets.
|
PacketBuffer buffer(100, &tick_timer, &mock_stats); // 100 packets.
|
||||||
const uint16_t start_seq_no = 17;
|
const uint16_t start_seq_no = 17;
|
||||||
const uint32_t start_ts = 4711;
|
const uint32_t start_ts = 4711;
|
||||||
@ -371,7 +371,7 @@ TEST(PacketBuffer, Failures) {
|
|||||||
int payload_len = 100;
|
int payload_len = 100;
|
||||||
PacketGenerator gen(start_seq_no, start_ts, 0, ts_increment);
|
PacketGenerator gen(start_seq_no, start_ts, 0, ts_increment);
|
||||||
TickTimer tick_timer;
|
TickTimer tick_timer;
|
||||||
StrictMock<MockStatisticsCalculator> mock_stats;
|
StrictMock<MockStatisticsCalculator> mock_stats(&tick_timer);
|
||||||
|
|
||||||
PacketBuffer buffer(100, &tick_timer, &mock_stats); // 100 packets.
|
PacketBuffer buffer(100, &tick_timer, &mock_stats); // 100 packets.
|
||||||
{
|
{
|
||||||
@ -510,7 +510,7 @@ TEST(PacketBuffer, GetSpanSamples) {
|
|||||||
constexpr int kSampleRateHz = 48000;
|
constexpr int kSampleRateHz = 48000;
|
||||||
constexpr bool kCountWaitingTime = false;
|
constexpr bool kCountWaitingTime = false;
|
||||||
TickTimer tick_timer;
|
TickTimer tick_timer;
|
||||||
StrictMock<MockStatisticsCalculator> mock_stats;
|
StrictMock<MockStatisticsCalculator> mock_stats(&tick_timer);
|
||||||
PacketBuffer buffer(3, &tick_timer, &mock_stats);
|
PacketBuffer buffer(3, &tick_timer, &mock_stats);
|
||||||
PacketGenerator gen(0, kStartTimeStamp, 0, kFrameSizeSamples);
|
PacketGenerator gen(0, kStartTimeStamp, 0, kFrameSizeSamples);
|
||||||
MockDecoderDatabase decoder_database;
|
MockDecoderDatabase decoder_database;
|
||||||
@ -558,7 +558,7 @@ TEST(PacketBuffer, GetSpanSamplesCountWaitingTime) {
|
|||||||
constexpr bool kCountWaitingTime = true;
|
constexpr bool kCountWaitingTime = true;
|
||||||
constexpr size_t kLastDecodedSizeSamples = 0;
|
constexpr size_t kLastDecodedSizeSamples = 0;
|
||||||
TickTimer tick_timer;
|
TickTimer tick_timer;
|
||||||
StrictMock<MockStatisticsCalculator> mock_stats;
|
StrictMock<MockStatisticsCalculator> mock_stats(&tick_timer);
|
||||||
PacketBuffer buffer(3, &tick_timer, &mock_stats);
|
PacketBuffer buffer(3, &tick_timer, &mock_stats);
|
||||||
PacketGenerator gen(0, kStartTimeStamp, 0, kFrameSizeSamples);
|
PacketGenerator gen(0, kStartTimeStamp, 0, kFrameSizeSamples);
|
||||||
MockDecoderDatabase decoder_database;
|
MockDecoderDatabase decoder_database;
|
||||||
|
|||||||
@ -112,7 +112,7 @@ void StatisticsCalculator::PeriodicUmaAverage::Reset() {
|
|||||||
counter_ = 0;
|
counter_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
StatisticsCalculator::StatisticsCalculator()
|
StatisticsCalculator::StatisticsCalculator(TickTimer* tick_timer)
|
||||||
: preemptive_samples_(0),
|
: preemptive_samples_(0),
|
||||||
accelerate_samples_(0),
|
accelerate_samples_(0),
|
||||||
expanded_speech_samples_(0),
|
expanded_speech_samples_(0),
|
||||||
@ -129,7 +129,13 @@ StatisticsCalculator::StatisticsCalculator()
|
|||||||
1000),
|
1000),
|
||||||
buffer_full_counter_("WebRTC.Audio.JitterBufferFullPerMinute",
|
buffer_full_counter_("WebRTC.Audio.JitterBufferFullPerMinute",
|
||||||
60000, // 60 seconds report interval.
|
60000, // 60 seconds report interval.
|
||||||
100) {}
|
100),
|
||||||
|
expand_uma_logger_("WebRTC.Audio.ExpandRatePercent",
|
||||||
|
10, // Report once every 10 s.
|
||||||
|
tick_timer),
|
||||||
|
speech_expand_uma_logger_("WebRTC.Audio.SpeechExpandRatePercent",
|
||||||
|
10, // Report once every 10 s.
|
||||||
|
tick_timer) {}
|
||||||
|
|
||||||
StatisticsCalculator::~StatisticsCalculator() = default;
|
StatisticsCalculator::~StatisticsCalculator() = default;
|
||||||
|
|
||||||
@ -260,6 +266,12 @@ void StatisticsCalculator::IncreaseCounter(size_t num_samples, int fs_hz) {
|
|||||||
timestamps_since_last_report_ = 0;
|
timestamps_since_last_report_ = 0;
|
||||||
}
|
}
|
||||||
lifetime_stats_.total_samples_received += num_samples;
|
lifetime_stats_.total_samples_received += num_samples;
|
||||||
|
expand_uma_logger_.UpdateSampleCounter(lifetime_stats_.concealed_samples,
|
||||||
|
fs_hz);
|
||||||
|
speech_expand_uma_logger_.UpdateSampleCounter(
|
||||||
|
lifetime_stats_.concealed_samples -
|
||||||
|
lifetime_stats_.silent_concealed_samples,
|
||||||
|
fs_hz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatisticsCalculator::JitterBufferDelay(size_t num_samples,
|
void StatisticsCalculator::JitterBufferDelay(size_t num_samples,
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#include "api/neteq/neteq.h"
|
#include "api/neteq/neteq.h"
|
||||||
|
#include "modules/audio_coding/neteq/expand_uma_logger.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
@ -24,7 +25,7 @@ class DelayManager;
|
|||||||
// This class handles various network statistics in NetEq.
|
// This class handles various network statistics in NetEq.
|
||||||
class StatisticsCalculator {
|
class StatisticsCalculator {
|
||||||
public:
|
public:
|
||||||
StatisticsCalculator();
|
StatisticsCalculator(TickTimer* tick_timer);
|
||||||
|
|
||||||
virtual ~StatisticsCalculator();
|
virtual ~StatisticsCalculator();
|
||||||
|
|
||||||
@ -205,6 +206,8 @@ class StatisticsCalculator {
|
|||||||
PeriodicUmaAverage excess_buffer_delay_;
|
PeriodicUmaAverage excess_buffer_delay_;
|
||||||
PeriodicUmaCount buffer_full_counter_;
|
PeriodicUmaCount buffer_full_counter_;
|
||||||
bool decoded_output_played_ = false;
|
bool decoded_output_played_ = false;
|
||||||
|
ExpandUmaLogger expand_uma_logger_;
|
||||||
|
ExpandUmaLogger speech_expand_uma_logger_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@ -15,7 +15,8 @@
|
|||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
TEST(LifetimeStatistics, TotalSamplesReceived) {
|
TEST(LifetimeStatistics, TotalSamplesReceived) {
|
||||||
StatisticsCalculator stats;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator stats(&timer);
|
||||||
for (int i = 0; i < 10; ++i) {
|
for (int i = 0; i < 10; ++i) {
|
||||||
stats.IncreaseCounter(480, 48000); // 10 ms at 48 kHz.
|
stats.IncreaseCounter(480, 48000); // 10 ms at 48 kHz.
|
||||||
}
|
}
|
||||||
@ -23,7 +24,8 @@ TEST(LifetimeStatistics, TotalSamplesReceived) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(LifetimeStatistics, SamplesConcealed) {
|
TEST(LifetimeStatistics, SamplesConcealed) {
|
||||||
StatisticsCalculator stats;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator stats(&timer);
|
||||||
stats.ExpandedVoiceSamples(100, false);
|
stats.ExpandedVoiceSamples(100, false);
|
||||||
stats.ExpandedNoiseSamples(17, false);
|
stats.ExpandedNoiseSamples(17, false);
|
||||||
EXPECT_EQ(100u + 17u, stats.GetLifetimeStatistics().concealed_samples);
|
EXPECT_EQ(100u + 17u, stats.GetLifetimeStatistics().concealed_samples);
|
||||||
@ -34,7 +36,8 @@ TEST(LifetimeStatistics, SamplesConcealed) {
|
|||||||
// would not expect the value to decrease). Instead, the correction should be
|
// would not expect the value to decrease). Instead, the correction should be
|
||||||
// made to future increments to the stat.
|
// made to future increments to the stat.
|
||||||
TEST(LifetimeStatistics, SamplesConcealedCorrection) {
|
TEST(LifetimeStatistics, SamplesConcealedCorrection) {
|
||||||
StatisticsCalculator stats;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator stats(&timer);
|
||||||
stats.ExpandedVoiceSamples(100, false);
|
stats.ExpandedVoiceSamples(100, false);
|
||||||
EXPECT_EQ(100u, stats.GetLifetimeStatistics().concealed_samples);
|
EXPECT_EQ(100u, stats.GetLifetimeStatistics().concealed_samples);
|
||||||
stats.ExpandedVoiceSamplesCorrection(-10);
|
stats.ExpandedVoiceSamplesCorrection(-10);
|
||||||
@ -55,7 +58,8 @@ TEST(LifetimeStatistics, SamplesConcealedCorrection) {
|
|||||||
// in a modification to concealed_samples stats. Only PLC operations (i.e.,
|
// in a modification to concealed_samples stats. Only PLC operations (i.e.,
|
||||||
// "expand" and "merge") should affect the stat.
|
// "expand" and "merge") should affect the stat.
|
||||||
TEST(LifetimeStatistics, NoUpdateOnTimeStretch) {
|
TEST(LifetimeStatistics, NoUpdateOnTimeStretch) {
|
||||||
StatisticsCalculator stats;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator stats(&timer);
|
||||||
stats.ExpandedVoiceSamples(100, false);
|
stats.ExpandedVoiceSamples(100, false);
|
||||||
stats.AcceleratedSamples(4711);
|
stats.AcceleratedSamples(4711);
|
||||||
stats.PreemptiveExpandedSamples(17);
|
stats.PreemptiveExpandedSamples(17);
|
||||||
@ -64,7 +68,8 @@ TEST(LifetimeStatistics, NoUpdateOnTimeStretch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(StatisticsCalculator, ExpandedSamplesCorrection) {
|
TEST(StatisticsCalculator, ExpandedSamplesCorrection) {
|
||||||
StatisticsCalculator stats;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator stats(&timer);
|
||||||
NetEqNetworkStatistics stats_output;
|
NetEqNetworkStatistics stats_output;
|
||||||
constexpr int kSampleRateHz = 48000;
|
constexpr int kSampleRateHz = 48000;
|
||||||
constexpr int k10MsSamples = kSampleRateHz / 100;
|
constexpr int k10MsSamples = kSampleRateHz / 100;
|
||||||
@ -100,7 +105,8 @@ TEST(StatisticsCalculator, ExpandedSamplesCorrection) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(StatisticsCalculator, RelativePacketArrivalDelay) {
|
TEST(StatisticsCalculator, RelativePacketArrivalDelay) {
|
||||||
StatisticsCalculator stats;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator stats(&timer);
|
||||||
|
|
||||||
stats.RelativePacketArrivalDelay(50);
|
stats.RelativePacketArrivalDelay(50);
|
||||||
NetEqLifetimeStatistics stats_output = stats.GetLifetimeStatistics();
|
NetEqLifetimeStatistics stats_output = stats.GetLifetimeStatistics();
|
||||||
@ -112,7 +118,8 @@ TEST(StatisticsCalculator, RelativePacketArrivalDelay) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(StatisticsCalculator, ReceivedPacket) {
|
TEST(StatisticsCalculator, ReceivedPacket) {
|
||||||
StatisticsCalculator stats;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator stats(&timer);
|
||||||
|
|
||||||
stats.ReceivedPacket();
|
stats.ReceivedPacket();
|
||||||
NetEqLifetimeStatistics stats_output = stats.GetLifetimeStatistics();
|
NetEqLifetimeStatistics stats_output = stats.GetLifetimeStatistics();
|
||||||
@ -126,7 +133,8 @@ TEST(StatisticsCalculator, ReceivedPacket) {
|
|||||||
TEST(StatisticsCalculator, InterruptionCounter) {
|
TEST(StatisticsCalculator, InterruptionCounter) {
|
||||||
constexpr int fs_khz = 48;
|
constexpr int fs_khz = 48;
|
||||||
constexpr int fs_hz = fs_khz * 1000;
|
constexpr int fs_hz = fs_khz * 1000;
|
||||||
StatisticsCalculator stats;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator stats(&timer);
|
||||||
stats.DecodedOutputPlayed();
|
stats.DecodedOutputPlayed();
|
||||||
stats.EndExpandEvent(fs_hz);
|
stats.EndExpandEvent(fs_hz);
|
||||||
auto lts = stats.GetLifetimeStatistics();
|
auto lts = stats.GetLifetimeStatistics();
|
||||||
@ -160,7 +168,8 @@ TEST(StatisticsCalculator, InterruptionCounter) {
|
|||||||
TEST(StatisticsCalculator, InterruptionCounterDoNotLogBeforeDecoding) {
|
TEST(StatisticsCalculator, InterruptionCounterDoNotLogBeforeDecoding) {
|
||||||
constexpr int fs_khz = 48;
|
constexpr int fs_khz = 48;
|
||||||
constexpr int fs_hz = fs_khz * 1000;
|
constexpr int fs_hz = fs_khz * 1000;
|
||||||
StatisticsCalculator stats;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator stats(&timer);
|
||||||
|
|
||||||
// Add an event that is longer than 150 ms. Should normally be logged, but we
|
// Add an event that is longer than 150 ms. Should normally be logged, but we
|
||||||
// have not called DecodedOutputPlayed() yet, so it shouldn't this time.
|
// have not called DecodedOutputPlayed() yet, so it shouldn't this time.
|
||||||
@ -180,7 +189,8 @@ TEST(StatisticsCalculator, InterruptionCounterDoNotLogBeforeDecoding) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(StatisticsCalculator, DiscardedPackets) {
|
TEST(StatisticsCalculator, DiscardedPackets) {
|
||||||
StatisticsCalculator statistics_calculator;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator statistics_calculator(&timer);
|
||||||
EXPECT_EQ(0u,
|
EXPECT_EQ(0u,
|
||||||
statistics_calculator.GetLifetimeStatistics().packets_discarded);
|
statistics_calculator.GetLifetimeStatistics().packets_discarded);
|
||||||
|
|
||||||
@ -204,7 +214,8 @@ TEST(StatisticsCalculator, DiscardedPackets) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(StatisticsCalculator, JitterBufferDelay) {
|
TEST(StatisticsCalculator, JitterBufferDelay) {
|
||||||
StatisticsCalculator stats;
|
TickTimer timer;
|
||||||
|
StatisticsCalculator stats(&timer);
|
||||||
NetEqLifetimeStatistics lts;
|
NetEqLifetimeStatistics lts;
|
||||||
lts = stats.GetLifetimeStatistics();
|
lts = stats.GetLifetimeStatistics();
|
||||||
EXPECT_EQ(lts.total_processing_delay_us, 0ul);
|
EXPECT_EQ(lts.total_processing_delay_us, 0ul);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user