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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "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 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 23 | #include "absl/flags/flag.h" |
Fredrik Solenberg | bbf21a3 | 2018-04-12 22:44:09 +0200 | [diff] [blame] | 24 | #include "api/audio/audio_frame.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 25 | #include "api/audio_codecs/builtin_audio_decoder_factory.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 26 | #include "modules/audio_coding/codecs/pcm16b/pcm16b.h" |
| 27 | #include "modules/audio_coding/neteq/tools/audio_loop.h" |
Henrik Lundin | 7687ad5 | 2018-07-02 10:14:46 +0200 | [diff] [blame] | 28 | #include "modules/audio_coding/neteq/tools/neteq_packet_source_input.h" |
| 29 | #include "modules/audio_coding/neteq/tools/neteq_test.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 30 | #include "modules/audio_coding/neteq/tools/rtp_file_source.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 31 | #include "modules/include/module_common_types_public.h" |
Niels Möller | 53382cb | 2018-11-27 14:05:08 +0100 | [diff] [blame] | 32 | #include "modules/rtp_rtcp/include/rtcp_statistics.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 33 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 34 | #include "rtc_base/ignore_wundef.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 35 | #include "rtc_base/message_digest.h" |
Karl Wiberg | e40468b | 2017-11-22 10:42:26 +0100 | [diff] [blame] | 36 | #include "rtc_base/numerics/safe_conversions.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 37 | #include "rtc_base/string_encode.h" |
Jonas Olsson | 366a50c | 2018-09-06 13:41:30 +0200 | [diff] [blame] | 38 | #include "rtc_base/strings/string_builder.h" |
Niels Möller | a12c42a | 2018-07-25 16:05:48 +0200 | [diff] [blame] | 39 | #include "rtc_base/system/arch.h" |
Henrik Lundin | e9619f8 | 2017-11-27 14:05:27 +0100 | [diff] [blame] | 40 | #include "test/field_trial.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 41 | #include "test/gtest.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 42 | #include "test/testsupport/file_utils.h" |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 43 | |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 44 | #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT |
kwiberg | 77eab70 | 2016-09-28 17:42:01 -0700 | [diff] [blame] | 45 | RTC_PUSH_IGNORING_WUNDEF() |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 46 | #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
| 47 | #include "external/webrtc/webrtc/modules/audio_coding/neteq/neteq_unittest.pb.h" |
| 48 | #else |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 49 | #include "modules/audio_coding/neteq/neteq_unittest.pb.h" |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 50 | #endif |
kwiberg | 77eab70 | 2016-09-28 17:42:01 -0700 | [diff] [blame] | 51 | RTC_POP_IGNORING_WUNDEF() |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 52 | #endif |
| 53 | |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 54 | ABSL_FLAG(bool, gen_ref, false, "Generate reference files."); |
turaj@webrtc.org | a6101d7 | 2013-10-01 22:01:09 +0000 | [diff] [blame] | 55 | |
kwiberg | 5adaf73 | 2016-10-04 09:33:27 -0700 | [diff] [blame] | 56 | namespace webrtc { |
| 57 | |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 58 | namespace { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 59 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 60 | const std::string& PlatformChecksum(const std::string& checksum_general, |
Henrik Lundin | 8cd750d | 2017-10-12 13:07:11 +0200 | [diff] [blame] | 61 | const std::string& checksum_android_32, |
| 62 | const std::string& checksum_android_64, |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 63 | const std::string& checksum_win_32, |
| 64 | const std::string& checksum_win_64) { |
kwiberg | 77eab70 | 2016-09-28 17:42:01 -0700 | [diff] [blame] | 65 | #if defined(WEBRTC_ANDROID) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 66 | #ifdef WEBRTC_ARCH_64_BITS |
| 67 | return checksum_android_64; |
| 68 | #else |
| 69 | return checksum_android_32; |
| 70 | #endif // WEBRTC_ARCH_64_BITS |
kwiberg | 77eab70 | 2016-09-28 17:42:01 -0700 | [diff] [blame] | 71 | #elif defined(WEBRTC_WIN) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 72 | #ifdef WEBRTC_ARCH_64_BITS |
| 73 | return checksum_win_64; |
| 74 | #else |
| 75 | return checksum_win_32; |
| 76 | #endif // WEBRTC_ARCH_64_BITS |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 77 | #else |
| 78 | return checksum_general; |
| 79 | #endif // WEBRTC_WIN |
| 80 | } |
| 81 | |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 82 | #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT |
| 83 | void Convert(const webrtc::NetEqNetworkStatistics& stats_raw, |
| 84 | webrtc::neteq_unittest::NetEqNetworkStatistics* stats) { |
| 85 | stats->set_current_buffer_size_ms(stats_raw.current_buffer_size_ms); |
| 86 | stats->set_preferred_buffer_size_ms(stats_raw.preferred_buffer_size_ms); |
| 87 | stats->set_jitter_peaks_found(stats_raw.jitter_peaks_found); |
| 88 | stats->set_packet_loss_rate(stats_raw.packet_loss_rate); |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 89 | stats->set_expand_rate(stats_raw.expand_rate); |
| 90 | stats->set_speech_expand_rate(stats_raw.speech_expand_rate); |
| 91 | stats->set_preemptive_rate(stats_raw.preemptive_rate); |
| 92 | stats->set_accelerate_rate(stats_raw.accelerate_rate); |
| 93 | stats->set_secondary_decoded_rate(stats_raw.secondary_decoded_rate); |
minyue-webrtc | 0c3ca75 | 2017-08-23 15:59:38 +0200 | [diff] [blame] | 94 | stats->set_secondary_discarded_rate(stats_raw.secondary_discarded_rate); |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 95 | stats->set_clockdrift_ppm(stats_raw.clockdrift_ppm); |
| 96 | stats->set_added_zero_samples(stats_raw.added_zero_samples); |
| 97 | stats->set_mean_waiting_time_ms(stats_raw.mean_waiting_time_ms); |
| 98 | stats->set_median_waiting_time_ms(stats_raw.median_waiting_time_ms); |
| 99 | stats->set_min_waiting_time_ms(stats_raw.min_waiting_time_ms); |
| 100 | stats->set_max_waiting_time_ms(stats_raw.max_waiting_time_ms); |
| 101 | } |
| 102 | |
| 103 | void Convert(const webrtc::RtcpStatistics& stats_raw, |
| 104 | webrtc::neteq_unittest::RtcpStatistics* stats) { |
| 105 | stats->set_fraction_lost(stats_raw.fraction_lost); |
srte | 186d9c3 | 2017-08-04 05:03:53 -0700 | [diff] [blame] | 106 | stats->set_cumulative_lost(stats_raw.packets_lost); |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 107 | stats->set_extended_max_sequence_number( |
srte | 186d9c3 | 2017-08-04 05:03:53 -0700 | [diff] [blame] | 108 | stats_raw.extended_highest_sequence_number); |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 109 | stats->set_jitter(stats_raw.jitter); |
| 110 | } |
| 111 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 112 | void AddMessage(FILE* file, |
| 113 | rtc::MessageDigest* digest, |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 114 | const std::string& message) { |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 115 | int32_t size = message.length(); |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 116 | if (file) |
| 117 | ASSERT_EQ(1u, fwrite(&size, sizeof(size), 1, file)); |
| 118 | digest->Update(&size, sizeof(size)); |
| 119 | |
| 120 | if (file) |
| 121 | ASSERT_EQ(static_cast<size_t>(size), |
| 122 | fwrite(message.data(), sizeof(char), size, file)); |
| 123 | digest->Update(message.data(), sizeof(char) * size); |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 124 | } |
| 125 | |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 126 | #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT |
| 127 | |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 128 | void LoadDecoders(webrtc::NetEq* neteq) { |
kwiberg | 5adaf73 | 2016-10-04 09:33:27 -0700 | [diff] [blame] | 129 | ASSERT_EQ(true, |
| 130 | neteq->RegisterPayloadType(0, SdpAudioFormat("pcmu", 8000, 1))); |
Niels Möller | 0554368 | 2019-01-10 16:55:06 +0100 | [diff] [blame] | 131 | ASSERT_EQ(true, |
| 132 | neteq->RegisterPayloadType(8, SdpAudioFormat("pcma", 8000, 1))); |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 133 | #ifdef WEBRTC_CODEC_ILBC |
kwiberg | 5adaf73 | 2016-10-04 09:33:27 -0700 | [diff] [blame] | 134 | ASSERT_EQ(true, |
| 135 | neteq->RegisterPayloadType(102, SdpAudioFormat("ilbc", 8000, 1))); |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 136 | #endif |
| 137 | #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) |
kwiberg | 5adaf73 | 2016-10-04 09:33:27 -0700 | [diff] [blame] | 138 | ASSERT_EQ(true, |
| 139 | neteq->RegisterPayloadType(103, SdpAudioFormat("isac", 16000, 1))); |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 140 | #endif |
| 141 | #ifdef WEBRTC_CODEC_ISAC |
kwiberg | 5adaf73 | 2016-10-04 09:33:27 -0700 | [diff] [blame] | 142 | ASSERT_EQ(true, |
| 143 | neteq->RegisterPayloadType(104, SdpAudioFormat("isac", 32000, 1))); |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 144 | #endif |
| 145 | #ifdef WEBRTC_CODEC_OPUS |
kwiberg | 5adaf73 | 2016-10-04 09:33:27 -0700 | [diff] [blame] | 146 | ASSERT_EQ(true, |
| 147 | neteq->RegisterPayloadType( |
| 148 | 111, SdpAudioFormat("opus", 48000, 2, {{"stereo", "0"}}))); |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 149 | #endif |
kwiberg | 5adaf73 | 2016-10-04 09:33:27 -0700 | [diff] [blame] | 150 | ASSERT_EQ(true, |
| 151 | neteq->RegisterPayloadType(93, SdpAudioFormat("L16", 8000, 1))); |
| 152 | ASSERT_EQ(true, |
| 153 | neteq->RegisterPayloadType(94, SdpAudioFormat("L16", 16000, 1))); |
| 154 | ASSERT_EQ(true, |
| 155 | neteq->RegisterPayloadType(95, SdpAudioFormat("L16", 32000, 1))); |
| 156 | ASSERT_EQ(true, |
| 157 | neteq->RegisterPayloadType(13, SdpAudioFormat("cn", 8000, 1))); |
| 158 | ASSERT_EQ(true, |
| 159 | neteq->RegisterPayloadType(98, SdpAudioFormat("cn", 16000, 1))); |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 160 | } |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 161 | } // namespace |
| 162 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 163 | class ResultSink { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 164 | public: |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 165 | explicit ResultSink(const std::string& output_file); |
| 166 | ~ResultSink(); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 167 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 168 | template <typename T> |
| 169 | void AddResult(const T* test_results, size_t length); |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 170 | |
| 171 | void AddResult(const NetEqNetworkStatistics& stats); |
| 172 | void AddResult(const RtcpStatistics& stats); |
| 173 | |
| 174 | void VerifyChecksum(const std::string& ref_check_sum); |
| 175 | |
| 176 | private: |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 177 | FILE* output_fp_; |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 178 | std::unique_ptr<rtc::MessageDigest> digest_; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 179 | }; |
| 180 | |
Joachim Bauch | 4e90919 | 2017-12-19 22:27:51 +0100 | [diff] [blame] | 181 | ResultSink::ResultSink(const std::string& output_file) |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 182 | : output_fp_(nullptr), |
Joachim Bauch | 4e90919 | 2017-12-19 22:27:51 +0100 | [diff] [blame] | 183 | digest_(rtc::MessageDigestFactory::Create(rtc::DIGEST_SHA_1)) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 184 | if (!output_file.empty()) { |
| 185 | output_fp_ = fopen(output_file.c_str(), "wb"); |
| 186 | EXPECT_TRUE(output_fp_ != NULL); |
| 187 | } |
| 188 | } |
| 189 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 190 | ResultSink::~ResultSink() { |
| 191 | if (output_fp_) |
| 192 | fclose(output_fp_); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 193 | } |
| 194 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 195 | template <typename T> |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 196 | void ResultSink::AddResult(const T* test_results, size_t length) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 197 | if (output_fp_) { |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 198 | ASSERT_EQ(length, fwrite(test_results, sizeof(T), length, output_fp_)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 199 | } |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 200 | digest_->Update(test_results, sizeof(T) * length); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 201 | } |
| 202 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 203 | void ResultSink::AddResult(const NetEqNetworkStatistics& stats_raw) { |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 204 | #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 205 | neteq_unittest::NetEqNetworkStatistics stats; |
| 206 | Convert(stats_raw, &stats); |
| 207 | |
Mirko Bonadei | e45c688 | 2019-02-16 09:59:29 +0100 | [diff] [blame] | 208 | std::string stats_string; |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 209 | ASSERT_TRUE(stats.SerializeToString(&stats_string)); |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 210 | AddMessage(output_fp_, digest_.get(), stats_string); |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 211 | #else |
| 212 | FAIL() << "Writing to reference file requires Proto Buffer."; |
| 213 | #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 214 | } |
| 215 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 216 | void ResultSink::AddResult(const RtcpStatistics& stats_raw) { |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 217 | #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 218 | neteq_unittest::RtcpStatistics stats; |
| 219 | Convert(stats_raw, &stats); |
| 220 | |
Mirko Bonadei | e45c688 | 2019-02-16 09:59:29 +0100 | [diff] [blame] | 221 | std::string stats_string; |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 222 | ASSERT_TRUE(stats.SerializeToString(&stats_string)); |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 223 | AddMessage(output_fp_, digest_.get(), stats_string); |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 224 | #else |
| 225 | FAIL() << "Writing to reference file requires Proto Buffer."; |
| 226 | #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 227 | } |
| 228 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 229 | void ResultSink::VerifyChecksum(const std::string& checksum) { |
| 230 | std::vector<char> buffer; |
| 231 | buffer.resize(digest_->Size()); |
| 232 | digest_->Finish(&buffer[0], buffer.size()); |
| 233 | const std::string result = rtc::hex_encode(&buffer[0], digest_->Size()); |
Yves Gerey | a038e71 | 2018-11-14 10:45:50 +0100 | [diff] [blame] | 234 | if (checksum.size() == result.size()) { |
| 235 | EXPECT_EQ(checksum, result); |
| 236 | } else { |
| 237 | // Check result is one the '|'-separated checksums. |
| 238 | EXPECT_NE(checksum.find(result), std::string::npos) |
| 239 | << result << " should be one of these:\n" |
| 240 | << checksum; |
| 241 | } |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | class NetEqDecodingTest : public ::testing::Test { |
| 245 | protected: |
| 246 | // NetEQ must be polled for data once every 10 ms. Thus, neither of the |
| 247 | // constants below can be changed. |
| 248 | static const int kTimeStepMs = 10; |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 249 | static const size_t kBlockSize8kHz = kTimeStepMs * 8; |
| 250 | static const size_t kBlockSize16kHz = kTimeStepMs * 16; |
| 251 | static const size_t kBlockSize32kHz = kTimeStepMs * 32; |
minyue | 93c08b7 | 2015-12-22 09:57:41 -0800 | [diff] [blame] | 252 | static const size_t kBlockSize48kHz = kTimeStepMs * 48; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 253 | static const int kInitSampleRateHz = 8000; |
| 254 | |
| 255 | NetEqDecodingTest(); |
| 256 | virtual void SetUp(); |
| 257 | virtual void TearDown(); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 258 | void OpenInputFile(const std::string& rtp_file); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 259 | void Process(); |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 260 | |
henrik.lundin@webrtc.org | 4e4b098 | 2014-08-11 14:48:49 +0000 | [diff] [blame] | 261 | void DecodeAndCompare(const std::string& rtp_file, |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 262 | const std::string& output_checksum, |
| 263 | const std::string& network_stats_checksum, |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 264 | bool gen_ref); |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 265 | |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 266 | static void PopulateRtpInfo(int frame_index, |
| 267 | int timestamp, |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 268 | RTPHeader* rtp_info); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 269 | static void PopulateCng(int frame_index, |
| 270 | int timestamp, |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 271 | RTPHeader* rtp_info, |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 272 | uint8_t* payload, |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 273 | size_t* payload_len); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 274 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 275 | void WrapTest(uint16_t start_seq_no, |
| 276 | uint32_t start_timestamp, |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 277 | const std::set<uint16_t>& drop_seq_numbers, |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 278 | bool expect_seq_no_wrap, |
| 279 | bool expect_timestamp_wrap); |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 280 | |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 281 | void LongCngWithClockDrift(double drift_factor, |
| 282 | double network_freeze_ms, |
| 283 | bool pull_audio_during_freeze, |
| 284 | int delay_tolerance_ms, |
| 285 | int max_time_to_speech_ms); |
| 286 | |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 287 | void DuplicateCng(); |
henrik.lundin@webrtc.org | fcfc6a9 | 2014-02-13 11:42:28 +0000 | [diff] [blame] | 288 | |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 289 | NetEq* neteq_; |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 290 | NetEq::Config config_; |
kwiberg | 2d0c332 | 2016-02-14 09:28:33 -0800 | [diff] [blame] | 291 | std::unique_ptr<test::RtpFileSource> rtp_source_; |
| 292 | std::unique_ptr<test::Packet> packet_; |
Ivo Creusen | 24192c2 | 2019-07-12 17:00:25 +0200 | [diff] [blame] | 293 | unsigned int sim_clock_; |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 294 | AudioFrame out_frame_; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 295 | int output_sample_rate_; |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 296 | int algorithmic_delay_ms_; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 297 | }; |
| 298 | |
| 299 | // Allocating the static const so that it can be passed by reference. |
| 300 | const int NetEqDecodingTest::kTimeStepMs; |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 301 | const size_t NetEqDecodingTest::kBlockSize8kHz; |
| 302 | const size_t NetEqDecodingTest::kBlockSize16kHz; |
| 303 | const size_t NetEqDecodingTest::kBlockSize32kHz; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 304 | const int NetEqDecodingTest::kInitSampleRateHz; |
| 305 | |
| 306 | NetEqDecodingTest::NetEqDecodingTest() |
Ivo Creusen | 24192c2 | 2019-07-12 17:00:25 +0200 | [diff] [blame] | 307 | : neteq_(NULL), |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 308 | config_(), |
Ivo Creusen | 24192c2 | 2019-07-12 17:00:25 +0200 | [diff] [blame] | 309 | sim_clock_(0), |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 310 | output_sample_rate_(kInitSampleRateHz), |
| 311 | algorithmic_delay_ms_(0) { |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 312 | config_.sample_rate_hz = kInitSampleRateHz; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | void NetEqDecodingTest::SetUp() { |
Ivo Creusen | 24192c2 | 2019-07-12 17:00:25 +0200 | [diff] [blame] | 316 | neteq_ = NetEq::Create(config_, CreateBuiltinAudioDecoderFactory()); |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 317 | NetEqNetworkStatistics stat; |
| 318 | ASSERT_EQ(0, neteq_->NetworkStatistics(&stat)); |
| 319 | algorithmic_delay_ms_ = stat.current_buffer_size_ms; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 320 | ASSERT_TRUE(neteq_); |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 321 | LoadDecoders(neteq_); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | void NetEqDecodingTest::TearDown() { |
| 325 | delete neteq_; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 326 | } |
| 327 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 328 | void NetEqDecodingTest::OpenInputFile(const std::string& rtp_file) { |
henrik.lundin@webrtc.org | 966a708 | 2014-11-17 09:08:38 +0000 | [diff] [blame] | 329 | rtp_source_.reset(test::RtpFileSource::Create(rtp_file)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 330 | } |
| 331 | |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 332 | void NetEqDecodingTest::Process() { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 333 | // Check if time to receive. |
Ivo Creusen | 24192c2 | 2019-07-12 17:00:25 +0200 | [diff] [blame] | 334 | while (packet_ && sim_clock_ >= packet_->time_ms()) { |
henrik.lundin@webrtc.org | 966a708 | 2014-11-17 09:08:38 +0000 | [diff] [blame] | 335 | if (packet_->payload_length_bytes() > 0) { |
ivoc | 72c08ed | 2016-01-20 07:26:24 -0800 | [diff] [blame] | 336 | #ifndef WEBRTC_CODEC_ISAC |
| 337 | // Ignore payload type 104 (iSAC-swb) if ISAC is not supported. |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 338 | if (packet_->header().payloadType != 104) |
ivoc | 72c08ed | 2016-01-20 07:26:24 -0800 | [diff] [blame] | 339 | #endif |
Henrik Lundin | 70c09bd | 2017-04-24 15:56:56 +0200 | [diff] [blame] | 340 | ASSERT_EQ(0, |
| 341 | neteq_->InsertPacket( |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 342 | packet_->header(), |
Henrik Lundin | 70c09bd | 2017-04-24 15:56:56 +0200 | [diff] [blame] | 343 | rtc::ArrayView<const uint8_t>( |
| 344 | packet_->payload(), packet_->payload_length_bytes()), |
| 345 | static_cast<uint32_t>(packet_->time_ms() * |
| 346 | (output_sample_rate_ / 1000)))); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 347 | } |
| 348 | // Get next packet. |
henrik.lundin | 46ba49c | 2016-05-24 22:50:47 -0700 | [diff] [blame] | 349 | packet_ = rtp_source_->NextPacket(); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 350 | } |
| 351 | |
henrik.lundin@webrtc.org | e1d468c | 2013-01-30 07:37:20 +0000 | [diff] [blame] | 352 | // Get audio from NetEq. |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 353 | bool muted; |
| 354 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 355 | ASSERT_FALSE(muted); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 356 | ASSERT_TRUE((out_frame_.samples_per_channel_ == kBlockSize8kHz) || |
| 357 | (out_frame_.samples_per_channel_ == kBlockSize16kHz) || |
| 358 | (out_frame_.samples_per_channel_ == kBlockSize32kHz) || |
| 359 | (out_frame_.samples_per_channel_ == kBlockSize48kHz)); |
| 360 | output_sample_rate_ = out_frame_.sample_rate_hz_; |
henrik.lundin | d89814b | 2015-11-23 06:49:25 -0800 | [diff] [blame] | 361 | 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] | 362 | |
| 363 | // Increase time. |
Ivo Creusen | 24192c2 | 2019-07-12 17:00:25 +0200 | [diff] [blame] | 364 | sim_clock_ += kTimeStepMs; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 365 | } |
| 366 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 367 | void NetEqDecodingTest::DecodeAndCompare( |
| 368 | const std::string& rtp_file, |
| 369 | const std::string& output_checksum, |
| 370 | const std::string& network_stats_checksum, |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 371 | bool gen_ref) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 372 | OpenInputFile(rtp_file); |
| 373 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 374 | std::string ref_out_file = |
| 375 | gen_ref ? webrtc::test::OutputPath() + "neteq_universal_ref.pcm" : ""; |
| 376 | ResultSink output(ref_out_file); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 377 | |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 378 | std::string stat_out_file = |
| 379 | gen_ref ? webrtc::test::OutputPath() + "neteq_network_stats.dat" : ""; |
| 380 | ResultSink network_stats(stat_out_file); |
henrik.lundin@webrtc.org | 4e4b098 | 2014-08-11 14:48:49 +0000 | [diff] [blame] | 381 | |
henrik.lundin | 46ba49c | 2016-05-24 22:50:47 -0700 | [diff] [blame] | 382 | packet_ = rtp_source_->NextPacket(); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 383 | int i = 0; |
Henrik Lundin | ac0a503 | 2017-09-25 12:22:46 +0200 | [diff] [blame] | 384 | uint64_t last_concealed_samples = 0; |
| 385 | uint64_t last_total_samples_received = 0; |
henrik.lundin@webrtc.org | 966a708 | 2014-11-17 09:08:38 +0000 | [diff] [blame] | 386 | while (packet_) { |
Jonas Olsson | 366a50c | 2018-09-06 13:41:30 +0200 | [diff] [blame] | 387 | rtc::StringBuilder ss; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 388 | ss << "Lap number " << i++ << " in DecodeAndCompare while loop"; |
| 389 | SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 390 | ASSERT_NO_FATAL_FAILURE(Process()); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 391 | ASSERT_NO_FATAL_FAILURE( |
| 392 | output.AddResult(out_frame_.data(), out_frame_.samples_per_channel_)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 393 | |
| 394 | // Query the network statistics API once per second |
Ivo Creusen | 24192c2 | 2019-07-12 17:00:25 +0200 | [diff] [blame] | 395 | if (sim_clock_ % 1000 == 0) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 396 | // Process NetworkStatistics. |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 397 | NetEqNetworkStatistics current_network_stats; |
| 398 | ASSERT_EQ(0, neteq_->NetworkStatistics(¤t_network_stats)); |
| 399 | ASSERT_NO_FATAL_FAILURE(network_stats.AddResult(current_network_stats)); |
| 400 | |
Henrik Lundin | ac0a503 | 2017-09-25 12:22:46 +0200 | [diff] [blame] | 401 | // Verify that liftime stats and network stats report similar loss |
| 402 | // concealment rates. |
| 403 | auto lifetime_stats = neteq_->GetLifetimeStatistics(); |
| 404 | const uint64_t delta_concealed_samples = |
| 405 | lifetime_stats.concealed_samples - last_concealed_samples; |
| 406 | last_concealed_samples = lifetime_stats.concealed_samples; |
| 407 | const uint64_t delta_total_samples_received = |
| 408 | lifetime_stats.total_samples_received - last_total_samples_received; |
| 409 | last_total_samples_received = lifetime_stats.total_samples_received; |
| 410 | // The tolerance is 1% but expressed in Q14. |
| 411 | EXPECT_NEAR( |
| 412 | (delta_concealed_samples << 14) / delta_total_samples_received, |
| 413 | current_network_stats.expand_rate, (2 << 14) / 100.0); |
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); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | void NetEqDecodingTest::PopulateRtpInfo(int frame_index, |
| 424 | int timestamp, |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 425 | RTPHeader* rtp_info) { |
| 426 | rtp_info->sequenceNumber = frame_index; |
| 427 | rtp_info->timestamp = timestamp; |
| 428 | rtp_info->ssrc = 0x1234; // Just an arbitrary SSRC. |
| 429 | rtp_info->payloadType = 94; // PCM16b WB codec. |
| 430 | rtp_info->markerBit = 0; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | void NetEqDecodingTest::PopulateCng(int frame_index, |
| 434 | int timestamp, |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 435 | RTPHeader* rtp_info, |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 436 | uint8_t* payload, |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 437 | size_t* payload_len) { |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 438 | rtp_info->sequenceNumber = frame_index; |
| 439 | rtp_info->timestamp = timestamp; |
| 440 | rtp_info->ssrc = 0x1234; // Just an arbitrary SSRC. |
| 441 | rtp_info->payloadType = 98; // WB CNG. |
| 442 | rtp_info->markerBit = 0; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 443 | payload[0] = 64; // Noise level -64 dBov, quite arbitrarily chosen. |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 444 | *payload_len = 1; // Only noise level, no spectral parameters. |
| 445 | } |
| 446 | |
ivoc | 72c08ed | 2016-01-20 07:26:24 -0800 | [diff] [blame] | 447 | #if !defined(WEBRTC_IOS) && defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \ |
| 448 | (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) && \ |
Karl Wiberg | eb254b4 | 2017-11-01 15:08:12 +0100 | [diff] [blame] | 449 | defined(WEBRTC_CODEC_ILBC) && !defined(WEBRTC_ARCH_ARM64) |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 450 | #define MAYBE_TestBitExactness TestBitExactness |
kwiberg | 98ab3a4 | 2015-09-30 21:54:21 -0700 | [diff] [blame] | 451 | #else |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 452 | #define MAYBE_TestBitExactness DISABLED_TestBitExactness |
kwiberg | 98ab3a4 | 2015-09-30 21:54:21 -0700 | [diff] [blame] | 453 | #endif |
minyue | 5f026d0 | 2015-12-16 07:36:04 -0800 | [diff] [blame] | 454 | TEST_F(NetEqDecodingTest, MAYBE_TestBitExactness) { |
minyue | 49c454e | 2016-01-08 11:30:14 -0800 | [diff] [blame] | 455 | const std::string input_rtp_file = |
| 456 | webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp"); |
henrik.lundin@webrtc.org | 4e4b098 | 2014-08-11 14:48:49 +0000 | [diff] [blame] | 457 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 458 | const std::string output_checksum = |
Jakob Ivarsson | a36c591 | 2019-06-27 10:12:02 +0200 | [diff] [blame] | 459 | PlatformChecksum("998be2e5a707e636af0b6298f54bedfabe72aae1", |
| 460 | "61e238ece4cd3b67d66a0b7047e06b20607dcb79", "not used", |
| 461 | "998be2e5a707e636af0b6298f54bedfabe72aae1", |
| 462 | "4116ac2a6e75baac3194b712d6fabe28b384275e"); |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 463 | |
henrik.lundin | 2979f55 | 2017-05-05 05:04:16 -0700 | [diff] [blame] | 464 | const std::string network_stats_checksum = |
Jakob Ivarsson | a36c591 | 2019-06-27 10:12:02 +0200 | [diff] [blame] | 465 | PlatformChecksum("3689c9f0ab9e50cefab3e44c37c3d7aa0de82ca4", |
| 466 | "0a596217fccd8d90eff7d1666b8cc63143eeda12", "not used", |
| 467 | "3689c9f0ab9e50cefab3e44c37c3d7aa0de82ca4", |
| 468 | "3689c9f0ab9e50cefab3e44c37c3d7aa0de82ca4"); |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 469 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 470 | DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum, |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 471 | absl::GetFlag(FLAGS_gen_ref)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 472 | } |
| 473 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 474 | #if !defined(WEBRTC_IOS) && defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \ |
minyue-webrtc | 516711c | 2017-07-27 17:45:49 +0200 | [diff] [blame] | 475 | defined(WEBRTC_CODEC_OPUS) |
minyue | 93c08b7 | 2015-12-22 09:57:41 -0800 | [diff] [blame] | 476 | #define MAYBE_TestOpusBitExactness TestOpusBitExactness |
| 477 | #else |
| 478 | #define MAYBE_TestOpusBitExactness DISABLED_TestOpusBitExactness |
| 479 | #endif |
minyue-webrtc | adb58b8 | 2017-07-26 17:59:59 +0200 | [diff] [blame] | 480 | TEST_F(NetEqDecodingTest, MAYBE_TestOpusBitExactness) { |
minyue | 93c08b7 | 2015-12-22 09:57:41 -0800 | [diff] [blame] | 481 | const std::string input_rtp_file = |
| 482 | webrtc::test::ResourcePath("audio_coding/neteq_opus", "rtp"); |
minyue | 93c08b7 | 2015-12-22 09:57:41 -0800 | [diff] [blame] | 483 | |
Yves Gerey | a038e71 | 2018-11-14 10:45:50 +0100 | [diff] [blame] | 484 | // Checksum depends on libopus being compiled with or without SSE. |
| 485 | const std::string maybe_sse = |
Jakob Ivarsson | a36c591 | 2019-06-27 10:12:02 +0200 | [diff] [blame] | 486 | "6b602683ca7285a98118b4824d72f4257952c18f|" |
| 487 | "eb0b68bddcac00fc85403df64f83126f8ea9bc93"; |
Yves Gerey | a038e71 | 2018-11-14 10:45:50 +0100 | [diff] [blame] | 488 | const std::string output_checksum = PlatformChecksum( |
Jakob Ivarsson | a36c591 | 2019-06-27 10:12:02 +0200 | [diff] [blame] | 489 | maybe_sse, "f95f2a220c9ca5d60b81c4653d46e0de2bee159f", |
| 490 | "6f288a03d34958f62496f18fa85655593eef4dbe", maybe_sse, maybe_sse); |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 491 | |
henrik.lundin | 2979f55 | 2017-05-05 05:04:16 -0700 | [diff] [blame] | 492 | const std::string network_stats_checksum = |
Jakob Ivarsson | a36c591 | 2019-06-27 10:12:02 +0200 | [diff] [blame] | 493 | PlatformChecksum("0b3d34baffaf651812ffaf06ea1b5ce45ea1c47a", |
| 494 | "a71dce66c7bea85ba22d4e29a5298f606f810444", |
| 495 | "7c64e1e915bace7c4bf583484efd64eaf234552f", |
| 496 | "0b3d34baffaf651812ffaf06ea1b5ce45ea1c47a", |
| 497 | "0b3d34baffaf651812ffaf06ea1b5ce45ea1c47a"); |
minyue | 4f90677 | 2016-04-29 11:05:14 -0700 | [diff] [blame] | 498 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 499 | DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum, |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 500 | absl::GetFlag(FLAGS_gen_ref)); |
minyue | 93c08b7 | 2015-12-22 09:57:41 -0800 | [diff] [blame] | 501 | } |
| 502 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 503 | #if !defined(WEBRTC_IOS) && defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \ |
Henrik Lundin | e9619f8 | 2017-11-27 14:05:27 +0100 | [diff] [blame] | 504 | defined(WEBRTC_CODEC_OPUS) |
| 505 | #define MAYBE_TestOpusDtxBitExactness TestOpusDtxBitExactness |
| 506 | #else |
| 507 | #define MAYBE_TestOpusDtxBitExactness DISABLED_TestOpusDtxBitExactness |
| 508 | #endif |
Henrik Lundin | 4f2a4a1 | 2018-01-26 17:32:56 +0100 | [diff] [blame] | 509 | TEST_F(NetEqDecodingTest, MAYBE_TestOpusDtxBitExactness) { |
Henrik Lundin | e9619f8 | 2017-11-27 14:05:27 +0100 | [diff] [blame] | 510 | const std::string input_rtp_file = |
| 511 | webrtc::test::ResourcePath("audio_coding/neteq_opus_dtx", "rtp"); |
| 512 | |
Yves Gerey | a038e71 | 2018-11-14 10:45:50 +0100 | [diff] [blame] | 513 | const std::string maybe_sse = |
| 514 | "713af6c92881f5aab1285765ee6680da9d1c06ce|" |
| 515 | "2ac10c4e79aeedd0df2863b079da5848b40f00b5"; |
| 516 | const std::string output_checksum = PlatformChecksum( |
| 517 | maybe_sse, "3ec991b96872123f1554c03c543ca5d518431e46", |
| 518 | "da9f9a2d94e0c2d67342fad4965d7b91cda50b25", maybe_sse, maybe_sse); |
Henrik Lundin | e9619f8 | 2017-11-27 14:05:27 +0100 | [diff] [blame] | 519 | |
| 520 | const std::string network_stats_checksum = |
| 521 | "bab58dc587d956f326056d7340c96eb9d2d3cc21"; |
| 522 | |
Henrik Lundin | e9619f8 | 2017-11-27 14:05:27 +0100 | [diff] [blame] | 523 | DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum, |
Mirko Bonadei | 2ab97f6 | 2019-07-18 13:44:12 +0200 | [diff] [blame] | 524 | absl::GetFlag(FLAGS_gen_ref)); |
Henrik Lundin | e9619f8 | 2017-11-27 14:05:27 +0100 | [diff] [blame] | 525 | } |
| 526 | |
henrik.lundin@webrtc.org | 7cbc4f9 | 2014-10-07 06:37:39 +0000 | [diff] [blame] | 527 | // Use fax mode to avoid time-scaling. This is to simplify the testing of |
| 528 | // packet waiting times in the packet buffer. |
| 529 | class NetEqDecodingTestFaxMode : public NetEqDecodingTest { |
| 530 | protected: |
| 531 | NetEqDecodingTestFaxMode() : NetEqDecodingTest() { |
Henrik Lundin | 7687ad5 | 2018-07-02 10:14:46 +0200 | [diff] [blame] | 532 | config_.for_test_no_time_stretching = true; |
henrik.lundin@webrtc.org | 7cbc4f9 | 2014-10-07 06:37:39 +0000 | [diff] [blame] | 533 | } |
Gustaf Ullberg | b0a0207 | 2017-10-02 12:00:34 +0200 | [diff] [blame] | 534 | void TestJitterBufferDelay(bool apply_packet_loss); |
henrik.lundin@webrtc.org | 7cbc4f9 | 2014-10-07 06:37:39 +0000 | [diff] [blame] | 535 | }; |
| 536 | |
| 537 | TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 538 | // Insert 30 dummy packets at once. Each packet contains 10 ms 16 kHz audio. |
| 539 | size_t num_frames = 30; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 540 | const size_t kSamples = 10 * 16; |
| 541 | const size_t kPayloadBytes = kSamples * 2; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 542 | for (size_t i = 0; i < num_frames; ++i) { |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 543 | const uint8_t payload[kPayloadBytes] = {0}; |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 544 | RTPHeader rtp_info; |
Mirko Bonadei | a811027 | 2017-10-18 14:22:50 +0200 | [diff] [blame] | 545 | rtp_info.sequenceNumber = rtc::checked_cast<uint16_t>(i); |
| 546 | rtp_info.timestamp = rtc::checked_cast<uint32_t>(i * kSamples); |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 547 | rtp_info.ssrc = 0x1234; // Just an arbitrary SSRC. |
| 548 | rtp_info.payloadType = 94; // PCM16b WB codec. |
| 549 | rtp_info.markerBit = 0; |
| 550 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 551 | } |
| 552 | // Pull out all data. |
| 553 | for (size_t i = 0; i < num_frames; ++i) { |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 554 | bool muted; |
| 555 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 556 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 557 | } |
| 558 | |
Henrik Lundin | 1bb8cf8 | 2015-08-25 13:08:04 +0200 | [diff] [blame] | 559 | NetEqNetworkStatistics stats; |
| 560 | EXPECT_EQ(0, neteq_->NetworkStatistics(&stats)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 561 | // Since all frames are dumped into NetEQ at once, but pulled out with 10 ms |
| 562 | // 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] | 563 | // each packet. Thus, we are calculating the statistics for a series from 10 |
| 564 | // to 300, in steps of 10 ms. |
| 565 | EXPECT_EQ(155, stats.mean_waiting_time_ms); |
| 566 | EXPECT_EQ(155, stats.median_waiting_time_ms); |
| 567 | EXPECT_EQ(10, stats.min_waiting_time_ms); |
| 568 | EXPECT_EQ(300, stats.max_waiting_time_ms); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 569 | |
| 570 | // Check statistics again and make sure it's been reset. |
Henrik Lundin | 1bb8cf8 | 2015-08-25 13:08:04 +0200 | [diff] [blame] | 571 | EXPECT_EQ(0, neteq_->NetworkStatistics(&stats)); |
| 572 | EXPECT_EQ(-1, stats.mean_waiting_time_ms); |
| 573 | EXPECT_EQ(-1, stats.median_waiting_time_ms); |
| 574 | EXPECT_EQ(-1, stats.min_waiting_time_ms); |
| 575 | EXPECT_EQ(-1, stats.max_waiting_time_ms); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 576 | } |
| 577 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 578 | TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimeNegative) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 579 | const int kNumFrames = 3000; // Needed for convergence. |
| 580 | int frame_index = 0; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 581 | const size_t kSamples = 10 * 16; |
| 582 | const size_t kPayloadBytes = kSamples * 2; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 583 | while (frame_index < kNumFrames) { |
| 584 | // Insert one packet each time, except every 10th time where we insert two |
| 585 | // packets at once. This will create a negative clock-drift of approx. 10%. |
| 586 | int num_packets = (frame_index % 10 == 0 ? 2 : 1); |
| 587 | for (int n = 0; n < num_packets; ++n) { |
| 588 | uint8_t payload[kPayloadBytes] = {0}; |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 589 | RTPHeader rtp_info; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 590 | PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info); |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 591 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 592 | ++frame_index; |
| 593 | } |
| 594 | |
| 595 | // Pull out data once. |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 596 | bool muted; |
| 597 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 598 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | NetEqNetworkStatistics network_stats; |
| 602 | ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats)); |
henrik.lundin | 0d83857 | 2016-10-13 03:35:55 -0700 | [diff] [blame] | 603 | EXPECT_EQ(-103192, network_stats.clockdrift_ppm); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 604 | } |
| 605 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 606 | TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimePositive) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 607 | const int kNumFrames = 5000; // Needed for convergence. |
| 608 | int frame_index = 0; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 609 | const size_t kSamples = 10 * 16; |
| 610 | const size_t kPayloadBytes = kSamples * 2; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 611 | for (int i = 0; i < kNumFrames; ++i) { |
| 612 | // Insert one packet each time, except every 10th time where we don't insert |
| 613 | // any packet. This will create a positive clock-drift of approx. 11%. |
| 614 | int num_packets = (i % 10 == 9 ? 0 : 1); |
| 615 | for (int n = 0; n < num_packets; ++n) { |
| 616 | uint8_t payload[kPayloadBytes] = {0}; |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 617 | RTPHeader rtp_info; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 618 | PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info); |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 619 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 620 | ++frame_index; |
| 621 | } |
| 622 | |
| 623 | // Pull out data once. |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 624 | bool muted; |
| 625 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 626 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 627 | } |
| 628 | |
| 629 | NetEqNetworkStatistics network_stats; |
| 630 | ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats)); |
henrik.lundin | 0d83857 | 2016-10-13 03:35:55 -0700 | [diff] [blame] | 631 | EXPECT_EQ(110953, network_stats.clockdrift_ppm); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 632 | } |
| 633 | |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 634 | void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor, |
| 635 | double network_freeze_ms, |
| 636 | bool pull_audio_during_freeze, |
| 637 | int delay_tolerance_ms, |
| 638 | int max_time_to_speech_ms) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 639 | uint16_t seq_no = 0; |
| 640 | uint32_t timestamp = 0; |
| 641 | const int kFrameSizeMs = 30; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 642 | const size_t kSamples = kFrameSizeMs * 16; |
| 643 | const size_t kPayloadBytes = kSamples * 2; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 644 | double next_input_time_ms = 0.0; |
| 645 | double t_ms; |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 646 | bool muted; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 647 | |
| 648 | // Insert speech for 5 seconds. |
| 649 | const int kSpeechDurationMs = 5000; |
| 650 | for (t_ms = 0; t_ms < kSpeechDurationMs; t_ms += 10) { |
| 651 | // Each turn in this for loop is 10 ms. |
| 652 | while (next_input_time_ms <= t_ms) { |
| 653 | // Insert one 30 ms speech frame. |
| 654 | uint8_t payload[kPayloadBytes] = {0}; |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 655 | RTPHeader rtp_info; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 656 | PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 657 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 658 | ++seq_no; |
| 659 | timestamp += kSamples; |
henrik.lundin@webrtc.org | fcfc6a9 | 2014-02-13 11:42:28 +0000 | [diff] [blame] | 660 | next_input_time_ms += static_cast<double>(kFrameSizeMs) * drift_factor; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 661 | } |
| 662 | // Pull out data once. |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 663 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 664 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 665 | } |
| 666 | |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 667 | EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); |
Danil Chapovalov | b602123 | 2018-06-19 13:26:36 +0200 | [diff] [blame] | 668 | absl::optional<uint32_t> playout_timestamp = neteq_->GetPlayoutTimestamp(); |
henrik.lundin | 0d96ab7 | 2016-04-06 12:28:26 -0700 | [diff] [blame] | 669 | ASSERT_TRUE(playout_timestamp); |
| 670 | int32_t delay_before = timestamp - *playout_timestamp; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 671 | |
| 672 | // Insert CNG for 1 minute (= 60000 ms). |
| 673 | const int kCngPeriodMs = 100; |
| 674 | const int kCngPeriodSamples = kCngPeriodMs * 16; // Period in 16 kHz samples. |
| 675 | const int kCngDurationMs = 60000; |
| 676 | for (; t_ms < kSpeechDurationMs + kCngDurationMs; t_ms += 10) { |
| 677 | // Each turn in this for loop is 10 ms. |
| 678 | while (next_input_time_ms <= t_ms) { |
| 679 | // Insert one CNG frame each 100 ms. |
| 680 | uint8_t payload[kPayloadBytes]; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 681 | size_t payload_len; |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 682 | RTPHeader rtp_info; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 683 | PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 684 | ASSERT_EQ(0, neteq_->InsertPacket( |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 685 | rtp_info, |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 686 | rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 687 | ++seq_no; |
| 688 | timestamp += kCngPeriodSamples; |
henrik.lundin@webrtc.org | fcfc6a9 | 2014-02-13 11:42:28 +0000 | [diff] [blame] | 689 | next_input_time_ms += static_cast<double>(kCngPeriodMs) * drift_factor; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 690 | } |
| 691 | // Pull out data once. |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 692 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 693 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 694 | } |
| 695 | |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 696 | EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 697 | |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 698 | if (network_freeze_ms > 0) { |
| 699 | // First keep pulling audio for |network_freeze_ms| without inserting |
| 700 | // any data, then insert CNG data corresponding to |network_freeze_ms| |
| 701 | // without pulling any output audio. |
| 702 | const double loop_end_time = t_ms + network_freeze_ms; |
| 703 | for (; t_ms < loop_end_time; t_ms += 10) { |
| 704 | // Pull out data once. |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 705 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 706 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 707 | EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 708 | } |
| 709 | bool pull_once = pull_audio_during_freeze; |
| 710 | // If |pull_once| is true, GetAudio will be called once half-way through |
| 711 | // the network recovery period. |
| 712 | double pull_time_ms = (t_ms + next_input_time_ms) / 2; |
| 713 | while (next_input_time_ms <= t_ms) { |
| 714 | if (pull_once && next_input_time_ms >= pull_time_ms) { |
| 715 | pull_once = false; |
| 716 | // Pull out data once. |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 717 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 718 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 719 | EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 720 | t_ms += 10; |
| 721 | } |
| 722 | // Insert one CNG frame each 100 ms. |
| 723 | uint8_t payload[kPayloadBytes]; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 724 | size_t payload_len; |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 725 | RTPHeader rtp_info; |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 726 | PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 727 | ASSERT_EQ(0, neteq_->InsertPacket( |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 728 | rtp_info, |
kwiberg | ee2bac2 | 2015-11-11 10:34:00 -0800 | [diff] [blame] | 729 | rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 730 | ++seq_no; |
| 731 | timestamp += kCngPeriodSamples; |
| 732 | next_input_time_ms += kCngPeriodMs * drift_factor; |
| 733 | } |
| 734 | } |
| 735 | |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 736 | // Insert speech again until output type is speech. |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 737 | double speech_restart_time_ms = t_ms; |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 738 | while (out_frame_.speech_type_ != AudioFrame::kNormalSpeech) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 739 | // Each turn in this for loop is 10 ms. |
| 740 | while (next_input_time_ms <= t_ms) { |
| 741 | // Insert one 30 ms speech frame. |
| 742 | uint8_t payload[kPayloadBytes] = {0}; |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 743 | RTPHeader rtp_info; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 744 | PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 745 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 746 | ++seq_no; |
| 747 | timestamp += kSamples; |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 748 | next_input_time_ms += kFrameSizeMs * drift_factor; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 749 | } |
| 750 | // Pull out data once. |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 751 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 752 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 753 | // Increase clock. |
| 754 | t_ms += 10; |
| 755 | } |
| 756 | |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 757 | // Check that the speech starts again within reasonable time. |
| 758 | double time_until_speech_returns_ms = t_ms - speech_restart_time_ms; |
| 759 | EXPECT_LT(time_until_speech_returns_ms, max_time_to_speech_ms); |
henrik.lundin | 114c1b3 | 2017-04-26 07:47:32 -0700 | [diff] [blame] | 760 | playout_timestamp = neteq_->GetPlayoutTimestamp(); |
henrik.lundin | 0d96ab7 | 2016-04-06 12:28:26 -0700 | [diff] [blame] | 761 | ASSERT_TRUE(playout_timestamp); |
| 762 | int32_t delay_after = timestamp - *playout_timestamp; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 763 | // 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] | 764 | EXPECT_LE(delay_after, delay_before + delay_tolerance_ms * 16); |
| 765 | EXPECT_GE(delay_after, delay_before - delay_tolerance_ms * 16); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 766 | } |
| 767 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 768 | TEST_F(NetEqDecodingTest, LongCngWithNegativeClockDrift) { |
henrik.lundin@webrtc.org | fcfc6a9 | 2014-02-13 11:42:28 +0000 | [diff] [blame] | 769 | // Apply a clock drift of -25 ms / s (sender faster than receiver). |
| 770 | const double kDriftFactor = 1000.0 / (1000.0 + 25.0); |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 771 | const double kNetworkFreezeTimeMs = 0.0; |
| 772 | const bool kGetAudioDuringFreezeRecovery = false; |
| 773 | const int kDelayToleranceMs = 20; |
| 774 | const int kMaxTimeToSpeechMs = 100; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 775 | LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, |
| 776 | kGetAudioDuringFreezeRecovery, kDelayToleranceMs, |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 777 | kMaxTimeToSpeechMs); |
henrik.lundin@webrtc.org | fcfc6a9 | 2014-02-13 11:42:28 +0000 | [diff] [blame] | 778 | } |
| 779 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 780 | TEST_F(NetEqDecodingTest, LongCngWithPositiveClockDrift) { |
henrik.lundin@webrtc.org | fcfc6a9 | 2014-02-13 11:42:28 +0000 | [diff] [blame] | 781 | // Apply a clock drift of +25 ms / s (sender slower than receiver). |
| 782 | const double kDriftFactor = 1000.0 / (1000.0 - 25.0); |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 783 | const double kNetworkFreezeTimeMs = 0.0; |
| 784 | const bool kGetAudioDuringFreezeRecovery = false; |
| 785 | const int kDelayToleranceMs = 20; |
| 786 | const int kMaxTimeToSpeechMs = 100; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 787 | LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, |
| 788 | kGetAudioDuringFreezeRecovery, kDelayToleranceMs, |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 789 | kMaxTimeToSpeechMs); |
| 790 | } |
| 791 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 792 | TEST_F(NetEqDecodingTest, LongCngWithNegativeClockDriftNetworkFreeze) { |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 793 | // Apply a clock drift of -25 ms / s (sender faster than receiver). |
| 794 | const double kDriftFactor = 1000.0 / (1000.0 + 25.0); |
| 795 | const double kNetworkFreezeTimeMs = 5000.0; |
| 796 | const bool kGetAudioDuringFreezeRecovery = false; |
Jakob Ivarsson | a36c591 | 2019-06-27 10:12:02 +0200 | [diff] [blame] | 797 | const int kDelayToleranceMs = 60; |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 798 | const int kMaxTimeToSpeechMs = 200; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 799 | LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, |
| 800 | kGetAudioDuringFreezeRecovery, kDelayToleranceMs, |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 801 | kMaxTimeToSpeechMs); |
| 802 | } |
| 803 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 804 | TEST_F(NetEqDecodingTest, LongCngWithPositiveClockDriftNetworkFreeze) { |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 805 | // Apply a clock drift of +25 ms / s (sender slower than receiver). |
| 806 | const double kDriftFactor = 1000.0 / (1000.0 - 25.0); |
| 807 | const double kNetworkFreezeTimeMs = 5000.0; |
| 808 | const bool kGetAudioDuringFreezeRecovery = false; |
| 809 | const int kDelayToleranceMs = 20; |
| 810 | const int kMaxTimeToSpeechMs = 100; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 811 | LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, |
| 812 | kGetAudioDuringFreezeRecovery, kDelayToleranceMs, |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 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; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 823 | LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, |
| 824 | kGetAudioDuringFreezeRecovery, kDelayToleranceMs, |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 825 | kMaxTimeToSpeechMs); |
| 826 | } |
| 827 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 828 | TEST_F(NetEqDecodingTest, LongCngWithoutClockDrift) { |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 829 | const double kDriftFactor = 1.0; // No drift. |
| 830 | const double kNetworkFreezeTimeMs = 0.0; |
| 831 | const bool kGetAudioDuringFreezeRecovery = false; |
| 832 | const int kDelayToleranceMs = 10; |
| 833 | const int kMaxTimeToSpeechMs = 50; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 834 | LongCngWithClockDrift(kDriftFactor, kNetworkFreezeTimeMs, |
| 835 | kGetAudioDuringFreezeRecovery, kDelayToleranceMs, |
henrik.lundin@webrtc.org | 24779fe | 2014-03-14 12:40:05 +0000 | [diff] [blame] | 836 | kMaxTimeToSpeechMs); |
henrik.lundin@webrtc.org | fcfc6a9 | 2014-02-13 11:42:28 +0000 | [diff] [blame] | 837 | } |
| 838 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 839 | TEST_F(NetEqDecodingTest, UnknownPayloadType) { |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 840 | const size_t kPayloadBytes = 100; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 841 | uint8_t payload[kPayloadBytes] = {0}; |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 842 | RTPHeader rtp_info; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 843 | PopulateRtpInfo(0, 0, &rtp_info); |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 844 | rtp_info.payloadType = 1; // Not registered as a decoder. |
| 845 | EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 846 | } |
| 847 | |
Peter Boström | e2976c8 | 2016-01-04 22:44:05 +0100 | [diff] [blame] | 848 | #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) |
ivoc | 72c08ed | 2016-01-20 07:26:24 -0800 | [diff] [blame] | 849 | #define MAYBE_DecoderError DecoderError |
| 850 | #else |
| 851 | #define MAYBE_DecoderError DISABLED_DecoderError |
| 852 | #endif |
| 853 | |
Peter Boström | e2976c8 | 2016-01-04 22:44:05 +0100 | [diff] [blame] | 854 | TEST_F(NetEqDecodingTest, MAYBE_DecoderError) { |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 855 | const size_t kPayloadBytes = 100; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 856 | uint8_t payload[kPayloadBytes] = {0}; |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 857 | RTPHeader rtp_info; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 858 | PopulateRtpInfo(0, 0, &rtp_info); |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 859 | rtp_info.payloadType = 103; // iSAC, but the payload is invalid. |
| 860 | EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 861 | // Set all of |out_data_| to 1, and verify that it was set to 0 by the call |
| 862 | // to GetAudio. |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 863 | int16_t* out_frame_data = out_frame_.mutable_data(); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 864 | for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; ++i) { |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 865 | out_frame_data[i] = 1; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 866 | } |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 867 | bool muted; |
| 868 | EXPECT_EQ(NetEq::kFail, neteq_->GetAudio(&out_frame_, &muted)); |
| 869 | ASSERT_FALSE(muted); |
ivoc | 72c08ed | 2016-01-20 07:26:24 -0800 | [diff] [blame] | 870 | |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 871 | // Verify that the first 160 samples are set to 0. |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 872 | static const int kExpectedOutputLength = 160; // 10 ms at 16 kHz sample rate. |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 873 | const int16_t* const_out_frame_data = out_frame_.data(); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 874 | for (int i = 0; i < kExpectedOutputLength; ++i) { |
Jonas Olsson | 366a50c | 2018-09-06 13:41:30 +0200 | [diff] [blame] | 875 | rtc::StringBuilder ss; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 876 | ss << "i = " << i; |
| 877 | SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 878 | EXPECT_EQ(0, const_out_frame_data[i]); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 879 | } |
| 880 | } |
| 881 | |
henrik.lundin@webrtc.org | b4e80e0 | 2014-05-15 07:14:00 +0000 | [diff] [blame] | 882 | TEST_F(NetEqDecodingTest, GetAudioBeforeInsertPacket) { |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 883 | // Set all of |out_data_| to 1, and verify that it was set to 0 by the call |
| 884 | // to GetAudio. |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 885 | int16_t* out_frame_data = out_frame_.mutable_data(); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 886 | for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; ++i) { |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 887 | out_frame_data[i] = 1; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 888 | } |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 889 | bool muted; |
| 890 | EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 891 | ASSERT_FALSE(muted); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 892 | // Verify that the first block of samples is set to 0. |
| 893 | static const int kExpectedOutputLength = |
| 894 | kInitSampleRateHz / 100; // 10 ms at initial sample rate. |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 895 | const int16_t* const_out_frame_data = out_frame_.data(); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 896 | for (int i = 0; i < kExpectedOutputLength; ++i) { |
Jonas Olsson | 366a50c | 2018-09-06 13:41:30 +0200 | [diff] [blame] | 897 | rtc::StringBuilder ss; |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 898 | ss << "i = " << i; |
| 899 | SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 900 | EXPECT_EQ(0, const_out_frame_data[i]); |
henrik.lundin@webrtc.org | d94659d | 2013-01-29 12:09:21 +0000 | [diff] [blame] | 901 | } |
henrik.lundin | d89814b | 2015-11-23 06:49:25 -0800 | [diff] [blame] | 902 | // Verify that the sample rate did not change from the initial configuration. |
| 903 | 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] | 904 | } |
turaj@webrtc.org | ff43c85 | 2013-09-25 00:07:27 +0000 | [diff] [blame] | 905 | |
henrik.lundin@webrtc.org | 9b8102c | 2014-08-21 08:27:44 +0000 | [diff] [blame] | 906 | class NetEqBgnTest : public NetEqDecodingTest { |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 907 | protected: |
henrik.lundin@webrtc.org | 9b8102c | 2014-08-21 08:27:44 +0000 | [diff] [blame] | 908 | void CheckBgn(int sampling_rate_hz) { |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 909 | size_t expected_samples_per_channel = 0; |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 910 | uint8_t payload_type = 0xFF; // Invalid. |
| 911 | if (sampling_rate_hz == 8000) { |
| 912 | expected_samples_per_channel = kBlockSize8kHz; |
| 913 | payload_type = 93; // PCM 16, 8 kHz. |
| 914 | } else if (sampling_rate_hz == 16000) { |
| 915 | expected_samples_per_channel = kBlockSize16kHz; |
| 916 | payload_type = 94; // PCM 16, 16 kHZ. |
| 917 | } else if (sampling_rate_hz == 32000) { |
| 918 | expected_samples_per_channel = kBlockSize32kHz; |
| 919 | payload_type = 95; // PCM 16, 32 kHz. |
| 920 | } else { |
| 921 | ASSERT_TRUE(false); // Unsupported test case. |
| 922 | } |
turaj@webrtc.org | ff43c85 | 2013-09-25 00:07:27 +0000 | [diff] [blame] | 923 | |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 924 | AudioFrame output; |
henrik.lundin@webrtc.org | 9b8102c | 2014-08-21 08:27:44 +0000 | [diff] [blame] | 925 | test::AudioLoop input; |
| 926 | // We are using the same 32 kHz input file for all tests, regardless of |
| 927 | // |sampling_rate_hz|. The output may sound weird, but the test is still |
| 928 | // valid. |
| 929 | ASSERT_TRUE(input.Init( |
| 930 | webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"), |
| 931 | 10 * sampling_rate_hz, // Max 10 seconds loop length. |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 932 | expected_samples_per_channel)); |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 933 | |
| 934 | // Payload of 10 ms of PCM16 32 kHz. |
| 935 | uint8_t payload[kBlockSize32kHz * sizeof(int16_t)]; |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 936 | RTPHeader rtp_info; |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 937 | PopulateRtpInfo(0, 0, &rtp_info); |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 938 | rtp_info.payloadType = payload_type; |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 939 | |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 940 | uint32_t receive_timestamp = 0; |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 941 | bool muted; |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 942 | for (int n = 0; n < 10; ++n) { // Insert few packets and get audio. |
kwiberg | 288886b | 2015-11-06 01:21:35 -0800 | [diff] [blame] | 943 | auto block = input.GetNextBlock(); |
| 944 | ASSERT_EQ(expected_samples_per_channel, block.size()); |
| 945 | size_t enc_len_bytes = |
| 946 | WebRtcPcm16b_Encode(block.data(), block.size(), payload); |
henrik.lundin@webrtc.org | 9b8102c | 2014-08-21 08:27:44 +0000 | [diff] [blame] | 947 | ASSERT_EQ(enc_len_bytes, expected_samples_per_channel * 2); |
| 948 | |
Henrik Lundin | 70c09bd | 2017-04-24 15:56:56 +0200 | [diff] [blame] | 949 | ASSERT_EQ(0, neteq_->InsertPacket( |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 950 | rtp_info, |
Henrik Lundin | 70c09bd | 2017-04-24 15:56:56 +0200 | [diff] [blame] | 951 | rtc::ArrayView<const uint8_t>(payload, enc_len_bytes), |
| 952 | receive_timestamp)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 953 | output.Reset(); |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 954 | ASSERT_EQ(0, neteq_->GetAudio(&output, &muted)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 955 | ASSERT_EQ(1u, output.num_channels_); |
| 956 | ASSERT_EQ(expected_samples_per_channel, output.samples_per_channel_); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 957 | ASSERT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 958 | |
| 959 | // Next packet. |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 960 | rtp_info.timestamp += |
| 961 | rtc::checked_cast<uint32_t>(expected_samples_per_channel); |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 962 | rtp_info.sequenceNumber++; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 963 | receive_timestamp += |
| 964 | rtc::checked_cast<uint32_t>(expected_samples_per_channel); |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 965 | } |
| 966 | |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 967 | output.Reset(); |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 968 | |
| 969 | // Get audio without inserting packets, expecting PLC and PLC-to-CNG. Pull |
| 970 | // one frame without checking speech-type. This is the first frame pulled |
| 971 | // without inserting any packet, and might not be labeled as PLC. |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 972 | ASSERT_EQ(0, neteq_->GetAudio(&output, &muted)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 973 | ASSERT_EQ(1u, output.num_channels_); |
| 974 | ASSERT_EQ(expected_samples_per_channel, output.samples_per_channel_); |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 975 | |
| 976 | // To be able to test the fading of background noise we need at lease to |
| 977 | // pull 611 frames. |
| 978 | const int kFadingThreshold = 611; |
| 979 | |
| 980 | // Test several CNG-to-PLC packet for the expected behavior. The number 20 |
| 981 | // is arbitrary, but sufficiently large to test enough number of frames. |
| 982 | const int kNumPlcToCngTestFrames = 20; |
| 983 | bool plc_to_cng = false; |
| 984 | for (int n = 0; n < kFadingThreshold + kNumPlcToCngTestFrames; ++n) { |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 985 | output.Reset(); |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 986 | // Set to non-zero. |
| 987 | memset(output.mutable_data(), 1, AudioFrame::kMaxDataSizeBytes); |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 988 | ASSERT_EQ(0, neteq_->GetAudio(&output, &muted)); |
| 989 | ASSERT_FALSE(muted); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 990 | ASSERT_EQ(1u, output.num_channels_); |
| 991 | ASSERT_EQ(expected_samples_per_channel, output.samples_per_channel_); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 992 | if (output.speech_type_ == AudioFrame::kPLCCNG) { |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 993 | plc_to_cng = true; |
| 994 | double sum_squared = 0; |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 995 | const int16_t* output_data = output.data(); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 996 | for (size_t k = 0; |
| 997 | k < output.num_channels_ * output.samples_per_channel_; ++k) |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 998 | sum_squared += output_data[k] * output_data[k]; |
Henrik Lundin | 6719017 | 2018-04-20 15:34:48 +0200 | [diff] [blame] | 999 | EXPECT_EQ(0, sum_squared); |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 1000 | } else { |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1001 | EXPECT_EQ(AudioFrame::kPLC, output.speech_type_); |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 1002 | } |
| 1003 | } |
| 1004 | EXPECT_TRUE(plc_to_cng); // Just to be sure that PLC-to-CNG has occurred. |
| 1005 | } |
| 1006 | }; |
| 1007 | |
Henrik Lundin | 6719017 | 2018-04-20 15:34:48 +0200 | [diff] [blame] | 1008 | TEST_F(NetEqBgnTest, RunTest) { |
henrik.lundin@webrtc.org | 9b8102c | 2014-08-21 08:27:44 +0000 | [diff] [blame] | 1009 | CheckBgn(8000); |
| 1010 | CheckBgn(16000); |
| 1011 | CheckBgn(32000); |
| 1012 | } |
henrik.lundin@webrtc.org | ea25784 | 2014-08-07 12:27:37 +0000 | [diff] [blame] | 1013 | |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1014 | void NetEqDecodingTest::WrapTest(uint16_t start_seq_no, |
| 1015 | uint32_t start_timestamp, |
| 1016 | const std::set<uint16_t>& drop_seq_numbers, |
| 1017 | bool expect_seq_no_wrap, |
| 1018 | bool expect_timestamp_wrap) { |
| 1019 | uint16_t seq_no = start_seq_no; |
| 1020 | uint32_t timestamp = start_timestamp; |
| 1021 | const int kBlocksPerFrame = 3; // Number of 10 ms blocks per frame. |
| 1022 | const int kFrameSizeMs = kBlocksPerFrame * kTimeStepMs; |
| 1023 | const int kSamples = kBlockSize16kHz * kBlocksPerFrame; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 1024 | const size_t kPayloadBytes = kSamples * sizeof(int16_t); |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1025 | double next_input_time_ms = 0.0; |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1026 | uint32_t receive_timestamp = 0; |
| 1027 | |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1028 | // Insert speech for 2 seconds. |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1029 | const int kSpeechDurationMs = 2000; |
| 1030 | int packets_inserted = 0; |
| 1031 | uint16_t last_seq_no; |
| 1032 | uint32_t last_timestamp; |
| 1033 | bool timestamp_wrapped = false; |
| 1034 | bool seq_no_wrapped = false; |
| 1035 | for (double t_ms = 0; t_ms < kSpeechDurationMs; t_ms += 10) { |
| 1036 | // Each turn in this for loop is 10 ms. |
| 1037 | while (next_input_time_ms <= t_ms) { |
| 1038 | // Insert one 30 ms speech frame. |
| 1039 | uint8_t payload[kPayloadBytes] = {0}; |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 1040 | RTPHeader rtp_info; |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1041 | PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
| 1042 | if (drop_seq_numbers.find(seq_no) == drop_seq_numbers.end()) { |
| 1043 | // This sequence number was not in the set to drop. Insert it. |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 1044 | ASSERT_EQ(0, |
| 1045 | neteq_->InsertPacket(rtp_info, payload, receive_timestamp)); |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1046 | ++packets_inserted; |
| 1047 | } |
| 1048 | NetEqNetworkStatistics network_stats; |
| 1049 | ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats)); |
| 1050 | |
| 1051 | // Due to internal NetEq logic, preferred buffer-size is about 4 times the |
| 1052 | // packet size for first few packets. Therefore we refrain from checking |
| 1053 | // the criteria. |
| 1054 | if (packets_inserted > 4) { |
| 1055 | // Expect preferred and actual buffer size to be no more than 2 frames. |
| 1056 | EXPECT_LE(network_stats.preferred_buffer_size_ms, kFrameSizeMs * 2); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 1057 | EXPECT_LE(network_stats.current_buffer_size_ms, |
| 1058 | kFrameSizeMs * 2 + algorithmic_delay_ms_); |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1059 | } |
| 1060 | last_seq_no = seq_no; |
| 1061 | last_timestamp = timestamp; |
| 1062 | |
| 1063 | ++seq_no; |
| 1064 | timestamp += kSamples; |
| 1065 | receive_timestamp += kSamples; |
| 1066 | next_input_time_ms += static_cast<double>(kFrameSizeMs); |
| 1067 | |
| 1068 | seq_no_wrapped |= seq_no < last_seq_no; |
| 1069 | timestamp_wrapped |= timestamp < last_timestamp; |
| 1070 | } |
| 1071 | // Pull out data once. |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1072 | AudioFrame output; |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1073 | bool muted; |
| 1074 | ASSERT_EQ(0, neteq_->GetAudio(&output, &muted)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1075 | ASSERT_EQ(kBlockSize16kHz, output.samples_per_channel_); |
| 1076 | ASSERT_EQ(1u, output.num_channels_); |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1077 | |
| 1078 | // Expect delay (in samples) to be less than 2 packets. |
Danil Chapovalov | b602123 | 2018-06-19 13:26:36 +0200 | [diff] [blame] | 1079 | absl::optional<uint32_t> playout_timestamp = neteq_->GetPlayoutTimestamp(); |
henrik.lundin | 0d96ab7 | 2016-04-06 12:28:26 -0700 | [diff] [blame] | 1080 | ASSERT_TRUE(playout_timestamp); |
| 1081 | EXPECT_LE(timestamp - *playout_timestamp, |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1082 | static_cast<uint32_t>(kSamples * 2)); |
turaj@webrtc.org | 78b41a0 | 2013-11-22 20:27:07 +0000 | [diff] [blame] | 1083 | } |
| 1084 | // Make sure we have actually tested wrap-around. |
| 1085 | ASSERT_EQ(expect_seq_no_wrap, seq_no_wrapped); |
| 1086 | ASSERT_EQ(expect_timestamp_wrap, timestamp_wrapped); |
| 1087 | } |
| 1088 | |
| 1089 | TEST_F(NetEqDecodingTest, SequenceNumberWrap) { |
| 1090 | // Start with a sequence number that will soon wrap. |
| 1091 | std::set<uint16_t> drop_seq_numbers; // Don't drop any packets. |
| 1092 | WrapTest(0xFFFF - 10, 0, drop_seq_numbers, true, false); |
| 1093 | } |
| 1094 | |
| 1095 | TEST_F(NetEqDecodingTest, SequenceNumberWrapAndDrop) { |
| 1096 | // Start with a sequence number that will soon wrap. |
| 1097 | std::set<uint16_t> drop_seq_numbers; |
| 1098 | drop_seq_numbers.insert(0xFFFF); |
| 1099 | drop_seq_numbers.insert(0x0); |
| 1100 | WrapTest(0xFFFF - 10, 0, drop_seq_numbers, true, false); |
| 1101 | } |
| 1102 | |
| 1103 | TEST_F(NetEqDecodingTest, TimestampWrap) { |
| 1104 | // Start with a timestamp that will soon wrap. |
| 1105 | std::set<uint16_t> drop_seq_numbers; |
| 1106 | WrapTest(0, 0xFFFFFFFF - 3000, drop_seq_numbers, false, true); |
| 1107 | } |
| 1108 | |
| 1109 | TEST_F(NetEqDecodingTest, TimestampAndSequenceNumberWrap) { |
| 1110 | // Start with a timestamp and a sequence number that will wrap at the same |
| 1111 | // time. |
| 1112 | std::set<uint16_t> drop_seq_numbers; |
| 1113 | WrapTest(0xFFFF - 10, 0xFFFFFFFF - 5000, drop_seq_numbers, true, true); |
| 1114 | } |
| 1115 | |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1116 | void NetEqDecodingTest::DuplicateCng() { |
| 1117 | uint16_t seq_no = 0; |
| 1118 | uint32_t timestamp = 0; |
| 1119 | const int kFrameSizeMs = 10; |
| 1120 | const int kSampleRateKhz = 16; |
| 1121 | const int kSamples = kFrameSizeMs * kSampleRateKhz; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 1122 | const size_t kPayloadBytes = kSamples * 2; |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1123 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 1124 | const int algorithmic_delay_samples = |
| 1125 | std::max(algorithmic_delay_ms_ * kSampleRateKhz, 5 * kSampleRateKhz / 8); |
henrik.lundin@webrtc.org | c93437e | 2014-12-01 11:42:42 +0000 | [diff] [blame] | 1126 | // 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] | 1127 | // correct. |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1128 | uint8_t payload[kPayloadBytes] = {0}; |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 1129 | RTPHeader rtp_info; |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1130 | bool muted; |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1131 | for (int i = 0; i < 3; ++i) { |
| 1132 | PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 1133 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1134 | ++seq_no; |
| 1135 | timestamp += kSamples; |
| 1136 | |
| 1137 | // Pull audio once. |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1138 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1139 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1140 | } |
| 1141 | // Verify speech output. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1142 | EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1143 | |
| 1144 | // Insert same CNG packet twice. |
| 1145 | const int kCngPeriodMs = 100; |
| 1146 | const int kCngPeriodSamples = kCngPeriodMs * kSampleRateKhz; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 1147 | size_t payload_len; |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1148 | PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
| 1149 | // This is the first time this CNG packet is inserted. |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 1150 | ASSERT_EQ( |
| 1151 | 0, neteq_->InsertPacket( |
| 1152 | 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] | 1153 | |
| 1154 | // Pull audio once and make sure CNG is played. |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1155 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1156 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1157 | EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); |
henrik.lundin | 114c1b3 | 2017-04-26 07:47:32 -0700 | [diff] [blame] | 1158 | EXPECT_FALSE( |
| 1159 | neteq_->GetPlayoutTimestamp()); // Returns empty value during CNG. |
henrik.lundin | 0d96ab7 | 2016-04-06 12:28:26 -0700 | [diff] [blame] | 1160 | EXPECT_EQ(timestamp - algorithmic_delay_samples, |
| 1161 | out_frame_.timestamp_ + out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1162 | |
| 1163 | // Insert the same CNG packet again. Note that at this point it is old, since |
| 1164 | // we have already decoded the first copy of it. |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 1165 | ASSERT_EQ( |
| 1166 | 0, neteq_->InsertPacket( |
| 1167 | 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] | 1168 | |
| 1169 | // Pull audio until we have played |kCngPeriodMs| of CNG. Start at 10 ms since |
| 1170 | // we have already pulled out CNG once. |
| 1171 | for (int cng_time_ms = 10; cng_time_ms < kCngPeriodMs; cng_time_ms += 10) { |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1172 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1173 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1174 | EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); |
henrik.lundin | 114c1b3 | 2017-04-26 07:47:32 -0700 | [diff] [blame] | 1175 | EXPECT_FALSE( |
| 1176 | neteq_->GetPlayoutTimestamp()); // Returns empty value during CNG. |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1177 | EXPECT_EQ(timestamp - algorithmic_delay_samples, |
henrik.lundin | 0d96ab7 | 2016-04-06 12:28:26 -0700 | [diff] [blame] | 1178 | out_frame_.timestamp_ + out_frame_.samples_per_channel_); |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1179 | } |
| 1180 | |
| 1181 | // Insert speech again. |
| 1182 | ++seq_no; |
| 1183 | timestamp += kCngPeriodSamples; |
| 1184 | PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 1185 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | ca8cb95 | 2014-03-12 10:26:52 +0000 | [diff] [blame] | 1186 | |
| 1187 | // Pull audio once and verify that the output is speech again. |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1188 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1189 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1190 | EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); |
Danil Chapovalov | b602123 | 2018-06-19 13:26:36 +0200 | [diff] [blame] | 1191 | absl::optional<uint32_t> playout_timestamp = neteq_->GetPlayoutTimestamp(); |
henrik.lundin | 0d96ab7 | 2016-04-06 12:28:26 -0700 | [diff] [blame] | 1192 | ASSERT_TRUE(playout_timestamp); |
turaj@webrtc.org | 8d1cdaa | 2014-04-11 18:47:55 +0000 | [diff] [blame] | 1193 | EXPECT_EQ(timestamp + kSamples - algorithmic_delay_samples, |
henrik.lundin | 0d96ab7 | 2016-04-06 12:28:26 -0700 | [diff] [blame] | 1194 | *playout_timestamp); |
wu@webrtc.org | 94454b7 | 2014-06-05 20:34:08 +0000 | [diff] [blame] | 1195 | } |
| 1196 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 1197 | TEST_F(NetEqDecodingTest, DiscardDuplicateCng) { |
| 1198 | DuplicateCng(); |
| 1199 | } |
henrik.lundin@webrtc.org | c93437e | 2014-12-01 11:42:42 +0000 | [diff] [blame] | 1200 | |
| 1201 | TEST_F(NetEqDecodingTest, CngFirst) { |
| 1202 | uint16_t seq_no = 0; |
| 1203 | uint32_t timestamp = 0; |
| 1204 | const int kFrameSizeMs = 10; |
| 1205 | const int kSampleRateKhz = 16; |
| 1206 | const int kSamples = kFrameSizeMs * kSampleRateKhz; |
| 1207 | const int kPayloadBytes = kSamples * 2; |
| 1208 | const int kCngPeriodMs = 100; |
| 1209 | const int kCngPeriodSamples = kCngPeriodMs * kSampleRateKhz; |
| 1210 | size_t payload_len; |
| 1211 | |
| 1212 | uint8_t payload[kPayloadBytes] = {0}; |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 1213 | RTPHeader rtp_info; |
henrik.lundin@webrtc.org | c93437e | 2014-12-01 11:42:42 +0000 | [diff] [blame] | 1214 | |
| 1215 | PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 1216 | ASSERT_EQ( |
| 1217 | NetEq::kOK, |
| 1218 | neteq_->InsertPacket( |
| 1219 | 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] | 1220 | ++seq_no; |
| 1221 | timestamp += kCngPeriodSamples; |
| 1222 | |
| 1223 | // Pull audio once and make sure CNG is played. |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1224 | bool muted; |
| 1225 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1226 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1227 | EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); |
henrik.lundin@webrtc.org | c93437e | 2014-12-01 11:42:42 +0000 | [diff] [blame] | 1228 | |
| 1229 | // Insert some speech packets. |
henrik.lundin | 549d80b | 2016-08-25 00:44:24 -0700 | [diff] [blame] | 1230 | const uint32_t first_speech_timestamp = timestamp; |
| 1231 | int timeout_counter = 0; |
| 1232 | do { |
| 1233 | ASSERT_LT(timeout_counter++, 20) << "Test timed out"; |
henrik.lundin@webrtc.org | c93437e | 2014-12-01 11:42:42 +0000 | [diff] [blame] | 1234 | PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 1235 | ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin@webrtc.org | c93437e | 2014-12-01 11:42:42 +0000 | [diff] [blame] | 1236 | ++seq_no; |
| 1237 | timestamp += kSamples; |
| 1238 | |
| 1239 | // Pull audio once. |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1240 | ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
henrik.lundin | 6d8e011 | 2016-03-04 10:34:21 -0800 | [diff] [blame] | 1241 | ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
henrik.lundin | 549d80b | 2016-08-25 00:44:24 -0700 | [diff] [blame] | 1242 | } while (!IsNewerTimestamp(out_frame_.timestamp_, first_speech_timestamp)); |
henrik.lundin@webrtc.org | c93437e | 2014-12-01 11:42:42 +0000 | [diff] [blame] | 1243 | // Verify speech output. |
henrik.lundin | 55480f5 | 2016-03-08 02:37:57 -0800 | [diff] [blame] | 1244 | EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); |
henrik.lundin@webrtc.org | c93437e | 2014-12-01 11:42:42 +0000 | [diff] [blame] | 1245 | } |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1246 | |
| 1247 | class NetEqDecodingTestWithMutedState : public NetEqDecodingTest { |
| 1248 | public: |
| 1249 | NetEqDecodingTestWithMutedState() : NetEqDecodingTest() { |
| 1250 | config_.enable_muted_state = true; |
| 1251 | } |
| 1252 | |
| 1253 | protected: |
| 1254 | static constexpr size_t kSamples = 10 * 16; |
| 1255 | static constexpr size_t kPayloadBytes = kSamples * 2; |
| 1256 | |
| 1257 | void InsertPacket(uint32_t rtp_timestamp) { |
| 1258 | uint8_t payload[kPayloadBytes] = {0}; |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 1259 | RTPHeader rtp_info; |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1260 | PopulateRtpInfo(0, rtp_timestamp, &rtp_info); |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 1261 | EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1262 | } |
| 1263 | |
henrik.lundin | 42feb51 | 2016-09-20 06:51:40 -0700 | [diff] [blame] | 1264 | void InsertCngPacket(uint32_t rtp_timestamp) { |
| 1265 | uint8_t payload[kPayloadBytes] = {0}; |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 1266 | RTPHeader rtp_info; |
henrik.lundin | 42feb51 | 2016-09-20 06:51:40 -0700 | [diff] [blame] | 1267 | size_t payload_len; |
| 1268 | PopulateCng(0, rtp_timestamp, &rtp_info, payload, &payload_len); |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 1269 | EXPECT_EQ( |
| 1270 | NetEq::kOK, |
| 1271 | neteq_->InsertPacket( |
| 1272 | rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
henrik.lundin | 42feb51 | 2016-09-20 06:51:40 -0700 | [diff] [blame] | 1273 | } |
| 1274 | |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1275 | bool GetAudioReturnMuted() { |
| 1276 | bool muted; |
| 1277 | EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 1278 | return muted; |
| 1279 | } |
| 1280 | |
| 1281 | void GetAudioUntilMuted() { |
| 1282 | while (!GetAudioReturnMuted()) { |
| 1283 | ASSERT_LT(counter_++, 1000) << "Test timed out"; |
| 1284 | } |
| 1285 | } |
| 1286 | |
| 1287 | void GetAudioUntilNormal() { |
| 1288 | bool muted = false; |
| 1289 | while (out_frame_.speech_type_ != AudioFrame::kNormalSpeech) { |
| 1290 | EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 1291 | ASSERT_LT(counter_++, 1000) << "Test timed out"; |
| 1292 | } |
| 1293 | EXPECT_FALSE(muted); |
| 1294 | } |
| 1295 | |
| 1296 | int counter_ = 0; |
| 1297 | }; |
| 1298 | |
| 1299 | // Verifies that NetEq goes in and out of muted state as expected. |
| 1300 | TEST_F(NetEqDecodingTestWithMutedState, MutedState) { |
| 1301 | // Insert one speech packet. |
| 1302 | InsertPacket(0); |
| 1303 | // Pull out audio once and expect it not to be muted. |
| 1304 | EXPECT_FALSE(GetAudioReturnMuted()); |
| 1305 | // Pull data until faded out. |
| 1306 | GetAudioUntilMuted(); |
henrik.lundin | a449107 | 2017-07-06 05:23:53 -0700 | [diff] [blame] | 1307 | EXPECT_TRUE(out_frame_.muted()); |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1308 | |
| 1309 | // Verify that output audio is not written during muted mode. Other parameters |
| 1310 | // should be correct, though. |
| 1311 | AudioFrame new_frame; |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 1312 | int16_t* frame_data = new_frame.mutable_data(); |
| 1313 | for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; i++) { |
| 1314 | frame_data[i] = 17; |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1315 | } |
| 1316 | bool muted; |
| 1317 | EXPECT_EQ(0, neteq_->GetAudio(&new_frame, &muted)); |
| 1318 | EXPECT_TRUE(muted); |
henrik.lundin | a449107 | 2017-07-06 05:23:53 -0700 | [diff] [blame] | 1319 | EXPECT_TRUE(out_frame_.muted()); |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 1320 | for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; i++) { |
| 1321 | EXPECT_EQ(17, frame_data[i]); |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1322 | } |
| 1323 | EXPECT_EQ(out_frame_.timestamp_ + out_frame_.samples_per_channel_, |
| 1324 | new_frame.timestamp_); |
| 1325 | EXPECT_EQ(out_frame_.samples_per_channel_, new_frame.samples_per_channel_); |
| 1326 | EXPECT_EQ(out_frame_.sample_rate_hz_, new_frame.sample_rate_hz_); |
| 1327 | EXPECT_EQ(out_frame_.num_channels_, new_frame.num_channels_); |
| 1328 | EXPECT_EQ(out_frame_.speech_type_, new_frame.speech_type_); |
| 1329 | EXPECT_EQ(out_frame_.vad_activity_, new_frame.vad_activity_); |
| 1330 | |
| 1331 | // Insert new data. Timestamp is corrected for the time elapsed since the last |
| 1332 | // packet. Verify that normal operation resumes. |
| 1333 | InsertPacket(kSamples * counter_); |
| 1334 | GetAudioUntilNormal(); |
henrik.lundin | a449107 | 2017-07-06 05:23:53 -0700 | [diff] [blame] | 1335 | EXPECT_FALSE(out_frame_.muted()); |
henrik.lundin | 612c25e | 2016-05-25 08:21:04 -0700 | [diff] [blame] | 1336 | |
| 1337 | NetEqNetworkStatistics stats; |
| 1338 | EXPECT_EQ(0, neteq_->NetworkStatistics(&stats)); |
| 1339 | // NetEqNetworkStatistics::expand_rate tells the fraction of samples that were |
| 1340 | // concealment samples, in Q14 (16384 = 100%) .The vast majority should be |
| 1341 | // concealment samples in this test. |
| 1342 | EXPECT_GT(stats.expand_rate, 14000); |
| 1343 | // And, it should be greater than the speech_expand_rate. |
| 1344 | EXPECT_GT(stats.expand_rate, stats.speech_expand_rate); |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1345 | } |
| 1346 | |
| 1347 | // Verifies that NetEq goes out of muted state when given a delayed packet. |
| 1348 | TEST_F(NetEqDecodingTestWithMutedState, MutedStateDelayedPacket) { |
| 1349 | // Insert one speech packet. |
| 1350 | InsertPacket(0); |
| 1351 | // Pull out audio once and expect it not to be muted. |
| 1352 | EXPECT_FALSE(GetAudioReturnMuted()); |
| 1353 | // Pull data until faded out. |
| 1354 | GetAudioUntilMuted(); |
| 1355 | // Insert new data. Timestamp is only corrected for the half of the time |
| 1356 | // elapsed since the last packet. That is, the new packet is delayed. Verify |
| 1357 | // that normal operation resumes. |
| 1358 | InsertPacket(kSamples * counter_ / 2); |
| 1359 | GetAudioUntilNormal(); |
| 1360 | } |
| 1361 | |
| 1362 | // Verifies that NetEq goes out of muted state when given a future packet. |
| 1363 | TEST_F(NetEqDecodingTestWithMutedState, MutedStateFuturePacket) { |
| 1364 | // Insert one speech packet. |
| 1365 | InsertPacket(0); |
| 1366 | // Pull out audio once and expect it not to be muted. |
| 1367 | EXPECT_FALSE(GetAudioReturnMuted()); |
| 1368 | // Pull data until faded out. |
| 1369 | GetAudioUntilMuted(); |
| 1370 | // Insert new data. Timestamp is over-corrected for the time elapsed since the |
| 1371 | // last packet. That is, the new packet is too early. Verify that normal |
| 1372 | // operation resumes. |
| 1373 | InsertPacket(kSamples * counter_ * 2); |
| 1374 | GetAudioUntilNormal(); |
| 1375 | } |
| 1376 | |
| 1377 | // Verifies that NetEq goes out of muted state when given an old packet. |
| 1378 | TEST_F(NetEqDecodingTestWithMutedState, MutedStateOldPacket) { |
| 1379 | // Insert one speech packet. |
| 1380 | InsertPacket(0); |
| 1381 | // Pull out audio once and expect it not to be muted. |
| 1382 | EXPECT_FALSE(GetAudioReturnMuted()); |
| 1383 | // Pull data until faded out. |
| 1384 | GetAudioUntilMuted(); |
| 1385 | |
| 1386 | EXPECT_NE(AudioFrame::kNormalSpeech, out_frame_.speech_type_); |
| 1387 | // Insert packet which is older than the first packet. |
| 1388 | InsertPacket(kSamples * (counter_ - 1000)); |
| 1389 | EXPECT_FALSE(GetAudioReturnMuted()); |
| 1390 | EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); |
| 1391 | } |
| 1392 | |
henrik.lundin | 42feb51 | 2016-09-20 06:51:40 -0700 | [diff] [blame] | 1393 | // Verifies that NetEq doesn't enter muted state when CNG mode is active and the |
| 1394 | // packet stream is suspended for a long time. |
| 1395 | TEST_F(NetEqDecodingTestWithMutedState, DoNotMuteExtendedCngWithoutPackets) { |
| 1396 | // Insert one CNG packet. |
| 1397 | InsertCngPacket(0); |
| 1398 | |
| 1399 | // Pull 10 seconds of audio (10 ms audio generated per lap). |
| 1400 | for (int i = 0; i < 1000; ++i) { |
| 1401 | bool muted; |
| 1402 | EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 1403 | ASSERT_FALSE(muted); |
| 1404 | } |
| 1405 | EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); |
| 1406 | } |
| 1407 | |
| 1408 | // Verifies that NetEq goes back to normal after a long CNG period with the |
| 1409 | // packet stream suspended. |
| 1410 | TEST_F(NetEqDecodingTestWithMutedState, RecoverAfterExtendedCngWithoutPackets) { |
| 1411 | // Insert one CNG packet. |
| 1412 | InsertCngPacket(0); |
| 1413 | |
| 1414 | // Pull 10 seconds of audio (10 ms audio generated per lap). |
| 1415 | for (int i = 0; i < 1000; ++i) { |
| 1416 | bool muted; |
| 1417 | EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 1418 | } |
| 1419 | |
| 1420 | // Insert new data. Timestamp is corrected for the time elapsed since the last |
| 1421 | // packet. Verify that normal operation resumes. |
| 1422 | InsertPacket(kSamples * counter_); |
| 1423 | GetAudioUntilNormal(); |
| 1424 | } |
| 1425 | |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1426 | class NetEqDecodingTestTwoInstances : public NetEqDecodingTest { |
| 1427 | public: |
| 1428 | NetEqDecodingTestTwoInstances() : NetEqDecodingTest() {} |
| 1429 | |
| 1430 | void SetUp() override { |
| 1431 | NetEqDecodingTest::SetUp(); |
| 1432 | config2_ = config_; |
| 1433 | } |
| 1434 | |
| 1435 | void CreateSecondInstance() { |
Ivo Creusen | 24192c2 | 2019-07-12 17:00:25 +0200 | [diff] [blame] | 1436 | neteq2_.reset(NetEq::Create(config2_, CreateBuiltinAudioDecoderFactory())); |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1437 | ASSERT_TRUE(neteq2_); |
| 1438 | LoadDecoders(neteq2_.get()); |
| 1439 | } |
| 1440 | |
| 1441 | protected: |
| 1442 | std::unique_ptr<NetEq> neteq2_; |
| 1443 | NetEq::Config config2_; |
| 1444 | }; |
| 1445 | |
| 1446 | namespace { |
| 1447 | ::testing::AssertionResult AudioFramesEqualExceptData(const AudioFrame& a, |
| 1448 | const AudioFrame& b) { |
| 1449 | if (a.timestamp_ != b.timestamp_) |
| 1450 | return ::testing::AssertionFailure() << "timestamp_ diff (" << a.timestamp_ |
| 1451 | << " != " << b.timestamp_ << ")"; |
| 1452 | if (a.sample_rate_hz_ != b.sample_rate_hz_) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 1453 | return ::testing::AssertionFailure() |
| 1454 | << "sample_rate_hz_ diff (" << a.sample_rate_hz_ |
| 1455 | << " != " << b.sample_rate_hz_ << ")"; |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1456 | if (a.samples_per_channel_ != b.samples_per_channel_) |
| 1457 | return ::testing::AssertionFailure() |
| 1458 | << "samples_per_channel_ diff (" << a.samples_per_channel_ |
| 1459 | << " != " << b.samples_per_channel_ << ")"; |
| 1460 | if (a.num_channels_ != b.num_channels_) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 1461 | return ::testing::AssertionFailure() |
| 1462 | << "num_channels_ diff (" << a.num_channels_ |
| 1463 | << " != " << b.num_channels_ << ")"; |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1464 | if (a.speech_type_ != b.speech_type_) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 1465 | return ::testing::AssertionFailure() |
| 1466 | << "speech_type_ diff (" << a.speech_type_ |
| 1467 | << " != " << b.speech_type_ << ")"; |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1468 | if (a.vad_activity_ != b.vad_activity_) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 1469 | return ::testing::AssertionFailure() |
| 1470 | << "vad_activity_ diff (" << a.vad_activity_ |
| 1471 | << " != " << b.vad_activity_ << ")"; |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1472 | return ::testing::AssertionSuccess(); |
| 1473 | } |
| 1474 | |
| 1475 | ::testing::AssertionResult AudioFramesEqual(const AudioFrame& a, |
| 1476 | const AudioFrame& b) { |
| 1477 | ::testing::AssertionResult res = AudioFramesEqualExceptData(a, b); |
| 1478 | if (!res) |
| 1479 | return res; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 1480 | if (memcmp(a.data(), b.data(), |
| 1481 | a.samples_per_channel_ * a.num_channels_ * sizeof(*a.data())) != |
| 1482 | 0) { |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1483 | return ::testing::AssertionFailure() << "data_ diff"; |
| 1484 | } |
| 1485 | return ::testing::AssertionSuccess(); |
| 1486 | } |
| 1487 | |
| 1488 | } // namespace |
| 1489 | |
| 1490 | TEST_F(NetEqDecodingTestTwoInstances, CompareMutedStateOnOff) { |
| 1491 | ASSERT_FALSE(config_.enable_muted_state); |
| 1492 | config2_.enable_muted_state = true; |
| 1493 | CreateSecondInstance(); |
| 1494 | |
| 1495 | // Insert one speech packet into both NetEqs. |
| 1496 | const size_t kSamples = 10 * 16; |
| 1497 | const size_t kPayloadBytes = kSamples * 2; |
| 1498 | uint8_t payload[kPayloadBytes] = {0}; |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 1499 | RTPHeader rtp_info; |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1500 | PopulateRtpInfo(0, 0, &rtp_info); |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 1501 | EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 1502 | EXPECT_EQ(0, neteq2_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1503 | |
| 1504 | AudioFrame out_frame1, out_frame2; |
| 1505 | bool muted; |
| 1506 | for (int i = 0; i < 1000; ++i) { |
Jonas Olsson | 366a50c | 2018-09-06 13:41:30 +0200 | [diff] [blame] | 1507 | rtc::StringBuilder ss; |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1508 | ss << "i = " << i; |
| 1509 | SCOPED_TRACE(ss.str()); // Print out the loop iterator on failure. |
| 1510 | EXPECT_EQ(0, neteq_->GetAudio(&out_frame1, &muted)); |
| 1511 | EXPECT_FALSE(muted); |
| 1512 | EXPECT_EQ(0, neteq2_->GetAudio(&out_frame2, &muted)); |
| 1513 | if (muted) { |
| 1514 | EXPECT_TRUE(AudioFramesEqualExceptData(out_frame1, out_frame2)); |
| 1515 | } else { |
| 1516 | EXPECT_TRUE(AudioFramesEqual(out_frame1, out_frame2)); |
| 1517 | } |
| 1518 | } |
| 1519 | EXPECT_TRUE(muted); |
| 1520 | |
| 1521 | // Insert new data. Timestamp is corrected for the time elapsed since the last |
| 1522 | // packet. |
| 1523 | PopulateRtpInfo(0, kSamples * 1000, &rtp_info); |
henrik.lundin | 246ef3e | 2017-04-24 09:14:32 -0700 | [diff] [blame] | 1524 | EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 1525 | EXPECT_EQ(0, neteq2_->InsertPacket(rtp_info, payload, 0)); |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1526 | |
| 1527 | int counter = 0; |
| 1528 | while (out_frame1.speech_type_ != AudioFrame::kNormalSpeech) { |
| 1529 | ASSERT_LT(counter++, 1000) << "Test timed out"; |
Jonas Olsson | 366a50c | 2018-09-06 13:41:30 +0200 | [diff] [blame] | 1530 | rtc::StringBuilder ss; |
henrik.lundin | 7a92681 | 2016-05-12 13:51:28 -0700 | [diff] [blame] | 1531 | ss << "counter = " << counter; |
| 1532 | SCOPED_TRACE(ss.str()); // Print out the loop iterator on failure. |
| 1533 | EXPECT_EQ(0, neteq_->GetAudio(&out_frame1, &muted)); |
| 1534 | EXPECT_FALSE(muted); |
| 1535 | EXPECT_EQ(0, neteq2_->GetAudio(&out_frame2, &muted)); |
| 1536 | if (muted) { |
| 1537 | EXPECT_TRUE(AudioFramesEqualExceptData(out_frame1, out_frame2)); |
| 1538 | } else { |
| 1539 | EXPECT_TRUE(AudioFramesEqual(out_frame1, out_frame2)); |
| 1540 | } |
| 1541 | } |
| 1542 | EXPECT_FALSE(muted); |
| 1543 | } |
| 1544 | |
henrik.lundin | 114c1b3 | 2017-04-26 07:47:32 -0700 | [diff] [blame] | 1545 | TEST_F(NetEqDecodingTest, LastDecodedTimestampsEmpty) { |
| 1546 | EXPECT_TRUE(neteq_->LastDecodedTimestamps().empty()); |
| 1547 | |
| 1548 | // Pull out data once. |
| 1549 | AudioFrame output; |
| 1550 | bool muted; |
| 1551 | ASSERT_EQ(0, neteq_->GetAudio(&output, &muted)); |
| 1552 | |
| 1553 | EXPECT_TRUE(neteq_->LastDecodedTimestamps().empty()); |
| 1554 | } |
| 1555 | |
| 1556 | TEST_F(NetEqDecodingTest, LastDecodedTimestampsOneDecoded) { |
| 1557 | // Insert one packet with PCM16b WB data (this is what PopulateRtpInfo does by |
| 1558 | // default). Make the length 10 ms. |
| 1559 | constexpr size_t kPayloadSamples = 16 * 10; |
| 1560 | constexpr size_t kPayloadBytes = 2 * kPayloadSamples; |
| 1561 | uint8_t payload[kPayloadBytes] = {0}; |
| 1562 | |
| 1563 | RTPHeader rtp_info; |
| 1564 | constexpr uint32_t kRtpTimestamp = 0x1234; |
| 1565 | PopulateRtpInfo(0, kRtpTimestamp, &rtp_info); |
| 1566 | EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 1567 | |
| 1568 | // Pull out data once. |
| 1569 | AudioFrame output; |
| 1570 | bool muted; |
| 1571 | ASSERT_EQ(0, neteq_->GetAudio(&output, &muted)); |
| 1572 | |
| 1573 | EXPECT_EQ(std::vector<uint32_t>({kRtpTimestamp}), |
| 1574 | neteq_->LastDecodedTimestamps()); |
| 1575 | |
| 1576 | // Nothing decoded on the second call. |
| 1577 | ASSERT_EQ(0, neteq_->GetAudio(&output, &muted)); |
| 1578 | EXPECT_TRUE(neteq_->LastDecodedTimestamps().empty()); |
| 1579 | } |
| 1580 | |
| 1581 | TEST_F(NetEqDecodingTest, LastDecodedTimestampsTwoDecoded) { |
| 1582 | // Insert two packets with PCM16b WB data (this is what PopulateRtpInfo does |
| 1583 | // by default). Make the length 5 ms so that NetEq must decode them both in |
| 1584 | // the same GetAudio call. |
| 1585 | constexpr size_t kPayloadSamples = 16 * 5; |
| 1586 | constexpr size_t kPayloadBytes = 2 * kPayloadSamples; |
| 1587 | uint8_t payload[kPayloadBytes] = {0}; |
| 1588 | |
| 1589 | RTPHeader rtp_info; |
| 1590 | constexpr uint32_t kRtpTimestamp1 = 0x1234; |
| 1591 | PopulateRtpInfo(0, kRtpTimestamp1, &rtp_info); |
| 1592 | EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 1593 | constexpr uint32_t kRtpTimestamp2 = kRtpTimestamp1 + kPayloadSamples; |
| 1594 | PopulateRtpInfo(1, kRtpTimestamp2, &rtp_info); |
| 1595 | EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 1596 | |
| 1597 | // Pull out data once. |
| 1598 | AudioFrame output; |
| 1599 | bool muted; |
| 1600 | ASSERT_EQ(0, neteq_->GetAudio(&output, &muted)); |
| 1601 | |
| 1602 | EXPECT_EQ(std::vector<uint32_t>({kRtpTimestamp1, kRtpTimestamp2}), |
| 1603 | neteq_->LastDecodedTimestamps()); |
| 1604 | } |
| 1605 | |
Gustaf Ullberg | 9a2e906 | 2017-09-18 09:28:20 +0200 | [diff] [blame] | 1606 | TEST_F(NetEqDecodingTest, TestConcealmentEvents) { |
| 1607 | const int kNumConcealmentEvents = 19; |
| 1608 | const size_t kSamples = 10 * 16; |
| 1609 | const size_t kPayloadBytes = kSamples * 2; |
| 1610 | int seq_no = 0; |
| 1611 | RTPHeader rtp_info; |
| 1612 | rtp_info.ssrc = 0x1234; // Just an arbitrary SSRC. |
| 1613 | rtp_info.payloadType = 94; // PCM16b WB codec. |
| 1614 | rtp_info.markerBit = 0; |
| 1615 | const uint8_t payload[kPayloadBytes] = {0}; |
| 1616 | bool muted; |
| 1617 | |
| 1618 | for (int i = 0; i < kNumConcealmentEvents; i++) { |
| 1619 | // Insert some packets of 10 ms size. |
| 1620 | for (int j = 0; j < 10; j++) { |
| 1621 | rtp_info.sequenceNumber = seq_no++; |
| 1622 | rtp_info.timestamp = rtp_info.sequenceNumber * kSamples; |
| 1623 | neteq_->InsertPacket(rtp_info, payload, 0); |
| 1624 | neteq_->GetAudio(&out_frame_, &muted); |
| 1625 | } |
| 1626 | |
| 1627 | // Lose a number of packets. |
| 1628 | int num_lost = 1 + i; |
| 1629 | for (int j = 0; j < num_lost; j++) { |
| 1630 | seq_no++; |
| 1631 | neteq_->GetAudio(&out_frame_, &muted); |
| 1632 | } |
| 1633 | } |
| 1634 | |
| 1635 | // Check number of concealment events. |
| 1636 | NetEqLifetimeStatistics stats = neteq_->GetLifetimeStatistics(); |
| 1637 | EXPECT_EQ(kNumConcealmentEvents, static_cast<int>(stats.concealment_events)); |
| 1638 | } |
| 1639 | |
Gustaf Ullberg | b0a0207 | 2017-10-02 12:00:34 +0200 | [diff] [blame] | 1640 | // Test that the jitter buffer delay stat is computed correctly. |
| 1641 | void NetEqDecodingTestFaxMode::TestJitterBufferDelay(bool apply_packet_loss) { |
| 1642 | const int kNumPackets = 10; |
| 1643 | const int kDelayInNumPackets = 2; |
| 1644 | const int kPacketLenMs = 10; // All packets are of 10 ms size. |
| 1645 | const size_t kSamples = kPacketLenMs * 16; |
| 1646 | const size_t kPayloadBytes = kSamples * 2; |
| 1647 | RTPHeader rtp_info; |
| 1648 | rtp_info.ssrc = 0x1234; // Just an arbitrary SSRC. |
| 1649 | rtp_info.payloadType = 94; // PCM16b WB codec. |
| 1650 | rtp_info.markerBit = 0; |
| 1651 | const uint8_t payload[kPayloadBytes] = {0}; |
| 1652 | bool muted; |
| 1653 | int packets_sent = 0; |
| 1654 | int packets_received = 0; |
| 1655 | int expected_delay = 0; |
Chen Xing | 0acffb5 | 2019-01-15 15:46:29 +0100 | [diff] [blame] | 1656 | uint64_t expected_emitted_count = 0; |
Gustaf Ullberg | b0a0207 | 2017-10-02 12:00:34 +0200 | [diff] [blame] | 1657 | while (packets_received < kNumPackets) { |
| 1658 | // Insert packet. |
| 1659 | if (packets_sent < kNumPackets) { |
| 1660 | rtp_info.sequenceNumber = packets_sent++; |
| 1661 | rtp_info.timestamp = rtp_info.sequenceNumber * kSamples; |
| 1662 | neteq_->InsertPacket(rtp_info, payload, 0); |
| 1663 | } |
| 1664 | |
| 1665 | // Get packet. |
| 1666 | if (packets_sent > kDelayInNumPackets) { |
| 1667 | neteq_->GetAudio(&out_frame_, &muted); |
| 1668 | packets_received++; |
| 1669 | |
| 1670 | // The delay reported by the jitter buffer never exceeds |
| 1671 | // the number of samples previously fetched with GetAudio |
| 1672 | // (hence the min()). |
| 1673 | int packets_delay = std::min(packets_received, kDelayInNumPackets + 1); |
| 1674 | |
| 1675 | // The increase of the expected delay is the product of |
| 1676 | // the current delay of the jitter buffer in ms * the |
| 1677 | // number of samples that are sent for play out. |
| 1678 | int current_delay_ms = packets_delay * kPacketLenMs; |
| 1679 | expected_delay += current_delay_ms * kSamples; |
Chen Xing | 0acffb5 | 2019-01-15 15:46:29 +0100 | [diff] [blame] | 1680 | expected_emitted_count += kSamples; |
Gustaf Ullberg | b0a0207 | 2017-10-02 12:00:34 +0200 | [diff] [blame] | 1681 | } |
| 1682 | } |
| 1683 | |
| 1684 | if (apply_packet_loss) { |
| 1685 | // Extra call to GetAudio to cause concealment. |
| 1686 | neteq_->GetAudio(&out_frame_, &muted); |
| 1687 | } |
| 1688 | |
| 1689 | // Check jitter buffer delay. |
| 1690 | NetEqLifetimeStatistics stats = neteq_->GetLifetimeStatistics(); |
| 1691 | EXPECT_EQ(expected_delay, static_cast<int>(stats.jitter_buffer_delay_ms)); |
Chen Xing | 0acffb5 | 2019-01-15 15:46:29 +0100 | [diff] [blame] | 1692 | EXPECT_EQ(expected_emitted_count, stats.jitter_buffer_emitted_count); |
Gustaf Ullberg | b0a0207 | 2017-10-02 12:00:34 +0200 | [diff] [blame] | 1693 | } |
| 1694 | |
| 1695 | TEST_F(NetEqDecodingTestFaxMode, TestJitterBufferDelayWithoutLoss) { |
| 1696 | TestJitterBufferDelay(false); |
| 1697 | } |
| 1698 | |
| 1699 | TEST_F(NetEqDecodingTestFaxMode, TestJitterBufferDelayWithLoss) { |
| 1700 | TestJitterBufferDelay(true); |
| 1701 | } |
| 1702 | |
Jakob Ivarsson | 26c59ff | 2019-02-28 09:55:49 +0100 | [diff] [blame] | 1703 | TEST_F(NetEqDecodingTestFaxMode, TestJitterBufferDelayWithAcceleration) { |
| 1704 | const int kPacketLenMs = 10; // All packets are of 10 ms size. |
| 1705 | const size_t kSamples = kPacketLenMs * 16; |
| 1706 | const size_t kPayloadBytes = kSamples * 2; |
| 1707 | RTPHeader rtp_info; |
| 1708 | rtp_info.ssrc = 0x1234; // Just an arbitrary SSRC. |
| 1709 | rtp_info.payloadType = 94; // PCM16b WB codec. |
| 1710 | rtp_info.markerBit = 0; |
| 1711 | const uint8_t payload[kPayloadBytes] = {0}; |
| 1712 | |
| 1713 | neteq_->InsertPacket(rtp_info, payload, 0); |
| 1714 | |
| 1715 | bool muted; |
| 1716 | neteq_->GetAudio(&out_frame_, &muted); |
| 1717 | |
| 1718 | rtp_info.sequenceNumber += 1; |
| 1719 | rtp_info.timestamp += kSamples; |
| 1720 | neteq_->InsertPacket(rtp_info, payload, 0); |
| 1721 | rtp_info.sequenceNumber += 1; |
| 1722 | rtp_info.timestamp += kSamples; |
| 1723 | neteq_->InsertPacket(rtp_info, payload, 0); |
| 1724 | |
| 1725 | // We have two packets in the buffer and kAccelerate operation will |
| 1726 | // extract 20 ms of data. |
| 1727 | neteq_->GetAudio(&out_frame_, &muted, Operations::kAccelerate); |
| 1728 | |
| 1729 | // Check jitter buffer delay. |
| 1730 | NetEqLifetimeStatistics stats = neteq_->GetLifetimeStatistics(); |
| 1731 | EXPECT_EQ(10 * kSamples * 3, stats.jitter_buffer_delay_ms); |
| 1732 | EXPECT_EQ(kSamples * 3, stats.jitter_buffer_emitted_count); |
| 1733 | } |
| 1734 | |
Henrik Lundin | 7687ad5 | 2018-07-02 10:14:46 +0200 | [diff] [blame] | 1735 | namespace test { |
Henrik Lundin | 7687ad5 | 2018-07-02 10:14:46 +0200 | [diff] [blame] | 1736 | TEST(NetEqNoTimeStretchingMode, RunTest) { |
| 1737 | NetEq::Config config; |
| 1738 | config.for_test_no_time_stretching = true; |
| 1739 | auto codecs = NetEqTest::StandardDecoderMap(); |
Henrik Lundin | 7687ad5 | 2018-07-02 10:14:46 +0200 | [diff] [blame] | 1740 | NetEqPacketSourceInput::RtpHeaderExtensionMap rtp_ext_map = { |
| 1741 | {1, kRtpExtensionAudioLevel}, |
| 1742 | {3, kRtpExtensionAbsoluteSendTime}, |
| 1743 | {5, kRtpExtensionTransportSequenceNumber}, |
| 1744 | {7, kRtpExtensionVideoContentType}, |
| 1745 | {8, kRtpExtensionVideoTiming}}; |
| 1746 | std::unique_ptr<NetEqInput> input(new NetEqRtpDumpInput( |
| 1747 | webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp"), |
Bjorn Terelius | 5350d1c | 2018-10-11 16:51:23 +0200 | [diff] [blame] | 1748 | rtp_ext_map, absl::nullopt /*No SSRC filter*/)); |
Henrik Lundin | 7687ad5 | 2018-07-02 10:14:46 +0200 | [diff] [blame] | 1749 | std::unique_ptr<TimeLimitedNetEqInput> input_time_limit( |
| 1750 | new TimeLimitedNetEqInput(std::move(input), 20000)); |
| 1751 | std::unique_ptr<AudioSink> output(new VoidAudioSink); |
| 1752 | NetEqTest::Callbacks callbacks; |
Niels Möller | bd6dee8 | 2019-01-02 09:39:47 +0100 | [diff] [blame] | 1753 | NetEqTest test(config, CreateBuiltinAudioDecoderFactory(), codecs, nullptr, |
| 1754 | std::move(input_time_limit), std::move(output), callbacks); |
Henrik Lundin | 7687ad5 | 2018-07-02 10:14:46 +0200 | [diff] [blame] | 1755 | test.Run(); |
| 1756 | const auto stats = test.SimulationStats(); |
| 1757 | EXPECT_EQ(0, stats.accelerate_rate); |
| 1758 | EXPECT_EQ(0, stats.preemptive_rate); |
| 1759 | } |
Henrik Lundin | 7687ad5 | 2018-07-02 10:14:46 +0200 | [diff] [blame] | 1760 | |
| 1761 | } // namespace test |
henrik.lundin@webrtc.org | e7ce437 | 2014-01-09 14:01:55 +0000 | [diff] [blame] | 1762 | } // namespace webrtc |