1 /* 2 * Copyright (c) 2021 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 "audio/test/audio_end_to_end_test.h" 12 #include "system_wrappers/include/sleep.h" 13 #include "test/gtest.h" 14 15 namespace webrtc { 16 namespace test { 17 18 using NackTest = CallTest; 19 TEST_F(NackTest,ShouldNackInLossyNetwork)20TEST_F(NackTest, ShouldNackInLossyNetwork) { 21 class NackTest : public AudioEndToEndTest { 22 public: 23 const int kTestDurationMs = 2000; 24 const int64_t kRttMs = 30; 25 const int64_t kLossPercent = 30; 26 const int kNackHistoryMs = 1000; 27 28 BuiltInNetworkBehaviorConfig GetNetworkPipeConfig() const override { 29 BuiltInNetworkBehaviorConfig pipe_config; 30 pipe_config.queue_delay_ms = kRttMs / 2; 31 pipe_config.loss_percent = kLossPercent; 32 return pipe_config; 33 } 34 35 void ModifyAudioConfigs(AudioSendStream::Config* send_config, 36 std::vector<AudioReceiveStreamInterface::Config>* 37 receive_configs) override { 38 ASSERT_EQ(receive_configs->size(), 1U); 39 (*receive_configs)[0].rtp.nack.rtp_history_ms = kNackHistoryMs; 40 AudioEndToEndTest::ModifyAudioConfigs(send_config, receive_configs); 41 } 42 43 void PerformTest() override { SleepMs(kTestDurationMs); } 44 45 void OnStreamsStopped() override { 46 AudioReceiveStreamInterface::Stats recv_stats = 47 receive_stream()->GetStats(/*get_and_clear_legacy_stats=*/true); 48 EXPECT_GT(recv_stats.nacks_sent, 0U); 49 AudioSendStream::Stats send_stats = send_stream()->GetStats(); 50 EXPECT_GT(send_stats.retransmitted_packets_sent, 0U); 51 EXPECT_GT(send_stats.nacks_rcvd, 0U); 52 } 53 } test; 54 55 RunBaseTest(&test); 56 } 57 58 } // namespace test 59 } // namespace webrtc 60