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