OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 15 matching lines...) Expand all Loading... | |
26 #include "gflags/gflags.h" | 26 #include "gflags/gflags.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
28 #include "webrtc/base/scoped_ptr.h" | 28 #include "webrtc/base/scoped_ptr.h" |
29 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" | 29 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" |
30 #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" | 30 #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" |
31 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" | 31 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" |
32 #include "webrtc/test/testsupport/fileutils.h" | 32 #include "webrtc/test/testsupport/fileutils.h" |
33 #include "webrtc/test/testsupport/gtest_disable.h" | 33 #include "webrtc/test/testsupport/gtest_disable.h" |
34 #include "webrtc/typedefs.h" | 34 #include "webrtc/typedefs.h" |
35 | 35 |
36 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT | |
37 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | |
38 #include "external/webrtc/webrtc/modules/audio_coding/neteq/neteq_unittest.pb.h" | |
39 #else | |
40 #include "webrtc/audio_coding/neteq/neteq_unittest.pb.h" | |
41 #endif | |
42 #endif | |
43 | |
36 DEFINE_bool(gen_ref, false, "Generate reference files."); | 44 DEFINE_bool(gen_ref, false, "Generate reference files."); |
37 | 45 |
38 namespace webrtc { | 46 namespace webrtc { |
39 | 47 |
40 static bool IsAllZero(const int16_t* buf, size_t buf_length) { | 48 static bool IsAllZero(const int16_t* buf, size_t buf_length) { |
41 bool all_zero = true; | 49 bool all_zero = true; |
42 for (size_t n = 0; n < buf_length && all_zero; ++n) | 50 for (size_t n = 0; n < buf_length && all_zero; ++n) |
43 all_zero = buf[n] == 0; | 51 all_zero = buf[n] == 0; |
44 return all_zero; | 52 return all_zero; |
45 } | 53 } |
46 | 54 |
47 static bool IsAllNonZero(const int16_t* buf, size_t buf_length) { | 55 static bool IsAllNonZero(const int16_t* buf, size_t buf_length) { |
48 bool all_non_zero = true; | 56 bool all_non_zero = true; |
49 for (size_t n = 0; n < buf_length && all_non_zero; ++n) | 57 for (size_t n = 0; n < buf_length && all_non_zero; ++n) |
50 all_non_zero = buf[n] != 0; | 58 all_non_zero = buf[n] != 0; |
51 return all_non_zero; | 59 return all_non_zero; |
52 } | 60 } |
53 | 61 |
62 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT | |
63 static void Convert(const NetEqNetworkStatistics& stats_raw, | |
hlundin-webrtc
2015/12/16 10:04:51
Please, enclose these methods in an unnamed namesp
minyue-webrtc
2015/12/16 13:51:26
Done.
| |
64 neteq_unittest::NetEqNetworkStatistics* stats) { | |
hlundin-webrtc
2015/12/16 10:04:51
Should you perhaps name the protobuf representatio
minyue-webrtc
2015/12/16 13:51:27
I actually used NetworkStatistics from beginning a
hlundin-webrtc
2015/12/16 14:10:50
Acknowledged.
| |
65 stats->set_current_buffer_size_ms(stats_raw.current_buffer_size_ms); | |
66 stats->set_preferred_buffer_size_ms(stats_raw.preferred_buffer_size_ms); | |
67 stats->set_jitter_peaks_found(stats_raw.jitter_peaks_found); | |
68 stats->set_packet_loss_rate(stats_raw.packet_loss_rate); | |
69 stats->set_packet_discard_rate(stats_raw.packet_discard_rate); | |
70 stats->set_expand_rate(stats_raw.expand_rate); | |
71 stats->set_speech_expand_rate(stats_raw.speech_expand_rate); | |
72 stats->set_preemptive_rate(stats_raw.preemptive_rate); | |
73 stats->set_accelerate_rate(stats_raw.accelerate_rate); | |
74 stats->set_secondary_decoded_rate(stats_raw.secondary_decoded_rate); | |
75 stats->set_clockdrift_ppm(stats_raw.clockdrift_ppm); | |
76 stats->set_added_zero_samples(stats_raw.added_zero_samples); | |
77 stats->set_mean_waiting_time_ms(stats_raw.mean_waiting_time_ms); | |
78 stats->set_median_waiting_time_ms(stats_raw.median_waiting_time_ms); | |
79 stats->set_min_waiting_time_ms(stats_raw.min_waiting_time_ms); | |
80 stats->set_max_waiting_time_ms(stats_raw.max_waiting_time_ms); | |
81 } | |
82 | |
83 static void Convert(const RtcpStatistics& stats_raw, | |
84 neteq_unittest::RtcpStatistics* stats) { | |
85 stats->set_fraction_lost(stats_raw.fraction_lost); | |
86 stats->set_cumulative_lost(stats_raw.cumulative_lost); | |
87 stats->set_extended_max_sequence_number( | |
88 stats_raw.extended_max_sequence_number); | |
89 stats->set_jitter(stats_raw.jitter); | |
90 } | |
91 | |
92 static void WriteMessage(FILE* file, const std::string& message) { | |
93 int32_t size = message.length(); | |
94 ASSERT_EQ(1u, fwrite(&size, sizeof(size), 1, file)); | |
95 if (size <= 0) | |
96 return; | |
97 ASSERT_EQ(static_cast<size_t>(size), | |
98 fwrite(message.data(), sizeof(char), size, file)); | |
99 } | |
100 | |
101 static void ReadMessage(FILE* file, std::string* message) { | |
102 int32_t size; | |
103 ASSERT_EQ(1u, fread(&size, sizeof(size), 1, file)); | |
104 if (size <= 0) | |
105 return; | |
106 rtc::scoped_ptr<char[]> buffer(new char[size]); | |
107 ASSERT_EQ(static_cast<size_t>(size), | |
108 fread(buffer.get(), sizeof(char), size, file)); | |
109 message->assign(buffer.get(), size); | |
110 } | |
111 | |
hlundin-webrtc
2015/12/16 10:04:51
Close the #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT he
minyue-webrtc
2015/12/16 13:51:27
Done.
| |
54 class RefFiles { | 112 class RefFiles { |
55 public: | 113 public: |
56 RefFiles(const std::string& input_file, const std::string& output_file); | 114 RefFiles(const std::string& input_file, const std::string& output_file); |
57 ~RefFiles(); | 115 ~RefFiles(); |
58 template<class T> void ProcessReference(const T& test_results); | 116 template<class T> void ProcessReference(const T& test_results); |
59 template<typename T, size_t n> void ProcessReference( | 117 template<typename T, size_t n> void ProcessReference( |
60 const T (&test_results)[n], | 118 const T (&test_results)[n], |
61 size_t length); | 119 size_t length); |
62 template<typename T, size_t n> void WriteToFile( | 120 template<typename T, size_t n> void WriteToFile( |
63 const T (&test_results)[n], | 121 const T (&test_results)[n], |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 if (input_fp_) { | 179 if (input_fp_) { |
122 // Read from ref file. | 180 // Read from ref file. |
123 T* ref = new T[length]; | 181 T* ref = new T[length]; |
124 ASSERT_EQ(length, fread(ref, sizeof(T), length, input_fp_)); | 182 ASSERT_EQ(length, fread(ref, sizeof(T), length, input_fp_)); |
125 // Compare | 183 // Compare |
126 ASSERT_EQ(0, memcmp(&test_results, ref, sizeof(T) * length)); | 184 ASSERT_EQ(0, memcmp(&test_results, ref, sizeof(T) * length)); |
127 delete [] ref; | 185 delete [] ref; |
128 } | 186 } |
129 } | 187 } |
130 | 188 |
131 void RefFiles::WriteToFile(const NetEqNetworkStatistics& stats) { | 189 void RefFiles::WriteToFile(const NetEqNetworkStatistics& stats_raw) { |
hlundin-webrtc
2015/12/16 10:04:51
Provide dummy implementations of WriteToFile and R
minyue-webrtc
2015/12/16 13:51:26
Done.
| |
132 if (output_fp_) { | 190 if (!output_fp_) |
133 ASSERT_EQ(1u, fwrite(&stats, sizeof(NetEqNetworkStatistics), 1, | 191 return; |
134 output_fp_)); | 192 neteq_unittest::NetEqNetworkStatistics stats; |
135 } | 193 Convert(stats_raw, &stats); |
194 | |
195 std::string stats_string; | |
196 ASSERT_TRUE(stats.SerializeToString(&stats_string)); | |
197 WriteMessage(output_fp_, stats_string); | |
136 } | 198 } |
137 | 199 |
138 void RefFiles::ReadFromFileAndCompare( | 200 void RefFiles::ReadFromFileAndCompare( |
139 const NetEqNetworkStatistics& stats) { | 201 const NetEqNetworkStatistics& stats) { |
140 // TODO(minyue): Update resource/audio_coding/neteq_network_stats.dat and | 202 if (!input_fp_) |
141 // resource/audio_coding/neteq_network_stats_win32.dat. | 203 return; |
142 struct NetEqNetworkStatisticsOld { | 204 |
143 uint16_t current_buffer_size_ms; // Current jitter buffer size in ms. | 205 std::string stats_string; |
144 uint16_t preferred_buffer_size_ms; // Target buffer size in ms. | 206 ReadMessage(input_fp_, &stats_string); |
145 uint16_t jitter_peaks_found; // 1 if adding extra delay due to peaky | 207 neteq_unittest::NetEqNetworkStatistics ref_stats; |
146 // jitter; 0 otherwise. | 208 ASSERT_TRUE(ref_stats.ParseFromString(stats_string)); |
147 uint16_t packet_loss_rate; // Loss rate (network + late) in Q14. | 209 |
148 uint16_t packet_discard_rate; // Late loss rate in Q14. | 210 // Compare |
149 uint16_t expand_rate; // Fraction (of original stream) of synthesized | 211 ASSERT_EQ(stats.current_buffer_size_ms, ref_stats.current_buffer_size_ms()); |
150 // audio inserted through expansion (in Q14). | 212 ASSERT_EQ(stats.preferred_buffer_size_ms, |
151 uint16_t preemptive_rate; // Fraction of data inserted through pre-emptive | 213 ref_stats.preferred_buffer_size_ms()); |
152 // expansion (in Q14). | 214 ASSERT_EQ(stats.jitter_peaks_found, ref_stats.jitter_peaks_found()); |
153 uint16_t accelerate_rate; // Fraction of data removed through acceleration | 215 ASSERT_EQ(stats.packet_loss_rate, ref_stats.packet_loss_rate()); |
154 // (in Q14). | 216 ASSERT_EQ(stats.packet_discard_rate, ref_stats.packet_discard_rate()); |
155 int32_t clockdrift_ppm; // Average clock-drift in parts-per-million | 217 ASSERT_EQ(stats.expand_rate, ref_stats.expand_rate()); |
156 // (positive or negative). | 218 ASSERT_EQ(stats.preemptive_rate, ref_stats.preemptive_rate()); |
157 int added_zero_samples; // Number of zero samples added in "off" mode. | 219 ASSERT_EQ(stats.accelerate_rate, ref_stats.accelerate_rate()); |
158 }; | 220 ASSERT_EQ(stats.clockdrift_ppm, ref_stats.clockdrift_ppm()); |
159 if (input_fp_) { | 221 ASSERT_EQ(stats.added_zero_samples, ref_stats.added_zero_samples()); |
160 // Read from ref file. | 222 ASSERT_EQ(stats.secondary_decoded_rate, 0); |
161 size_t stat_size = sizeof(NetEqNetworkStatisticsOld); | 223 ASSERT_LE(stats.speech_expand_rate, ref_stats.expand_rate()); |
162 NetEqNetworkStatisticsOld ref_stats; | |
163 ASSERT_EQ(1u, fread(&ref_stats, stat_size, 1, input_fp_)); | |
164 // Compare | |
165 ASSERT_EQ(stats.current_buffer_size_ms, ref_stats.current_buffer_size_ms); | |
166 ASSERT_EQ(stats.preferred_buffer_size_ms, | |
167 ref_stats.preferred_buffer_size_ms); | |
168 ASSERT_EQ(stats.jitter_peaks_found, ref_stats.jitter_peaks_found); | |
169 ASSERT_EQ(stats.packet_loss_rate, ref_stats.packet_loss_rate); | |
170 ASSERT_EQ(stats.packet_discard_rate, ref_stats.packet_discard_rate); | |
171 ASSERT_EQ(stats.expand_rate, ref_stats.expand_rate); | |
172 ASSERT_EQ(stats.preemptive_rate, ref_stats.preemptive_rate); | |
173 ASSERT_EQ(stats.accelerate_rate, ref_stats.accelerate_rate); | |
174 ASSERT_EQ(stats.clockdrift_ppm, ref_stats.clockdrift_ppm); | |
175 ASSERT_EQ(stats.added_zero_samples, | |
176 static_cast<size_t>(ref_stats.added_zero_samples)); | |
177 ASSERT_EQ(stats.secondary_decoded_rate, 0); | |
178 ASSERT_LE(stats.speech_expand_rate, ref_stats.expand_rate); | |
179 } | |
180 } | 224 } |
181 | 225 |
182 void RefFiles::WriteToFile(const RtcpStatistics& stats) { | 226 void RefFiles::WriteToFile(const RtcpStatistics& stats_raw) { |
183 if (output_fp_) { | 227 if (!output_fp_) |
184 ASSERT_EQ(1u, fwrite(&(stats.fraction_lost), sizeof(stats.fraction_lost), 1, | 228 return; |
185 output_fp_)); | 229 neteq_unittest::RtcpStatistics stats; |
186 ASSERT_EQ(1u, fwrite(&(stats.cumulative_lost), | 230 Convert(stats_raw, &stats); |
187 sizeof(stats.cumulative_lost), 1, output_fp_)); | 231 |
188 ASSERT_EQ(1u, fwrite(&(stats.extended_max_sequence_number), | 232 std::string stats_string; |
189 sizeof(stats.extended_max_sequence_number), 1, | 233 ASSERT_TRUE(stats.SerializeToString(&stats_string)); |
190 output_fp_)); | 234 WriteMessage(output_fp_, stats_string); |
191 ASSERT_EQ(1u, fwrite(&(stats.jitter), sizeof(stats.jitter), 1, | |
192 output_fp_)); | |
193 } | |
194 } | 235 } |
195 | 236 |
196 void RefFiles::ReadFromFileAndCompare( | 237 void RefFiles::ReadFromFileAndCompare( |
197 const RtcpStatistics& stats) { | 238 const RtcpStatistics& stats) { |
198 if (input_fp_) { | 239 if (!input_fp_) |
199 // Read from ref file. | 240 return; |
200 RtcpStatistics ref_stats; | 241 |
201 ASSERT_EQ(1u, fread(&(ref_stats.fraction_lost), | 242 std::string stats_string; |
202 sizeof(ref_stats.fraction_lost), 1, input_fp_)); | 243 ReadMessage(input_fp_, &stats_string); |
203 ASSERT_EQ(1u, fread(&(ref_stats.cumulative_lost), | 244 neteq_unittest::RtcpStatistics ref_stats; |
204 sizeof(ref_stats.cumulative_lost), 1, input_fp_)); | 245 ASSERT_TRUE(ref_stats.ParseFromString(stats_string)); |
205 ASSERT_EQ(1u, fread(&(ref_stats.extended_max_sequence_number), | 246 |
206 sizeof(ref_stats.extended_max_sequence_number), 1, | 247 // Compare |
207 input_fp_)); | 248 ASSERT_EQ(stats.fraction_lost, ref_stats.fraction_lost()); |
208 ASSERT_EQ(1u, fread(&(ref_stats.jitter), sizeof(ref_stats.jitter), 1, | 249 ASSERT_EQ(stats.cumulative_lost, ref_stats.cumulative_lost()); |
209 input_fp_)); | 250 ASSERT_EQ(stats.extended_max_sequence_number, |
210 // Compare | 251 ref_stats.extended_max_sequence_number()); |
211 ASSERT_EQ(ref_stats.fraction_lost, stats.fraction_lost); | 252 ASSERT_EQ(stats.jitter, ref_stats.jitter()); |
212 ASSERT_EQ(ref_stats.cumulative_lost, stats.cumulative_lost); | |
213 ASSERT_EQ(ref_stats.extended_max_sequence_number, | |
214 stats.extended_max_sequence_number); | |
215 ASSERT_EQ(ref_stats.jitter, stats.jitter); | |
216 } | |
217 } | 253 } |
254 #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT | |
218 | 255 |
219 class NetEqDecodingTest : public ::testing::Test { | 256 class NetEqDecodingTest : public ::testing::Test { |
220 protected: | 257 protected: |
221 // NetEQ must be polled for data once every 10 ms. Thus, neither of the | 258 // NetEQ must be polled for data once every 10 ms. Thus, neither of the |
222 // constants below can be changed. | 259 // constants below can be changed. |
223 static const int kTimeStepMs = 10; | 260 static const int kTimeStepMs = 10; |
224 static const size_t kBlockSize8kHz = kTimeStepMs * 8; | 261 static const size_t kBlockSize8kHz = kTimeStepMs * 8; |
225 static const size_t kBlockSize16kHz = kTimeStepMs * 16; | 262 static const size_t kBlockSize16kHz = kTimeStepMs * 16; |
226 static const size_t kBlockSize32kHz = kTimeStepMs * 32; | 263 static const size_t kBlockSize32kHz = kTimeStepMs * 32; |
227 static const size_t kMaxBlockSize = kBlockSize32kHz; | 264 static const size_t kMaxBlockSize = kBlockSize32kHz; |
228 static const int kInitSampleRateHz = 8000; | 265 static const int kInitSampleRateHz = 8000; |
229 | 266 |
230 NetEqDecodingTest(); | 267 NetEqDecodingTest(); |
231 virtual void SetUp(); | 268 virtual void SetUp(); |
232 virtual void TearDown(); | 269 virtual void TearDown(); |
233 void SelectDecoders(NetEqDecoder* used_codec); | 270 void SelectDecoders(NetEqDecoder* used_codec); |
234 void LoadDecoders(); | 271 void LoadDecoders(); |
235 void OpenInputFile(const std::string &rtp_file); | 272 void OpenInputFile(const std::string &rtp_file); |
236 void Process(size_t* out_len); | 273 void Process(size_t* out_len); |
274 | |
275 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT | |
hlundin-webrtc
2015/12/16 10:04:51
Remove this #ifdef.
minyue-webrtc
2015/12/16 13:51:27
Done.
| |
237 void DecodeAndCompare(const std::string& rtp_file, | 276 void DecodeAndCompare(const std::string& rtp_file, |
238 const std::string& ref_file, | 277 const std::string& ref_file, |
239 const std::string& stat_ref_file, | 278 const std::string& stat_ref_file, |
240 const std::string& rtcp_ref_file); | 279 const std::string& rtcp_ref_file); |
280 #endif | |
281 | |
241 static void PopulateRtpInfo(int frame_index, | 282 static void PopulateRtpInfo(int frame_index, |
242 int timestamp, | 283 int timestamp, |
243 WebRtcRTPHeader* rtp_info); | 284 WebRtcRTPHeader* rtp_info); |
244 static void PopulateCng(int frame_index, | 285 static void PopulateCng(int frame_index, |
245 int timestamp, | 286 int timestamp, |
246 WebRtcRTPHeader* rtp_info, | 287 WebRtcRTPHeader* rtp_info, |
247 uint8_t* payload, | 288 uint8_t* payload, |
248 size_t* payload_len); | 289 size_t* payload_len); |
249 | 290 |
250 void WrapTest(uint16_t start_seq_no, uint32_t start_timestamp, | 291 void WrapTest(uint16_t start_seq_no, uint32_t start_timestamp, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 ASSERT_TRUE((*out_len == kBlockSize8kHz) || | 411 ASSERT_TRUE((*out_len == kBlockSize8kHz) || |
371 (*out_len == kBlockSize16kHz) || | 412 (*out_len == kBlockSize16kHz) || |
372 (*out_len == kBlockSize32kHz)); | 413 (*out_len == kBlockSize32kHz)); |
373 output_sample_rate_ = static_cast<int>(*out_len / 10 * 1000); | 414 output_sample_rate_ = static_cast<int>(*out_len / 10 * 1000); |
374 EXPECT_EQ(output_sample_rate_, neteq_->last_output_sample_rate_hz()); | 415 EXPECT_EQ(output_sample_rate_, neteq_->last_output_sample_rate_hz()); |
375 | 416 |
376 // Increase time. | 417 // Increase time. |
377 sim_clock_ += kTimeStepMs; | 418 sim_clock_ += kTimeStepMs; |
378 } | 419 } |
379 | 420 |
421 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT | |
hlundin-webrtc
2015/12/16 10:04:51
Remove this #ifdef.
minyue-webrtc
2015/12/16 13:51:26
Done.
| |
380 void NetEqDecodingTest::DecodeAndCompare(const std::string& rtp_file, | 422 void NetEqDecodingTest::DecodeAndCompare(const std::string& rtp_file, |
381 const std::string& ref_file, | 423 const std::string& ref_file, |
382 const std::string& stat_ref_file, | 424 const std::string& stat_ref_file, |
383 const std::string& rtcp_ref_file) { | 425 const std::string& rtcp_ref_file) { |
384 OpenInputFile(rtp_file); | 426 OpenInputFile(rtp_file); |
385 | 427 |
386 std::string ref_out_file = ""; | 428 std::string ref_out_file = ""; |
387 if (ref_file.empty()) { | 429 if (ref_file.empty()) { |
388 ref_out_file = webrtc::test::OutputPath() + "neteq_universal_ref.pcm"; | 430 ref_out_file = webrtc::test::OutputPath() + "neteq_universal_ref.pcm"; |
389 } | 431 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 // Compare with CurrentDelay, which should be identical. | 463 // Compare with CurrentDelay, which should be identical. |
422 EXPECT_EQ(network_stats.current_buffer_size_ms, neteq_->CurrentDelayMs()); | 464 EXPECT_EQ(network_stats.current_buffer_size_ms, neteq_->CurrentDelayMs()); |
423 | 465 |
424 // Process RTCPstat. | 466 // Process RTCPstat. |
425 RtcpStatistics rtcp_stats; | 467 RtcpStatistics rtcp_stats; |
426 neteq_->GetRtcpStatistics(&rtcp_stats); | 468 neteq_->GetRtcpStatistics(&rtcp_stats); |
427 ASSERT_NO_FATAL_FAILURE(rtcp_stat_files.ProcessReference(rtcp_stats)); | 469 ASSERT_NO_FATAL_FAILURE(rtcp_stat_files.ProcessReference(rtcp_stats)); |
428 } | 470 } |
429 } | 471 } |
430 } | 472 } |
473 #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT | |
474 | |
431 | 475 |
432 void NetEqDecodingTest::PopulateRtpInfo(int frame_index, | 476 void NetEqDecodingTest::PopulateRtpInfo(int frame_index, |
433 int timestamp, | 477 int timestamp, |
434 WebRtcRTPHeader* rtp_info) { | 478 WebRtcRTPHeader* rtp_info) { |
435 rtp_info->header.sequenceNumber = frame_index; | 479 rtp_info->header.sequenceNumber = frame_index; |
436 rtp_info->header.timestamp = timestamp; | 480 rtp_info->header.timestamp = timestamp; |
437 rtp_info->header.ssrc = 0x1234; // Just an arbitrary SSRC. | 481 rtp_info->header.ssrc = 0x1234; // Just an arbitrary SSRC. |
438 rtp_info->header.payloadType = 94; // PCM16b WB codec. | 482 rtp_info->header.payloadType = 94; // PCM16b WB codec. |
439 rtp_info->header.markerBit = 0; | 483 rtp_info->header.markerBit = 0; |
440 } | 484 } |
(...skipping 12 matching lines...) Expand all Loading... | |
453 *payload_len = 1; // Only noise level, no spectral parameters. | 497 *payload_len = 1; // Only noise level, no spectral parameters. |
454 } | 498 } |
455 | 499 |
456 #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) && \ | 500 #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) && \ |
457 defined(WEBRTC_CODEC_ILBC) && defined(WEBRTC_CODEC_G722) | 501 defined(WEBRTC_CODEC_ILBC) && defined(WEBRTC_CODEC_G722) |
458 #define IF_ALL_CODECS(x) x | 502 #define IF_ALL_CODECS(x) x |
459 #else | 503 #else |
460 #define IF_ALL_CODECS(x) DISABLED_##x | 504 #define IF_ALL_CODECS(x) DISABLED_##x |
461 #endif | 505 #endif |
462 | 506 |
507 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT | |
hlundin-webrtc
2015/12/16 10:04:51
The preferred way of disabling tests is to do the
minyue-webrtc
2015/12/16 13:51:26
Done.
| |
463 TEST_F(NetEqDecodingTest, | 508 TEST_F(NetEqDecodingTest, |
464 DISABLED_ON_IOS(DISABLED_ON_ANDROID(IF_ALL_CODECS(TestBitExactness)))) { | 509 DISABLED_ON_IOS(DISABLED_ON_ANDROID(IF_ALL_CODECS(TestBitExactness)))) { |
465 const std::string input_rtp_file = webrtc::test::ProjectRootPath() + | 510 const std::string input_rtp_file = webrtc::test::ProjectRootPath() + |
466 "resources/audio_coding/neteq_universal_new.rtp"; | 511 "resources/audio_coding/neteq_universal_new.rtp"; |
467 // Note that neteq4_universal_ref.pcm and neteq4_universal_ref_win_32.pcm | 512 // Note that neteq4_universal_ref.pcm and neteq4_universal_ref_win_32.pcm |
468 // are identical. The latter could have been removed, but if clients still | 513 // are identical. The latter could have been removed, but if clients still |
469 // have a copy of the file, the test will fail. | 514 // have a copy of the file, the test will fail. |
470 const std::string input_ref_file = | 515 const std::string input_ref_file = |
471 webrtc::test::ResourcePath("audio_coding/neteq4_universal_ref", "pcm"); | 516 webrtc::test::ResourcePath("audio_coding/neteq4_universal_ref", "pcm"); |
472 #if defined(_MSC_VER) && (_MSC_VER >= 1700) | 517 #if defined(_MSC_VER) && (_MSC_VER >= 1700) |
(...skipping 10 matching lines...) Expand all Loading... | |
483 | 528 |
484 if (FLAGS_gen_ref) { | 529 if (FLAGS_gen_ref) { |
485 DecodeAndCompare(input_rtp_file, "", "", ""); | 530 DecodeAndCompare(input_rtp_file, "", "", ""); |
486 } else { | 531 } else { |
487 DecodeAndCompare(input_rtp_file, | 532 DecodeAndCompare(input_rtp_file, |
488 input_ref_file, | 533 input_ref_file, |
489 network_stat_ref_file, | 534 network_stat_ref_file, |
490 rtcp_stat_ref_file); | 535 rtcp_stat_ref_file); |
491 } | 536 } |
492 } | 537 } |
538 #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT | |
493 | 539 |
494 // Use fax mode to avoid time-scaling. This is to simplify the testing of | 540 // Use fax mode to avoid time-scaling. This is to simplify the testing of |
495 // packet waiting times in the packet buffer. | 541 // packet waiting times in the packet buffer. |
496 class NetEqDecodingTestFaxMode : public NetEqDecodingTest { | 542 class NetEqDecodingTestFaxMode : public NetEqDecodingTest { |
497 protected: | 543 protected: |
498 NetEqDecodingTestFaxMode() : NetEqDecodingTest() { | 544 NetEqDecodingTestFaxMode() : NetEqDecodingTest() { |
499 config_.playout_mode = kPlayoutFax; | 545 config_.playout_mode = kPlayoutFax; |
500 } | 546 } |
501 }; | 547 }; |
502 | 548 |
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1546 // Pull audio once. | 1592 // Pull audio once. |
1547 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, | 1593 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, |
1548 &num_channels, &type)); | 1594 &num_channels, &type)); |
1549 ASSERT_EQ(kBlockSize16kHz, out_len); | 1595 ASSERT_EQ(kBlockSize16kHz, out_len); |
1550 } | 1596 } |
1551 // Verify speech output. | 1597 // Verify speech output. |
1552 EXPECT_EQ(kOutputNormal, type); | 1598 EXPECT_EQ(kOutputNormal, type); |
1553 } | 1599 } |
1554 | 1600 |
1555 } // namespace webrtc | 1601 } // namespace webrtc |
OLD | NEW |