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