Add stats totalSamplesReceived and concealedSamples
Adds two new stats to RTCMediaStreamTrackStats:
* totalSamplesReceived is the total number of samples received on
the audio channel and includes real and synthetic samples.
* concealedSamples is the total number of synthetic samples
received on the audio channel used to conceal packet loss.
Bug: webrtc:8076
Change-Id: I36e9828525ec341490cf3310a972b56a8b443667
Reviewed-on: https://chromium-review.googlesource.com/615902
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#19506}
This commit is contained in:
@ -332,6 +332,10 @@ void AcmReceiver::GetNetworkStatistics(NetworkStatistics* acm_stat) {
|
||||
acm_stat->medianWaitingTimeMs = neteq_stat.median_waiting_time_ms;
|
||||
acm_stat->minWaitingTimeMs = neteq_stat.min_waiting_time_ms;
|
||||
acm_stat->maxWaitingTimeMs = neteq_stat.max_waiting_time_ms;
|
||||
|
||||
NetEqLifetimeStatistics neteq_lifetime_stat = neteq_->GetLifetimeStatistics();
|
||||
acm_stat->totalSamplesReceived = neteq_lifetime_stat.total_samples_received;
|
||||
acm_stat->concealedSamples = neteq_lifetime_stat.concealed_samples;
|
||||
}
|
||||
|
||||
int AcmReceiver::DecoderByPayloadType(uint8_t payload_type,
|
||||
|
||||
@ -58,6 +58,18 @@ struct NetEqNetworkStatistics {
|
||||
int max_waiting_time_ms;
|
||||
};
|
||||
|
||||
// NetEq statistics that persist over the lifetime of the class.
|
||||
// These metrics are never reset.
|
||||
struct NetEqLifetimeStatistics {
|
||||
// Total number of audio samples received, including synthesized samples.
|
||||
// https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalsamplesreceived
|
||||
uint64_t total_samples_received = 0;
|
||||
// Total number of inbound audio samples that are based on synthesized data to
|
||||
// conceal packet loss.
|
||||
// https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-concealedsamples
|
||||
uint64_t concealed_samples = 0;
|
||||
};
|
||||
|
||||
enum NetEqPlayoutMode {
|
||||
kPlayoutOn,
|
||||
kPlayoutOff,
|
||||
@ -220,6 +232,10 @@ class NetEq {
|
||||
// after the call.
|
||||
virtual int NetworkStatistics(NetEqNetworkStatistics* stats) = 0;
|
||||
|
||||
// Returns a copy of this class's lifetime statistics. These statistics are
|
||||
// never reset.
|
||||
virtual NetEqLifetimeStatistics GetLifetimeStatistics() const = 0;
|
||||
|
||||
// Writes the current RTCP statistics to |stats|. The statistics are reset
|
||||
// and a new report period is started with the call.
|
||||
virtual void GetRtcpStatistics(RtcpStatistics* stats) = 0;
|
||||
|
||||
@ -380,6 +380,11 @@ int NetEqImpl::NetworkStatistics(NetEqNetworkStatistics* stats) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
NetEqLifetimeStatistics NetEqImpl::GetLifetimeStatistics() const {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
return stats_.GetLifetimeStatistics();
|
||||
}
|
||||
|
||||
void NetEqImpl::GetRtcpStatistics(RtcpStatistics* stats) {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (stats) {
|
||||
|
||||
@ -185,6 +185,8 @@ class NetEqImpl : public webrtc::NetEq {
|
||||
// and a new report period is started with the call.
|
||||
void GetRtcpStatistics(RtcpStatistics* stats) override;
|
||||
|
||||
NetEqLifetimeStatistics GetLifetimeStatistics() const override;
|
||||
|
||||
// Same as RtcpStatistics(), but does not reset anything.
|
||||
void GetRtcpStatisticsNoReset(RtcpStatistics* stats) override;
|
||||
|
||||
|
||||
@ -153,24 +153,29 @@ void StatisticsCalculator::ResetMcu() {
|
||||
|
||||
void StatisticsCalculator::ExpandedVoiceSamples(size_t num_samples) {
|
||||
expanded_speech_samples_ += num_samples;
|
||||
lifetime_stats_.concealed_samples += num_samples;
|
||||
}
|
||||
|
||||
void StatisticsCalculator::ExpandedNoiseSamples(size_t num_samples) {
|
||||
expanded_noise_samples_ += num_samples;
|
||||
lifetime_stats_.concealed_samples += num_samples;
|
||||
}
|
||||
|
||||
void StatisticsCalculator::ExpandedVoiceSamplesCorrection(int num_samples) {
|
||||
expanded_speech_samples_ =
|
||||
AddIntToSizeTWithLowerCap(num_samples, expanded_speech_samples_);
|
||||
lifetime_stats_.concealed_samples += num_samples;
|
||||
}
|
||||
|
||||
void StatisticsCalculator::ExpandedNoiseSamplesCorrection(int num_samples) {
|
||||
expanded_noise_samples_ =
|
||||
AddIntToSizeTWithLowerCap(num_samples, expanded_noise_samples_);
|
||||
lifetime_stats_.concealed_samples += num_samples;
|
||||
}
|
||||
|
||||
void StatisticsCalculator::PreemptiveExpandedSamples(size_t num_samples) {
|
||||
preemptive_samples_ += num_samples;
|
||||
lifetime_stats_.concealed_samples += num_samples;
|
||||
}
|
||||
|
||||
void StatisticsCalculator::AcceleratedSamples(size_t num_samples) {
|
||||
@ -205,6 +210,7 @@ void StatisticsCalculator::IncreaseCounter(size_t num_samples, int fs_hz) {
|
||||
timestamps_since_last_report_ = 0;
|
||||
discarded_packets_ = 0;
|
||||
}
|
||||
lifetime_stats_.total_samples_received += num_samples;
|
||||
}
|
||||
|
||||
void StatisticsCalculator::SecondaryDecodedSamples(int num_samples) {
|
||||
@ -307,6 +313,10 @@ void StatisticsCalculator::GetNetworkStatistics(
|
||||
Reset();
|
||||
}
|
||||
|
||||
NetEqLifetimeStatistics StatisticsCalculator::GetLifetimeStatistics() const {
|
||||
return lifetime_stats_;
|
||||
}
|
||||
|
||||
uint16_t StatisticsCalculator::CalculateQ14Ratio(size_t numerator,
|
||||
uint32_t denominator) {
|
||||
if (numerator == 0) {
|
||||
|
||||
@ -99,6 +99,10 @@ class StatisticsCalculator {
|
||||
const DecisionLogic& decision_logic,
|
||||
NetEqNetworkStatistics *stats);
|
||||
|
||||
// Returns a copy of this class's lifetime statistics. These statistics are
|
||||
// never reset.
|
||||
NetEqLifetimeStatistics GetLifetimeStatistics() const;
|
||||
|
||||
private:
|
||||
static const int kMaxReportPeriod = 60; // Seconds before auto-reset.
|
||||
static const size_t kLenWaitingTimes = 100;
|
||||
@ -158,6 +162,8 @@ class StatisticsCalculator {
|
||||
// Calculates numerator / denominator, and returns the value in Q14.
|
||||
static uint16_t CalculateQ14Ratio(size_t numerator, uint32_t denominator);
|
||||
|
||||
// TODO(steveanton): Add unit tests for the lifetime stats.
|
||||
NetEqLifetimeStatistics lifetime_stats_;
|
||||
size_t preemptive_samples_;
|
||||
size_t accelerate_samples_;
|
||||
size_t added_zero_samples_;
|
||||
|
||||
Reference in New Issue
Block a user