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

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

Issue 1292423003: NetEq: Implement counting of Delayed Packet Outage Events per minute (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@neteq-metrics
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
« no previous file with comments | « webrtc/modules/audio_coding/neteq/statistics_calculator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "webrtc/modules/audio_coding/neteq/statistics_calculator.h" 11 #include "webrtc/modules/audio_coding/neteq/statistics_calculator.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 #include <string.h> // memset 14 #include <string.h> // memset
15 15
16 #include "webrtc/base/checks.h"
16 #include "webrtc/modules/audio_coding/neteq/decision_logic.h" 17 #include "webrtc/modules/audio_coding/neteq/decision_logic.h"
17 #include "webrtc/modules/audio_coding/neteq/delay_manager.h" 18 #include "webrtc/modules/audio_coding/neteq/delay_manager.h"
18 #include "webrtc/system_wrappers/interface/metrics.h" 19 #include "webrtc/system_wrappers/interface/metrics.h"
19 20
20 namespace webrtc { 21 namespace webrtc {
21 22
23 void StatisticsCalculator::DelayedPacketOutagesPerMinuteCounter::
24 RegisterEvent() {
25 ++counter_;
26 }
27
28 void StatisticsCalculator::DelayedPacketOutagesPerMinuteCounter::AdvanceClock(
29 int step_ms) {
30 timer_ += step_ms;
31 if (timer_ < kReportIntervalMs) {
32 return;
33 }
34 LogToUma();
35 counter_ = 0;
36 timer_ -= kReportIntervalMs;
37 DCHECK_GE(timer_, 0);
38 }
39
40 void StatisticsCalculator::DelayedPacketOutagesPerMinuteCounter::LogToUma()
41 const {
42 RTC_HISTOGRAM_COUNTS_100("WebRTC.Audio.DelayedPacketOutageEventsPerMinute",
43 counter_);
44 }
45
22 StatisticsCalculator::StatisticsCalculator() 46 StatisticsCalculator::StatisticsCalculator()
23 : preemptive_samples_(0), 47 : preemptive_samples_(0),
24 accelerate_samples_(0), 48 accelerate_samples_(0),
25 added_zero_samples_(0), 49 added_zero_samples_(0),
26 expanded_speech_samples_(0), 50 expanded_speech_samples_(0),
27 expanded_noise_samples_(0), 51 expanded_noise_samples_(0),
28 discarded_packets_(0), 52 discarded_packets_(0),
29 lost_timestamps_(0), 53 lost_timestamps_(0),
30 timestamps_since_last_report_(0), 54 timestamps_since_last_report_(0),
31 len_waiting_times_(0), 55 len_waiting_times_(0),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 101
78 void StatisticsCalculator::PacketsDiscarded(int num_packets) { 102 void StatisticsCalculator::PacketsDiscarded(int num_packets) {
79 discarded_packets_ += num_packets; 103 discarded_packets_ += num_packets;
80 } 104 }
81 105
82 void StatisticsCalculator::LostSamples(int num_samples) { 106 void StatisticsCalculator::LostSamples(int num_samples) {
83 lost_timestamps_ += num_samples; 107 lost_timestamps_ += num_samples;
84 } 108 }
85 109
86 void StatisticsCalculator::IncreaseCounter(int num_samples, int fs_hz) { 110 void StatisticsCalculator::IncreaseCounter(int num_samples, int fs_hz) {
111 delayed_packet_outage_counter_.AdvanceClock(
112 rtc::CheckedDivExact(1000 * num_samples, fs_hz));
87 timestamps_since_last_report_ += static_cast<uint32_t>(num_samples); 113 timestamps_since_last_report_ += static_cast<uint32_t>(num_samples);
88 if (timestamps_since_last_report_ > 114 if (timestamps_since_last_report_ >
89 static_cast<uint32_t>(fs_hz * kMaxReportPeriod)) { 115 static_cast<uint32_t>(fs_hz * kMaxReportPeriod)) {
90 lost_timestamps_ = 0; 116 lost_timestamps_ = 0;
91 timestamps_since_last_report_ = 0; 117 timestamps_since_last_report_ = 0;
92 discarded_packets_ = 0; 118 discarded_packets_ = 0;
93 } 119 }
94 } 120 }
95 121
96 void StatisticsCalculator::SecondaryDecodedSamples(int num_samples) { 122 void StatisticsCalculator::SecondaryDecodedSamples(int num_samples) {
97 secondary_decoded_samples_ += num_samples; 123 secondary_decoded_samples_ += num_samples;
98 } 124 }
99 125
100 void StatisticsCalculator::LogDelayedPacketOutageEvent(int outage_duration_ms) { 126 void StatisticsCalculator::LogDelayedPacketOutageEvent(int outage_duration_ms) {
101 RTC_HISTOGRAM_COUNTS("WebRTC.Audio.DelayedPacketOutageEventMs", 127 RTC_HISTOGRAM_COUNTS("WebRTC.Audio.DelayedPacketOutageEventMs",
102 outage_duration_ms, 1 /* min */, 2000 /* max */, 128 outage_duration_ms, 1 /* min */, 2000 /* max */,
103 100 /* bucket count */); 129 100 /* bucket count */);
130 delayed_packet_outage_counter_.RegisterEvent();
104 } 131 }
105 132
106 void StatisticsCalculator::StoreWaitingTime(int waiting_time_ms) { 133 void StatisticsCalculator::StoreWaitingTime(int waiting_time_ms) {
107 assert(next_waiting_time_index_ < kLenWaitingTimes); 134 assert(next_waiting_time_index_ < kLenWaitingTimes);
108 waiting_times_[next_waiting_time_index_] = waiting_time_ms; 135 waiting_times_[next_waiting_time_index_] = waiting_time_ms;
109 next_waiting_time_index_++; 136 next_waiting_time_index_++;
110 if (next_waiting_time_index_ >= kLenWaitingTimes) { 137 if (next_waiting_time_index_ >= kLenWaitingTimes) {
111 next_waiting_time_index_ = 0; 138 next_waiting_time_index_ = 0;
112 } 139 }
113 if (len_waiting_times_ < kLenWaitingTimes) { 140 if (len_waiting_times_ < kLenWaitingTimes) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // Ratio must be smaller than 1 in Q14. 210 // Ratio must be smaller than 1 in Q14.
184 assert((numerator << 14) / denominator < (1 << 14)); 211 assert((numerator << 14) / denominator < (1 << 14));
185 return static_cast<uint16_t>((numerator << 14) / denominator); 212 return static_cast<uint16_t>((numerator << 14) / denominator);
186 } else { 213 } else {
187 // Will not produce a ratio larger than 1, since this is probably an error. 214 // Will not produce a ratio larger than 1, since this is probably an error.
188 return 1 << 14; 215 return 1 << 14;
189 } 216 }
190 } 217 }
191 218
192 } // namespace webrtc 219 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/statistics_calculator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698