tor-browser

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

neteq_decoding_test.h (3381B)


      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 #ifndef MODULES_AUDIO_CODING_NETEQ_TEST_NETEQ_DECODING_TEST_H_
     12 #define MODULES_AUDIO_CODING_NETEQ_TEST_NETEQ_DECODING_TEST_H_
     13 
     14 #include <cstddef>
     15 #include <cstdint>
     16 #include <memory>
     17 #include <set>
     18 
     19 #include "absl/strings/string_view.h"
     20 #include "api/audio/audio_frame.h"
     21 #include "api/environment/environment.h"
     22 #include "api/neteq/neteq.h"
     23 #include "api/rtp_headers.h"
     24 #include "modules/audio_coding/neteq/tools/rtp_file_source.h"
     25 #include "modules/rtp_rtcp/source/rtp_packet_received.h"
     26 #include "system_wrappers/include/clock.h"
     27 #include "test/gtest.h"
     28 
     29 namespace webrtc {
     30 
     31 class NetEqDecodingTest : public ::testing::Test {
     32 protected:
     33  // NetEQ must be polled for data once every 10 ms.
     34  // Thus, none of the constants below can be changed.
     35  static constexpr int kTimeStepMs = 10;
     36  static constexpr size_t kBlockSize8kHz = kTimeStepMs * 8;
     37  static constexpr size_t kBlockSize16kHz = kTimeStepMs * 16;
     38  static constexpr size_t kBlockSize32kHz = kTimeStepMs * 32;
     39  static constexpr size_t kBlockSize48kHz = kTimeStepMs * 48;
     40  static constexpr int kInitSampleRateHz = 8000;
     41 
     42  NetEqDecodingTest();
     43  virtual void SetUp();
     44  virtual void TearDown();
     45  void OpenInputFile(absl::string_view rtp_file);
     46  void Process();
     47 
     48  void DecodeAndCompare(absl::string_view rtp_file,
     49                        absl::string_view output_checksum,
     50                        absl::string_view network_stats_checksum,
     51                        bool gen_ref);
     52 
     53  static void PopulateRtpInfo(int frame_index,
     54                              int timestamp,
     55                              RTPHeader* rtp_info);
     56  static void PopulateCng(int frame_index,
     57                          int timestamp,
     58                          RTPHeader* rtp_info,
     59                          uint8_t* payload,
     60                          size_t* payload_len);
     61 
     62  void WrapTest(uint16_t start_seq_no,
     63                uint32_t start_timestamp,
     64                const std::set<uint16_t>& drop_seq_numbers,
     65                bool expect_seq_no_wrap,
     66                bool expect_timestamp_wrap);
     67 
     68  void LongCngWithClockDrift(double drift_factor,
     69                             double network_freeze_ms,
     70                             bool pull_audio_during_freeze,
     71                             int delay_tolerance_ms,
     72                             int max_time_to_speech_ms);
     73 
     74  SimulatedClock clock_;
     75  const Environment env_;
     76  std::unique_ptr<NetEq> neteq_;
     77  NetEq::Config config_;
     78  std::unique_ptr<test::RtpFileSource> rtp_source_;
     79  std::unique_ptr<RtpPacketReceived> packet_;
     80  AudioFrame out_frame_;
     81  int output_sample_rate_;
     82  int algorithmic_delay_ms_;
     83 };
     84 
     85 class NetEqDecodingTestTwoInstances : public NetEqDecodingTest {
     86 public:
     87  NetEqDecodingTestTwoInstances() : NetEqDecodingTest() {}
     88 
     89  void SetUp() override;
     90 
     91  void CreateSecondInstance();
     92 
     93 protected:
     94  std::unique_ptr<NetEq> neteq2_;
     95  NetEq::Config config2_;
     96 };
     97 
     98 }  // namespace webrtc
     99 #endif  // MODULES_AUDIO_CODING_NETEQ_TEST_NETEQ_DECODING_TEST_H_