2013-01-29 12:09:21 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_
|
|
|
|
|
#define MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2015-08-25 13:08:04 +02:00
|
|
|
#include <deque>
|
2015-08-19 10:46:50 +02:00
|
|
|
#include <string>
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2019-10-31 14:38:11 +01:00
|
|
|
#include "api/neteq/neteq.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "rtc_base/constructor_magic.h"
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
class DelayManager;
|
|
|
|
|
|
|
|
|
|
// This class handles various network statistics in NetEq.
|
|
|
|
|
class StatisticsCalculator {
|
|
|
|
|
public:
|
|
|
|
|
StatisticsCalculator();
|
|
|
|
|
|
2015-08-25 13:08:04 +02:00
|
|
|
virtual ~StatisticsCalculator();
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// Resets most of the counters.
|
|
|
|
|
void Reset();
|
|
|
|
|
|
|
|
|
|
// Resets the counters that are not handled by Reset().
|
|
|
|
|
void ResetMcu();
|
|
|
|
|
|
|
|
|
|
// Reports that |num_samples| samples were produced through expansion, and
|
|
|
|
|
// that the expansion produced other than just noise samples.
|
2017-09-18 09:28:20 +02:00
|
|
|
void ExpandedVoiceSamples(size_t num_samples, bool is_new_concealment_event);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// Reports that |num_samples| samples were produced through expansion, and
|
|
|
|
|
// that the expansion produced only noise samples.
|
2017-09-18 09:28:20 +02:00
|
|
|
void ExpandedNoiseSamples(size_t num_samples, bool is_new_concealment_event);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2017-05-05 05:04:16 -07:00
|
|
|
// Corrects the statistics for number of samples produced through non-noise
|
|
|
|
|
// expansion by adding |num_samples| (negative or positive) to the current
|
|
|
|
|
// value. The result is capped to zero to avoid negative values.
|
|
|
|
|
void ExpandedVoiceSamplesCorrection(int num_samples);
|
|
|
|
|
|
|
|
|
|
// Same as ExpandedVoiceSamplesCorrection but for noise samples.
|
|
|
|
|
void ExpandedNoiseSamplesCorrection(int num_samples);
|
|
|
|
|
|
2019-04-26 09:47:07 +02:00
|
|
|
void DecodedOutputPlayed();
|
|
|
|
|
|
|
|
|
|
// Mark end of expand event; triggers some stats to be reported.
|
|
|
|
|
void EndExpandEvent(int fs_hz);
|
|
|
|
|
|
2013-01-29 12:09:21 +00:00
|
|
|
// Reports that |num_samples| samples were produced through preemptive
|
|
|
|
|
// expansion.
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
void PreemptiveExpandedSamples(size_t num_samples);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// Reports that |num_samples| samples were removed through accelerate.
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
void AcceleratedSamples(size_t num_samples);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// Reports that |num_packets| packets were discarded.
|
2017-07-05 11:17:40 +02:00
|
|
|
virtual void PacketsDiscarded(size_t num_packets);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2019-04-24 14:06:24 +02:00
|
|
|
// Reports that |num_packets| secondary (FEC) packets were discarded.
|
|
|
|
|
virtual void SecondaryPacketsDiscarded(size_t num_packets);
|
|
|
|
|
|
|
|
|
|
// Reports that |num_packets| secondary (FEC) packets were received.
|
|
|
|
|
virtual void SecondaryPacketsReceived(size_t num_packets);
|
2017-08-23 15:59:38 +02:00
|
|
|
|
2013-01-29 12:09:21 +00:00
|
|
|
// Increases the report interval counter with |num_samples| at a sample rate
|
2015-08-19 10:46:50 +02:00
|
|
|
// of |fs_hz|. This is how the StatisticsCalculator gets notified that current
|
|
|
|
|
// time is increasing.
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
void IncreaseCounter(size_t num_samples, int fs_hz);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2017-10-02 12:00:34 +02:00
|
|
|
// Update jitter buffer delay counter.
|
2020-03-11 11:18:54 +01:00
|
|
|
void JitterBufferDelay(size_t num_samples,
|
|
|
|
|
uint64_t waiting_time_ms,
|
|
|
|
|
uint64_t target_delay_ms);
|
2017-10-02 12:00:34 +02:00
|
|
|
|
2013-01-29 12:09:21 +00:00
|
|
|
// Stores new packet waiting time in waiting time statistics.
|
|
|
|
|
void StoreWaitingTime(int waiting_time_ms);
|
|
|
|
|
|
2015-02-17 10:17:09 +00:00
|
|
|
// Reports that |num_samples| samples were decoded from secondary packets.
|
|
|
|
|
void SecondaryDecodedSamples(int num_samples);
|
|
|
|
|
|
2019-03-05 16:59:03 +01:00
|
|
|
// Reports that the packet buffer was flushed.
|
2018-09-27 11:43:42 +02:00
|
|
|
void FlushedPacketBuffer();
|
|
|
|
|
|
2019-03-05 16:59:03 +01:00
|
|
|
// Reports that the jitter buffer received a packet.
|
|
|
|
|
void ReceivedPacket();
|
|
|
|
|
|
|
|
|
|
// Reports that a received packet was delayed by |delay_ms| milliseconds.
|
|
|
|
|
virtual void RelativePacketArrivalDelay(size_t delay_ms);
|
|
|
|
|
|
2018-11-27 12:52:16 +01:00
|
|
|
// Logs a delayed packet outage event of |num_samples| expanded at a sample
|
|
|
|
|
// rate of |fs_hz|. A delayed packet outage event is defined as an expand
|
|
|
|
|
// period caused not by an actual packet loss, but by a delayed packet.
|
|
|
|
|
virtual void LogDelayedPacketOutageEvent(int num_samples, int fs_hz);
|
2015-08-18 14:58:09 +02:00
|
|
|
|
2020-09-14 10:47:50 +02:00
|
|
|
// Returns the current network statistics in |stats|. The number of samples
|
|
|
|
|
// per packet is |samples_per_packet|. The method does not populate
|
2017-09-25 12:30:58 +02:00
|
|
|
// |preferred_buffer_size_ms|, |jitter_peaks_found| or |clockdrift_ppm|; use
|
|
|
|
|
// the PopulateDelayManagerStats method for those.
|
2020-09-14 10:47:50 +02:00
|
|
|
void GetNetworkStatistics(size_t samples_per_packet,
|
2013-01-29 12:09:21 +00:00
|
|
|
NetEqNetworkStatistics* stats);
|
|
|
|
|
|
2017-08-24 17:15:13 -07:00
|
|
|
// Returns a copy of this class's lifetime statistics. These statistics are
|
|
|
|
|
// never reset.
|
|
|
|
|
NetEqLifetimeStatistics GetLifetimeStatistics() const;
|
|
|
|
|
|
2018-09-13 14:39:55 +02:00
|
|
|
NetEqOperationsAndState GetOperationsAndState() const;
|
|
|
|
|
|
2013-01-29 12:09:21 +00:00
|
|
|
private:
|
|
|
|
|
static const int kMaxReportPeriod = 60; // Seconds before auto-reset.
|
2015-08-25 13:08:04 +02:00
|
|
|
static const size_t kLenWaitingTimes = 100;
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2015-08-19 10:46:50 +02:00
|
|
|
class PeriodicUmaLogger {
|
|
|
|
|
public:
|
|
|
|
|
PeriodicUmaLogger(const std::string& uma_name,
|
|
|
|
|
int report_interval_ms,
|
|
|
|
|
int max_value);
|
|
|
|
|
virtual ~PeriodicUmaLogger();
|
|
|
|
|
void AdvanceClock(int step_ms);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void LogToUma(int value) const;
|
|
|
|
|
virtual int Metric() const = 0;
|
|
|
|
|
virtual void Reset() = 0;
|
|
|
|
|
|
|
|
|
|
const std::string uma_name_;
|
|
|
|
|
const int report_interval_ms_;
|
|
|
|
|
const int max_value_;
|
|
|
|
|
int timer_ = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class PeriodicUmaCount final : public PeriodicUmaLogger {
|
|
|
|
|
public:
|
|
|
|
|
PeriodicUmaCount(const std::string& uma_name,
|
|
|
|
|
int report_interval_ms,
|
|
|
|
|
int max_value);
|
|
|
|
|
~PeriodicUmaCount() override;
|
|
|
|
|
void RegisterSample();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
int Metric() const override;
|
|
|
|
|
void Reset() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int counter_ = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class PeriodicUmaAverage final : public PeriodicUmaLogger {
|
|
|
|
|
public:
|
|
|
|
|
PeriodicUmaAverage(const std::string& uma_name,
|
|
|
|
|
int report_interval_ms,
|
|
|
|
|
int max_value);
|
|
|
|
|
~PeriodicUmaAverage() override;
|
|
|
|
|
void RegisterSample(int value);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
int Metric() const override;
|
|
|
|
|
void Reset() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
double sum_ = 0.0;
|
|
|
|
|
int counter_ = 0;
|
|
|
|
|
};
|
|
|
|
|
|
2017-09-25 12:22:46 +02:00
|
|
|
// Corrects the concealed samples counter in lifetime_stats_. The value of
|
|
|
|
|
// num_samples_ is added directly to the stat if the correction is positive.
|
|
|
|
|
// If the correction is negative, it is cached and will be subtracted against
|
|
|
|
|
// future additions to the counter. This is meant to be called from
|
|
|
|
|
// Expanded{Voice,Noise}Samples{Correction}.
|
2018-02-07 18:46:33 +01:00
|
|
|
void ConcealedSamplesCorrection(int num_samples, bool is_voice);
|
2017-09-25 12:22:46 +02:00
|
|
|
|
2013-01-29 12:09:21 +00:00
|
|
|
// Calculates numerator / denominator, and returns the value in Q14.
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
static uint16_t CalculateQ14Ratio(size_t numerator, uint32_t denominator);
|
|
|
|
|
|
2017-08-24 17:15:13 -07:00
|
|
|
NetEqLifetimeStatistics lifetime_stats_;
|
2018-09-13 14:39:55 +02:00
|
|
|
NetEqOperationsAndState operations_and_state_;
|
2017-09-25 12:22:46 +02:00
|
|
|
size_t concealed_samples_correction_ = 0;
|
2019-04-24 14:06:24 +02:00
|
|
|
size_t silent_concealed_samples_correction_ = 0;
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t preemptive_samples_;
|
|
|
|
|
size_t accelerate_samples_;
|
|
|
|
|
size_t expanded_speech_samples_;
|
|
|
|
|
size_t expanded_noise_samples_;
|
2019-04-26 09:47:07 +02:00
|
|
|
size_t concealed_samples_at_event_end_ = 0;
|
2014-10-08 12:10:53 +00:00
|
|
|
uint32_t timestamps_since_last_report_;
|
2015-08-25 13:08:04 +02:00
|
|
|
std::deque<int> waiting_times_;
|
2015-02-17 10:17:09 +00:00
|
|
|
uint32_t secondary_decoded_samples_;
|
2017-08-23 15:59:38 +02:00
|
|
|
size_t discarded_secondary_packets_;
|
2015-08-19 10:46:50 +02:00
|
|
|
PeriodicUmaCount delayed_packet_outage_counter_;
|
|
|
|
|
PeriodicUmaAverage excess_buffer_delay_;
|
2018-10-16 16:55:52 +02:00
|
|
|
PeriodicUmaCount buffer_full_counter_;
|
2019-04-26 09:47:07 +02:00
|
|
|
bool decoded_output_played_ = false;
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2015-09-16 05:37:44 -07:00
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(StatisticsCalculator);
|
2013-01-29 12:09:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_
|