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 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 void StatisticsCalculator::PacketsDiscarded(int num_packets) { | 77 void StatisticsCalculator::PacketsDiscarded(int num_packets) { |
78 discarded_packets_ += num_packets; | 78 discarded_packets_ += num_packets; |
79 } | 79 } |
80 | 80 |
81 void StatisticsCalculator::LostSamples(int num_samples) { | 81 void StatisticsCalculator::LostSamples(int num_samples) { |
82 lost_timestamps_ += num_samples; | 82 lost_timestamps_ += num_samples; |
83 } | 83 } |
84 | 84 |
85 void StatisticsCalculator::IncreaseCounter(int num_samples, int fs_hz) { | 85 void StatisticsCalculator::IncreaseCounter(int num_samples, int fs_hz) { |
86 timestamps_since_last_report_ += num_samples; | 86 timestamps_since_last_report_ += static_cast<uint32_t>(num_samples); |
87 if (timestamps_since_last_report_ > | 87 if (timestamps_since_last_report_ > |
88 static_cast<uint32_t>(fs_hz * kMaxReportPeriod)) { | 88 static_cast<uint32_t>(fs_hz * kMaxReportPeriod)) { |
89 lost_timestamps_ = 0; | 89 lost_timestamps_ = 0; |
90 timestamps_since_last_report_ = 0; | 90 timestamps_since_last_report_ = 0; |
91 discarded_packets_ = 0; | 91 discarded_packets_ = 0; |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 void StatisticsCalculator::SecondaryDecodedSamples(int num_samples) { | 95 void StatisticsCalculator::SecondaryDecodedSamples(int num_samples) { |
96 secondary_decoded_samples_ += num_samples; | 96 secondary_decoded_samples_ += num_samples; |
(...skipping 17 matching lines...) Expand all Loading... |
114 int samples_per_packet, | 114 int samples_per_packet, |
115 const DelayManager& delay_manager, | 115 const DelayManager& delay_manager, |
116 const DecisionLogic& decision_logic, | 116 const DecisionLogic& decision_logic, |
117 NetEqNetworkStatistics *stats) { | 117 NetEqNetworkStatistics *stats) { |
118 if (fs_hz <= 0 || !stats) { | 118 if (fs_hz <= 0 || !stats) { |
119 assert(false); | 119 assert(false); |
120 return; | 120 return; |
121 } | 121 } |
122 | 122 |
123 stats->added_zero_samples = added_zero_samples_; | 123 stats->added_zero_samples = added_zero_samples_; |
124 stats->current_buffer_size_ms = num_samples_in_buffers * 1000 / fs_hz; | 124 stats->current_buffer_size_ms = |
| 125 static_cast<uint16_t>(num_samples_in_buffers * 1000 / fs_hz); |
125 const int ms_per_packet = decision_logic.packet_length_samples() / | 126 const int ms_per_packet = decision_logic.packet_length_samples() / |
126 (fs_hz / 1000); | 127 (fs_hz / 1000); |
127 stats->preferred_buffer_size_ms = (delay_manager.TargetLevel() >> 8) * | 128 stats->preferred_buffer_size_ms = (delay_manager.TargetLevel() >> 8) * |
128 ms_per_packet; | 129 ms_per_packet; |
129 stats->jitter_peaks_found = delay_manager.PeakFound(); | 130 stats->jitter_peaks_found = delay_manager.PeakFound(); |
130 stats->clockdrift_ppm = delay_manager.AverageIAT(); | 131 stats->clockdrift_ppm = delay_manager.AverageIAT(); |
131 | 132 |
132 stats->packet_loss_rate = | 133 stats->packet_loss_rate = |
133 CalculateQ14Ratio(lost_timestamps_, timestamps_since_last_report_); | 134 CalculateQ14Ratio(lost_timestamps_, timestamps_since_last_report_); |
134 | 135 |
(...skipping 25 matching lines...) Expand all Loading... |
160 } | 161 } |
161 | 162 |
162 void StatisticsCalculator::WaitingTimes(std::vector<int>* waiting_times) { | 163 void StatisticsCalculator::WaitingTimes(std::vector<int>* waiting_times) { |
163 if (!waiting_times) { | 164 if (!waiting_times) { |
164 return; | 165 return; |
165 } | 166 } |
166 waiting_times->assign(waiting_times_, waiting_times_ + len_waiting_times_); | 167 waiting_times->assign(waiting_times_, waiting_times_ + len_waiting_times_); |
167 ResetWaitingTimeStatistics(); | 168 ResetWaitingTimeStatistics(); |
168 } | 169 } |
169 | 170 |
170 int StatisticsCalculator::CalculateQ14Ratio(uint32_t numerator, | 171 uint16_t StatisticsCalculator::CalculateQ14Ratio(uint32_t numerator, |
171 uint32_t denominator) { | 172 uint32_t denominator) { |
172 if (numerator == 0) { | 173 if (numerator == 0) { |
173 return 0; | 174 return 0; |
174 } else if (numerator < denominator) { | 175 } else if (numerator < denominator) { |
175 // Ratio must be smaller than 1 in Q14. | 176 // Ratio must be smaller than 1 in Q14. |
176 assert((numerator << 14) / denominator < (1 << 14)); | 177 assert((numerator << 14) / denominator < (1 << 14)); |
177 return (numerator << 14) / denominator; | 178 return static_cast<uint16_t>((numerator << 14) / denominator); |
178 } else { | 179 } else { |
179 // Will not produce a ratio larger than 1, since this is probably an error. | 180 // Will not produce a ratio larger than 1, since this is probably an error. |
180 return 1 << 14; | 181 return 1 << 14; |
181 } | 182 } |
182 } | 183 } |
183 | 184 |
184 } // namespace webrtc | 185 } // namespace webrtc |
OLD | NEW |