| OLD | NEW |
| 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 <deque> |
| 14 #include <string> | 15 #include <string> |
| 15 #include <vector> | |
| 16 | 16 |
| 17 #include "webrtc/base/constructormagic.h" | 17 #include "webrtc/base/constructormagic.h" |
| 18 #include "webrtc/modules/audio_coding/neteq/interface/neteq.h" | 18 #include "webrtc/modules/audio_coding/neteq/interface/neteq.h" |
| 19 #include "webrtc/typedefs.h" | 19 #include "webrtc/typedefs.h" |
| 20 | 20 |
| 21 namespace webrtc { | 21 namespace webrtc { |
| 22 | 22 |
| 23 // Forward declarations. | 23 // Forward declarations. |
| 24 class DecisionLogic; | 24 class DecisionLogic; |
| 25 class DelayManager; | 25 class DelayManager; |
| 26 | 26 |
| 27 // This class handles various network statistics in NetEq. | 27 // This class handles various network statistics in NetEq. |
| 28 class StatisticsCalculator { | 28 class StatisticsCalculator { |
| 29 public: | 29 public: |
| 30 StatisticsCalculator(); | 30 StatisticsCalculator(); |
| 31 | 31 |
| 32 virtual ~StatisticsCalculator() {} | 32 virtual ~StatisticsCalculator(); |
| 33 | 33 |
| 34 // Resets most of the counters. | 34 // Resets most of the counters. |
| 35 void Reset(); | 35 void Reset(); |
| 36 | 36 |
| 37 // Resets the counters that are not handled by Reset(). | 37 // Resets the counters that are not handled by Reset(). |
| 38 void ResetMcu(); | 38 void ResetMcu(); |
| 39 | 39 |
| 40 // Resets the waiting time statistics. | |
| 41 void ResetWaitingTimeStatistics(); | |
| 42 | |
| 43 // Reports that |num_samples| samples were produced through expansion, and | 40 // Reports that |num_samples| samples were produced through expansion, and |
| 44 // that the expansion produced other than just noise samples. | 41 // that the expansion produced other than just noise samples. |
| 45 void ExpandedVoiceSamples(size_t num_samples); | 42 void ExpandedVoiceSamples(size_t num_samples); |
| 46 | 43 |
| 47 // Reports that |num_samples| samples were produced through expansion, and | 44 // Reports that |num_samples| samples were produced through expansion, and |
| 48 // that the expansion produced only noise samples. | 45 // that the expansion produced only noise samples. |
| 49 void ExpandedNoiseSamples(size_t num_samples); | 46 void ExpandedNoiseSamples(size_t num_samples); |
| 50 | 47 |
| 51 // Reports that |num_samples| samples were produced through preemptive | 48 // Reports that |num_samples| samples were produced through preemptive |
| 52 // expansion. | 49 // expansion. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // is |fs_hz|, the total number of samples in packet buffer and sync buffer | 81 // is |fs_hz|, the total number of samples in packet buffer and sync buffer |
| 85 // yet to play out is |num_samples_in_buffers|, and the number of samples per | 82 // yet to play out is |num_samples_in_buffers|, and the number of samples per |
| 86 // packet is |samples_per_packet|. | 83 // packet is |samples_per_packet|. |
| 87 void GetNetworkStatistics(int fs_hz, | 84 void GetNetworkStatistics(int fs_hz, |
| 88 size_t num_samples_in_buffers, | 85 size_t num_samples_in_buffers, |
| 89 size_t samples_per_packet, | 86 size_t samples_per_packet, |
| 90 const DelayManager& delay_manager, | 87 const DelayManager& delay_manager, |
| 91 const DecisionLogic& decision_logic, | 88 const DecisionLogic& decision_logic, |
| 92 NetEqNetworkStatistics *stats); | 89 NetEqNetworkStatistics *stats); |
| 93 | 90 |
| 94 void WaitingTimes(std::vector<int>* waiting_times); | |
| 95 | |
| 96 private: | 91 private: |
| 97 static const int kMaxReportPeriod = 60; // Seconds before auto-reset. | 92 static const int kMaxReportPeriod = 60; // Seconds before auto-reset. |
| 98 static const int kLenWaitingTimes = 100; | 93 static const size_t kLenWaitingTimes = 100; |
| 99 | 94 |
| 100 class PeriodicUmaLogger { | 95 class PeriodicUmaLogger { |
| 101 public: | 96 public: |
| 102 PeriodicUmaLogger(const std::string& uma_name, | 97 PeriodicUmaLogger(const std::string& uma_name, |
| 103 int report_interval_ms, | 98 int report_interval_ms, |
| 104 int max_value); | 99 int max_value); |
| 105 virtual ~PeriodicUmaLogger(); | 100 virtual ~PeriodicUmaLogger(); |
| 106 void AdvanceClock(int step_ms); | 101 void AdvanceClock(int step_ms); |
| 107 | 102 |
| 108 protected: | 103 protected: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 static uint16_t CalculateQ14Ratio(size_t numerator, uint32_t denominator); | 148 static uint16_t CalculateQ14Ratio(size_t numerator, uint32_t denominator); |
| 154 | 149 |
| 155 size_t preemptive_samples_; | 150 size_t preemptive_samples_; |
| 156 size_t accelerate_samples_; | 151 size_t accelerate_samples_; |
| 157 size_t added_zero_samples_; | 152 size_t added_zero_samples_; |
| 158 size_t expanded_speech_samples_; | 153 size_t expanded_speech_samples_; |
| 159 size_t expanded_noise_samples_; | 154 size_t expanded_noise_samples_; |
| 160 size_t discarded_packets_; | 155 size_t discarded_packets_; |
| 161 size_t lost_timestamps_; | 156 size_t lost_timestamps_; |
| 162 uint32_t timestamps_since_last_report_; | 157 uint32_t timestamps_since_last_report_; |
| 163 int waiting_times_[kLenWaitingTimes]; // Used as a circular buffer. | 158 std::deque<int> waiting_times_; |
| 164 int len_waiting_times_; | |
| 165 int next_waiting_time_index_; | |
| 166 uint32_t secondary_decoded_samples_; | 159 uint32_t secondary_decoded_samples_; |
| 167 PeriodicUmaCount delayed_packet_outage_counter_; | 160 PeriodicUmaCount delayed_packet_outage_counter_; |
| 168 PeriodicUmaAverage excess_buffer_delay_; | 161 PeriodicUmaAverage excess_buffer_delay_; |
| 169 | 162 |
| 170 DISALLOW_COPY_AND_ASSIGN(StatisticsCalculator); | 163 DISALLOW_COPY_AND_ASSIGN(StatisticsCalculator); |
| 171 }; | 164 }; |
| 172 | 165 |
| 173 } // namespace webrtc | 166 } // namespace webrtc |
| 174 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_ | 167 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_ |
| OLD | NEW |