OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 bool fec_enabled_; | 78 bool fec_enabled_; |
79 }; | 79 }; |
80 | 80 |
81 class NetEqNetworkStatsTest : public NetEqExternalDecoderTest { | 81 class NetEqNetworkStatsTest : public NetEqExternalDecoderTest { |
82 public: | 82 public: |
83 static const int kPayloadSizeByte = 30; | 83 static const int kPayloadSizeByte = 30; |
84 static const int kFrameSizeMs = 20; | 84 static const int kFrameSizeMs = 20; |
85 static const int kMaxOutputSize = 960; // 10 ms * 48 kHz * 2 channels. | 85 static const int kMaxOutputSize = 960; // 10 ms * 48 kHz * 2 channels. |
86 | 86 |
87 enum logic { | 87 enum logic { |
88 IGNORE, | 88 kIgnore, |
89 EQUAL, | 89 kEqual, |
90 SMALLER_THAN, | 90 kSmallerThan, |
91 LARGER_THAN, | 91 kLargerThan, |
92 }; | 92 }; |
93 | 93 |
94 struct NetEqNetworkStatsCheck { | 94 struct NetEqNetworkStatsCheck { |
95 logic current_buffer_size_ms; | 95 logic current_buffer_size_ms; |
96 logic preferred_buffer_size_ms; | 96 logic preferred_buffer_size_ms; |
97 logic jitter_peaks_found; | 97 logic jitter_peaks_found; |
98 logic packet_loss_rate; | 98 logic packet_loss_rate; |
99 logic packet_discard_rate; | 99 logic packet_discard_rate; |
100 logic expand_rate; | 100 logic expand_rate; |
101 logic speech_expand_rate; | 101 logic speech_expand_rate; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // expects.x = -1, do not care | 136 // expects.x = -1, do not care |
137 // expects.x = 0, 'x' in current stats should equal 'x' in |stats_ref| | 137 // expects.x = 0, 'x' in current stats should equal 'x' in |stats_ref| |
138 // expects.x = 1, 'x' in current stats should < 'x' in |stats_ref| | 138 // expects.x = 1, 'x' in current stats should < 'x' in |stats_ref| |
139 // expects.x = 2, 'x' in current stats should > 'x' in |stats_ref| | 139 // expects.x = 2, 'x' in current stats should > 'x' in |stats_ref| |
140 void CheckNetworkStatistics(NetEqNetworkStatsCheck expects) { | 140 void CheckNetworkStatistics(NetEqNetworkStatsCheck expects) { |
141 NetEqNetworkStatistics stats; | 141 NetEqNetworkStatistics stats; |
142 neteq()->NetworkStatistics(&stats); | 142 neteq()->NetworkStatistics(&stats); |
143 | 143 |
144 #define CHECK_NETEQ_NETWORK_STATS(x)\ | 144 #define CHECK_NETEQ_NETWORK_STATS(x)\ |
145 switch (expects.x) {\ | 145 switch (expects.x) {\ |
146 case EQUAL:\ | 146 case kEqual:\ |
147 EXPECT_EQ(stats.x, expects.stats_ref.x);\ | 147 EXPECT_EQ(stats.x, expects.stats_ref.x);\ |
148 break;\ | 148 break;\ |
149 case SMALLER_THAN:\ | 149 case kSmallerThan:\ |
150 EXPECT_LT(stats.x, expects.stats_ref.x);\ | 150 EXPECT_LT(stats.x, expects.stats_ref.x);\ |
151 break;\ | 151 break;\ |
152 case LARGER_THAN:\ | 152 case kLargerThan:\ |
153 EXPECT_GT(stats.x, expects.stats_ref.x);\ | 153 EXPECT_GT(stats.x, expects.stats_ref.x);\ |
154 break;\ | 154 break;\ |
155 default:\ | 155 default:\ |
156 break;\ | 156 break;\ |
157 } | 157 } |
158 | 158 |
159 CHECK_NETEQ_NETWORK_STATS(current_buffer_size_ms); | 159 CHECK_NETEQ_NETWORK_STATS(current_buffer_size_ms); |
160 CHECK_NETEQ_NETWORK_STATS(preferred_buffer_size_ms); | 160 CHECK_NETEQ_NETWORK_STATS(preferred_buffer_size_ms); |
161 CHECK_NETEQ_NETWORK_STATS(jitter_peaks_found); | 161 CHECK_NETEQ_NETWORK_STATS(jitter_peaks_found); |
162 CHECK_NETEQ_NETWORK_STATS(packet_loss_rate); | 162 CHECK_NETEQ_NETWORK_STATS(packet_loss_rate); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 GetOutputAudio(kMaxOutputSize, output_, &output_type); | 197 GetOutputAudio(kMaxOutputSize, output_, &output_type); |
198 time_now += kOutputLengthMs; | 198 time_now += kOutputLengthMs; |
199 } | 199 } |
200 CheckNetworkStatistics(expects); | 200 CheckNetworkStatistics(expects); |
201 neteq()->FlushBuffers(); | 201 neteq()->FlushBuffers(); |
202 } | 202 } |
203 | 203 |
204 void DecodeFecTest() { | 204 void DecodeFecTest() { |
205 external_decoder_->set_fec_enabled(false); | 205 external_decoder_->set_fec_enabled(false); |
206 NetEqNetworkStatsCheck expects = { | 206 NetEqNetworkStatsCheck expects = { |
207 IGNORE, // current_buffer_size_ms | 207 kIgnore, // current_buffer_size_ms |
208 IGNORE, // preferred_buffer_size_ms | 208 kIgnore, // preferred_buffer_size_ms |
209 IGNORE, // jitter_peaks_found | 209 kIgnore, // jitter_peaks_found |
210 EQUAL, // packet_loss_rate | 210 kEqual, // packet_loss_rate |
211 EQUAL, // packet_discard_rate | 211 kEqual, // packet_discard_rate |
212 EQUAL, // expand_rate | 212 kEqual, // expand_rate |
213 EQUAL, // voice_expand_rate | 213 kEqual, // voice_expand_rate |
214 IGNORE, // preemptive_rate | 214 kIgnore, // preemptive_rate |
215 EQUAL, // accelerate_rate | 215 kEqual, // accelerate_rate |
216 EQUAL, // decoded_fec_rate | 216 kEqual, // decoded_fec_rate |
217 IGNORE, // clockdrift_ppm | 217 kIgnore, // clockdrift_ppm |
218 EQUAL, // added_zero_samples | 218 kEqual, // added_zero_samples |
219 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | 219 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} |
220 }; | 220 }; |
221 RunTest(50, expects); | 221 RunTest(50, expects); |
222 | 222 |
223 // Next we introduce packet losses. | 223 // Next we introduce packet losses. |
224 SetPacketLossRate(0.1); | 224 SetPacketLossRate(0.1); |
225 expects.stats_ref.packet_loss_rate = 1337; | 225 expects.stats_ref.packet_loss_rate = 1337; |
226 expects.stats_ref.expand_rate = expects.stats_ref.speech_expand_rate = 1065; | 226 expects.stats_ref.expand_rate = expects.stats_ref.speech_expand_rate = 1065; |
227 RunTest(50, expects); | 227 RunTest(50, expects); |
228 | 228 |
229 // Next we enable FEC. | 229 // Next we enable FEC. |
230 external_decoder_->set_fec_enabled(true); | 230 external_decoder_->set_fec_enabled(true); |
231 // If FEC fills in the lost packets, no packet loss will be counted. | 231 // If FEC fills in the lost packets, no packet loss will be counted. |
232 expects.stats_ref.packet_loss_rate = 0; | 232 expects.stats_ref.packet_loss_rate = 0; |
233 expects.stats_ref.expand_rate = expects.stats_ref.speech_expand_rate = 0; | 233 expects.stats_ref.expand_rate = expects.stats_ref.speech_expand_rate = 0; |
234 expects.stats_ref.secondary_decoded_rate = 2006; | 234 expects.stats_ref.secondary_decoded_rate = 2006; |
235 RunTest(50, expects); | 235 RunTest(50, expects); |
236 } | 236 } |
237 | 237 |
238 void NoiseExpansionTest() { | 238 void NoiseExpansionTest() { |
239 NetEqNetworkStatsCheck expects = { | 239 NetEqNetworkStatsCheck expects = { |
240 IGNORE, // current_buffer_size_ms | 240 kIgnore, // current_buffer_size_ms |
241 IGNORE, // preferred_buffer_size_ms | 241 kIgnore, // preferred_buffer_size_ms |
242 IGNORE, // jitter_peaks_found | 242 kIgnore, // jitter_peaks_found |
243 EQUAL, // packet_loss_rate | 243 kEqual, // packet_loss_rate |
244 EQUAL, // packet_discard_rate | 244 kEqual, // packet_discard_rate |
245 EQUAL, // expand_rate | 245 kEqual, // expand_rate |
246 EQUAL, // speech_expand_rate | 246 kEqual, // speech_expand_rate |
247 IGNORE, // preemptive_rate | 247 kIgnore, // preemptive_rate |
248 EQUAL, // accelerate_rate | 248 kEqual, // accelerate_rate |
249 EQUAL, // decoded_fec_rate | 249 kEqual, // decoded_fec_rate |
250 IGNORE, // clockdrift_ppm | 250 kIgnore, // clockdrift_ppm |
251 EQUAL, // added_zero_samples | 251 kEqual, // added_zero_samples |
252 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | 252 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} |
253 }; | 253 }; |
254 RunTest(50, expects); | 254 RunTest(50, expects); |
255 | 255 |
256 SetPacketLossRate(1); | 256 SetPacketLossRate(1); |
257 expects.stats_ref.expand_rate = 16384; | 257 expects.stats_ref.expand_rate = 16384; |
258 expects.stats_ref.speech_expand_rate = 5324; | 258 expects.stats_ref.speech_expand_rate = 5324; |
259 RunTest(10, expects); // Lost 10 * 20ms in a row. | 259 RunTest(10, expects); // Lost 10 * 20ms in a row. |
260 } | 260 } |
261 | 261 |
(...skipping 29 matching lines...) Expand all Loading... |
291 test.NoiseExpansionTest(); | 291 test.NoiseExpansionTest(); |
292 EXPECT_CALL(decoder, Die()).Times(1); | 292 EXPECT_CALL(decoder, Die()).Times(1); |
293 } | 293 } |
294 | 294 |
295 } // namespace test | 295 } // namespace test |
296 } // namespace webrtc | 296 } // namespace webrtc |
297 | 297 |
298 | 298 |
299 | 299 |
300 | 300 |
OLD | NEW |