turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 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 | |
pbos@webrtc.org | 12dc1a3 | 2013-08-05 16:22:53 +0000 | [diff] [blame] | 11 | #include <assert.h> |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 12 | #include <math.h> |
oprypin | 6e09d87 | 2017-08-31 03:21:39 -0700 | [diff] [blame] | 13 | #include <string.h> |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 14 | |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 15 | #include <iostream> |
kwiberg | 3747838 | 2016-02-14 20:40:57 -0800 | [diff] [blame] | 16 | #include <memory> |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 17 | |
Karl Wiberg | 5817d3d | 2018-04-06 10:06:42 +0200 | [diff] [blame] | 18 | #include "api/audio_codecs/builtin_audio_decoder_factory.h" |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 19 | #include "common_types.h" // NOLINT(build/include) |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #include "modules/audio_coding/codecs/audio_format_conversion.h" |
| 21 | #include "modules/audio_coding/include/audio_coding_module.h" |
| 22 | #include "modules/audio_coding/include/audio_coding_module_typedefs.h" |
| 23 | #include "modules/audio_coding/test/Channel.h" |
| 24 | #include "modules/audio_coding/test/PCMFile.h" |
| 25 | #include "modules/audio_coding/test/utility.h" |
| 26 | #include "rtc_base/flags.h" |
| 27 | #include "system_wrappers/include/event_wrapper.h" |
| 28 | #include "test/gtest.h" |
| 29 | #include "test/testsupport/fileutils.h" |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 30 | |
| 31 | DEFINE_string(codec, "isac", "Codec Name"); |
oprypin | 6e09d87 | 2017-08-31 03:21:39 -0700 | [diff] [blame] | 32 | DEFINE_int(sample_rate_hz, 16000, "Sampling rate in Hertz."); |
| 33 | DEFINE_int(num_channels, 1, "Number of Channels."); |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 34 | DEFINE_string(input_file, "", "Input file, PCM16 32 kHz, optional."); |
oprypin | 6e09d87 | 2017-08-31 03:21:39 -0700 | [diff] [blame] | 35 | DEFINE_int(delay, 0, "Delay in millisecond."); |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 36 | DEFINE_bool(dtx, false, "Enable DTX at the sender side."); |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 37 | DEFINE_bool(packet_loss, false, "Apply packet loss, c.f. Channel{.cc, .h}."); |
| 38 | DEFINE_bool(fec, false, "Use Forward Error Correction (FEC)."); |
oprypin | 6e09d87 | 2017-08-31 03:21:39 -0700 | [diff] [blame] | 39 | DEFINE_bool(help, false, "Print this message."); |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 40 | |
| 41 | namespace webrtc { |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 42 | |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 43 | namespace { |
| 44 | |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 45 | struct CodecSettings { |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 46 | char name[50]; |
| 47 | int sample_rate_hz; |
| 48 | int num_channels; |
| 49 | }; |
| 50 | |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 51 | struct AcmSettings { |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 52 | bool dtx; |
| 53 | bool fec; |
| 54 | }; |
| 55 | |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 56 | struct TestSettings { |
| 57 | CodecSettings codec; |
| 58 | AcmSettings acm; |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 59 | bool packet_loss; |
| 60 | }; |
| 61 | |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 62 | } // namespace |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 63 | |
| 64 | class DelayTest { |
| 65 | public: |
henrik.lundin@webrtc.org | adaf809 | 2014-04-17 08:29:10 +0000 | [diff] [blame] | 66 | DelayTest() |
Karl Wiberg | 5817d3d | 2018-04-06 10:06:42 +0200 | [diff] [blame] | 67 | : acm_a_(AudioCodingModule::Create( |
| 68 | AudioCodingModule::Config(CreateBuiltinAudioDecoderFactory()))), |
| 69 | acm_b_(AudioCodingModule::Create( |
| 70 | AudioCodingModule::Config(CreateBuiltinAudioDecoderFactory()))), |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 71 | channel_a2b_(new Channel), |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 72 | test_cntr_(0), |
| 73 | encoding_sample_rate_hz_(8000) {} |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 74 | |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 75 | ~DelayTest() { |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 76 | if (channel_a2b_ != NULL) { |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 77 | delete channel_a2b_; |
| 78 | channel_a2b_ = NULL; |
| 79 | } |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 80 | in_file_a_.Close(); |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 81 | } |
| 82 | |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 83 | void Initialize() { |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 84 | test_cntr_ = 0; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 85 | std::string file_name = |
| 86 | webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); |
oprypin | 6e09d87 | 2017-08-31 03:21:39 -0700 | [diff] [blame] | 87 | if (strlen(FLAG_input_file) > 0) |
| 88 | file_name = FLAG_input_file; |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 89 | in_file_a_.Open(file_name, 32000, "rb"); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 90 | ASSERT_EQ(0, acm_a_->InitializeReceiver()) |
| 91 | << "Couldn't initialize receiver.\n"; |
| 92 | ASSERT_EQ(0, acm_b_->InitializeReceiver()) |
| 93 | << "Couldn't initialize receiver.\n"; |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 94 | |
oprypin | 6e09d87 | 2017-08-31 03:21:39 -0700 | [diff] [blame] | 95 | if (FLAG_delay > 0) { |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 96 | ASSERT_EQ(0, acm_b_->SetMinimumPlayoutDelay(FLAG_delay)) |
| 97 | << "Failed to set minimum delay.\n"; |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 98 | } |
| 99 | |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 100 | int num_encoders = acm_a_->NumberOfCodecs(); |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 101 | CodecInst my_codec_param; |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 102 | for (int n = 0; n < num_encoders; n++) { |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 103 | EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param)) << "Failed to get codec."; |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 104 | if (STR_CASE_CMP(my_codec_param.plname, "opus") == 0) |
| 105 | my_codec_param.channels = 1; |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 106 | else if (my_codec_param.channels > 1) |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 107 | continue; |
| 108 | if (STR_CASE_CMP(my_codec_param.plname, "CN") == 0 && |
| 109 | my_codec_param.plfreq == 48000) |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 110 | continue; |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 111 | if (STR_CASE_CMP(my_codec_param.plname, "telephone-event") == 0) |
| 112 | continue; |
kwiberg | da2bf4e | 2016-10-24 13:47:09 -0700 | [diff] [blame] | 113 | ASSERT_EQ(true, |
| 114 | acm_b_->RegisterReceiveCodec(my_codec_param.pltype, |
| 115 | CodecInstToSdp(my_codec_param))); |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | // Create and connect the channel |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 119 | ASSERT_EQ(0, acm_a_->RegisterTransportCallback(channel_a2b_)) |
| 120 | << "Couldn't register Transport callback.\n"; |
andrew@webrtc.org | 89df092 | 2013-09-12 01:27:43 +0000 | [diff] [blame] | 121 | channel_a2b_->RegisterReceiverACM(acm_b_.get()); |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 124 | void Perform(const TestSettings* config, |
| 125 | size_t num_tests, |
| 126 | int duration_sec, |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 127 | const char* output_prefix) { |
| 128 | for (size_t n = 0; n < num_tests; ++n) { |
| 129 | ApplyConfig(config[n]); |
| 130 | Run(duration_sec, output_prefix); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | private: |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 135 | void ApplyConfig(const TestSettings& config) { |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 136 | printf("====================================\n"); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 137 | printf( |
| 138 | "Test %d \n" |
| 139 | "Codec: %s, %d kHz, %d channel(s)\n" |
| 140 | "ACM: DTX %s, FEC %s\n" |
| 141 | "Channel: %s\n", |
| 142 | ++test_cntr_, config.codec.name, config.codec.sample_rate_hz, |
| 143 | config.codec.num_channels, config.acm.dtx ? "on" : "off", |
| 144 | config.acm.fec ? "on" : "off", |
| 145 | config.packet_loss ? "with packet-loss" : "no packet-loss"); |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 146 | SendCodec(config.codec); |
| 147 | ConfigAcm(config.acm); |
| 148 | ConfigChannel(config.packet_loss); |
| 149 | } |
| 150 | |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 151 | void SendCodec(const CodecSettings& config) { |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 152 | CodecInst my_codec_param; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 153 | ASSERT_EQ( |
| 154 | 0, AudioCodingModule::Codec(config.name, &my_codec_param, |
| 155 | config.sample_rate_hz, config.num_channels)) |
| 156 | << "Specified codec is not supported.\n"; |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 157 | |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 158 | encoding_sample_rate_hz_ = my_codec_param.plfreq; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 159 | ASSERT_EQ(0, acm_a_->RegisterSendCodec(my_codec_param)) |
| 160 | << "Failed to register send-codec.\n"; |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 161 | } |
| 162 | |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 163 | void ConfigAcm(const AcmSettings& config) { |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 164 | ASSERT_EQ(0, acm_a_->SetVAD(config.dtx, config.dtx, VADAggr)) |
| 165 | << "Failed to set VAD.\n"; |
| 166 | ASSERT_EQ(0, acm_a_->SetREDStatus(config.fec)) << "Failed to set RED.\n"; |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | void ConfigChannel(bool packet_loss) { |
| 170 | channel_a2b_->SetFECTestWithPacketLoss(packet_loss); |
| 171 | } |
| 172 | |
| 173 | void OpenOutFile(const char* output_id) { |
| 174 | std::stringstream file_stream; |
oprypin | 6e09d87 | 2017-08-31 03:21:39 -0700 | [diff] [blame] | 175 | file_stream << "delay_test_" << FLAG_codec << "_" << FLAG_sample_rate_hz |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 176 | << "Hz" |
| 177 | << "_" << FLAG_delay << "ms.pcm"; |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 178 | std::cout << "Output file: " << file_stream.str() << std::endl << std::endl; |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 179 | std::string file_name = webrtc::test::OutputPath() + file_stream.str(); |
| 180 | out_file_b_.Open(file_name.c_str(), 32000, "wb"); |
| 181 | } |
| 182 | |
| 183 | void Run(int duration_sec, const char* output_prefix) { |
| 184 | OpenOutFile(output_prefix); |
| 185 | AudioFrame audio_frame; |
| 186 | uint32_t out_freq_hz_b = out_file_b_.SamplingFrequency(); |
| 187 | |
| 188 | int num_frames = 0; |
| 189 | int in_file_frames = 0; |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 190 | uint32_t received_ts; |
| 191 | double average_delay = 0; |
| 192 | double inst_delay_sec = 0; |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 193 | while (num_frames < (duration_sec * 100)) { |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 194 | if (in_file_a_.EndOfFile()) { |
| 195 | in_file_a_.Rewind(); |
| 196 | } |
| 197 | |
| 198 | // Print delay information every 16 frame |
| 199 | if ((num_frames & 0x3F) == 0x3F) { |
minyue@webrtc.org | c0bd7be | 2015-02-18 15:24:13 +0000 | [diff] [blame] | 200 | NetworkStatistics statistics; |
| 201 | acm_b_->GetNetworkStatistics(&statistics); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 202 | fprintf(stdout, |
| 203 | "delay: min=%3d max=%3d mean=%3d median=%3d" |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 204 | " ts-based average = %6.3f, " |
| 205 | "curr buff-lev = %4u opt buff-lev = %4u \n", |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 206 | statistics.minWaitingTimeMs, statistics.maxWaitingTimeMs, |
| 207 | statistics.meanWaitingTimeMs, statistics.medianWaitingTimeMs, |
| 208 | average_delay, statistics.currentBufferSize, |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 209 | statistics.preferredBufferSize); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 210 | fflush(stdout); |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | in_file_a_.Read10MsData(audio_frame); |
henrik.lundin@webrtc.org | f56c162 | 2015-03-02 12:29:30 +0000 | [diff] [blame] | 214 | ASSERT_GE(acm_a_->Add10MsData(audio_frame), 0); |
henrik.lundin | d4ccb00 | 2016-05-17 12:21:55 -0700 | [diff] [blame] | 215 | bool muted; |
| 216 | ASSERT_EQ(0, |
| 217 | acm_b_->PlayoutData10Ms(out_freq_hz_b, &audio_frame, &muted)); |
| 218 | RTC_DCHECK(!muted); |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 219 | out_file_b_.Write10MsData( |
yujo | 36b1a5f | 2017-06-12 12:45:32 -0700 | [diff] [blame] | 220 | audio_frame.data(), |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 221 | audio_frame.samples_per_channel_ * audio_frame.num_channels_); |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 222 | received_ts = channel_a2b_->LastInTimestamp(); |
Danil Chapovalov | b602123 | 2018-06-19 13:26:36 +0200 | [diff] [blame] | 223 | absl::optional<uint32_t> playout_timestamp = acm_b_->PlayoutTimestamp(); |
henrik.lundin | 9a410dd | 2016-04-06 01:39:22 -0700 | [diff] [blame] | 224 | ASSERT_TRUE(playout_timestamp); |
| 225 | inst_delay_sec = static_cast<uint32_t>(received_ts - *playout_timestamp) / |
| 226 | static_cast<double>(encoding_sample_rate_hz_); |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 227 | |
| 228 | if (num_frames > 10) |
| 229 | average_delay = 0.95 * average_delay + 0.05 * inst_delay_sec; |
| 230 | |
| 231 | ++num_frames; |
| 232 | ++in_file_frames; |
| 233 | } |
| 234 | out_file_b_.Close(); |
| 235 | } |
| 236 | |
kwiberg | 3747838 | 2016-02-14 20:40:57 -0800 | [diff] [blame] | 237 | std::unique_ptr<AudioCodingModule> acm_a_; |
| 238 | std::unique_ptr<AudioCodingModule> acm_b_; |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 239 | |
| 240 | Channel* channel_a2b_; |
| 241 | |
| 242 | PCMFile in_file_a_; |
| 243 | PCMFile out_file_b_; |
| 244 | int test_cntr_; |
| 245 | int encoding_sample_rate_hz_; |
| 246 | }; |
| 247 | |
andresp@webrtc.org | 185bae4 | 2013-05-14 08:02:25 +0000 | [diff] [blame] | 248 | } // namespace webrtc |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 249 | |
| 250 | int main(int argc, char* argv[]) { |
oprypin | 6e09d87 | 2017-08-31 03:21:39 -0700 | [diff] [blame] | 251 | if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true)) { |
| 252 | return 1; |
| 253 | } |
| 254 | if (FLAG_help) { |
| 255 | rtc::FlagList::Print(nullptr, false); |
| 256 | return 0; |
| 257 | } |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 258 | |
oprypin | 6e09d87 | 2017-08-31 03:21:39 -0700 | [diff] [blame] | 259 | webrtc::TestSettings test_setting; |
| 260 | strcpy(test_setting.codec.name, FLAG_codec); |
| 261 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 262 | if (FLAG_sample_rate_hz != 8000 && FLAG_sample_rate_hz != 16000 && |
| 263 | FLAG_sample_rate_hz != 32000 && FLAG_sample_rate_hz != 48000) { |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 264 | std::cout << "Invalid sampling rate.\n"; |
| 265 | return 1; |
| 266 | } |
oprypin | 6e09d87 | 2017-08-31 03:21:39 -0700 | [diff] [blame] | 267 | test_setting.codec.sample_rate_hz = FLAG_sample_rate_hz; |
| 268 | if (FLAG_num_channels < 1 || FLAG_num_channels > 2) { |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 269 | std::cout << "Only mono and stereo are supported.\n"; |
| 270 | return 1; |
| 271 | } |
oprypin | 6e09d87 | 2017-08-31 03:21:39 -0700 | [diff] [blame] | 272 | test_setting.codec.num_channels = FLAG_num_channels; |
| 273 | test_setting.acm.dtx = FLAG_dtx; |
| 274 | test_setting.acm.fec = FLAG_fec; |
| 275 | test_setting.packet_loss = FLAG_packet_loss; |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 276 | |
henrik.lundin@webrtc.org | adaf809 | 2014-04-17 08:29:10 +0000 | [diff] [blame] | 277 | webrtc::DelayTest delay_test; |
turaj@webrtc.org | 7a05ae5 | 2013-11-18 18:16:53 +0000 | [diff] [blame] | 278 | delay_test.Initialize(); |
| 279 | delay_test.Perform(&test_setting, 1, 240, "delay_test"); |
| 280 | return 0; |
| 281 | } |