tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nack_test.cc (2204B)


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