Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: webrtc/modules/audio_coding/neteq/statistics_calculator.cc

Issue 1284303003: NetEq: Implement Average Excess Buffer Delay stats (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@neteq-metrics2
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 25 matching lines...) Expand all
36 timer_ -= kReportIntervalMs; 36 timer_ -= kReportIntervalMs;
37 DCHECK_GE(timer_, 0); 37 DCHECK_GE(timer_, 0);
38 } 38 }
39 39
40 void StatisticsCalculator::DelayedPacketOutagesPerMinuteCounter::LogToUma() 40 void StatisticsCalculator::DelayedPacketOutagesPerMinuteCounter::LogToUma()
41 const { 41 const {
42 RTC_HISTOGRAM_COUNTS_100("WebRTC.Audio.DelayedPacketOutageEventsPerMinute", 42 RTC_HISTOGRAM_COUNTS_100("WebRTC.Audio.DelayedPacketOutageEventsPerMinute",
43 counter_); 43 counter_);
44 } 44 }
45 45
46 void StatisticsCalculator::AverageExcessBufferDelayMs::
47 RegisterPacketWaitingTime(int time_ms) {
48 sum_ += time_ms;
49 ++num_packets_;
50 }
51
52 void StatisticsCalculator::AverageExcessBufferDelayMs::AdvanceClock(
53 int step_ms) {
54 timer_ += step_ms;
55 if (timer_ < kReportIntervalMs) {
56 return;
57 }
58 LogToUma();
59 sum_ = 0.0;
60 num_packets_ = 0;
61 timer_ -= kReportIntervalMs;
62 DCHECK_GE(timer_, 0);
63 }
64
65 void StatisticsCalculator::AverageExcessBufferDelayMs::LogToUma() {
66 if (num_packets_ > 0) {
67 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Audio.AverageExcessBufferDelayMs",
68 static_cast<int>(sum_ / num_packets_));
69 }
70 }
71
46 StatisticsCalculator::StatisticsCalculator() 72 StatisticsCalculator::StatisticsCalculator()
47 : preemptive_samples_(0), 73 : preemptive_samples_(0),
48 accelerate_samples_(0), 74 accelerate_samples_(0),
49 added_zero_samples_(0), 75 added_zero_samples_(0),
50 expanded_speech_samples_(0), 76 expanded_speech_samples_(0),
51 expanded_noise_samples_(0), 77 expanded_noise_samples_(0),
52 discarded_packets_(0), 78 discarded_packets_(0),
53 lost_timestamps_(0), 79 lost_timestamps_(0),
54 timestamps_since_last_report_(0), 80 timestamps_since_last_report_(0),
55 len_waiting_times_(0), 81 len_waiting_times_(0),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 127
102 void StatisticsCalculator::PacketsDiscarded(int num_packets) { 128 void StatisticsCalculator::PacketsDiscarded(int num_packets) {
103 discarded_packets_ += num_packets; 129 discarded_packets_ += num_packets;
104 } 130 }
105 131
106 void StatisticsCalculator::LostSamples(int num_samples) { 132 void StatisticsCalculator::LostSamples(int num_samples) {
107 lost_timestamps_ += num_samples; 133 lost_timestamps_ += num_samples;
108 } 134 }
109 135
110 void StatisticsCalculator::IncreaseCounter(int num_samples, int fs_hz) { 136 void StatisticsCalculator::IncreaseCounter(int num_samples, int fs_hz) {
111 delayed_packet_outage_counter_.AdvanceClock( 137 const int time_step_ms = rtc::CheckedDivExact(1000 * num_samples, fs_hz);
112 rtc::CheckedDivExact(1000 * num_samples, fs_hz)); 138 delayed_packet_outage_counter_.AdvanceClock(time_step_ms);
139 excess_buffer_delay_.AdvanceClock(time_step_ms);
113 timestamps_since_last_report_ += static_cast<uint32_t>(num_samples); 140 timestamps_since_last_report_ += static_cast<uint32_t>(num_samples);
114 if (timestamps_since_last_report_ > 141 if (timestamps_since_last_report_ >
115 static_cast<uint32_t>(fs_hz * kMaxReportPeriod)) { 142 static_cast<uint32_t>(fs_hz * kMaxReportPeriod)) {
116 lost_timestamps_ = 0; 143 lost_timestamps_ = 0;
117 timestamps_since_last_report_ = 0; 144 timestamps_since_last_report_ = 0;
118 discarded_packets_ = 0; 145 discarded_packets_ = 0;
119 } 146 }
120 } 147 }
121 148
122 void StatisticsCalculator::SecondaryDecodedSamples(int num_samples) { 149 void StatisticsCalculator::SecondaryDecodedSamples(int num_samples) {
123 secondary_decoded_samples_ += num_samples; 150 secondary_decoded_samples_ += num_samples;
124 } 151 }
125 152
126 void StatisticsCalculator::LogDelayedPacketOutageEvent(int outage_duration_ms) { 153 void StatisticsCalculator::LogDelayedPacketOutageEvent(int outage_duration_ms) {
127 RTC_HISTOGRAM_COUNTS("WebRTC.Audio.DelayedPacketOutageEventMs", 154 RTC_HISTOGRAM_COUNTS("WebRTC.Audio.DelayedPacketOutageEventMs",
128 outage_duration_ms, 1 /* min */, 2000 /* max */, 155 outage_duration_ms, 1 /* min */, 2000 /* max */,
129 100 /* bucket count */); 156 100 /* bucket count */);
130 delayed_packet_outage_counter_.RegisterEvent(); 157 delayed_packet_outage_counter_.RegisterEvent();
131 } 158 }
132 159
133 void StatisticsCalculator::StoreWaitingTime(int waiting_time_ms) { 160 void StatisticsCalculator::StoreWaitingTime(int waiting_time_ms) {
161 excess_buffer_delay_.RegisterPacketWaitingTime(waiting_time_ms);
134 assert(next_waiting_time_index_ < kLenWaitingTimes); 162 assert(next_waiting_time_index_ < kLenWaitingTimes);
135 waiting_times_[next_waiting_time_index_] = waiting_time_ms; 163 waiting_times_[next_waiting_time_index_] = waiting_time_ms;
136 next_waiting_time_index_++; 164 next_waiting_time_index_++;
137 if (next_waiting_time_index_ >= kLenWaitingTimes) { 165 if (next_waiting_time_index_ >= kLenWaitingTimes) {
138 next_waiting_time_index_ = 0; 166 next_waiting_time_index_ = 0;
139 } 167 }
140 if (len_waiting_times_ < kLenWaitingTimes) { 168 if (len_waiting_times_ < kLenWaitingTimes) {
141 len_waiting_times_++; 169 len_waiting_times_++;
142 } 170 }
143 } 171 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // Ratio must be smaller than 1 in Q14. 238 // Ratio must be smaller than 1 in Q14.
211 assert((numerator << 14) / denominator < (1 << 14)); 239 assert((numerator << 14) / denominator < (1 << 14));
212 return static_cast<uint16_t>((numerator << 14) / denominator); 240 return static_cast<uint16_t>((numerator << 14) / denominator);
213 } else { 241 } else {
214 // Will not produce a ratio larger than 1, since this is probably an error. 242 // Will not produce a ratio larger than 1, since this is probably an error.
215 return 1 << 14; 243 return 1 << 14;
216 } 244 }
217 } 245 }
218 246
219 } // namespace webrtc 247 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698