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

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

Issue 1289753008: DRAFT: Make new base class PeriodicUmaLogger (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@neteq-metrics3
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 | « no previous file | webrtc/modules/audio_coding/neteq/statistics_calculator.cc » ('j') | 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 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_ 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_
13 13
14 #include <string>
14 #include <vector> 15 #include <vector>
15 16
16 #include "webrtc/base/constructormagic.h" 17 #include "webrtc/base/constructormagic.h"
17 #include "webrtc/modules/audio_coding/neteq/interface/neteq.h" 18 #include "webrtc/modules/audio_coding/neteq/interface/neteq.h"
18 #include "webrtc/typedefs.h" 19 #include "webrtc/typedefs.h"
19 20
20 namespace webrtc { 21 namespace webrtc {
21 22
22 // Forward declarations. 23 // Forward declarations.
23 class DecisionLogic; 24 class DecisionLogic;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 const DelayManager& delay_manager, 90 const DelayManager& delay_manager,
90 const DecisionLogic& decision_logic, 91 const DecisionLogic& decision_logic,
91 NetEqNetworkStatistics *stats); 92 NetEqNetworkStatistics *stats);
92 93
93 void WaitingTimes(std::vector<int>* waiting_times); 94 void WaitingTimes(std::vector<int>* waiting_times);
94 95
95 private: 96 private:
96 static const int kMaxReportPeriod = 60; // Seconds before auto-reset. 97 static const int kMaxReportPeriod = 60; // Seconds before auto-reset.
97 static const int kLenWaitingTimes = 100; 98 static const int kLenWaitingTimes = 100;
98 99
99 class DelayedPacketOutagesPerMinuteCounter { 100 class PeriodicUmaLogger {
100 public: 101 public:
101 ~DelayedPacketOutagesPerMinuteCounter() { 102 PeriodicUmaLogger(const std::string& uma_name,
102 LogToUma(); // Log the count for the current (incomplete) interval. 103 int report_interval_ms,
103 } 104 int max_value);
104 void RegisterEvent(); 105 virtual ~PeriodicUmaLogger();
105 void AdvanceClock(int step_ms); 106 void AdvanceClock(int step_ms);
106 107
107 private: 108 protected:
108 static const int kReportIntervalMs = 60 * 1000; // One minute. 109 void LogToUma(int value) const;
110 virtual int Metric() const = 0;
111 virtual void Reset() = 0;
109 112
110 void LogToUma() const; 113 const std::string uma_name_;
111 114 const int report_interval_ms_;
112 int counter_ = 0; 115 const int max_value_;
113 int timer_ = 0; 116 int timer_ = 0;
114 }; 117 };
115 118
116 class AverageExcessBufferDelayMs { 119 class DelayedPacketOutagesPerMinuteCounter final : public PeriodicUmaLogger {
117 public: 120 public:
121 DelayedPacketOutagesPerMinuteCounter();
122 ~DelayedPacketOutagesPerMinuteCounter() {
123 // Log the count for the current (incomplete) interval.
124 LogToUma(Metric());
125 }
126 void RegisterEvent();
127
128 protected:
129 int Metric() const override;
130 void Reset() override;
131
132 private:
133 int counter_ = 0;
134 };
135
136 class AverageExcessBufferDelayMs final : public PeriodicUmaLogger {
137 public:
138 AverageExcessBufferDelayMs();
118 ~AverageExcessBufferDelayMs() { 139 ~AverageExcessBufferDelayMs() {
119 LogToUma(); // Log the average for the current (incomplete) interval. 140 // Log the average for the current (incomplete) interval.
141 LogToUma(Metric());
120 } 142 }
121 void RegisterPacketWaitingTime(int time_ms); 143 void RegisterPacketWaitingTime(int time_ms);
122 void AdvanceClock(int step_ms); 144
145 protected:
146 int Metric() const override;
147 void Reset() override;
123 148
124 private: 149 private:
125 static const int kReportIntervalMs = 60 * 1000; // One minute.
126
127 void LogToUma();
128
129 double sum_ = 0.0; 150 double sum_ = 0.0;
130 int num_packets_ = 0; 151 int num_packets_ = 0;
131 int timer_ = 0;
132 }; 152 };
133 153
134 // Calculates numerator / denominator, and returns the value in Q14. 154 // Calculates numerator / denominator, and returns the value in Q14.
135 static uint16_t CalculateQ14Ratio(uint32_t numerator, uint32_t denominator); 155 static uint16_t CalculateQ14Ratio(uint32_t numerator, uint32_t denominator);
136 156
137 uint32_t preemptive_samples_; 157 uint32_t preemptive_samples_;
138 uint32_t accelerate_samples_; 158 uint32_t accelerate_samples_;
139 int added_zero_samples_; 159 int added_zero_samples_;
140 uint32_t expanded_speech_samples_; 160 uint32_t expanded_speech_samples_;
141 uint32_t expanded_noise_samples_; 161 uint32_t expanded_noise_samples_;
142 int discarded_packets_; 162 int discarded_packets_;
143 uint32_t lost_timestamps_; 163 uint32_t lost_timestamps_;
144 uint32_t timestamps_since_last_report_; 164 uint32_t timestamps_since_last_report_;
145 int waiting_times_[kLenWaitingTimes]; // Used as a circular buffer. 165 int waiting_times_[kLenWaitingTimes]; // Used as a circular buffer.
146 int len_waiting_times_; 166 int len_waiting_times_;
147 int next_waiting_time_index_; 167 int next_waiting_time_index_;
148 uint32_t secondary_decoded_samples_; 168 uint32_t secondary_decoded_samples_;
149 DelayedPacketOutagesPerMinuteCounter delayed_packet_outage_counter_; 169 DelayedPacketOutagesPerMinuteCounter delayed_packet_outage_counter_;
150 AverageExcessBufferDelayMs excess_buffer_delay_; 170 AverageExcessBufferDelayMs excess_buffer_delay_;
151 171
152 DISALLOW_COPY_AND_ASSIGN(StatisticsCalculator); 172 DISALLOW_COPY_AND_ASSIGN(StatisticsCalculator);
153 }; 173 };
154 174
155 } // namespace webrtc 175 } // namespace webrtc
156 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_ 176 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_coding/neteq/statistics_calculator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698