neteq_unittest.cc (39222B)
1 /* 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include "api/neteq/neteq.h" 12 13 #include <algorithm> 14 #include <cstdint> 15 #include <cstdlib> 16 #include <cstring> // memset 17 #include <map> 18 #include <memory> 19 #include <optional> 20 #include <set> 21 #include <string> 22 #include <utility> 23 24 #include "absl/flags/flag.h" 25 #include "api/array_view.h" 26 #include "api/audio/audio_frame.h" 27 #include "api/audio_codecs/builtin_audio_decoder_factory.h" 28 #include "api/rtp_headers.h" 29 #include "api/units/time_delta.h" 30 #include "modules/audio_coding/codecs/pcm16b/pcm16b.h" 31 #include "modules/audio_coding/neteq/test/neteq_decoding_test.h" 32 #include "modules/audio_coding/neteq/tools/audio_loop.h" 33 #include "modules/audio_coding/neteq/tools/audio_sink.h" 34 #include "modules/audio_coding/neteq/tools/neteq_input.h" 35 #include "modules/audio_coding/neteq/tools/neteq_rtp_dump_input.h" 36 #include "modules/audio_coding/neteq/tools/neteq_test.h" 37 #include "modules/include/module_common_types_public.h" 38 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" 39 #include "rtc_base/numerics/safe_conversions.h" 40 #include "rtc_base/strings/string_builder.h" 41 #include "rtc_base/system/arch.h" 42 #include "test/gtest.h" 43 #include "test/testsupport/file_utils.h" 44 45 ABSL_FLAG(bool, gen_ref, false, "Generate reference files."); 46 47 namespace webrtc { 48 49 // TODO(bugs.webrtc.org/345525069): Either fix/enable or remove. 50 TEST_F(NetEqDecodingTest, DISABLED_TestBitExactness) { 51 const std::string input_rtp_file = 52 test::ResourcePath("audio_coding/neteq_universal_new", "rtp"); 53 54 const std::string output_checksum = 55 "dee7a10ab92526876a70a85bc48a4906901af3df"; 56 57 const std::string network_stats_checksum = 58 "911dbf5fd97f48d25b8f0967286eb73c9d6f6158"; 59 60 DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum, 61 absl::GetFlag(FLAGS_gen_ref)); 62 } 63 64 // TODO: https://issues.webrtc.org/411157363 - reenable test after update. 65 #if defined(WEBRTC_LINUX) && defined(WEBRTC_ARCH_X86_64) && \ 66 defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && defined(WEBRTC_CODEC_OPUS) 67 #define MAYBE_TestOpusBitExactness DISABLED_TestOpusBitExactness 68 #else 69 #define MAYBE_TestOpusBitExactness DISABLED_TestOpusBitExactness 70 #endif 71 TEST_F(NetEqDecodingTest, MAYBE_TestOpusBitExactness) { 72 const std::string input_rtp_file = 73 test::ResourcePath("audio_coding/neteq_opus", "rtp"); 74 75 const std::string output_checksum = 76 "434bdc4ec08546510ee903d001c8be1a01c44e24|" 77 "4336be0091e2faad7a194c16ee0a05e727325727|" 78 "cefd2de4adfa8f6a9b66a3639ad63c2f6779d0cd"; 79 80 const std::string network_stats_checksum = 81 "06f6b9a86aeae6317fd25a36edf9ed16f35e798f|" 82 "80ab17c17da030d4f2dfbf314ac44aacdadd7f0c"; 83 84 DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum, 85 absl::GetFlag(FLAGS_gen_ref)); 86 } 87 88 // TODO: https://issues.webrtc.org/411157363 - reenable test after update. 89 #if defined(WEBRTC_LINUX) && defined(WEBRTC_ARCH_X86_64) && \ 90 defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && defined(WEBRTC_CODEC_OPUS) 91 #define MAYBE_TestOpusDtxBitExactness DISABLED_TestOpusDtxBitExactness 92 #else 93 #define MAYBE_TestOpusDtxBitExactness DISABLED_TestOpusDtxBitExactness 94 #endif 95 TEST_F(NetEqDecodingTest, MAYBE_TestOpusDtxBitExactness) { 96 const std::string input_rtp_file = 97 test::ResourcePath("audio_coding/neteq_opus_dtx", "rtp"); 98 99 const std::string output_checksum = 100 "7eddce841cbfa500964c91cdae78b01b9f448948|" 101 "5d13affec87bf4cc8c7667f0cd0d25e1ad09c7c3"; 102 103 const std::string network_stats_checksum = 104 "6af74a713749cc4343464718b6af54f1e5b06ad9"; 105 106 DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum, 107 absl::GetFlag(FLAGS_gen_ref)); 108 } 109 110 // Use fax mode to avoid time-scaling. This is to simplify the testing of 111 // packet waiting times in the packet buffer. 112 class NetEqDecodingTestFaxMode : public NetEqDecodingTest { 113 protected: 114 NetEqDecodingTestFaxMode() : NetEqDecodingTest() { 115 config_.for_test_no_time_stretching = true; 116 } 117 void TestJitterBufferDelay(bool apply_packet_loss); 118 }; 119 120 TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) { 121 // Insert 30 dummy packets at once. Each packet contains 10 ms 16 kHz audio. 122 size_t num_frames = 30; 123 const size_t kSamples = 10 * 16; 124 const size_t kPayloadBytes = kSamples * 2; 125 for (size_t i = 0; i < num_frames; ++i) { 126 const uint8_t payload[kPayloadBytes] = {0}; 127 RTPHeader rtp_info; 128 rtp_info.sequenceNumber = checked_cast<uint16_t>(i); 129 rtp_info.timestamp = checked_cast<uint32_t>(i * kSamples); 130 rtp_info.ssrc = 0x1234; // Just an arbitrary SSRC. 131 rtp_info.payloadType = 94; // PCM16b WB codec. 132 rtp_info.markerBit = 0; 133 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, clock_.CurrentTime())); 134 } 135 // Pull out all data. 136 for (size_t i = 0; i < num_frames; ++i) { 137 bool muted; 138 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); 139 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); 140 } 141 142 NetEqNetworkStatistics stats; 143 EXPECT_EQ(0, neteq_->NetworkStatistics(&stats)); 144 // Since all frames are dumped into NetEQ at once, but pulled out with 10 ms 145 // spacing (per definition), we expect the delay to increase with 10 ms for 146 // each packet. Thus, we are calculating the statistics for a series from 10 147 // to 300, in steps of 10 ms. 148 EXPECT_EQ(155, stats.mean_waiting_time_ms); 149 EXPECT_EQ(155, stats.median_waiting_time_ms); 150 EXPECT_EQ(10, stats.min_waiting_time_ms); 151 EXPECT_EQ(300, stats.max_waiting_time_ms); 152 153 // Check statistics again and make sure it's been reset. 154 EXPECT_EQ(0, neteq_->NetworkStatistics(&stats)); 155 EXPECT_EQ(-1, stats.mean_waiting_time_ms); 156 EXPECT_EQ(-1, stats.median_waiting_time_ms); 157 EXPECT_EQ(-1, stats.min_waiting_time_ms); 158 EXPECT_EQ(-1, stats.max_waiting_time_ms); 159 } 160 161 TEST_F(NetEqDecodingTest, LongCngWithNegativeClockDrift) { 162 // Apply a clock drift of -25 ms / s (sender faster than receiver). 163 const double kDriftFactor = 1000.0 / (1000.0 + 25.0); 164 const double kNetworkFreezeTimeMs = 0.0; 165 const bool kGetAudioDuringFreezeRecovery = false; 166 const int kDelayToleranceMs = 60; 167 const int kMaxTimeToSpeechMs = 100; 168 LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, 169 kGetAudioDuringFreezeRecovery, kDelayToleranceMs, 170 kMaxTimeToSpeechMs); 171 } 172 173 TEST_F(NetEqDecodingTest, LongCngWithPositiveClockDrift) { 174 // Apply a clock drift of +25 ms / s (sender slower than receiver). 175 const double kDriftFactor = 1000.0 / (1000.0 - 25.0); 176 const double kNetworkFreezeTimeMs = 0.0; 177 const bool kGetAudioDuringFreezeRecovery = false; 178 const int kDelayToleranceMs = 40; 179 const int kMaxTimeToSpeechMs = 100; 180 LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, 181 kGetAudioDuringFreezeRecovery, kDelayToleranceMs, 182 kMaxTimeToSpeechMs); 183 } 184 185 TEST_F(NetEqDecodingTest, LongCngWithNegativeClockDriftNetworkFreeze) { 186 // Apply a clock drift of -25 ms / s (sender faster than receiver). 187 const double kDriftFactor = 1000.0 / (1000.0 + 25.0); 188 const double kNetworkFreezeTimeMs = 5000.0; 189 const bool kGetAudioDuringFreezeRecovery = false; 190 const int kDelayToleranceMs = 60; 191 const int kMaxTimeToSpeechMs = 200; 192 LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, 193 kGetAudioDuringFreezeRecovery, kDelayToleranceMs, 194 kMaxTimeToSpeechMs); 195 } 196 197 TEST_F(NetEqDecodingTest, LongCngWithPositiveClockDriftNetworkFreeze) { 198 // Apply a clock drift of +25 ms / s (sender slower than receiver). 199 const double kDriftFactor = 1000.0 / (1000.0 - 25.0); 200 const double kNetworkFreezeTimeMs = 5000.0; 201 const bool kGetAudioDuringFreezeRecovery = false; 202 const int kDelayToleranceMs = 40; 203 const int kMaxTimeToSpeechMs = 100; 204 LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, 205 kGetAudioDuringFreezeRecovery, kDelayToleranceMs, 206 kMaxTimeToSpeechMs); 207 } 208 209 TEST_F(NetEqDecodingTest, LongCngWithPositiveClockDriftNetworkFreezeExtraPull) { 210 // Apply a clock drift of +25 ms / s (sender slower than receiver). 211 const double kDriftFactor = 1000.0 / (1000.0 - 25.0); 212 const double kNetworkFreezeTimeMs = 5000.0; 213 const bool kGetAudioDuringFreezeRecovery = true; 214 const int kDelayToleranceMs = 40; 215 const int kMaxTimeToSpeechMs = 100; 216 LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, 217 kGetAudioDuringFreezeRecovery, kDelayToleranceMs, 218 kMaxTimeToSpeechMs); 219 } 220 221 TEST_F(NetEqDecodingTest, LongCngWithoutClockDrift) { 222 const double kDriftFactor = 1.0; // No drift. 223 const double kNetworkFreezeTimeMs = 0.0; 224 const bool kGetAudioDuringFreezeRecovery = false; 225 const int kDelayToleranceMs = 10; 226 const int kMaxTimeToSpeechMs = 50; 227 LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, 228 kGetAudioDuringFreezeRecovery, kDelayToleranceMs, 229 kMaxTimeToSpeechMs); 230 } 231 232 TEST_F(NetEqDecodingTest, UnknownPayloadType) { 233 const size_t kPayloadBytes = 100; 234 uint8_t payload[kPayloadBytes] = {0}; 235 RTPHeader rtp_info; 236 PopulateRtpInfo(0, 0, &rtp_info); 237 rtp_info.payloadType = 1; // Not registered as a decoder. 238 EXPECT_EQ(NetEq::kFail, 239 neteq_->InsertPacket(rtp_info, payload, clock_.CurrentTime())); 240 } 241 242 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) 243 #define MAYBE_DecoderError DecoderError 244 #else 245 #define MAYBE_DecoderError DISABLED_DecoderError 246 #endif 247 248 TEST_F(NetEqDecodingTest, MAYBE_DecoderError) { 249 const size_t kPayloadBytes = 100; 250 uint8_t payload[kPayloadBytes] = {0}; 251 RTPHeader rtp_info; 252 PopulateRtpInfo(0, 0, &rtp_info); 253 rtp_info.payloadType = 103; // iSAC, but the payload is invalid. 254 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, clock_.CurrentTime())); 255 // Set all of `out_data_` to 1, and verify that it was set to 0 by the call 256 // to GetAudio. 257 int16_t* out_frame_data = out_frame_.mutable_data(); 258 for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; ++i) { 259 out_frame_data[i] = 1; 260 } 261 bool muted; 262 EXPECT_EQ(NetEq::kFail, neteq_->GetAudio(&out_frame_, &muted)); 263 ASSERT_FALSE(muted); 264 265 // Verify that the first 160 samples are set to 0. 266 static const int kExpectedOutputLength = 160; // 10 ms at 16 kHz sample rate. 267 const int16_t* const_out_frame_data = out_frame_.data(); 268 for (int i = 0; i < kExpectedOutputLength; ++i) { 269 StringBuilder ss; 270 ss << "i = " << i; 271 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. 272 EXPECT_EQ(0, const_out_frame_data[i]); 273 } 274 } 275 276 TEST_F(NetEqDecodingTest, GetAudioBeforeInsertPacket) { 277 // Set all of `out_data_` to 1, and verify that it was set to 0 by the call 278 // to GetAudio. 279 int16_t* out_frame_data = out_frame_.mutable_data(); 280 for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; ++i) { 281 out_frame_data[i] = 1; 282 } 283 bool muted; 284 EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); 285 ASSERT_FALSE(muted); 286 // Verify that the first block of samples is set to 0. 287 static const int kExpectedOutputLength = 288 kInitSampleRateHz / 100; // 10 ms at initial sample rate. 289 const int16_t* const_out_frame_data = out_frame_.data(); 290 for (int i = 0; i < kExpectedOutputLength; ++i) { 291 StringBuilder ss; 292 ss << "i = " << i; 293 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. 294 EXPECT_EQ(0, const_out_frame_data[i]); 295 } 296 // Verify that the sample rate did not change from the initial configuration. 297 EXPECT_EQ(config_.sample_rate_hz, neteq_->last_output_sample_rate_hz()); 298 } 299 300 class NetEqBgnTest : public NetEqDecodingTest { 301 protected: 302 void CheckBgn(int sampling_rate_hz) { 303 size_t expected_samples_per_channel = 0; 304 uint8_t payload_type = 0xFF; // Invalid. 305 if (sampling_rate_hz == 8000) { 306 expected_samples_per_channel = kBlockSize8kHz; 307 payload_type = 93; // PCM 16, 8 kHz. 308 } else if (sampling_rate_hz == 16000) { 309 expected_samples_per_channel = kBlockSize16kHz; 310 payload_type = 94; // PCM 16, 16 kHZ. 311 } else if (sampling_rate_hz == 32000) { 312 expected_samples_per_channel = kBlockSize32kHz; 313 payload_type = 95; // PCM 16, 32 kHz. 314 } else { 315 ASSERT_TRUE(false); // Unsupported test case. 316 } 317 318 AudioFrame output; 319 test::AudioLoop input; 320 // We are using the same 32 kHz input file for all tests, regardless of 321 // `sampling_rate_hz`. The output may sound weird, but the test is still 322 // valid. 323 ASSERT_TRUE( 324 input.Init(test::ResourcePath("audio_coding/testfile32kHz", "pcm"), 325 10 * sampling_rate_hz, // Max 10 seconds loop length. 326 expected_samples_per_channel)); 327 328 // Payload of 10 ms of PCM16 32 kHz. 329 uint8_t payload[kBlockSize32kHz * sizeof(int16_t)]; 330 RTPHeader rtp_info; 331 PopulateRtpInfo(0, 0, &rtp_info); 332 rtp_info.payloadType = payload_type; 333 334 bool muted; 335 for (int n = 0; n < 10; ++n) { // Insert few packets and get audio. 336 auto block = input.GetNextBlock(); 337 ASSERT_EQ(expected_samples_per_channel, block.size()); 338 size_t enc_len_bytes = 339 WebRtcPcm16b_Encode(block.data(), block.size(), payload); 340 ASSERT_EQ(enc_len_bytes, expected_samples_per_channel * 2); 341 342 ASSERT_EQ(0, 343 neteq_->InsertPacket( 344 rtp_info, ArrayView<const uint8_t>(payload, enc_len_bytes), 345 clock_.CurrentTime())); 346 output.Reset(); 347 ASSERT_EQ(0, neteq_->GetAudio(&output, &muted)); 348 ASSERT_EQ(1u, output.num_channels_); 349 ASSERT_EQ(expected_samples_per_channel, output.samples_per_channel_); 350 ASSERT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); 351 352 // Next packet. 353 rtp_info.timestamp += 354 checked_cast<uint32_t>(expected_samples_per_channel); 355 rtp_info.sequenceNumber++; 356 } 357 358 output.Reset(); 359 360 // Get audio without inserting packets, expecting PLC and PLC-to-CNG. Pull 361 // one frame without checking speech-type. This is the first frame pulled 362 // without inserting any packet, and might not be labeled as PLC. 363 ASSERT_EQ(0, neteq_->GetAudio(&output, &muted)); 364 ASSERT_EQ(1u, output.num_channels_); 365 ASSERT_EQ(expected_samples_per_channel, output.samples_per_channel_); 366 367 // To be able to test the fading of background noise we need at lease to 368 // pull 611 frames. 369 const int kFadingThreshold = 611; 370 371 // Test several CNG-to-PLC packet for the expected behavior. The number 20 372 // is arbitrary, but sufficiently large to test enough number of frames. 373 const int kNumPlcToCngTestFrames = 20; 374 bool plc_to_cng = false; 375 for (int n = 0; n < kFadingThreshold + kNumPlcToCngTestFrames; ++n) { 376 output.Reset(); 377 // Set to non-zero. 378 memset(output.mutable_data(), 1, AudioFrame::kMaxDataSizeBytes); 379 ASSERT_EQ(0, neteq_->GetAudio(&output, &muted)); 380 ASSERT_FALSE(muted); 381 ASSERT_EQ(1u, output.num_channels_); 382 ASSERT_EQ(expected_samples_per_channel, output.samples_per_channel_); 383 if (output.speech_type_ == AudioFrame::kPLCCNG) { 384 plc_to_cng = true; 385 double sum_squared = 0; 386 const int16_t* output_data = output.data(); 387 for (size_t k = 0; 388 k < output.num_channels_ * output.samples_per_channel_; ++k) 389 sum_squared += output_data[k] * output_data[k]; 390 EXPECT_EQ(0, sum_squared); 391 } else { 392 EXPECT_EQ(AudioFrame::kPLC, output.speech_type_); 393 } 394 } 395 EXPECT_TRUE(plc_to_cng); // Just to be sure that PLC-to-CNG has occurred. 396 } 397 }; 398 399 TEST_F(NetEqBgnTest, RunTest) { 400 CheckBgn(8000); 401 CheckBgn(16000); 402 CheckBgn(32000); 403 } 404 405 TEST_F(NetEqDecodingTest, SequenceNumberWrap) { 406 // Start with a sequence number that will soon wrap. 407 std::set<uint16_t> drop_seq_numbers; // Don't drop any packets. 408 WrapTest(0xFFFF - 10, 0, drop_seq_numbers, true, false); 409 } 410 411 TEST_F(NetEqDecodingTest, SequenceNumberWrapAndDrop) { 412 // Start with a sequence number that will soon wrap. 413 std::set<uint16_t> drop_seq_numbers; 414 drop_seq_numbers.insert(0xFFFF); 415 drop_seq_numbers.insert(0x0); 416 WrapTest(0xFFFF - 10, 0, drop_seq_numbers, true, false); 417 } 418 419 TEST_F(NetEqDecodingTest, TimestampWrap) { 420 // Start with a timestamp that will soon wrap. 421 std::set<uint16_t> drop_seq_numbers; 422 WrapTest(0, 0xFFFFFFFF - 3000, drop_seq_numbers, false, true); 423 } 424 425 TEST_F(NetEqDecodingTest, TimestampAndSequenceNumberWrap) { 426 // Start with a timestamp and a sequence number that will wrap at the same 427 // time. 428 std::set<uint16_t> drop_seq_numbers; 429 WrapTest(0xFFFF - 10, 0xFFFFFFFF - 5000, drop_seq_numbers, true, true); 430 } 431 432 TEST_F(NetEqDecodingTest, DiscardDuplicateCng) { 433 uint16_t seq_no = 0; 434 uint32_t timestamp = 0; 435 const int kFrameSizeMs = 10; 436 const int kSampleRateKhz = 16; 437 const int kSamples = kFrameSizeMs * kSampleRateKhz; 438 const size_t kPayloadBytes = kSamples * 2; 439 440 const int algorithmic_delay_samples = 441 std::max(algorithmic_delay_ms_ * kSampleRateKhz, 5 * kSampleRateKhz / 8); 442 // Insert three speech packets. Three are needed to get the frame length 443 // correct. 444 uint8_t payload[kPayloadBytes] = {0}; 445 RTPHeader rtp_info; 446 bool muted; 447 for (int i = 0; i < 3; ++i) { 448 PopulateRtpInfo(seq_no, timestamp, &rtp_info); 449 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, clock_.CurrentTime())); 450 ++seq_no; 451 timestamp += kSamples; 452 453 // Pull audio once. 454 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); 455 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); 456 } 457 // Verify speech output. 458 EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); 459 460 // Insert same CNG packet twice. 461 const int kCngPeriodMs = 100; 462 const int kCngPeriodSamples = kCngPeriodMs * kSampleRateKhz; 463 size_t payload_len; 464 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); 465 // This is the first time this CNG packet is inserted. 466 ASSERT_EQ(0, neteq_->InsertPacket( 467 rtp_info, ArrayView<const uint8_t>(payload, payload_len), 468 clock_.CurrentTime())); 469 470 // Pull audio once and make sure CNG is played. 471 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); 472 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); 473 EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); 474 EXPECT_FALSE( 475 neteq_->GetPlayoutTimestamp()); // Returns empty value during CNG. 476 EXPECT_EQ(timestamp - algorithmic_delay_samples, 477 out_frame_.timestamp_ + out_frame_.samples_per_channel_); 478 479 // Insert the same CNG packet again. Note that at this point it is old, since 480 // we have already decoded the first copy of it. 481 ASSERT_EQ(0, neteq_->InsertPacket( 482 rtp_info, ArrayView<const uint8_t>(payload, payload_len), 483 clock_.CurrentTime())); 484 485 // Pull audio until we have played `kCngPeriodMs` of CNG. Start at 10 ms since 486 // we have already pulled out CNG once. 487 for (int cng_time_ms = 10; cng_time_ms < kCngPeriodMs; cng_time_ms += 10) { 488 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); 489 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); 490 EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); 491 EXPECT_FALSE( 492 neteq_->GetPlayoutTimestamp()); // Returns empty value during CNG. 493 EXPECT_EQ(timestamp - algorithmic_delay_samples, 494 out_frame_.timestamp_ + out_frame_.samples_per_channel_); 495 } 496 497 ++seq_no; 498 timestamp += kCngPeriodSamples; 499 uint32_t first_speech_timestamp = timestamp; 500 // Insert speech again. 501 for (int i = 0; i < 4; ++i) { 502 PopulateRtpInfo(seq_no, timestamp, &rtp_info); 503 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, clock_.CurrentTime())); 504 ++seq_no; 505 timestamp += kSamples; 506 } 507 508 // Pull audio once and verify that the output is speech again. 509 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); 510 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); 511 EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); 512 std::optional<uint32_t> playout_timestamp = neteq_->GetPlayoutTimestamp(); 513 ASSERT_TRUE(playout_timestamp); 514 EXPECT_EQ(first_speech_timestamp + kSamples - algorithmic_delay_samples, 515 *playout_timestamp); 516 } 517 518 TEST_F(NetEqDecodingTest, CngFirst) { 519 uint16_t seq_no = 0; 520 uint32_t timestamp = 0; 521 const int kFrameSizeMs = 10; 522 const int kSampleRateKhz = 16; 523 const int kSamples = kFrameSizeMs * kSampleRateKhz; 524 const int kPayloadBytes = kSamples * 2; 525 const int kCngPeriodMs = 100; 526 const int kCngPeriodSamples = kCngPeriodMs * kSampleRateKhz; 527 size_t payload_len; 528 529 uint8_t payload[kPayloadBytes] = {0}; 530 RTPHeader rtp_info; 531 532 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); 533 ASSERT_EQ(NetEq::kOK, 534 neteq_->InsertPacket(rtp_info, 535 ArrayView<const uint8_t>(payload, payload_len), 536 clock_.CurrentTime())); 537 ++seq_no; 538 timestamp += kCngPeriodSamples; 539 540 // Pull audio once and make sure CNG is played. 541 bool muted; 542 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); 543 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); 544 EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); 545 546 // Insert some speech packets. 547 const uint32_t first_speech_timestamp = timestamp; 548 int timeout_counter = 0; 549 do { 550 ASSERT_LT(timeout_counter++, 20) << "Test timed out"; 551 PopulateRtpInfo(seq_no, timestamp, &rtp_info); 552 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, clock_.CurrentTime())); 553 ++seq_no; 554 timestamp += kSamples; 555 556 // Pull audio once. 557 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); 558 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); 559 } while (!IsNewerTimestamp(out_frame_.timestamp_, first_speech_timestamp)); 560 // Verify speech output. 561 EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); 562 } 563 564 class NetEqDecodingTestWithMutedState : public NetEqDecodingTest { 565 public: 566 NetEqDecodingTestWithMutedState() : NetEqDecodingTest() { 567 config_.enable_muted_state = true; 568 } 569 570 protected: 571 static constexpr size_t kSamples = 10 * 16; 572 static constexpr size_t kPayloadBytes = kSamples * 2; 573 574 void InsertPacket(uint32_t rtp_timestamp) { 575 uint8_t payload[kPayloadBytes] = {0}; 576 RTPHeader rtp_info; 577 PopulateRtpInfo(0, rtp_timestamp, &rtp_info); 578 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, clock_.CurrentTime())); 579 } 580 581 void InsertCngPacket(uint32_t rtp_timestamp) { 582 uint8_t payload[kPayloadBytes] = {0}; 583 RTPHeader rtp_info; 584 size_t payload_len; 585 PopulateCng(0, rtp_timestamp, &rtp_info, payload, &payload_len); 586 EXPECT_EQ(NetEq::kOK, 587 neteq_->InsertPacket( 588 rtp_info, ArrayView<const uint8_t>(payload, payload_len), 589 clock_.CurrentTime())); 590 } 591 592 bool GetAudioReturnMuted() { 593 bool muted; 594 EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); 595 return muted; 596 } 597 598 void GetAudioUntilMuted() { 599 while (!GetAudioReturnMuted()) { 600 ASSERT_LT(counter_++, 1000) << "Test timed out"; 601 } 602 } 603 604 void GetAudioUntilNormal() { 605 bool muted = false; 606 while (out_frame_.speech_type_ != AudioFrame::kNormalSpeech) { 607 EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); 608 ASSERT_LT(counter_++, 1000) << "Test timed out"; 609 } 610 EXPECT_FALSE(muted); 611 } 612 613 int counter_ = 0; 614 }; 615 616 // Verifies that NetEq goes in and out of muted state as expected. 617 TEST_F(NetEqDecodingTestWithMutedState, MutedState) { 618 // Insert one speech packet. 619 InsertPacket(0); 620 // Pull out audio once and expect it not to be muted. 621 EXPECT_FALSE(GetAudioReturnMuted()); 622 // Pull data until faded out. 623 GetAudioUntilMuted(); 624 EXPECT_TRUE(out_frame_.muted()); 625 626 // Verify that output audio is not written during muted mode. Other parameters 627 // should be correct, though. 628 AudioFrame new_frame; 629 int16_t* frame_data = new_frame.mutable_data(); 630 for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; i++) { 631 frame_data[i] = 17; 632 } 633 bool muted; 634 EXPECT_EQ(0, neteq_->GetAudio(&new_frame, &muted)); 635 EXPECT_TRUE(muted); 636 EXPECT_TRUE(out_frame_.muted()); 637 for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; i++) { 638 EXPECT_EQ(17, frame_data[i]); 639 } 640 EXPECT_EQ(out_frame_.timestamp_ + out_frame_.samples_per_channel_, 641 new_frame.timestamp_); 642 EXPECT_EQ(out_frame_.samples_per_channel_, new_frame.samples_per_channel_); 643 EXPECT_EQ(out_frame_.sample_rate_hz_, new_frame.sample_rate_hz_); 644 EXPECT_EQ(out_frame_.num_channels_, new_frame.num_channels_); 645 EXPECT_EQ(out_frame_.speech_type_, new_frame.speech_type_); 646 EXPECT_EQ(out_frame_.vad_activity_, new_frame.vad_activity_); 647 648 // Insert new data. Timestamp is corrected for the time elapsed since the last 649 // packet. Verify that normal operation resumes. 650 InsertPacket(kSamples * counter_); 651 GetAudioUntilNormal(); 652 EXPECT_FALSE(out_frame_.muted()); 653 654 NetEqNetworkStatistics stats; 655 EXPECT_EQ(0, neteq_->NetworkStatistics(&stats)); 656 // NetEqNetworkStatistics::expand_rate tells the fraction of samples that were 657 // concealment samples, in Q14 (16384 = 100%) .The vast majority should be 658 // concealment samples in this test. 659 EXPECT_GT(stats.expand_rate, 13000); 660 // And, it should be greater than the speech_expand_rate. 661 EXPECT_GT(stats.expand_rate, stats.speech_expand_rate); 662 } 663 664 // Verifies that NetEq goes out of muted state when given a delayed packet. 665 TEST_F(NetEqDecodingTestWithMutedState, MutedStateDelayedPacket) { 666 // Insert one speech packet. 667 InsertPacket(0); 668 // Pull out audio once and expect it not to be muted. 669 EXPECT_FALSE(GetAudioReturnMuted()); 670 // Pull data until faded out. 671 GetAudioUntilMuted(); 672 // Insert new data. Timestamp is only corrected for the half of the time 673 // elapsed since the last packet. That is, the new packet is delayed. Verify 674 // that normal operation resumes. 675 InsertPacket(kSamples * counter_ / 2); 676 GetAudioUntilNormal(); 677 } 678 679 // Verifies that NetEq goes out of muted state when given a future packet. 680 TEST_F(NetEqDecodingTestWithMutedState, MutedStateFuturePacket) { 681 // Insert one speech packet. 682 InsertPacket(0); 683 // Pull out audio once and expect it not to be muted. 684 EXPECT_FALSE(GetAudioReturnMuted()); 685 // Pull data until faded out. 686 GetAudioUntilMuted(); 687 // Insert new data. Timestamp is over-corrected for the time elapsed since the 688 // last packet. That is, the new packet is too early. Verify that normal 689 // operation resumes. 690 InsertPacket(kSamples * counter_ * 2); 691 GetAudioUntilNormal(); 692 } 693 694 // Verifies that NetEq goes out of muted state when given an old packet. 695 TEST_F(NetEqDecodingTestWithMutedState, MutedStateOldPacket) { 696 // Insert one speech packet. 697 InsertPacket(0); 698 // Pull out audio once and expect it not to be muted. 699 EXPECT_FALSE(GetAudioReturnMuted()); 700 // Pull data until faded out. 701 GetAudioUntilMuted(); 702 703 EXPECT_NE(AudioFrame::kNormalSpeech, out_frame_.speech_type_); 704 // Insert a few packets which are older than the first packet. 705 for (int i = 0; i < 5; ++i) { 706 InsertPacket(kSamples * (i - 1000)); 707 } 708 GetAudioUntilNormal(); 709 } 710 711 // Verifies that NetEq doesn't enter muted state when CNG mode is active and the 712 // packet stream is suspended for a long time. 713 TEST_F(NetEqDecodingTestWithMutedState, DoNotMuteExtendedCngWithoutPackets) { 714 // Insert one CNG packet. 715 InsertCngPacket(0); 716 717 // Pull 10 seconds of audio (10 ms audio generated per lap). 718 for (int i = 0; i < 1000; ++i) { 719 bool muted; 720 EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); 721 ASSERT_FALSE(muted); 722 } 723 EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); 724 } 725 726 // Verifies that NetEq goes back to normal after a long CNG period with the 727 // packet stream suspended. 728 TEST_F(NetEqDecodingTestWithMutedState, RecoverAfterExtendedCngWithoutPackets) { 729 // Insert one CNG packet. 730 InsertCngPacket(0); 731 732 // Pull 10 seconds of audio (10 ms audio generated per lap). 733 for (int i = 0; i < 1000; ++i) { 734 bool muted; 735 EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); 736 } 737 738 // Insert new data. Timestamp is corrected for the time elapsed since the last 739 // packet. Verify that normal operation resumes. 740 InsertPacket(kSamples * counter_); 741 GetAudioUntilNormal(); 742 } 743 744 namespace { 745 ::testing::AssertionResult AudioFramesEqualExceptData(const AudioFrame& a, 746 const AudioFrame& b) { 747 if (a.timestamp_ != b.timestamp_) 748 return ::testing::AssertionFailure() << "timestamp_ diff (" << a.timestamp_ 749 << " != " << b.timestamp_ << ")"; 750 if (a.sample_rate_hz_ != b.sample_rate_hz_) 751 return ::testing::AssertionFailure() 752 << "sample_rate_hz_ diff (" << a.sample_rate_hz_ 753 << " != " << b.sample_rate_hz_ << ")"; 754 if (a.samples_per_channel_ != b.samples_per_channel_) 755 return ::testing::AssertionFailure() 756 << "samples_per_channel_ diff (" << a.samples_per_channel_ 757 << " != " << b.samples_per_channel_ << ")"; 758 if (a.num_channels_ != b.num_channels_) 759 return ::testing::AssertionFailure() 760 << "num_channels_ diff (" << a.num_channels_ 761 << " != " << b.num_channels_ << ")"; 762 if (a.speech_type_ != b.speech_type_) 763 return ::testing::AssertionFailure() 764 << "speech_type_ diff (" << a.speech_type_ 765 << " != " << b.speech_type_ << ")"; 766 if (a.vad_activity_ != b.vad_activity_) 767 return ::testing::AssertionFailure() 768 << "vad_activity_ diff (" << a.vad_activity_ 769 << " != " << b.vad_activity_ << ")"; 770 return ::testing::AssertionSuccess(); 771 } 772 773 ::testing::AssertionResult AudioFramesEqual(const AudioFrame& a, 774 const AudioFrame& b) { 775 ::testing::AssertionResult res = AudioFramesEqualExceptData(a, b); 776 if (!res) 777 return res; 778 if (memcmp(a.data(), b.data(), 779 a.samples_per_channel_ * a.num_channels_ * sizeof(*a.data())) != 780 0) { 781 return ::testing::AssertionFailure() << "data_ diff"; 782 } 783 return ::testing::AssertionSuccess(); 784 } 785 786 } // namespace 787 788 TEST_F(NetEqDecodingTestTwoInstances, CompareMutedStateOnOff) { 789 ASSERT_FALSE(config_.enable_muted_state); 790 config2_.enable_muted_state = true; 791 CreateSecondInstance(); 792 793 // Insert one speech packet into both NetEqs. 794 const size_t kSamples = 10 * 16; 795 const size_t kPayloadBytes = kSamples * 2; 796 uint8_t payload[kPayloadBytes] = {0}; 797 RTPHeader rtp_info; 798 PopulateRtpInfo(0, 0, &rtp_info); 799 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, clock_.CurrentTime())); 800 EXPECT_EQ(0, neteq2_->InsertPacket(rtp_info, payload, clock_.CurrentTime())); 801 802 AudioFrame out_frame1, out_frame2; 803 bool muted; 804 for (int i = 0; i < 1000; ++i) { 805 StringBuilder ss; 806 ss << "i = " << i; 807 SCOPED_TRACE(ss.str()); // Print out the loop iterator on failure. 808 EXPECT_EQ(0, neteq_->GetAudio(&out_frame1, &muted)); 809 EXPECT_FALSE(muted); 810 EXPECT_EQ(0, neteq2_->GetAudio(&out_frame2, &muted)); 811 if (muted) { 812 EXPECT_TRUE(AudioFramesEqualExceptData(out_frame1, out_frame2)); 813 } else { 814 EXPECT_TRUE(AudioFramesEqual(out_frame1, out_frame2)); 815 } 816 } 817 EXPECT_TRUE(muted); 818 819 // Insert new data. Timestamp is corrected for the time elapsed since the last 820 // packet. 821 for (int i = 0; i < 5; ++i) { 822 PopulateRtpInfo(0, kSamples * 1000 + kSamples * i, &rtp_info); 823 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, clock_.CurrentTime())); 824 EXPECT_EQ(0, 825 neteq2_->InsertPacket(rtp_info, payload, clock_.CurrentTime())); 826 } 827 828 int counter = 0; 829 while (out_frame1.speech_type_ != AudioFrame::kNormalSpeech) { 830 ASSERT_LT(counter++, 1000) << "Test timed out"; 831 StringBuilder ss; 832 ss << "counter = " << counter; 833 SCOPED_TRACE(ss.str()); // Print out the loop iterator on failure. 834 EXPECT_EQ(0, neteq_->GetAudio(&out_frame1, &muted)); 835 EXPECT_FALSE(muted); 836 EXPECT_EQ(0, neteq2_->GetAudio(&out_frame2, &muted)); 837 if (muted) { 838 EXPECT_TRUE(AudioFramesEqualExceptData(out_frame1, out_frame2)); 839 } else { 840 EXPECT_TRUE(AudioFramesEqual(out_frame1, out_frame2)); 841 } 842 } 843 EXPECT_FALSE(muted); 844 } 845 846 TEST_F(NetEqDecodingTest, TestConcealmentEvents) { 847 const int kNumConcealmentEvents = 19; 848 const size_t kSamples = 10 * 16; 849 const size_t kPayloadBytes = kSamples * 2; 850 int seq_no = 0; 851 RTPHeader rtp_info; 852 rtp_info.ssrc = 0x1234; // Just an arbitrary SSRC. 853 rtp_info.payloadType = 94; // PCM16b WB codec. 854 rtp_info.markerBit = 0; 855 const uint8_t payload[kPayloadBytes] = {0}; 856 bool muted; 857 858 for (int i = 0; i < kNumConcealmentEvents; i++) { 859 // Insert some packets of 10 ms size. 860 for (int j = 0; j < 10; j++) { 861 rtp_info.sequenceNumber = seq_no++; 862 rtp_info.timestamp = rtp_info.sequenceNumber * kSamples; 863 neteq_->InsertPacket(rtp_info, payload, clock_.CurrentTime()); 864 neteq_->GetAudio(&out_frame_, &muted); 865 } 866 867 // Lose a number of packets. 868 int num_lost = 1 + i; 869 for (int j = 0; j < num_lost; j++) { 870 seq_no++; 871 neteq_->GetAudio(&out_frame_, &muted); 872 } 873 } 874 875 // Check number of concealment events. 876 NetEqLifetimeStatistics stats = neteq_->GetLifetimeStatistics(); 877 EXPECT_EQ(kNumConcealmentEvents, static_cast<int>(stats.concealment_events)); 878 } 879 880 // Test that the jitter buffer delay stat is computed correctly. 881 void NetEqDecodingTestFaxMode::TestJitterBufferDelay(bool apply_packet_loss) { 882 const int kNumPackets = 10; 883 const int kDelayInNumPackets = 2; 884 const int kPacketLenMs = 10; // All packets are of 10 ms size. 885 const size_t kSamples = kPacketLenMs * 16; 886 const size_t kPayloadBytes = kSamples * 2; 887 RTPHeader rtp_info; 888 rtp_info.ssrc = 0x1234; // Just an arbitrary SSRC. 889 rtp_info.payloadType = 94; // PCM16b WB codec. 890 rtp_info.markerBit = 0; 891 const uint8_t payload[kPayloadBytes] = {0}; 892 bool muted; 893 int packets_sent = 0; 894 int packets_received = 0; 895 int expected_delay = 0; 896 int expected_target_delay = 0; 897 uint64_t expected_emitted_count = 0; 898 while (packets_received < kNumPackets) { 899 // Insert packet. 900 if (packets_sent < kNumPackets) { 901 rtp_info.sequenceNumber = packets_sent++; 902 rtp_info.timestamp = rtp_info.sequenceNumber * kSamples; 903 neteq_->InsertPacket(rtp_info, payload, clock_.CurrentTime()); 904 } 905 906 // Get packet. 907 if (packets_sent > kDelayInNumPackets) { 908 clock_.AdvanceTime(TimeDelta::Millis(kPacketLenMs)); 909 neteq_->GetAudio(&out_frame_, &muted); 910 packets_received++; 911 912 // The delay reported by the jitter buffer never exceeds 913 // the number of samples previously fetched with GetAudio 914 // (hence the min()). 915 int packets_delay = std::min(packets_received, kDelayInNumPackets + 1); 916 917 // The increase of the expected delay is the product of 918 // the current delay of the jitter buffer in ms * the 919 // number of samples that are sent for play out. 920 int current_delay_ms = packets_delay * kPacketLenMs; 921 expected_delay += current_delay_ms * kSamples; 922 expected_target_delay += neteq_->TargetDelayMs() * kSamples; 923 expected_emitted_count += kSamples; 924 } 925 } 926 927 if (apply_packet_loss) { 928 clock_.AdvanceTime(TimeDelta::Millis(kPacketLenMs)); 929 // Extra call to GetAudio to cause concealment. 930 neteq_->GetAudio(&out_frame_, &muted); 931 } 932 933 // Check jitter buffer delay. 934 NetEqLifetimeStatistics stats = neteq_->GetLifetimeStatistics(); 935 EXPECT_EQ(expected_delay, checked_cast<int>(stats.jitter_buffer_delay_ms)); 936 EXPECT_EQ(expected_emitted_count, stats.jitter_buffer_emitted_count); 937 EXPECT_EQ(expected_target_delay, 938 checked_cast<int>(stats.jitter_buffer_target_delay_ms)); 939 // In this test, since the packets are inserted with a receive time equal to 940 // the current clock time, the jitter buffer delay should match the total 941 // processing delay. 942 EXPECT_EQ(stats.jitter_buffer_delay_ms * 1000, 943 stats.total_processing_delay_us); 944 } 945 946 TEST_F(NetEqDecodingTestFaxMode, TestJitterBufferDelayWithoutLoss) { 947 TestJitterBufferDelay(false); 948 } 949 950 TEST_F(NetEqDecodingTestFaxMode, TestJitterBufferDelayWithLoss) { 951 TestJitterBufferDelay(true); 952 } 953 954 TEST_F(NetEqDecodingTestFaxMode, TestJitterBufferDelayWithAcceleration) { 955 const int kPacketLenMs = 10; // All packets are of 10 ms size. 956 const size_t kSamples = kPacketLenMs * 16; 957 const size_t kPayloadBytes = kSamples * 2; 958 RTPHeader rtp_info; 959 rtp_info.ssrc = 0x1234; // Just an arbitrary SSRC. 960 rtp_info.payloadType = 94; // PCM16b WB codec. 961 rtp_info.markerBit = 0; 962 const uint8_t payload[kPayloadBytes] = {0}; 963 964 int expected_target_delay = neteq_->TargetDelayMs() * kSamples; 965 neteq_->InsertPacket(rtp_info, payload, clock_.CurrentTime()); 966 967 bool muted; 968 neteq_->GetAudio(&out_frame_, &muted); 969 970 rtp_info.sequenceNumber += 1; 971 rtp_info.timestamp += kSamples; 972 neteq_->InsertPacket(rtp_info, payload, clock_.CurrentTime()); 973 rtp_info.sequenceNumber += 1; 974 rtp_info.timestamp += kSamples; 975 neteq_->InsertPacket(rtp_info, payload, clock_.CurrentTime()); 976 977 expected_target_delay += neteq_->TargetDelayMs() * 2 * kSamples; 978 // We have two packets in the buffer and kAccelerate operation will 979 // extract 20 ms of data. 980 neteq_->GetAudio(&out_frame_, &muted, nullptr, NetEq::Operation::kAccelerate); 981 982 // Check jitter buffer delay. 983 NetEqLifetimeStatistics stats = neteq_->GetLifetimeStatistics(); 984 EXPECT_EQ(10 * kSamples * 3, stats.jitter_buffer_delay_ms); 985 EXPECT_EQ(kSamples * 3, stats.jitter_buffer_emitted_count); 986 EXPECT_EQ(expected_target_delay, 987 checked_cast<int>(stats.jitter_buffer_target_delay_ms)); 988 } 989 990 namespace test { 991 TEST(NetEqNoTimeStretchingMode, RunTest) { 992 NetEq::Config config; 993 config.for_test_no_time_stretching = true; 994 auto codecs = NetEqTest::StandardDecoderMap(); 995 std::map<int, RTPExtensionType> rtp_ext_map = { 996 {1, kRtpExtensionAudioLevel}, 997 {3, kRtpExtensionAbsoluteSendTime}, 998 {5, kRtpExtensionTransportSequenceNumber}, 999 {7, kRtpExtensionVideoContentType}, 1000 {8, kRtpExtensionVideoTiming}}; 1001 std::unique_ptr<NetEqInput> input = CreateNetEqRtpDumpInput( 1002 test::ResourcePath("audio_coding/neteq_universal_new", "rtp"), 1003 rtp_ext_map, std::nullopt /*No SSRC filter*/); 1004 std::unique_ptr<TimeLimitedNetEqInput> input_time_limit( 1005 new TimeLimitedNetEqInput(std::move(input), 20000)); 1006 std::unique_ptr<AudioSink> output(new VoidAudioSink); 1007 NetEqTest::Callbacks callbacks; 1008 NetEqTest test(config, CreateBuiltinAudioDecoderFactory(), codecs, 1009 /*text_log=*/nullptr, /*neteq_factory=*/nullptr, 1010 /*input=*/std::move(input_time_limit), std::move(output), 1011 callbacks); 1012 test.Run(); 1013 const auto stats = test.SimulationStats(); 1014 EXPECT_EQ(0, stats.accelerate_rate); 1015 EXPECT_EQ(0, stats.preemptive_rate); 1016 } 1017 1018 } // namespace test 1019 } // namespace webrtc