henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 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 | |
Henrik Kjellander | 7464089 | 2015-10-29 11:31:02 +0100 | [diff] [blame] | 11 | #include "webrtc/modules/audio_coding/neteq/include/neteq.h" |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 12 | |
pbos@webrtc.org | 3ecc162 | 2014-03-07 15:23:34 +0000 | [diff] [blame] | 13 | #include <math.h> |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 14 | #include <stdlib.h> |
| 15 | #include <string.h> // memset |
| 16 | |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 17 | #include <algorithm> |
kwiberg | 2d0c332 | 2016-02-14 09:28:33 -0800 | [diff] [blame] | 18 | #include <memory> |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 19 | #include <set> |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 20 | #include <string> |
| 21 | #include <vector> |
| 22 | |
turaj@webrtc.org | a6101d7 | 2013-10-01 22:01:09 +0000 | [diff] [blame] | 23 | #include "gflags/gflags.h" |
kjellander@webrtc.org | 3c0aae1 | 2014-09-04 09:55:40 +0000 | [diff] [blame] | 24 | #include "testing/gtest/include/gtest/gtest.h" |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 25 | #include "webrtc/base/sha1digest.h" |
| 26 | #include "webrtc/base/stringencode.h" |
henrik.lundin@webrtc.org | 9b8102c | 2014-08-21 08:27:44 +0000 | [diff] [blame] | 27 | #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" |
henrik.lundin@webrtc.org | 966a708 | 2014-11-17 09:08:38 +0000 | [diff] [blame] | 28 | #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" |
kjellander@webrtc.org | 3c652b6 | 2015-11-18 23:07:57 +0100 | [diff] [blame] | 29 | #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 30 | #include "webrtc/modules/include/module_common_types.h" |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 31 | #include "webrtc/test/testsupport/fileutils.h" |
| 32 | #include "webrtc/typedefs.h" |
| 33 | |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 34 | #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT |
| 35 | #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
| 36 | #include "external/webrtc/webrtc/modules/audio_coding/neteq/neteq_unittest.pb.h" |
| 37 | #else |
| 38 | #include "webrtc/audio_coding/neteq/neteq_unittest.pb.h" |
| 39 | #endif |
| 40 | #endif |
| 41 | |
turaj@webrtc.org | a6101d7 | 2013-10-01 22:01:09 +0000 | [diff] [blame] | 42 | DEFINE_bool(gen_ref, false, "Generate reference files."); |
| 43 | |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 44 | namespace { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 45 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 46 | const std::string& PlatformChecksum(const std::string& checksum_general, |
| 47 | const std::string& checksum_android, |
| 48 | const std::string& checksum_win_32, |
| 49 | const std::string& checksum_win_64) { |
| 50 | #ifdef WEBRTC_ANDROID |
| 51 | return checksum_android; |
| 52 | #elif WEBRTC_WIN |
| 53 | #ifdef WEBRTC_ARCH_64_BITS |
| 54 | return checksum_win_64; |
| 55 | #else |
| 56 | return checksum_win_32; |
| 57 | #endif // WEBRTC_ARCH_64_BITS |
| 58 | #else |
| 59 | return checksum_general; |
| 60 | #endif // WEBRTC_WIN |
| 61 | } |
| 62 | |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 63 | bool IsAllZero(const int16_t* buf, size_t buf_length) { |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 64 | bool all_zero = true; |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 65 | for (size_t n = 0; n < buf_length && all_zero; ++n) |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 66 | all_zero = buf[n] == 0; |
| 67 | return all_zero; |
| 68 | } |
| 69 | |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 70 | bool IsAllNonZero(const int16_t* buf, size_t buf_length) { |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 71 | bool all_non_zero = true; |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 72 | for (size_t n = 0; n < buf_length && all_non_zero; ++n) |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 73 | all_non_zero = buf[n] != 0; |
| 74 | return all_non_zero; |
| 75 | } |
| 76 | |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 77 | #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT |
| 78 | void Convert(const webrtc::NetEqNetworkStatistics& stats_raw, |
| 79 | webrtc::neteq_unittest::NetEqNetworkStatistics* stats) { |
| 80 | stats->set_current_buffer_size_ms(stats_raw.current_buffer_size_ms); |
| 81 | stats->set_preferred_buffer_size_ms(stats_raw.preferred_buffer_size_ms); |
| 82 | stats->set_jitter_peaks_found(stats_raw.jitter_peaks_found); |
| 83 | stats->set_packet_loss_rate(stats_raw.packet_loss_rate); |
| 84 | stats->set_packet_discard_rate(stats_raw.packet_discard_rate); |
| 85 | stats->set_expand_rate(stats_raw.expand_rate); |
| 86 | stats->set_speech_expand_rate(stats_raw.speech_expand_rate); |
| 87 | stats->set_preemptive_rate(stats_raw.preemptive_rate); |
| 88 | stats->set_accelerate_rate(stats_raw.accelerate_rate); |
| 89 | stats->set_secondary_decoded_rate(stats_raw.secondary_decoded_rate); |
| 90 | stats->set_clockdrift_ppm(stats_raw.clockdrift_ppm); |
| 91 | stats->set_added_zero_samples(stats_raw.added_zero_samples); |
| 92 | stats->set_mean_waiting_time_ms(stats_raw.mean_waiting_time_ms); |
| 93 | stats->set_median_waiting_time_ms(stats_raw.median_waiting_time_ms); |
| 94 | stats->set_min_waiting_time_ms(stats_raw.min_waiting_time_ms); |
| 95 | stats->set_max_waiting_time_ms(stats_raw.max_waiting_time_ms); |
| 96 | } |
| 97 | |
| 98 | void Convert(const webrtc::RtcpStatistics& stats_raw, |
| 99 | webrtc::neteq_unittest::RtcpStatistics* stats) { |
| 100 | stats->set_fraction_lost(stats_raw.fraction_lost); |
| 101 | stats->set_cumulative_lost(stats_raw.cumulative_lost); |
| 102 | stats->set_extended_max_sequence_number( |
| 103 | stats_raw.extended_max_sequence_number); |
| 104 | stats->set_jitter(stats_raw.jitter); |
| 105 | } |
| 106 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 107 | void AddMessage(FILE* file, rtc::MessageDigest* digest, |
| 108 | const std::string& message) { |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 109 | int32_t size = message.length(); |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 110 | if (file) |
| 111 | ASSERT_EQ(1u, fwrite(&size, sizeof(size), 1, file)); |
| 112 | digest->Update(&size, sizeof(size)); |
| 113 | |
| 114 | if (file) |
| 115 | ASSERT_EQ(static_cast<size_t>(size), |
| 116 | fwrite(message.data(), sizeof(char), size, file)); |
| 117 | digest->Update(message.data(), sizeof(char) * size); |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 118 | } |
| 119 | |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 120 | #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT |
| 121 | |
| 122 | } // namespace |
| 123 | |
| 124 | namespace webrtc { |
| 125 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 126 | class ResultSink { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 127 | public: |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 128 | explicit ResultSink(const std::string& output_file); |
| 129 | ~ResultSink(); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 130 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 131 | template<typename T, size_t n> void AddResult( |
| 132 | const T (&test_results)[n], |
| 133 | size_t length); |
| 134 | |
| 135 | void AddResult(const NetEqNetworkStatistics& stats); |
| 136 | void AddResult(const RtcpStatistics& stats); |
| 137 | |
| 138 | void VerifyChecksum(const std::string& ref_check_sum); |
| 139 | |
| 140 | private: |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 141 | FILE* output_fp_; |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 142 | std::unique_ptr<rtc::MessageDigest> digest_; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 143 | }; |
| 144 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 145 | ResultSink::ResultSink(const std::string &output_file) |
| 146 | : output_fp_(nullptr), |
| 147 | digest_(new rtc::Sha1Digest()) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 148 | if (!output_file.empty()) { |
| 149 | output_fp_ = fopen(output_file.c_str(), "wb"); |
| 150 | EXPECT_TRUE(output_fp_ != NULL); |
| 151 | } |
| 152 | } |
| 153 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 154 | ResultSink::~ResultSink() { |
| 155 | if (output_fp_) |
| 156 | fclose(output_fp_); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | template<typename T, size_t n> |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 160 | void ResultSink::AddResult(const T (&test_results)[n], size_t length) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 161 | if (output_fp_) { |
| 162 | ASSERT_EQ(length, fwrite(&test_results, sizeof(T), length, output_fp_)); |
| 163 | } |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 164 | digest_->Update(&test_results, sizeof(T) * length); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 165 | } |
| 166 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 167 | void ResultSink::AddResult(const NetEqNetworkStatistics& stats_raw) { |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 168 | #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 169 | neteq_unittest::NetEqNetworkStatistics stats; |
| 170 | Convert(stats_raw, &stats); |
| 171 | |
| 172 | std::string stats_string; |
| 173 | ASSERT_TRUE(stats.SerializeToString(&stats_string)); |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 174 | AddMessage(output_fp_, digest_.get(), stats_string); |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 175 | #else |
| 176 | FAIL() << "Writing to reference file requires Proto Buffer."; |
| 177 | #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 178 | } |
| 179 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 180 | void ResultSink::AddResult(const RtcpStatistics& stats_raw) { |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 181 | #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 182 | neteq_unittest::RtcpStatistics stats; |
| 183 | Convert(stats_raw, &stats); |
| 184 | |
| 185 | std::string stats_string; |
| 186 | ASSERT_TRUE(stats.SerializeToString(&stats_string)); |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 187 | AddMessage(output_fp_, digest_.get(), stats_string); |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 188 | #else |
| 189 | FAIL() << "Writing to reference file requires Proto Buffer."; |
| 190 | #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 191 | } |
| 192 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 193 | void ResultSink::VerifyChecksum(const std::string& checksum) { |
| 194 | std::vector<char> buffer; |
| 195 | buffer.resize(digest_->Size()); |
| 196 | digest_->Finish(&buffer[0], buffer.size()); |
| 197 | const std::string result = rtc::hex_encode(&buffer[0], digest_->Size()); |
| 198 | EXPECT_EQ(checksum, result); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | class NetEqDecodingTest : public ::testing::Test { |
| 202 | protected: |
| 203 | // NetEQ must be polled for data once every 10 ms. Thus, neither of the |
| 204 | // constants below can be changed. |
| 205 | static const int kTimeStepMs = 10; |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 206 | static const size_t kBlockSize8kHz = kTimeStepMs * 8; |
| 207 | static const size_t kBlockSize16kHz = kTimeStepMs * 16; |
| 208 | static const size_t kBlockSize32kHz = kTimeStepMs * 32; |
minyue | 93c08b7 | 2015-12-22 09:57:41 -0800 | [diff] [blame] | 209 | static const size_t kBlockSize48kHz = kTimeStepMs * 48; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 210 | static const int kInitSampleRateHz = 8000; |
| 211 | |
| 212 | NetEqDecodingTest(); |
| 213 | virtual void SetUp(); |
| 214 | virtual void TearDown(); |
| 215 | void SelectDecoders(NetEqDecoder* used_codec); |
| 216 | void LoadDecoders(); |
| 217 | void OpenInputFile(const std::string &rtp_file); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 218 | void Process(); |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 219 | |
henrik.lundin@webrtc.org | 4e4b098 | 2014-08-11 14:48:49 +0000 | [diff] [blame] | 220 | void DecodeAndCompare(const std::string& rtp_file, |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 221 | const std::string& output_checksum, |
| 222 | const std::string& network_stats_checksum, |
| 223 | const std::string& rtcp_stats_checksum, |
| 224 | bool gen_ref); |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 225 | |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 226 | static void PopulateRtpInfo(int frame_index, |
| 227 | int timestamp, |
| 228 | WebRtcRTPHeader* rtp_info); |
| 229 | static void PopulateCng(int frame_index, |
| 230 | int timestamp, |
| 231 | WebRtcRTPHeader* rtp_info, |
| 232 | uint8_t* payload, |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 233 | size_t* payload_len); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 234 | |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 235 | void WrapTest(uint16_t start_seq_no, uint32_t start_timestamp, |
| 236 | const std::set<uint16_t>& drop_seq_numbers, |
| 237 | bool expect_seq_no_wrap, bool expect_timestamp_wrap); |
| 238 | |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 239 | void LongCngWithClockDrift(double drift_factor, |
| 240 | double network_freeze_ms, |
| 241 | bool pull_audio_during_freeze, |
| 242 | int delay_tolerance_ms, |
| 243 | int max_time_to_speech_ms); |
| 244 | |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 245 | void DuplicateCng(); |
henrik.lundin@webrtc.org | fcfc6a9 | 2014-02-13 11:42:28 +0000 | [diff] [blame] | 246 | |
henrik.lundin | 0d96ab7 | 2016-04-06 12:28:26 -0700 | [diff] [blame] | 247 | rtc::Optional<uint32_t> PlayoutTimestamp(); |
wu@webrtc.org | 94454b7 | 2014-06-05 20:34:08 +0000 | [diff] [blame] | 248 | |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 249 | NetEq* neteq_; |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 250 | NetEq::Config config_; |
kwiberg | 2d0c332 | 2016-02-14 09:28:33 -0800 | [diff] [blame] | 251 | std::unique_ptr<test::RtpFileSource> rtp_source_; |
| 252 | std::unique_ptr<test::Packet> packet_; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 253 | unsigned int sim_clock_; |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 254 | AudioFrame out_frame_; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 255 | int output_sample_rate_; |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 256 | int algorithmic_delay_ms_; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 257 | }; |
| 258 | |
| 259 | // Allocating the static const so that it can be passed by reference. |
| 260 | const int NetEqDecodingTest::kTimeStepMs; |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 261 | const size_t NetEqDecodingTest::kBlockSize8kHz; |
| 262 | const size_t NetEqDecodingTest::kBlockSize16kHz; |
| 263 | const size_t NetEqDecodingTest::kBlockSize32kHz; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 264 | const int NetEqDecodingTest::kInitSampleRateHz; |
| 265 | |
| 266 | NetEqDecodingTest::NetEqDecodingTest() |
| 267 | : neteq_(NULL), |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 268 | config_(), |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 269 | sim_clock_(0), |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 270 | output_sample_rate_(kInitSampleRateHz), |
| 271 | algorithmic_delay_ms_(0) { |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 272 | config_.sample_rate_hz = kInitSampleRateHz; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | void NetEqDecodingTest::SetUp() { |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 276 | neteq_ = NetEq::Create(config_); |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 277 | NetEqNetworkStatistics stat; |
| 278 | ASSERT_EQ(0, neteq_->NetworkStatistics(&stat)); |
| 279 | algorithmic_delay_ms_ = stat.current_buffer_size_ms; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 280 | ASSERT_TRUE(neteq_); |
| 281 | LoadDecoders(); |
| 282 | } |
| 283 | |
| 284 | void NetEqDecodingTest::TearDown() { |
| 285 | delete neteq_; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | void NetEqDecodingTest::LoadDecoders() { |
| 289 | // Load PCMu. |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 290 | ASSERT_EQ(0, |
| 291 | neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCMu, "pcmu", 0)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 292 | // Load PCMa. |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 293 | ASSERT_EQ(0, |
| 294 | neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCMa, "pcma", 8)); |
kwiberg | 98ab3a4 | 2015-09-30 21:54:21 -0700 | [diff] [blame] | 295 | #ifdef WEBRTC_CODEC_ILBC |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 296 | // Load iLBC. |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 297 | ASSERT_EQ( |
| 298 | 0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderILBC, "ilbc", 102)); |
kwiberg | 98ab3a4 | 2015-09-30 21:54:21 -0700 | [diff] [blame] | 299 | #endif |
| 300 | #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 301 | // Load iSAC. |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 302 | ASSERT_EQ( |
| 303 | 0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderISAC, "isac", 103)); |
kwiberg | 98ab3a4 | 2015-09-30 21:54:21 -0700 | [diff] [blame] | 304 | #endif |
| 305 | #ifdef WEBRTC_CODEC_ISAC |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 306 | // Load iSAC SWB. |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 307 | ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderISACswb, |
| 308 | "isac-swb", 104)); |
kwiberg | 98ab3a4 | 2015-09-30 21:54:21 -0700 | [diff] [blame] | 309 | #endif |
minyue | 93c08b7 | 2015-12-22 09:57:41 -0800 | [diff] [blame] | 310 | #ifdef WEBRTC_CODEC_OPUS |
| 311 | ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderOpus, |
| 312 | "opus", 111)); |
| 313 | #endif |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 314 | // Load PCM16B nb. |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 315 | ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16B, |
| 316 | "pcm16-nb", 93)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 317 | // Load PCM16B wb. |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 318 | ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16Bwb, |
| 319 | "pcm16-wb", 94)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 320 | // Load PCM16B swb32. |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 321 | ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16Bswb32kHz, |
| 322 | "pcm16-swb32", 95)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 323 | // Load CNG 8 kHz. |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 324 | ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGnb, |
| 325 | "cng-nb", 13)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 326 | // Load CNG 16 kHz. |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 327 | ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGwb, |
| 328 | "cng-wb", 98)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | void NetEqDecodingTest::OpenInputFile(const std::string &rtp_file) { |
henrik.lundin@webrtc.org | 966a708 | 2014-11-17 09:08:38 +0000 | [diff] [blame] | 332 | rtp_source_.reset(test::RtpFileSource::Create(rtp_file)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 333 | } |
| 334 | |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 335 | void NetEqDecodingTest::Process() { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 336 | // Check if time to receive. |
henrik.lundin@webrtc.org | 966a708 | 2014-11-17 09:08:38 +0000 | [diff] [blame] | 337 | while (packet_ && sim_clock_ >= packet_->time_ms()) { |
| 338 | if (packet_->payload_length_bytes() > 0) { |
| 339 | WebRtcRTPHeader rtp_header; |
| 340 | packet_->ConvertHeader(&rtp_header); |
ivoc | 72c08ed | 2016-01-20 07:26:24 -0800 | [diff] [blame] | 341 | #ifndef WEBRTC_CODEC_ISAC |
| 342 | // Ignore payload type 104 (iSAC-swb) if ISAC is not supported. |
| 343 | if (rtp_header.header.payloadType != 104) |
| 344 | #endif |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 345 | ASSERT_EQ(0, neteq_->InsertPacket( |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 346 | rtp_header, |
| 347 | rtc::ArrayView<const uint8_t>( |
| 348 | packet_->payload(), packet_->payload_length_bytes()), |
| 349 | static_cast<uint32_t>(packet_->time_ms() * |
| 350 | (output_sample_rate_ / 1000)))); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 351 | } |
| 352 | // Get next packet. |
henrik.lundin@webrtc.org | 966a708 | 2014-11-17 09:08:38 +0000 | [diff] [blame] | 353 | packet_.reset(rtp_source_->NextPacket()); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 354 | } |
| 355 | |
henrik.lundin@webrtc.org | e1d468c | 2013-01-30 07:37:20 +0000 | [diff] [blame] | 356 | // Get audio from NetEq. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 357 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 358 | ASSERT_TRUE((out_frame_.samples_per_channel_ == kBlockSize8kHz) || |
| 359 | (out_frame_.samples_per_channel_ == kBlockSize16kHz) || |
| 360 | (out_frame_.samples_per_channel_ == kBlockSize32kHz) || |
| 361 | (out_frame_.samples_per_channel_ == kBlockSize48kHz)); |
| 362 | output_sample_rate_ = out_frame_.sample_rate_hz_; |
henrik.lundin | d89814b | 2015-11-23 06:49:25 -0800 | [diff] [blame] | 363 | EXPECT_EQ(output_sample_rate_, neteq_->last_output_sample_rate_hz()); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 364 | |
| 365 | // Increase time. |
| 366 | sim_clock_ += kTimeStepMs; |
| 367 | } |
| 368 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 369 | void NetEqDecodingTest::DecodeAndCompare( |
| 370 | const std::string& rtp_file, |
| 371 | const std::string& output_checksum, |
| 372 | const std::string& network_stats_checksum, |
| 373 | const std::string& rtcp_stats_checksum, |
| 374 | bool gen_ref) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 375 | OpenInputFile(rtp_file); |
| 376 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 377 | std::string ref_out_file = |
| 378 | gen_ref ? webrtc::test::OutputPath() + "neteq_universal_ref.pcm" : ""; |
| 379 | ResultSink output(ref_out_file); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 380 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 381 | std::string stat_out_file = |
| 382 | gen_ref ? webrtc::test::OutputPath() + "neteq_network_stats.dat" : ""; |
| 383 | ResultSink network_stats(stat_out_file); |
henrik.lundin@webrtc.org | 4e4b098 | 2014-08-11 14:48:49 +0000 | [diff] [blame] | 384 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 385 | std::string rtcp_out_file = |
| 386 | gen_ref ? webrtc::test::OutputPath() + "neteq_rtcp_stats.dat" : ""; |
| 387 | ResultSink rtcp_stats(rtcp_out_file); |
henrik.lundin@webrtc.org | 4e4b098 | 2014-08-11 14:48:49 +0000 | [diff] [blame] | 388 | |
henrik.lundin@webrtc.org | 966a708 | 2014-11-17 09:08:38 +0000 | [diff] [blame] | 389 | packet_.reset(rtp_source_->NextPacket()); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 390 | int i = 0; |
henrik.lundin@webrtc.org | 966a708 | 2014-11-17 09:08:38 +0000 | [diff] [blame] | 391 | while (packet_) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 392 | std::ostringstream ss; |
| 393 | ss << "Lap number " << i++ << " in DecodeAndCompare while loop"; |
| 394 | SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 395 | ASSERT_NO_FATAL_FAILURE(Process()); |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 396 | ASSERT_NO_FATAL_FAILURE(output.AddResult( |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 397 | out_frame_.data_, out_frame_.samples_per_channel_)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 398 | |
| 399 | // Query the network statistics API once per second |
| 400 | if (sim_clock_ % 1000 == 0) { |
| 401 | // Process NetworkStatistics. |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 402 | NetEqNetworkStatistics current_network_stats; |
| 403 | ASSERT_EQ(0, neteq_->NetworkStatistics(¤t_network_stats)); |
| 404 | ASSERT_NO_FATAL_FAILURE(network_stats.AddResult(current_network_stats)); |
| 405 | |
henrik.lundin | 9c3efd0 | 2015-08-27 13:12:22 -0700 | [diff] [blame] | 406 | // Compare with CurrentDelay, which should be identical. |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 407 | EXPECT_EQ(current_network_stats.current_buffer_size_ms, |
| 408 | neteq_->CurrentDelayMs()); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 409 | |
| 410 | // Process RTCPstat. |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 411 | RtcpStatistics current_rtcp_stats; |
| 412 | neteq_->GetRtcpStatistics(¤t_rtcp_stats); |
| 413 | ASSERT_NO_FATAL_FAILURE(rtcp_stats.AddResult(current_rtcp_stats)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 414 | } |
| 415 | } |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 416 | |
| 417 | SCOPED_TRACE("Check output audio."); |
| 418 | output.VerifyChecksum(output_checksum); |
| 419 | SCOPED_TRACE("Check network stats."); |
| 420 | network_stats.VerifyChecksum(network_stats_checksum); |
| 421 | SCOPED_TRACE("Check rtcp stats."); |
| 422 | rtcp_stats.VerifyChecksum(rtcp_stats_checksum); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | void NetEqDecodingTest::PopulateRtpInfo(int frame_index, |
| 426 | int timestamp, |
| 427 | WebRtcRTPHeader* rtp_info) { |
| 428 | rtp_info->header.sequenceNumber = frame_index; |
| 429 | rtp_info->header.timestamp = timestamp; |
| 430 | rtp_info->header.ssrc = 0x1234; // Just an arbitrary SSRC. |
| 431 | rtp_info->header.payloadType = 94; // PCM16b WB codec. |
| 432 | rtp_info->header.markerBit = 0; |
| 433 | } |
| 434 | |
| 435 | void NetEqDecodingTest::PopulateCng(int frame_index, |
| 436 | int timestamp, |
| 437 | WebRtcRTPHeader* rtp_info, |
| 438 | uint8_t* payload, |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 439 | size_t* payload_len) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 440 | rtp_info->header.sequenceNumber = frame_index; |
| 441 | rtp_info->header.timestamp = timestamp; |
| 442 | rtp_info->header.ssrc = 0x1234; // Just an arbitrary SSRC. |
| 443 | rtp_info->header.payloadType = 98; // WB CNG. |
| 444 | rtp_info->header.markerBit = 0; |
| 445 | payload[0] = 64; // Noise level -64 dBov, quite arbitrarily chosen. |
| 446 | *payload_len = 1; // Only noise level, no spectral parameters. |
| 447 | } |
| 448 | |
kjellander@webrtc.org | c23bf2e | 2016-04-25 06:43:43 +0200 | [diff] [blame] | 449 | // Disabled for UBSan: https://bugs.chromium.org/p/webrtc/issues/detail?id=5820 |
ivoc | 72c08ed | 2016-01-20 07:26:24 -0800 | [diff] [blame] | 450 | #if !defined(WEBRTC_IOS) && defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \ |
| 451 | (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) && \ |
| 452 | defined(WEBRTC_CODEC_ILBC) && defined(WEBRTC_CODEC_G722) && \ |
kjellander@webrtc.org | c23bf2e | 2016-04-25 06:43:43 +0200 | [diff] [blame] | 453 | !defined(WEBRTC_ARCH_ARM64) && !defined(UNDEFINED_SANITIZER) |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 454 | #define MAYBE_TestBitExactness TestBitExactness |
kwiberg | 98ab3a4 | 2015-09-30 21:54:21 -0700 | [diff] [blame] | 455 | #else |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 456 | #define MAYBE_TestBitExactness DISABLED_TestBitExactness |
kwiberg | 98ab3a4 | 2015-09-30 21:54:21 -0700 | [diff] [blame] | 457 | #endif |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 458 | TEST_F(NetEqDecodingTest, MAYBE_TestBitExactness) { |
minyue | 49c454e | 2016-01-08 11:30:14 -0800 | [diff] [blame] | 459 | const std::string input_rtp_file = |
| 460 | webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp"); |
henrik.lundin@webrtc.org | 4e4b098 | 2014-08-11 14:48:49 +0000 | [diff] [blame] | 461 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 462 | const std::string output_checksum = PlatformChecksum( |
| 463 | "f587883b7c371ee8d87dbf1b0f07525af7d959b8", |
| 464 | "a349bd71dba548029b05d1d2a6dc7caafab9a856", |
| 465 | "f587883b7c371ee8d87dbf1b0f07525af7d959b8", |
| 466 | "08266b198e7686b3cd9330813e0d2cd72fc8fdc2"); |
| 467 | |
| 468 | const std::string network_stats_checksum = PlatformChecksum( |
| 469 | "2cf380a05ee07080bd72471e8ec7777a39644ec9", |
| 470 | "2853ab577fe571adfc7b18f77bbe58f1253d2019", |
| 471 | "2cf380a05ee07080bd72471e8ec7777a39644ec9", |
| 472 | "2cf380a05ee07080bd72471e8ec7777a39644ec9"); |
| 473 | |
| 474 | const std::string rtcp_stats_checksum = PlatformChecksum( |
| 475 | "b8880bf9fed2487efbddcb8d94b9937a29ae521d", |
| 476 | "f3f7b3d3e71d7e635240b5373b57df6a7e4ce9d4", |
| 477 | "b8880bf9fed2487efbddcb8d94b9937a29ae521d", |
| 478 | "b8880bf9fed2487efbddcb8d94b9937a29ae521d"); |
| 479 | |
| 480 | DecodeAndCompare(input_rtp_file, |
| 481 | output_checksum, |
| 482 | network_stats_checksum, |
| 483 | rtcp_stats_checksum, |
| 484 | FLAGS_gen_ref); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 485 | } |
| 486 | |
kjellander@webrtc.org | c23bf2e | 2016-04-25 06:43:43 +0200 | [diff] [blame] | 487 | // Disabled for UBSan: https://bugs.chromium.org/p/webrtc/issues/detail?id=5820 |
minyue | 93c08b7 | 2015-12-22 09:57:41 -0800 | [diff] [blame] | 488 | #if !defined(WEBRTC_IOS) && !defined(WEBRTC_ANDROID) && \ |
| 489 | defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \ |
kjellander@webrtc.org | c23bf2e | 2016-04-25 06:43:43 +0200 | [diff] [blame] | 490 | defined(WEBRTC_CODEC_OPUS) && !defined(UNDEFINED_SANITIZER) |
minyue | 93c08b7 | 2015-12-22 09:57:41 -0800 | [diff] [blame] | 491 | #define MAYBE_TestOpusBitExactness TestOpusBitExactness |
| 492 | #else |
| 493 | #define MAYBE_TestOpusBitExactness DISABLED_TestOpusBitExactness |
| 494 | #endif |
| 495 | TEST_F(NetEqDecodingTest, MAYBE_TestOpusBitExactness) { |
| 496 | const std::string input_rtp_file = |
| 497 | webrtc::test::ResourcePath("audio_coding/neteq_opus", "rtp"); |
minyue | 93c08b7 | 2015-12-22 09:57:41 -0800 | [diff] [blame] | 498 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 499 | const std::string output_checksum = PlatformChecksum( |
| 500 | "c23004d91ffbe5e7a1f24620fc89b58c0426040f", |
| 501 | "c23004d91ffbe5e7a1f24620fc89b58c0426040f", |
| 502 | "c23004d91ffbe5e7a1f24620fc89b58c0426040f", |
| 503 | "c23004d91ffbe5e7a1f24620fc89b58c0426040f"); |
| 504 | |
| 505 | const std::string network_stats_checksum = PlatformChecksum( |
| 506 | "dc2d9f584efb0111ebcd71a2c86f1fb09cd8c2bb", |
| 507 | "dc2d9f584efb0111ebcd71a2c86f1fb09cd8c2bb", |
| 508 | "dc2d9f584efb0111ebcd71a2c86f1fb09cd8c2bb", |
| 509 | "dc2d9f584efb0111ebcd71a2c86f1fb09cd8c2bb"); |
| 510 | |
| 511 | const std::string rtcp_stats_checksum = PlatformChecksum( |
| 512 | "e37c797e3de6a64dda88c9ade7a013d022a2e1e0", |
| 513 | "e37c797e3de6a64dda88c9ade7a013d022a2e1e0", |
| 514 | "e37c797e3de6a64dda88c9ade7a013d022a2e1e0", |
| 515 | "e37c797e3de6a64dda88c9ade7a013d022a2e1e0"); |
| 516 | |
| 517 | DecodeAndCompare(input_rtp_file, |
| 518 | output_checksum, |
| 519 | network_stats_checksum, |
| 520 | rtcp_stats_checksum, |
| 521 | FLAGS_gen_ref); |
minyue | 93c08b7 | 2015-12-22 09:57:41 -0800 | [diff] [blame] | 522 | } |
| 523 | |
henrik.lundin@webrtc.org | 7cbc4f9 | 2014-10-07 06:37:39 +0000 | [diff] [blame] | 524 | // Use fax mode to avoid time-scaling. This is to simplify the testing of |
| 525 | // packet waiting times in the packet buffer. |
| 526 | class NetEqDecodingTestFaxMode : public NetEqDecodingTest { |
| 527 | protected: |
| 528 | NetEqDecodingTestFaxMode() : NetEqDecodingTest() { |
| 529 | config_.playout_mode = kPlayoutFax; |
| 530 | } |
| 531 | }; |
| 532 | |
| 533 | TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 534 | // Insert 30 dummy packets at once. Each packet contains 10 ms 16 kHz audio. |
| 535 | size_t num_frames = 30; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 536 | const size_t kSamples = 10 * 16; |
| 537 | const size_t kPayloadBytes = kSamples * 2; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 538 | for (size_t i = 0; i < num_frames; ++i) { |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 539 | const uint8_t payload[kPayloadBytes] = {0}; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 540 | WebRtcRTPHeader rtp_info; |
| 541 | rtp_info.header.sequenceNumber = i; |
| 542 | rtp_info.header.timestamp = i * kSamples; |
| 543 | rtp_info.header.ssrc = 0x1234; // Just an arbitrary SSRC. |
| 544 | rtp_info.header.payloadType = 94; // PCM16b WB codec. |
| 545 | rtp_info.header.markerBit = 0; |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 546 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 547 | } |
| 548 | // Pull out all data. |
| 549 | for (size_t i = 0; i < num_frames; ++i) { |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 550 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 551 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 552 | } |
| 553 | |
Henrik Lundin | 1bb8cf8 | 2015-08-25 13:08:04 +0200 | [diff] [blame] | 554 | NetEqNetworkStatistics stats; |
| 555 | EXPECT_EQ(0, neteq_->NetworkStatistics(&stats)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 556 | // Since all frames are dumped into NetEQ at once, but pulled out with 10 ms |
| 557 | // spacing (per definition), we expect the delay to increase with 10 ms for |
Henrik Lundin | 1bb8cf8 | 2015-08-25 13:08:04 +0200 | [diff] [blame] | 558 | // each packet. Thus, we are calculating the statistics for a series from 10 |
| 559 | // to 300, in steps of 10 ms. |
| 560 | EXPECT_EQ(155, stats.mean_waiting_time_ms); |
| 561 | EXPECT_EQ(155, stats.median_waiting_time_ms); |
| 562 | EXPECT_EQ(10, stats.min_waiting_time_ms); |
| 563 | EXPECT_EQ(300, stats.max_waiting_time_ms); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 564 | |
| 565 | // Check statistics again and make sure it's been reset. |
Henrik Lundin | 1bb8cf8 | 2015-08-25 13:08:04 +0200 | [diff] [blame] | 566 | EXPECT_EQ(0, neteq_->NetworkStatistics(&stats)); |
| 567 | EXPECT_EQ(-1, stats.mean_waiting_time_ms); |
| 568 | EXPECT_EQ(-1, stats.median_waiting_time_ms); |
| 569 | EXPECT_EQ(-1, stats.min_waiting_time_ms); |
| 570 | EXPECT_EQ(-1, stats.max_waiting_time_ms); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 571 | } |
| 572 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 573 | TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimeNegative) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 574 | const int kNumFrames = 3000; // Needed for convergence. |
| 575 | int frame_index = 0; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 576 | const size_t kSamples = 10 * 16; |
| 577 | const size_t kPayloadBytes = kSamples * 2; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 578 | while (frame_index < kNumFrames) { |
| 579 | // Insert one packet each time, except every 10th time where we insert two |
| 580 | // packets at once. This will create a negative clock-drift of approx. 10%. |
| 581 | int num_packets = (frame_index % 10 == 0 ? 2 : 1); |
| 582 | for (int n = 0; n < num_packets; ++n) { |
| 583 | uint8_t payload[kPayloadBytes] = {0}; |
| 584 | WebRtcRTPHeader rtp_info; |
| 585 | PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info); |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 586 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 587 | ++frame_index; |
| 588 | } |
| 589 | |
| 590 | // Pull out data once. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 591 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 592 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | NetEqNetworkStatistics network_stats; |
| 596 | ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats)); |
| 597 | EXPECT_EQ(-103196, network_stats.clockdrift_ppm); |
| 598 | } |
| 599 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 600 | TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimePositive) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 601 | const int kNumFrames = 5000; // Needed for convergence. |
| 602 | int frame_index = 0; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 603 | const size_t kSamples = 10 * 16; |
| 604 | const size_t kPayloadBytes = kSamples * 2; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 605 | for (int i = 0; i < kNumFrames; ++i) { |
| 606 | // Insert one packet each time, except every 10th time where we don't insert |
| 607 | // any packet. This will create a positive clock-drift of approx. 11%. |
| 608 | int num_packets = (i % 10 == 9 ? 0 : 1); |
| 609 | for (int n = 0; n < num_packets; ++n) { |
| 610 | uint8_t payload[kPayloadBytes] = {0}; |
| 611 | WebRtcRTPHeader rtp_info; |
| 612 | PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info); |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 613 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 614 | ++frame_index; |
| 615 | } |
| 616 | |
| 617 | // Pull out data once. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 618 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 619 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 620 | } |
| 621 | |
| 622 | NetEqNetworkStatistics network_stats; |
| 623 | ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats)); |
| 624 | EXPECT_EQ(110946, network_stats.clockdrift_ppm); |
| 625 | } |
| 626 | |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 627 | void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor, |
| 628 | double network_freeze_ms, |
| 629 | bool pull_audio_during_freeze, |
| 630 | int delay_tolerance_ms, |
| 631 | int max_time_to_speech_ms) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 632 | uint16_t seq_no = 0; |
| 633 | uint32_t timestamp = 0; |
| 634 | const int kFrameSizeMs = 30; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 635 | const size_t kSamples = kFrameSizeMs * 16; |
| 636 | const size_t kPayloadBytes = kSamples * 2; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 637 | double next_input_time_ms = 0.0; |
| 638 | double t_ms; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 639 | |
| 640 | // Insert speech for 5 seconds. |
| 641 | const int kSpeechDurationMs = 5000; |
| 642 | for (t_ms = 0; t_ms < kSpeechDurationMs; t_ms += 10) { |
| 643 | // Each turn in this for loop is 10 ms. |
| 644 | while (next_input_time_ms <= t_ms) { |
| 645 | // Insert one 30 ms speech frame. |
| 646 | uint8_t payload[kPayloadBytes] = {0}; |
| 647 | WebRtcRTPHeader rtp_info; |
| 648 | PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 649 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 650 | ++seq_no; |
| 651 | timestamp += kSamples; |
henrik.lundin@webrtc.org | fcfc6a9 | 2014-02-13 11:42:28 +0000 | [diff] [blame] | 652 | next_input_time_ms += static_cast<double>(kFrameSizeMs) * drift_factor; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 653 | } |
| 654 | // Pull out data once. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 655 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 656 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 657 | } |
| 658 | |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 659 | EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); |
henrik.lundin | 0d96ab7 | 2016-04-06 12:28:26 -0700 | [diff] [blame] | 660 | rtc::Optional<uint32_t> playout_timestamp = PlayoutTimestamp(); |
| 661 | ASSERT_TRUE(playout_timestamp); |
| 662 | int32_t delay_before = timestamp - *playout_timestamp; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 663 | |
| 664 | // Insert CNG for 1 minute (= 60000 ms). |
| 665 | const int kCngPeriodMs = 100; |
| 666 | const int kCngPeriodSamples = kCngPeriodMs * 16; // Period in 16 kHz samples. |
| 667 | const int kCngDurationMs = 60000; |
| 668 | for (; t_ms < kSpeechDurationMs + kCngDurationMs; t_ms += 10) { |
| 669 | // Each turn in this for loop is 10 ms. |
| 670 | while (next_input_time_ms <= t_ms) { |
| 671 | // Insert one CNG frame each 100 ms. |
| 672 | uint8_t payload[kPayloadBytes]; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 673 | size_t payload_len; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 674 | WebRtcRTPHeader rtp_info; |
| 675 | PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 676 | ASSERT_EQ(0, neteq_->InsertPacket( |
| 677 | rtp_info, |
| 678 | rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 679 | ++seq_no; |
| 680 | timestamp += kCngPeriodSamples; |
henrik.lundin@webrtc.org | fcfc6a9 | 2014-02-13 11:42:28 +0000 | [diff] [blame] | 681 | next_input_time_ms += static_cast<double>(kCngPeriodMs) * drift_factor; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 682 | } |
| 683 | // Pull out data once. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 684 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 685 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 686 | } |
| 687 | |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 688 | EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 689 | |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 690 | if (network_freeze_ms > 0) { |
| 691 | // First keep pulling audio for |network_freeze_ms| without inserting |
| 692 | // any data, then insert CNG data corresponding to |network_freeze_ms| |
| 693 | // without pulling any output audio. |
| 694 | const double loop_end_time = t_ms + network_freeze_ms; |
| 695 | for (; t_ms < loop_end_time; t_ms += 10) { |
| 696 | // Pull out data once. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 697 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 698 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 699 | EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 700 | } |
| 701 | bool pull_once = pull_audio_during_freeze; |
| 702 | // If |pull_once| is true, GetAudio will be called once half-way through |
| 703 | // the network recovery period. |
| 704 | double pull_time_ms = (t_ms + next_input_time_ms) / 2; |
| 705 | while (next_input_time_ms <= t_ms) { |
| 706 | if (pull_once && next_input_time_ms >= pull_time_ms) { |
| 707 | pull_once = false; |
| 708 | // Pull out data once. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 709 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 710 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 711 | EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 712 | t_ms += 10; |
| 713 | } |
| 714 | // Insert one CNG frame each 100 ms. |
| 715 | uint8_t payload[kPayloadBytes]; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 716 | size_t payload_len; |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 717 | WebRtcRTPHeader rtp_info; |
| 718 | PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 719 | ASSERT_EQ(0, neteq_->InsertPacket( |
| 720 | rtp_info, |
| 721 | rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 722 | ++seq_no; |
| 723 | timestamp += kCngPeriodSamples; |
| 724 | next_input_time_ms += kCngPeriodMs * drift_factor; |
| 725 | } |
| 726 | } |
| 727 | |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 728 | // Insert speech again until output type is speech. |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 729 | double speech_restart_time_ms = t_ms; |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 730 | while (out_frame_.speech_type_ != AudioFrame::kNormalSpeech) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 731 | // Each turn in this for loop is 10 ms. |
| 732 | while (next_input_time_ms <= t_ms) { |
| 733 | // Insert one 30 ms speech frame. |
| 734 | uint8_t payload[kPayloadBytes] = {0}; |
| 735 | WebRtcRTPHeader rtp_info; |
| 736 | PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 737 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 738 | ++seq_no; |
| 739 | timestamp += kSamples; |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 740 | next_input_time_ms += kFrameSizeMs * drift_factor; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 741 | } |
| 742 | // Pull out data once. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 743 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 744 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 745 | // Increase clock. |
| 746 | t_ms += 10; |
| 747 | } |
| 748 | |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 749 | // Check that the speech starts again within reasonable time. |
| 750 | double time_until_speech_returns_ms = t_ms - speech_restart_time_ms; |
| 751 | EXPECT_LT(time_until_speech_returns_ms, max_time_to_speech_ms); |
henrik.lundin | 0d96ab7 | 2016-04-06 12:28:26 -0700 | [diff] [blame] | 752 | playout_timestamp = PlayoutTimestamp(); |
| 753 | ASSERT_TRUE(playout_timestamp); |
| 754 | int32_t delay_after = timestamp - *playout_timestamp; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 755 | // Compare delay before and after, and make sure it differs less than 20 ms. |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 756 | EXPECT_LE(delay_after, delay_before + delay_tolerance_ms * 16); |
| 757 | EXPECT_GE(delay_after, delay_before - delay_tolerance_ms * 16); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 758 | } |
| 759 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 760 | TEST_F(NetEqDecodingTest, LongCngWithNegativeClockDrift) { |
henrik.lundin@webrtc.org | fcfc6a9 | 2014-02-13 11:42:28 +0000 | [diff] [blame] | 761 | // Apply a clock drift of -25 ms / s (sender faster than receiver). |
| 762 | const double kDriftFactor = 1000.0 / (1000.0 + 25.0); |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 763 | const double kNetworkFreezeTimeMs = 0.0; |
| 764 | const bool kGetAudioDuringFreezeRecovery = false; |
| 765 | const int kDelayToleranceMs = 20; |
| 766 | const int kMaxTimeToSpeechMs = 100; |
| 767 | LongCngWithClockDrift(kDriftFactor, |
| 768 | kNetworkFreezeTimeMs, |
| 769 | kGetAudioDuringFreezeRecovery, |
| 770 | kDelayToleranceMs, |
| 771 | kMaxTimeToSpeechMs); |
henrik.lundin@webrtc.org | fcfc6a9 | 2014-02-13 11:42:28 +0000 | [diff] [blame] | 772 | } |
| 773 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 774 | TEST_F(NetEqDecodingTest, LongCngWithPositiveClockDrift) { |
henrik.lundin@webrtc.org | fcfc6a9 | 2014-02-13 11:42:28 +0000 | [diff] [blame] | 775 | // Apply a clock drift of +25 ms / s (sender slower than receiver). |
| 776 | const double kDriftFactor = 1000.0 / (1000.0 - 25.0); |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 777 | const double kNetworkFreezeTimeMs = 0.0; |
| 778 | const bool kGetAudioDuringFreezeRecovery = false; |
| 779 | const int kDelayToleranceMs = 20; |
| 780 | const int kMaxTimeToSpeechMs = 100; |
| 781 | LongCngWithClockDrift(kDriftFactor, |
| 782 | kNetworkFreezeTimeMs, |
| 783 | kGetAudioDuringFreezeRecovery, |
| 784 | kDelayToleranceMs, |
| 785 | kMaxTimeToSpeechMs); |
| 786 | } |
| 787 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 788 | TEST_F(NetEqDecodingTest, LongCngWithNegativeClockDriftNetworkFreeze) { |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 789 | // Apply a clock drift of -25 ms / s (sender faster than receiver). |
| 790 | const double kDriftFactor = 1000.0 / (1000.0 + 25.0); |
| 791 | const double kNetworkFreezeTimeMs = 5000.0; |
| 792 | const bool kGetAudioDuringFreezeRecovery = false; |
| 793 | const int kDelayToleranceMs = 50; |
| 794 | const int kMaxTimeToSpeechMs = 200; |
| 795 | LongCngWithClockDrift(kDriftFactor, |
| 796 | kNetworkFreezeTimeMs, |
| 797 | kGetAudioDuringFreezeRecovery, |
| 798 | kDelayToleranceMs, |
| 799 | kMaxTimeToSpeechMs); |
| 800 | } |
| 801 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 802 | TEST_F(NetEqDecodingTest, LongCngWithPositiveClockDriftNetworkFreeze) { |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 803 | // Apply a clock drift of +25 ms / s (sender slower than receiver). |
| 804 | const double kDriftFactor = 1000.0 / (1000.0 - 25.0); |
| 805 | const double kNetworkFreezeTimeMs = 5000.0; |
| 806 | const bool kGetAudioDuringFreezeRecovery = false; |
| 807 | const int kDelayToleranceMs = 20; |
| 808 | const int kMaxTimeToSpeechMs = 100; |
| 809 | LongCngWithClockDrift(kDriftFactor, |
| 810 | kNetworkFreezeTimeMs, |
| 811 | kGetAudioDuringFreezeRecovery, |
| 812 | kDelayToleranceMs, |
| 813 | kMaxTimeToSpeechMs); |
| 814 | } |
| 815 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 816 | TEST_F(NetEqDecodingTest, LongCngWithPositiveClockDriftNetworkFreezeExtraPull) { |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 817 | // Apply a clock drift of +25 ms / s (sender slower than receiver). |
| 818 | const double kDriftFactor = 1000.0 / (1000.0 - 25.0); |
| 819 | const double kNetworkFreezeTimeMs = 5000.0; |
| 820 | const bool kGetAudioDuringFreezeRecovery = true; |
| 821 | const int kDelayToleranceMs = 20; |
| 822 | const int kMaxTimeToSpeechMs = 100; |
| 823 | LongCngWithClockDrift(kDriftFactor, |
| 824 | kNetworkFreezeTimeMs, |
| 825 | kGetAudioDuringFreezeRecovery, |
| 826 | kDelayToleranceMs, |
| 827 | kMaxTimeToSpeechMs); |
| 828 | } |
| 829 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 830 | TEST_F(NetEqDecodingTest, LongCngWithoutClockDrift) { |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 831 | const double kDriftFactor = 1.0; // No drift. |
| 832 | const double kNetworkFreezeTimeMs = 0.0; |
| 833 | const bool kGetAudioDuringFreezeRecovery = false; |
| 834 | const int kDelayToleranceMs = 10; |
| 835 | const int kMaxTimeToSpeechMs = 50; |
| 836 | LongCngWithClockDrift(kDriftFactor, |
| 837 | kNetworkFreezeTimeMs, |
| 838 | kGetAudioDuringFreezeRecovery, |
| 839 | kDelayToleranceMs, |
| 840 | kMaxTimeToSpeechMs); |
henrik.lundin@webrtc.org | fcfc6a9 | 2014-02-13 11:42:28 +0000 | [diff] [blame] | 841 | } |
| 842 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 843 | TEST_F(NetEqDecodingTest, UnknownPayloadType) { |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 844 | const size_t kPayloadBytes = 100; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 845 | uint8_t payload[kPayloadBytes] = {0}; |
| 846 | WebRtcRTPHeader rtp_info; |
| 847 | PopulateRtpInfo(0, 0, &rtp_info); |
| 848 | rtp_info.header.payloadType = 1; // Not registered as a decoder. |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 849 | EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 850 | EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); |
| 851 | } |
| 852 | |
Peter Boström | e2976c8 | 2016-01-04 22:44:05 +0100 | [diff] [blame] | 853 | #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) |
ivoc | 72c08ed | 2016-01-20 07:26:24 -0800 | [diff] [blame] | 854 | #define MAYBE_DecoderError DecoderError |
| 855 | #else |
| 856 | #define MAYBE_DecoderError DISABLED_DecoderError |
| 857 | #endif |
| 858 | |
Peter Boström | e2976c8 | 2016-01-04 22:44:05 +0100 | [diff] [blame] | 859 | TEST_F(NetEqDecodingTest, MAYBE_DecoderError) { |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 860 | const size_t kPayloadBytes = 100; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 861 | uint8_t payload[kPayloadBytes] = {0}; |
| 862 | WebRtcRTPHeader rtp_info; |
| 863 | PopulateRtpInfo(0, 0, &rtp_info); |
| 864 | rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid. |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 865 | EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 866 | // Set all of |out_data_| to 1, and verify that it was set to 0 by the call |
| 867 | // to GetAudio. |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 868 | for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; ++i) { |
| 869 | out_frame_.data_[i] = 1; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 870 | } |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 871 | EXPECT_EQ(NetEq::kFail, neteq_->GetAudio(&out_frame_)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 872 | // Verify that there is a decoder error to check. |
| 873 | EXPECT_EQ(NetEq::kDecoderErrorCode, neteq_->LastError()); |
ivoc | 72c08ed | 2016-01-20 07:26:24 -0800 | [diff] [blame] | 874 | |
| 875 | enum NetEqDecoderError { |
| 876 | ISAC_LENGTH_MISMATCH = 6730, |
| 877 | ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH = 6640 |
| 878 | }; |
| 879 | #if defined(WEBRTC_CODEC_ISAC) |
| 880 | EXPECT_EQ(ISAC_LENGTH_MISMATCH, neteq_->LastDecoderError()); |
| 881 | #elif defined(WEBRTC_CODEC_ISACFX) |
| 882 | EXPECT_EQ(ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH, neteq_->LastDecoderError()); |
| 883 | #endif |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 884 | // Verify that the first 160 samples are set to 0, and that the remaining |
| 885 | // samples are left unmodified. |
| 886 | static const int kExpectedOutputLength = 160; // 10 ms at 16 kHz sample rate. |
| 887 | for (int i = 0; i < kExpectedOutputLength; ++i) { |
| 888 | std::ostringstream ss; |
| 889 | ss << "i = " << i; |
| 890 | SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 891 | EXPECT_EQ(0, out_frame_.data_[i]); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 892 | } |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 893 | for (size_t i = kExpectedOutputLength; i < AudioFrame::kMaxDataSizeSamples; |
| 894 | ++i) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 895 | std::ostringstream ss; |
| 896 | ss << "i = " << i; |
| 897 | SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 898 | EXPECT_EQ(1, out_frame_.data_[i]); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 899 | } |
| 900 | } |
| 901 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 902 | TEST_F(NetEqDecodingTest, GetAudioBeforeInsertPacket) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 903 | // Set all of |out_data_| to 1, and verify that it was set to 0 by the call |
| 904 | // to GetAudio. |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 905 | for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; ++i) { |
| 906 | out_frame_.data_[i] = 1; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 907 | } |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 908 | EXPECT_EQ(0, neteq_->GetAudio(&out_frame_)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 909 | // Verify that the first block of samples is set to 0. |
| 910 | static const int kExpectedOutputLength = |
| 911 | kInitSampleRateHz / 100; // 10 ms at initial sample rate. |
| 912 | for (int i = 0; i < kExpectedOutputLength; ++i) { |
| 913 | std::ostringstream ss; |
| 914 | ss << "i = " << i; |
| 915 | SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 916 | EXPECT_EQ(0, out_frame_.data_[i]); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 917 | } |
henrik.lundin | d89814b | 2015-11-23 06:49:25 -0800 | [diff] [blame] | 918 | // Verify that the sample rate did not change from the initial configuration. |
| 919 | EXPECT_EQ(config_.sample_rate_hz, neteq_->last_output_sample_rate_hz()); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 920 | } |
turaj@webrtc.org | ff43c85 | 2013-09-25 00:07:27 +0000 | [diff] [blame] | 921 | |
henrik.lundin@webrtc.org | 9b8102c | 2014-08-21 08:27:44 +0000 | [diff] [blame] | 922 | class NetEqBgnTest : public NetEqDecodingTest { |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 923 | protected: |
henrik.lundin@webrtc.org | 9b8102c | 2014-08-21 08:27:44 +0000 | [diff] [blame] | 924 | virtual void TestCondition(double sum_squared_noise, |
| 925 | bool should_be_faded) = 0; |
turaj@webrtc.org | ff43c85 | 2013-09-25 00:07:27 +0000 | [diff] [blame] | 926 | |
henrik.lundin@webrtc.org | 9b8102c | 2014-08-21 08:27:44 +0000 | [diff] [blame] | 927 | void CheckBgn(int sampling_rate_hz) { |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 928 | size_t expected_samples_per_channel = 0; |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 929 | uint8_t payload_type = 0xFF; // Invalid. |
| 930 | if (sampling_rate_hz == 8000) { |
| 931 | expected_samples_per_channel = kBlockSize8kHz; |
| 932 | payload_type = 93; // PCM 16, 8 kHz. |
| 933 | } else if (sampling_rate_hz == 16000) { |
| 934 | expected_samples_per_channel = kBlockSize16kHz; |
| 935 | payload_type = 94; // PCM 16, 16 kHZ. |
| 936 | } else if (sampling_rate_hz == 32000) { |
| 937 | expected_samples_per_channel = kBlockSize32kHz; |
| 938 | payload_type = 95; // PCM 16, 32 kHz. |
| 939 | } else { |
| 940 | ASSERT_TRUE(false); // Unsupported test case. |
| 941 | } |
turaj@webrtc.org | ff43c85 | 2013-09-25 00:07:27 +0000 | [diff] [blame] | 942 | |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 943 | AudioFrame output; |
henrik.lundin@webrtc.org | 9b8102c | 2014-08-21 08:27:44 +0000 | [diff] [blame] | 944 | test::AudioLoop input; |
| 945 | // We are using the same 32 kHz input file for all tests, regardless of |
| 946 | // |sampling_rate_hz|. The output may sound weird, but the test is still |
| 947 | // valid. |
| 948 | ASSERT_TRUE(input.Init( |
| 949 | webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), |
| 950 | 10 * sampling_rate_hz, // Max 10 seconds loop length. |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 951 | expected_samples_per_channel)); |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 952 | |
| 953 | // Payload of 10 ms of PCM16 32 kHz. |
| 954 | uint8_t payload[kBlockSize32kHz * sizeof(int16_t)]; |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 955 | WebRtcRTPHeader rtp_info; |
| 956 | PopulateRtpInfo(0, 0, &rtp_info); |
| 957 | rtp_info.header.payloadType = payload_type; |
| 958 | |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 959 | uint32_t receive_timestamp = 0; |
| 960 | for (int n = 0; n < 10; ++n) { // Insert few packets and get audio. |
kwiberg | 288886b | 2015-11-06 01:21:35 -0800 | [diff] [blame] | 961 | auto block = input.GetNextBlock(); |
| 962 | ASSERT_EQ(expected_samples_per_channel, block.size()); |
| 963 | size_t enc_len_bytes = |
| 964 | WebRtcPcm16b_Encode(block.data(), block.size(), payload); |
henrik.lundin@webrtc.org | 9b8102c | 2014-08-21 08:27:44 +0000 | [diff] [blame] | 965 | ASSERT_EQ(enc_len_bytes, expected_samples_per_channel * 2); |
| 966 | |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 967 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, rtc::ArrayView<const uint8_t>( |
| 968 | payload, enc_len_bytes), |
| 969 | receive_timestamp)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 970 | output.Reset(); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 971 | ASSERT_EQ(0, neteq_->GetAudio(&output)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 972 | ASSERT_EQ(1u, output.num_channels_); |
| 973 | ASSERT_EQ(expected_samples_per_channel, output.samples_per_channel_); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 974 | ASSERT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 975 | |
| 976 | // Next packet. |
| 977 | rtp_info.header.timestamp += expected_samples_per_channel; |
| 978 | rtp_info.header.sequenceNumber++; |
| 979 | receive_timestamp += expected_samples_per_channel; |
| 980 | } |
| 981 | |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 982 | output.Reset(); |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 983 | |
| 984 | // Get audio without inserting packets, expecting PLC and PLC-to-CNG. Pull |
| 985 | // one frame without checking speech-type. This is the first frame pulled |
| 986 | // without inserting any packet, and might not be labeled as PLC. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 987 | ASSERT_EQ(0, neteq_->GetAudio(&output)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 988 | ASSERT_EQ(1u, output.num_channels_); |
| 989 | ASSERT_EQ(expected_samples_per_channel, output.samples_per_channel_); |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 990 | |
| 991 | // To be able to test the fading of background noise we need at lease to |
| 992 | // pull 611 frames. |
| 993 | const int kFadingThreshold = 611; |
| 994 | |
| 995 | // Test several CNG-to-PLC packet for the expected behavior. The number 20 |
| 996 | // is arbitrary, but sufficiently large to test enough number of frames. |
| 997 | const int kNumPlcToCngTestFrames = 20; |
| 998 | bool plc_to_cng = false; |
| 999 | for (int n = 0; n < kFadingThreshold + kNumPlcToCngTestFrames; ++n) { |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1000 | output.Reset(); |
| 1001 | memset(output.data_, 1, sizeof(output.data_)); // Set to non-zero. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1002 | ASSERT_EQ(0, neteq_->GetAudio(&output)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1003 | ASSERT_EQ(1u, output.num_channels_); |
| 1004 | ASSERT_EQ(expected_samples_per_channel, output.samples_per_channel_); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1005 | if (output.speech_type_ == AudioFrame::kPLCCNG) { |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 1006 | plc_to_cng = true; |
| 1007 | double sum_squared = 0; |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1008 | for (size_t k = 0; |
| 1009 | k < output.num_channels_ * output.samples_per_channel_; ++k) |
| 1010 | sum_squared += output.data_[k] * output.data_[k]; |
henrik.lundin@webrtc.org | 9b8102c | 2014-08-21 08:27:44 +0000 | [diff] [blame] | 1011 | TestCondition(sum_squared, n > kFadingThreshold); |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 1012 | } else { |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1013 | EXPECT_EQ(AudioFrame::kPLC, output.speech_type_); |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 1014 | } |
| 1015 | } |
| 1016 | EXPECT_TRUE(plc_to_cng); // Just to be sure that PLC-to-CNG has occurred. |
| 1017 | } |
| 1018 | }; |
| 1019 | |
henrik.lundin@webrtc.org | 9b8102c | 2014-08-21 08:27:44 +0000 | [diff] [blame] | 1020 | class NetEqBgnTestOn : public NetEqBgnTest { |
| 1021 | protected: |
| 1022 | NetEqBgnTestOn() : NetEqBgnTest() { |
| 1023 | config_.background_noise_mode = NetEq::kBgnOn; |
| 1024 | } |
| 1025 | |
| 1026 | void TestCondition(double sum_squared_noise, bool /*should_be_faded*/) { |
| 1027 | EXPECT_NE(0, sum_squared_noise); |
| 1028 | } |
| 1029 | }; |
| 1030 | |
| 1031 | class NetEqBgnTestOff : public NetEqBgnTest { |
| 1032 | protected: |
| 1033 | NetEqBgnTestOff() : NetEqBgnTest() { |
| 1034 | config_.background_noise_mode = NetEq::kBgnOff; |
| 1035 | } |
| 1036 | |
| 1037 | void TestCondition(double sum_squared_noise, bool /*should_be_faded*/) { |
| 1038 | EXPECT_EQ(0, sum_squared_noise); |
| 1039 | } |
| 1040 | }; |
| 1041 | |
| 1042 | class NetEqBgnTestFade : public NetEqBgnTest { |
| 1043 | protected: |
| 1044 | NetEqBgnTestFade() : NetEqBgnTest() { |
| 1045 | config_.background_noise_mode = NetEq::kBgnFade; |
| 1046 | } |
| 1047 | |
| 1048 | void TestCondition(double sum_squared_noise, bool should_be_faded) { |
| 1049 | if (should_be_faded) |
| 1050 | EXPECT_EQ(0, sum_squared_noise); |
| 1051 | } |
| 1052 | }; |
| 1053 | |
henrika | 1d34fe9 | 2015-06-16 10:04:20 +0200 | [diff] [blame] | 1054 | TEST_F(NetEqBgnTestOn, RunTest) { |
henrik.lundin@webrtc.org | 9b8102c | 2014-08-21 08:27:44 +0000 | [diff] [blame] | 1055 | CheckBgn(8000); |
| 1056 | CheckBgn(16000); |
| 1057 | CheckBgn(32000); |
turaj@webrtc.org | ff43c85 | 2013-09-25 00:07:27 +0000 | [diff] [blame] | 1058 | } |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1059 | |
henrika | 1d34fe9 | 2015-06-16 10:04:20 +0200 | [diff] [blame] | 1060 | TEST_F(NetEqBgnTestOff, RunTest) { |
henrik.lundin@webrtc.org | 9b8102c | 2014-08-21 08:27:44 +0000 | [diff] [blame] | 1061 | CheckBgn(8000); |
| 1062 | CheckBgn(16000); |
| 1063 | CheckBgn(32000); |
| 1064 | } |
| 1065 | |
henrika | 1d34fe9 | 2015-06-16 10:04:20 +0200 | [diff] [blame] | 1066 | TEST_F(NetEqBgnTestFade, RunTest) { |
henrik.lundin@webrtc.org | 9b8102c | 2014-08-21 08:27:44 +0000 | [diff] [blame] | 1067 | CheckBgn(8000); |
| 1068 | CheckBgn(16000); |
| 1069 | CheckBgn(32000); |
| 1070 | } |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 1071 | |
Peter Boström | e2976c8 | 2016-01-04 22:44:05 +0100 | [diff] [blame] | 1072 | #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) |
ivoc | 72c08ed | 2016-01-20 07:26:24 -0800 | [diff] [blame] | 1073 | #define MAYBE_SyncPacketInsert SyncPacketInsert |
| 1074 | #else |
| 1075 | #define MAYBE_SyncPacketInsert DISABLED_SyncPacketInsert |
| 1076 | #endif |
| 1077 | TEST_F(NetEqDecodingTest, MAYBE_SyncPacketInsert) { |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1078 | WebRtcRTPHeader rtp_info; |
| 1079 | uint32_t receive_timestamp = 0; |
| 1080 | // For the readability use the following payloads instead of the defaults of |
| 1081 | // this test. |
| 1082 | uint8_t kPcm16WbPayloadType = 1; |
| 1083 | uint8_t kCngNbPayloadType = 2; |
| 1084 | uint8_t kCngWbPayloadType = 3; |
| 1085 | uint8_t kCngSwb32PayloadType = 4; |
| 1086 | uint8_t kCngSwb48PayloadType = 5; |
| 1087 | uint8_t kAvtPayloadType = 6; |
| 1088 | uint8_t kRedPayloadType = 7; |
| 1089 | uint8_t kIsacPayloadType = 9; // Payload type 8 is already registered. |
| 1090 | |
| 1091 | // Register decoders. |
kwiberg | ee1879c | 2015-10-29 06:20:28 -0700 | [diff] [blame] | 1092 | ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16Bwb, |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 1093 | "pcm16-wb", kPcm16WbPayloadType)); |
kwiberg | ee1879c | 2015-10-29 06:20:28 -0700 | [diff] [blame] | 1094 | ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGnb, |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 1095 | "cng-nb", kCngNbPayloadType)); |
kwiberg | ee1879c | 2015-10-29 06:20:28 -0700 | [diff] [blame] | 1096 | ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGwb, |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 1097 | "cng-wb", kCngWbPayloadType)); |
kwiberg | ee1879c | 2015-10-29 06:20:28 -0700 | [diff] [blame] | 1098 | ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGswb32kHz, |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 1099 | "cng-swb32", kCngSwb32PayloadType)); |
kwiberg | ee1879c | 2015-10-29 06:20:28 -0700 | [diff] [blame] | 1100 | ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderCNGswb48kHz, |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 1101 | "cng-swb48", kCngSwb48PayloadType)); |
| 1102 | ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderAVT, "avt", |
kwiberg | ee1879c | 2015-10-29 06:20:28 -0700 | [diff] [blame] | 1103 | kAvtPayloadType)); |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 1104 | ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderRED, "red", |
kwiberg | ee1879c | 2015-10-29 06:20:28 -0700 | [diff] [blame] | 1105 | kRedPayloadType)); |
henrik.lundin | 4cf61dd | 2015-12-09 06:20:58 -0800 | [diff] [blame] | 1106 | ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderISAC, "isac", |
kwiberg | ee1879c | 2015-10-29 06:20:28 -0700 | [diff] [blame] | 1107 | kIsacPayloadType)); |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1108 | |
| 1109 | PopulateRtpInfo(0, 0, &rtp_info); |
| 1110 | rtp_info.header.payloadType = kPcm16WbPayloadType; |
| 1111 | |
| 1112 | // The first packet injected cannot be sync-packet. |
| 1113 | EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
| 1114 | |
| 1115 | // Payload length of 10 ms PCM16 16 kHz. |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 1116 | const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t); |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1117 | uint8_t payload[kPayloadBytes] = {0}; |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 1118 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp)); |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1119 | |
| 1120 | // Next packet. Last packet contained 10 ms audio. |
| 1121 | rtp_info.header.sequenceNumber++; |
| 1122 | rtp_info.header.timestamp += kBlockSize16kHz; |
| 1123 | receive_timestamp += kBlockSize16kHz; |
| 1124 | |
| 1125 | // Unacceptable payload types CNG, AVT (DTMF), RED. |
| 1126 | rtp_info.header.payloadType = kCngNbPayloadType; |
| 1127 | EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
| 1128 | |
| 1129 | rtp_info.header.payloadType = kCngWbPayloadType; |
| 1130 | EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
| 1131 | |
| 1132 | rtp_info.header.payloadType = kCngSwb32PayloadType; |
| 1133 | EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
| 1134 | |
| 1135 | rtp_info.header.payloadType = kCngSwb48PayloadType; |
| 1136 | EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
| 1137 | |
| 1138 | rtp_info.header.payloadType = kAvtPayloadType; |
| 1139 | EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
| 1140 | |
| 1141 | rtp_info.header.payloadType = kRedPayloadType; |
| 1142 | EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
| 1143 | |
| 1144 | // Change of codec cannot be initiated with a sync packet. |
| 1145 | rtp_info.header.payloadType = kIsacPayloadType; |
| 1146 | EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
| 1147 | |
| 1148 | // Change of SSRC is not allowed with a sync packet. |
| 1149 | rtp_info.header.payloadType = kPcm16WbPayloadType; |
| 1150 | ++rtp_info.header.ssrc; |
| 1151 | EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
| 1152 | |
| 1153 | --rtp_info.header.ssrc; |
| 1154 | EXPECT_EQ(0, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
| 1155 | } |
| 1156 | |
| 1157 | // First insert several noise like packets, then sync-packets. Decoding all |
| 1158 | // packets should not produce error, statistics should not show any packet loss |
| 1159 | // and sync-packets should decode to zero. |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1160 | // TODO(turajs) we will have a better test if we have a referece NetEq, and |
| 1161 | // when Sync packets are inserted in "test" NetEq we insert all-zero payload |
| 1162 | // in reference NetEq and compare the output of those two. |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 1163 | TEST_F(NetEqDecodingTest, SyncPacketDecode) { |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1164 | WebRtcRTPHeader rtp_info; |
| 1165 | PopulateRtpInfo(0, 0, &rtp_info); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 1166 | const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t); |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1167 | uint8_t payload[kPayloadBytes]; |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1168 | AudioFrame output; |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1169 | int algorithmic_frame_delay = algorithmic_delay_ms_ / 10 + 1; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 1170 | for (size_t n = 0; n < kPayloadBytes; ++n) { |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1171 | payload[n] = (rand() & 0xF0) + 1; // Non-zero random sequence. |
| 1172 | } |
| 1173 | // Insert some packets which decode to noise. We are not interested in |
| 1174 | // actual decoded values. |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1175 | uint32_t receive_timestamp = 0; |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1176 | for (int n = 0; n < 100; ++n) { |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 1177 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp)); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1178 | ASSERT_EQ(0, neteq_->GetAudio(&output)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1179 | ASSERT_EQ(kBlockSize16kHz, output.samples_per_channel_); |
| 1180 | ASSERT_EQ(1u, output.num_channels_); |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1181 | |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1182 | rtp_info.header.sequenceNumber++; |
| 1183 | rtp_info.header.timestamp += kBlockSize16kHz; |
| 1184 | receive_timestamp += kBlockSize16kHz; |
| 1185 | } |
| 1186 | const int kNumSyncPackets = 10; |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1187 | |
| 1188 | // Make sure sufficient number of sync packets are inserted that we can |
| 1189 | // conduct a test. |
| 1190 | ASSERT_GT(kNumSyncPackets, algorithmic_frame_delay); |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1191 | // Insert sync-packets, the decoded sequence should be all-zero. |
| 1192 | for (int n = 0; n < kNumSyncPackets; ++n) { |
| 1193 | ASSERT_EQ(0, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1194 | ASSERT_EQ(0, neteq_->GetAudio(&output)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1195 | ASSERT_EQ(kBlockSize16kHz, output.samples_per_channel_); |
| 1196 | ASSERT_EQ(1u, output.num_channels_); |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1197 | if (n > algorithmic_frame_delay) { |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1198 | EXPECT_TRUE(IsAllZero( |
| 1199 | output.data_, output.samples_per_channel_ * output.num_channels_)); |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1200 | } |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1201 | rtp_info.header.sequenceNumber++; |
| 1202 | rtp_info.header.timestamp += kBlockSize16kHz; |
| 1203 | receive_timestamp += kBlockSize16kHz; |
| 1204 | } |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1205 | |
| 1206 | // We insert regular packets, if sync packet are not correctly buffered then |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1207 | // network statistics would show some packet loss. |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1208 | for (int n = 0; n <= algorithmic_frame_delay + 10; ++n) { |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 1209 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp)); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1210 | ASSERT_EQ(0, neteq_->GetAudio(&output)); |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1211 | if (n >= algorithmic_frame_delay + 1) { |
| 1212 | // Expect that this frame contain samples from regular RTP. |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1213 | EXPECT_TRUE(IsAllNonZero( |
| 1214 | output.data_, output.samples_per_channel_ * output.num_channels_)); |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1215 | } |
| 1216 | rtp_info.header.sequenceNumber++; |
| 1217 | rtp_info.header.timestamp += kBlockSize16kHz; |
| 1218 | receive_timestamp += kBlockSize16kHz; |
| 1219 | } |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1220 | NetEqNetworkStatistics network_stats; |
| 1221 | ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats)); |
| 1222 | // Expecting a "clean" network. |
| 1223 | EXPECT_EQ(0, network_stats.packet_loss_rate); |
| 1224 | EXPECT_EQ(0, network_stats.expand_rate); |
| 1225 | EXPECT_EQ(0, network_stats.accelerate_rate); |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1226 | EXPECT_LE(network_stats.preemptive_rate, 150); |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1227 | } |
| 1228 | |
| 1229 | // Test if the size of the packet buffer reported correctly when containing |
| 1230 | // sync packets. Also, test if network packets override sync packets. That is to |
| 1231 | // prefer decoding a network packet to a sync packet, if both have same sequence |
| 1232 | // number and timestamp. |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 1233 | TEST_F(NetEqDecodingTest, SyncPacketBufferSizeAndOverridenByNetworkPackets) { |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1234 | WebRtcRTPHeader rtp_info; |
| 1235 | PopulateRtpInfo(0, 0, &rtp_info); |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 1236 | const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t); |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1237 | uint8_t payload[kPayloadBytes]; |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1238 | AudioFrame output; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 1239 | for (size_t n = 0; n < kPayloadBytes; ++n) { |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1240 | payload[n] = (rand() & 0xF0) + 1; // Non-zero random sequence. |
| 1241 | } |
| 1242 | // Insert some packets which decode to noise. We are not interested in |
| 1243 | // actual decoded values. |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1244 | uint32_t receive_timestamp = 0; |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1245 | int algorithmic_frame_delay = algorithmic_delay_ms_ / 10 + 1; |
| 1246 | for (int n = 0; n < algorithmic_frame_delay; ++n) { |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 1247 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp)); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1248 | ASSERT_EQ(0, neteq_->GetAudio(&output)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1249 | ASSERT_EQ(kBlockSize16kHz, output.samples_per_channel_); |
| 1250 | ASSERT_EQ(1u, output.num_channels_); |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1251 | rtp_info.header.sequenceNumber++; |
| 1252 | rtp_info.header.timestamp += kBlockSize16kHz; |
| 1253 | receive_timestamp += kBlockSize16kHz; |
| 1254 | } |
| 1255 | const int kNumSyncPackets = 10; |
| 1256 | |
| 1257 | WebRtcRTPHeader first_sync_packet_rtp_info; |
| 1258 | memcpy(&first_sync_packet_rtp_info, &rtp_info, sizeof(rtp_info)); |
| 1259 | |
| 1260 | // Insert sync-packets, but no decoding. |
| 1261 | for (int n = 0; n < kNumSyncPackets; ++n) { |
| 1262 | ASSERT_EQ(0, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
| 1263 | rtp_info.header.sequenceNumber++; |
| 1264 | rtp_info.header.timestamp += kBlockSize16kHz; |
| 1265 | receive_timestamp += kBlockSize16kHz; |
| 1266 | } |
| 1267 | NetEqNetworkStatistics network_stats; |
| 1268 | ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats)); |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1269 | EXPECT_EQ(kNumSyncPackets * 10 + algorithmic_delay_ms_, |
| 1270 | network_stats.current_buffer_size_ms); |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1271 | |
| 1272 | // Rewind |rtp_info| to that of the first sync packet. |
| 1273 | memcpy(&rtp_info, &first_sync_packet_rtp_info, sizeof(rtp_info)); |
| 1274 | |
| 1275 | // Insert. |
| 1276 | for (int n = 0; n < kNumSyncPackets; ++n) { |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 1277 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp)); |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1278 | rtp_info.header.sequenceNumber++; |
| 1279 | rtp_info.header.timestamp += kBlockSize16kHz; |
| 1280 | receive_timestamp += kBlockSize16kHz; |
| 1281 | } |
| 1282 | |
| 1283 | // Decode. |
| 1284 | for (int n = 0; n < kNumSyncPackets; ++n) { |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1285 | ASSERT_EQ(0, neteq_->GetAudio(&output)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1286 | ASSERT_EQ(kBlockSize16kHz, output.samples_per_channel_); |
| 1287 | ASSERT_EQ(1u, output.num_channels_); |
| 1288 | EXPECT_TRUE(IsAllNonZero( |
| 1289 | output.data_, output.samples_per_channel_ * output.num_channels_)); |
turaj@webrtc.org | 7b75ac6 | 2013-09-26 00:27:56 +0000 | [diff] [blame] | 1290 | } |
| 1291 | } |
| 1292 | |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1293 | void NetEqDecodingTest::WrapTest(uint16_t start_seq_no, |
| 1294 | uint32_t start_timestamp, |
| 1295 | const std::set<uint16_t>& drop_seq_numbers, |
| 1296 | bool expect_seq_no_wrap, |
| 1297 | bool expect_timestamp_wrap) { |
| 1298 | uint16_t seq_no = start_seq_no; |
| 1299 | uint32_t timestamp = start_timestamp; |
| 1300 | const int kBlocksPerFrame = 3; // Number of 10 ms blocks per frame. |
| 1301 | const int kFrameSizeMs = kBlocksPerFrame * kTimeStepMs; |
| 1302 | const int kSamples = kBlockSize16kHz * kBlocksPerFrame; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 1303 | const size_t kPayloadBytes = kSamples * sizeof(int16_t); |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1304 | double next_input_time_ms = 0.0; |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1305 | uint32_t receive_timestamp = 0; |
| 1306 | |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1307 | // Insert speech for 2 seconds. |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1308 | const int kSpeechDurationMs = 2000; |
| 1309 | int packets_inserted = 0; |
| 1310 | uint16_t last_seq_no; |
| 1311 | uint32_t last_timestamp; |
| 1312 | bool timestamp_wrapped = false; |
| 1313 | bool seq_no_wrapped = false; |
| 1314 | for (double t_ms = 0; t_ms < kSpeechDurationMs; t_ms += 10) { |
| 1315 | // Each turn in this for loop is 10 ms. |
| 1316 | while (next_input_time_ms <= t_ms) { |
| 1317 | // Insert one 30 ms speech frame. |
| 1318 | uint8_t payload[kPayloadBytes] = {0}; |
| 1319 | WebRtcRTPHeader rtp_info; |
| 1320 | PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
| 1321 | if (drop_seq_numbers.find(seq_no) == drop_seq_numbers.end()) { |
| 1322 | // This sequence number was not in the set to drop. Insert it. |
| 1323 | ASSERT_EQ(0, |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 1324 | neteq_->InsertPacket(rtp_info, payload, receive_timestamp)); |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1325 | ++packets_inserted; |
| 1326 | } |
| 1327 | NetEqNetworkStatistics network_stats; |
| 1328 | ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats)); |
| 1329 | |
| 1330 | // Due to internal NetEq logic, preferred buffer-size is about 4 times the |
| 1331 | // packet size for first few packets. Therefore we refrain from checking |
| 1332 | // the criteria. |
| 1333 | if (packets_inserted > 4) { |
| 1334 | // Expect preferred and actual buffer size to be no more than 2 frames. |
| 1335 | EXPECT_LE(network_stats.preferred_buffer_size_ms, kFrameSizeMs * 2); |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1336 | EXPECT_LE(network_stats.current_buffer_size_ms, kFrameSizeMs * 2 + |
| 1337 | algorithmic_delay_ms_); |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1338 | } |
| 1339 | last_seq_no = seq_no; |
| 1340 | last_timestamp = timestamp; |
| 1341 | |
| 1342 | ++seq_no; |
| 1343 | timestamp += kSamples; |
| 1344 | receive_timestamp += kSamples; |
| 1345 | next_input_time_ms += static_cast<double>(kFrameSizeMs); |
| 1346 | |
| 1347 | seq_no_wrapped |= seq_no < last_seq_no; |
| 1348 | timestamp_wrapped |= timestamp < last_timestamp; |
| 1349 | } |
| 1350 | // Pull out data once. |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1351 | AudioFrame output; |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1352 | ASSERT_EQ(0, neteq_->GetAudio(&output)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1353 | ASSERT_EQ(kBlockSize16kHz, output.samples_per_channel_); |
| 1354 | ASSERT_EQ(1u, output.num_channels_); |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1355 | |
| 1356 | // Expect delay (in samples) to be less than 2 packets. |
henrik.lundin | 0d96ab7 | 2016-04-06 12:28:26 -0700 | [diff] [blame] | 1357 | rtc::Optional<uint32_t> playout_timestamp = PlayoutTimestamp(); |
| 1358 | ASSERT_TRUE(playout_timestamp); |
| 1359 | EXPECT_LE(timestamp - *playout_timestamp, |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1360 | static_cast<uint32_t>(kSamples * 2)); |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1361 | } |
| 1362 | // Make sure we have actually tested wrap-around. |
| 1363 | ASSERT_EQ(expect_seq_no_wrap, seq_no_wrapped); |
| 1364 | ASSERT_EQ(expect_timestamp_wrap, timestamp_wrapped); |
| 1365 | } |
| 1366 | |
| 1367 | TEST_F(NetEqDecodingTest, SequenceNumberWrap) { |
| 1368 | // Start with a sequence number that will soon wrap. |
| 1369 | std::set<uint16_t> drop_seq_numbers; // Don't drop any packets. |
| 1370 | WrapTest(0xFFFF - 10, 0, drop_seq_numbers, true, false); |
| 1371 | } |
| 1372 | |
| 1373 | TEST_F(NetEqDecodingTest, SequenceNumberWrapAndDrop) { |
| 1374 | // Start with a sequence number that will soon wrap. |
| 1375 | std::set<uint16_t> drop_seq_numbers; |
| 1376 | drop_seq_numbers.insert(0xFFFF); |
| 1377 | drop_seq_numbers.insert(0x0); |
| 1378 | WrapTest(0xFFFF - 10, 0, drop_seq_numbers, true, false); |
| 1379 | } |
| 1380 | |
| 1381 | TEST_F(NetEqDecodingTest, TimestampWrap) { |
| 1382 | // Start with a timestamp that will soon wrap. |
| 1383 | std::set<uint16_t> drop_seq_numbers; |
| 1384 | WrapTest(0, 0xFFFFFFFF - 3000, drop_seq_numbers, false, true); |
| 1385 | } |
| 1386 | |
| 1387 | TEST_F(NetEqDecodingTest, TimestampAndSequenceNumberWrap) { |
| 1388 | // Start with a timestamp and a sequence number that will wrap at the same |
| 1389 | // time. |
| 1390 | std::set<uint16_t> drop_seq_numbers; |
| 1391 | WrapTest(0xFFFF - 10, 0xFFFFFFFF - 5000, drop_seq_numbers, true, true); |
| 1392 | } |
| 1393 | |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1394 | void NetEqDecodingTest::DuplicateCng() { |
| 1395 | uint16_t seq_no = 0; |
| 1396 | uint32_t timestamp = 0; |
| 1397 | const int kFrameSizeMs = 10; |
| 1398 | const int kSampleRateKhz = 16; |
| 1399 | const int kSamples = kFrameSizeMs * kSampleRateKhz; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 1400 | const size_t kPayloadBytes = kSamples * 2; |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1401 | |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1402 | const int algorithmic_delay_samples = std::max( |
| 1403 | algorithmic_delay_ms_ * kSampleRateKhz, 5 * kSampleRateKhz / 8); |
henrik.lundin@webrtc.org | c93437e | 2014-12-01 11:42:42 +0000 | [diff] [blame] | 1404 | // Insert three speech packets. Three are needed to get the frame length |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1405 | // correct. |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1406 | uint8_t payload[kPayloadBytes] = {0}; |
| 1407 | WebRtcRTPHeader rtp_info; |
| 1408 | for (int i = 0; i < 3; ++i) { |
| 1409 | PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 1410 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1411 | ++seq_no; |
| 1412 | timestamp += kSamples; |
| 1413 | |
| 1414 | // Pull audio once. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1415 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1416 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1417 | } |
| 1418 | // Verify speech output. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1419 | EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1420 | |
| 1421 | // Insert same CNG packet twice. |
| 1422 | const int kCngPeriodMs = 100; |
| 1423 | const int kCngPeriodSamples = kCngPeriodMs * kSampleRateKhz; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 1424 | size_t payload_len; |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1425 | PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
| 1426 | // This is the first time this CNG packet is inserted. |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 1427 | ASSERT_EQ( |
| 1428 | 0, neteq_->InsertPacket( |
| 1429 | rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1430 | |
| 1431 | // Pull audio once and make sure CNG is played. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1432 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1433 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1434 | EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); |
henrik.lundin | 0d96ab7 | 2016-04-06 12:28:26 -0700 | [diff] [blame] | 1435 | EXPECT_FALSE(PlayoutTimestamp()); // Returns empty value during CNG. |
| 1436 | EXPECT_EQ(timestamp - algorithmic_delay_samples, |
| 1437 | out_frame_.timestamp_ + out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1438 | |
| 1439 | // Insert the same CNG packet again. Note that at this point it is old, since |
| 1440 | // we have already decoded the first copy of it. |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 1441 | ASSERT_EQ( |
| 1442 | 0, neteq_->InsertPacket( |
| 1443 | rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1444 | |
| 1445 | // Pull audio until we have played |kCngPeriodMs| of CNG. Start at 10 ms since |
| 1446 | // we have already pulled out CNG once. |
| 1447 | for (int cng_time_ms = 10; cng_time_ms < kCngPeriodMs; cng_time_ms += 10) { |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1448 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1449 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1450 | EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); |
henrik.lundin | 0d96ab7 | 2016-04-06 12:28:26 -0700 | [diff] [blame] | 1451 | EXPECT_FALSE(PlayoutTimestamp()); // Returns empty value during CNG. |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1452 | EXPECT_EQ(timestamp - algorithmic_delay_samples, |
henrik.lundin | 0d96ab7 | 2016-04-06 12:28:26 -0700 | [diff] [blame] | 1453 | out_frame_.timestamp_ + out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1454 | } |
| 1455 | |
| 1456 | // Insert speech again. |
| 1457 | ++seq_no; |
| 1458 | timestamp += kCngPeriodSamples; |
| 1459 | PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 1460 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1461 | |
| 1462 | // Pull audio once and verify that the output is speech again. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1463 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1464 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1465 | EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); |
henrik.lundin | 0d96ab7 | 2016-04-06 12:28:26 -0700 | [diff] [blame] | 1466 | rtc::Optional<uint32_t> playout_timestamp = PlayoutTimestamp(); |
| 1467 | ASSERT_TRUE(playout_timestamp); |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1468 | EXPECT_EQ(timestamp + kSamples - algorithmic_delay_samples, |
henrik.lundin | 0d96ab7 | 2016-04-06 12:28:26 -0700 | [diff] [blame] | 1469 | *playout_timestamp); |
wu@webrtc.org | 94454b7 | 2014-06-05 20:34:08 +0000 | [diff] [blame] | 1470 | } |
| 1471 | |
henrik.lundin | 0d96ab7 | 2016-04-06 12:28:26 -0700 | [diff] [blame] | 1472 | rtc::Optional<uint32_t> NetEqDecodingTest::PlayoutTimestamp() { |
| 1473 | return neteq_->GetPlayoutTimestamp(); |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1474 | } |
| 1475 | |
| 1476 | TEST_F(NetEqDecodingTest, DiscardDuplicateCng) { DuplicateCng(); } |
henrik.lundin@webrtc.org | c93437e | 2014-12-01 11:42:42 +0000 | [diff] [blame] | 1477 | |
| 1478 | TEST_F(NetEqDecodingTest, CngFirst) { |
| 1479 | uint16_t seq_no = 0; |
| 1480 | uint32_t timestamp = 0; |
| 1481 | const int kFrameSizeMs = 10; |
| 1482 | const int kSampleRateKhz = 16; |
| 1483 | const int kSamples = kFrameSizeMs * kSampleRateKhz; |
| 1484 | const int kPayloadBytes = kSamples * 2; |
| 1485 | const int kCngPeriodMs = 100; |
| 1486 | const int kCngPeriodSamples = kCngPeriodMs * kSampleRateKhz; |
| 1487 | size_t payload_len; |
| 1488 | |
| 1489 | uint8_t payload[kPayloadBytes] = {0}; |
| 1490 | WebRtcRTPHeader rtp_info; |
| 1491 | |
| 1492 | PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 1493 | ASSERT_EQ( |
| 1494 | NetEq::kOK, |
| 1495 | neteq_->InsertPacket( |
| 1496 | rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
henrik.lundin@webrtc.org | c93437e | 2014-12-01 11:42:42 +0000 | [diff] [blame] | 1497 | ++seq_no; |
| 1498 | timestamp += kCngPeriodSamples; |
| 1499 | |
| 1500 | // Pull audio once and make sure CNG is played. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1501 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1502 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1503 | EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); |
henrik.lundin@webrtc.org | c93437e | 2014-12-01 11:42:42 +0000 | [diff] [blame] | 1504 | |
| 1505 | // Insert some speech packets. |
| 1506 | for (int i = 0; i < 3; ++i) { |
| 1507 | PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 1508 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | c93437e | 2014-12-01 11:42:42 +0000 | [diff] [blame] | 1509 | ++seq_no; |
| 1510 | timestamp += kSamples; |
| 1511 | |
| 1512 | // Pull audio once. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1513 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1514 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | c93437e | 2014-12-01 11:42:42 +0000 | [diff] [blame] | 1515 | } |
| 1516 | // Verify speech output. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1517 | EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); |
henrik.lundin@webrtc.org | c93437e | 2014-12-01 11:42:42 +0000 | [diff] [blame] | 1518 | } |
henrik.lundin@webrtc.org | e7ce437 | 2014-01-09 14:01:55 +0000 | [diff] [blame] | 1519 | } // namespace webrtc |