blob: 95af4d461a005003d33e14656936e11ab08f63cb [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
andrew@webrtc.org9dc45da2012-05-23 15:39:01 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#include "modules/audio_coding/test/iSACTest.h"
tina.legrand@webrtc.org73222cf2013-03-15 13:29:17 +000012
pbos@webrtc.org12dc1a32013-08-05 16:22:53 +000013#include <ctype.h>
niklase@google.com470e71d2011-07-07 08:21:25 +000014#include <stdio.h>
15#include <string.h>
16
kwiberg77eab702016-09-28 17:42:01 -070017#ifdef _WIN32
niklase@google.com470e71d2011-07-07 08:21:25 +000018#include <windows.h>
kwiberg77eab702016-09-28 17:42:01 -070019#elif defined(WEBRTC_LINUX)
pbos@webrtc.org12dc1a32013-08-05 16:22:53 +000020#include <time.h>
niklase@google.com470e71d2011-07-07 08:21:25 +000021#else
22#include <sys/time.h>
23#include <time.h>
andrew@webrtc.org89df0922013-09-12 01:27:43 +000024#endif
niklase@google.com470e71d2011-07-07 08:21:25 +000025
Karl Wiberg5817d3d2018-04-06 10:06:42 +020026#include "api/audio_codecs/builtin_audio_decoder_factory.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020027#include "modules/audio_coding/codecs/audio_format_conversion.h"
28#include "modules/audio_coding/test/utility.h"
Jonas Olsson366a50c2018-09-06 13:41:30 +020029#include "rtc_base/strings/string_builder.h"
Danil Chapovalovdb128562018-09-17 13:11:50 +020030#include "rtc_base/timeutils.h"
Niels Möllerfe3240a2018-09-06 16:47:42 +020031#include "system_wrappers/include/sleep.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020032#include "test/testsupport/fileutils.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000033
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000034namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000035
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000036void SetISACConfigDefault(ACMTestISACConfig& isacConfig) {
37 isacConfig.currentRateBitPerSec = 0;
38 isacConfig.currentFrameSizeMsec = 0;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000039 isacConfig.encodingMode = -1;
40 isacConfig.initRateBitPerSec = 0;
41 isacConfig.initFrameSizeInMsec = 0;
42 isacConfig.enforceFrameSize = false;
43 return;
niklase@google.com470e71d2011-07-07 08:21:25 +000044}
45
Yves Gerey665174f2018-06-19 15:03:05 +020046int16_t SetISAConfig(ACMTestISACConfig& isacConfig,
47 AudioCodingModule* acm,
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000048 int testMode) {
Yves Gerey665174f2018-06-19 15:03:05 +020049 if ((isacConfig.currentRateBitPerSec != 0) ||
50 (isacConfig.currentFrameSizeMsec != 0)) {
kwiberg1fd4a4a2015-11-03 11:20:50 -080051 auto sendCodec = acm->SendCodec();
52 EXPECT_TRUE(sendCodec);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000053 if (isacConfig.currentRateBitPerSec < 0) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000054 // Register iSAC in adaptive (channel-dependent) mode.
kwiberg1fd4a4a2015-11-03 11:20:50 -080055 sendCodec->rate = -1;
56 EXPECT_EQ(0, acm->RegisterSendCodec(*sendCodec));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000057 } else {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000058 if (isacConfig.currentRateBitPerSec != 0) {
kwiberg1fd4a4a2015-11-03 11:20:50 -080059 sendCodec->rate = isacConfig.currentRateBitPerSec;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000060 }
61 if (isacConfig.currentFrameSizeMsec != 0) {
Yves Gerey665174f2018-06-19 15:03:05 +020062 sendCodec->pacsize =
63 isacConfig.currentFrameSizeMsec * (sendCodec->plfreq / 1000);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000064 }
kwiberg1fd4a4a2015-11-03 11:20:50 -080065 EXPECT_EQ(0, acm->RegisterSendCodec(*sendCodec));
niklase@google.com470e71d2011-07-07 08:21:25 +000066 }
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000067 }
niklase@google.com470e71d2011-07-07 08:21:25 +000068
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000069 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000070}
71
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +000072ISACTest::ISACTest(int testMode)
Karl Wiberg5817d3d2018-04-06 10:06:42 +020073 : _acmA(AudioCodingModule::Create(
74 AudioCodingModule::Config(CreateBuiltinAudioDecoderFactory()))),
75 _acmB(AudioCodingModule::Create(
76 AudioCodingModule::Config(CreateBuiltinAudioDecoderFactory()))),
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +000077 _testMode(testMode) {}
niklase@google.com470e71d2011-07-07 08:21:25 +000078
turaj@webrtc.org55e17232013-10-29 04:40:09 +000079ISACTest::~ISACTest() {}
niklase@google.com470e71d2011-07-07 08:21:25 +000080
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000081void ISACTest::Setup() {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000082 int codecCntr;
83 CodecInst codecParam;
niklase@google.com470e71d2011-07-07 08:21:25 +000084
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000085 for (codecCntr = 0; codecCntr < AudioCodingModule::NumberOfCodecs();
Yves Gerey665174f2018-06-19 15:03:05 +020086 codecCntr++) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000087 EXPECT_EQ(0, AudioCodingModule::Codec(codecCntr, &codecParam));
Yves Gerey665174f2018-06-19 15:03:05 +020088 if (!STR_CASE_CMP(codecParam.plname, "ISAC") &&
89 codecParam.plfreq == 16000) {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000090 memcpy(&_paramISAC16kHz, &codecParam, sizeof(CodecInst));
91 _idISAC16kHz = codecCntr;
niklase@google.com470e71d2011-07-07 08:21:25 +000092 }
Yves Gerey665174f2018-06-19 15:03:05 +020093 if (!STR_CASE_CMP(codecParam.plname, "ISAC") &&
94 codecParam.plfreq == 32000) {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000095 memcpy(&_paramISAC32kHz, &codecParam, sizeof(CodecInst));
96 _idISAC32kHz = codecCntr;
niklase@google.com470e71d2011-07-07 08:21:25 +000097 }
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000098 }
niklase@google.com470e71d2011-07-07 08:21:25 +000099
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000100 // Register both iSAC-wb & iSAC-swb in both sides as receiver codecs.
kwibergda2bf4e2016-10-24 13:47:09 -0700101 EXPECT_EQ(true, _acmA->RegisterReceiveCodec(_paramISAC16kHz.pltype,
102 CodecInstToSdp(_paramISAC16kHz)));
103 EXPECT_EQ(true, _acmA->RegisterReceiveCodec(_paramISAC32kHz.pltype,
104 CodecInstToSdp(_paramISAC32kHz)));
105 EXPECT_EQ(true, _acmB->RegisterReceiveCodec(_paramISAC16kHz.pltype,
106 CodecInstToSdp(_paramISAC16kHz)));
107 EXPECT_EQ(true, _acmB->RegisterReceiveCodec(_paramISAC32kHz.pltype,
108 CodecInstToSdp(_paramISAC32kHz)));
niklase@google.com470e71d2011-07-07 08:21:25 +0000109
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000110 //--- Set A-to-B channel
turaj@webrtc.org55e17232013-10-29 04:40:09 +0000111 _channel_A2B.reset(new Channel);
112 EXPECT_EQ(0, _acmA->RegisterTransportCallback(_channel_A2B.get()));
113 _channel_A2B->RegisterReceiverACM(_acmB.get());
niklase@google.com470e71d2011-07-07 08:21:25 +0000114
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000115 //--- Set B-to-A channel
turaj@webrtc.org55e17232013-10-29 04:40:09 +0000116 _channel_B2A.reset(new Channel);
117 EXPECT_EQ(0, _acmB->RegisterTransportCallback(_channel_B2A.get()));
118 _channel_B2A->RegisterReceiverACM(_acmA.get());
niklase@google.com470e71d2011-07-07 08:21:25 +0000119
Yves Gerey665174f2018-06-19 15:03:05 +0200120 file_name_swb_ =
121 webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
niklase@google.com470e71d2011-07-07 08:21:25 +0000122
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000123 EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
124 EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000125
126 _inFileA.Open(file_name_swb_, 32000, "rb");
Henrik Lundin4d682082015-12-10 16:24:39 +0100127 // Set test length to 500 ms (50 blocks of 10 ms each).
128 _inFileA.SetNum10MsBlocksToRead(50);
129 // Fast-forward 1 second (100 blocks) since the files start with silence.
130 _inFileA.FastForward(100);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000131 std::string fileNameA = webrtc::test::OutputPath() + "testisac_a.pcm";
132 std::string fileNameB = webrtc::test::OutputPath() + "testisac_b.pcm";
133 _outFileA.Open(fileNameA, 32000, "wb");
134 _outFileB.Open(fileNameB, 32000, "wb");
135
136 while (!_inFileA.EndOfFile()) {
137 Run10ms();
138 }
139 CodecInst receiveCodec;
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000140 EXPECT_EQ(0, _acmA->ReceiveCodec(&receiveCodec));
141 EXPECT_EQ(0, _acmB->ReceiveCodec(&receiveCodec));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000142
143 _inFileA.Close();
144 _outFileA.Close();
145 _outFileB.Close();
niklase@google.com470e71d2011-07-07 08:21:25 +0000146}
147
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000148void ISACTest::Perform() {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000149 Setup();
niklase@google.com470e71d2011-07-07 08:21:25 +0000150
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000151 int16_t testNr = 0;
152 ACMTestISACConfig wbISACConfig;
153 ACMTestISACConfig swbISACConfig;
niklase@google.com470e71d2011-07-07 08:21:25 +0000154
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000155 SetISACConfigDefault(wbISACConfig);
156 SetISACConfigDefault(swbISACConfig);
niklase@google.com470e71d2011-07-07 08:21:25 +0000157
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000158 wbISACConfig.currentRateBitPerSec = -1;
159 swbISACConfig.currentRateBitPerSec = -1;
160 testNr++;
161 EncodeDecode(testNr, wbISACConfig, swbISACConfig);
162
163 if (_testMode != 0) {
niklase@google.com470e71d2011-07-07 08:21:25 +0000164 SetISACConfigDefault(wbISACConfig);
165 SetISACConfigDefault(swbISACConfig);
166
167 wbISACConfig.currentRateBitPerSec = -1;
168 swbISACConfig.currentRateBitPerSec = -1;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000169 wbISACConfig.initRateBitPerSec = 13000;
170 wbISACConfig.initFrameSizeInMsec = 60;
171 swbISACConfig.initRateBitPerSec = 20000;
172 swbISACConfig.initFrameSizeInMsec = 30;
niklase@google.com470e71d2011-07-07 08:21:25 +0000173 testNr++;
174 EncodeDecode(testNr, wbISACConfig, swbISACConfig);
175
niklase@google.com470e71d2011-07-07 08:21:25 +0000176 SetISACConfigDefault(wbISACConfig);
177 SetISACConfigDefault(swbISACConfig);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000178
179 wbISACConfig.currentRateBitPerSec = 20000;
180 swbISACConfig.currentRateBitPerSec = 48000;
niklase@google.com470e71d2011-07-07 08:21:25 +0000181 testNr++;
182 EncodeDecode(testNr, wbISACConfig, swbISACConfig);
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000183
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000184 wbISACConfig.currentRateBitPerSec = 16000;
185 swbISACConfig.currentRateBitPerSec = 30000;
186 wbISACConfig.currentFrameSizeMsec = 60;
niklase@google.com470e71d2011-07-07 08:21:25 +0000187 testNr++;
188 EncodeDecode(testNr, wbISACConfig, swbISACConfig);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000189 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000190
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000191 SetISACConfigDefault(wbISACConfig);
192 SetISACConfigDefault(swbISACConfig);
193 testNr++;
194 EncodeDecode(testNr, wbISACConfig, swbISACConfig);
niklase@google.com470e71d2011-07-07 08:21:25 +0000195
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000196 testNr++;
197 if (_testMode == 0) {
198 SwitchingSamplingRate(testNr, 4);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000199 } else {
200 SwitchingSamplingRate(testNr, 80);
201 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000202}
203
andresp@webrtc.orgd0b436a2014-01-13 13:15:59 +0000204void ISACTest::Run10ms() {
205 AudioFrame audioFrame;
206 EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0);
henrik.lundin@webrtc.orgf56c1622015-03-02 12:29:30 +0000207 EXPECT_GE(_acmA->Add10MsData(audioFrame), 0);
208 EXPECT_GE(_acmB->Add10MsData(audioFrame), 0);
henrik.lundind4ccb002016-05-17 12:21:55 -0700209 bool muted;
210 EXPECT_EQ(0, _acmA->PlayoutData10Ms(32000, &audioFrame, &muted));
211 ASSERT_FALSE(muted);
andresp@webrtc.orgd0b436a2014-01-13 13:15:59 +0000212 _outFileA.Write10MsData(audioFrame);
henrik.lundind4ccb002016-05-17 12:21:55 -0700213 EXPECT_EQ(0, _acmB->PlayoutData10Ms(32000, &audioFrame, &muted));
214 ASSERT_FALSE(muted);
andresp@webrtc.orgd0b436a2014-01-13 13:15:59 +0000215 _outFileB.Write10MsData(audioFrame);
216}
217
Yves Gerey665174f2018-06-19 15:03:05 +0200218void ISACTest::EncodeDecode(int testNr,
219 ACMTestISACConfig& wbISACConfig,
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000220 ACMTestISACConfig& swbISACConfig) {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000221 // Files in Side A and B
222 _inFileA.Open(file_name_swb_, 32000, "rb", true);
223 _inFileB.Open(file_name_swb_, 32000, "rb", true);
224
225 std::string file_name_out;
Jonas Olsson366a50c2018-09-06 13:41:30 +0200226 rtc::StringBuilder file_stream_a;
227 rtc::StringBuilder file_stream_b;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000228 file_stream_a << webrtc::test::OutputPath();
229 file_stream_b << webrtc::test::OutputPath();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000230 file_stream_a << "out_iSACTest_A_" << testNr << ".pcm";
231 file_stream_b << "out_iSACTest_B_" << testNr << ".pcm";
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000232 file_name_out = file_stream_a.str();
233 _outFileA.Open(file_name_out, 32000, "wb");
234 file_name_out = file_stream_b.str();
235 _outFileB.Open(file_name_out, 32000, "wb");
236
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000237 EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC16kHz));
238 EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
239 EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC32kHz));
240 EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000241
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000242 // Side A is sending super-wideband, and side B is sending wideband.
turaj@webrtc.org55e17232013-10-29 04:40:09 +0000243 SetISAConfig(swbISACConfig, _acmA.get(), _testMode);
244 SetISAConfig(wbISACConfig, _acmB.get(), _testMode);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000245
246 bool adaptiveMode = false;
Yves Gerey665174f2018-06-19 15:03:05 +0200247 if ((swbISACConfig.currentRateBitPerSec == -1) ||
248 (wbISACConfig.currentRateBitPerSec == -1)) {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000249 adaptiveMode = true;
250 }
251 _myTimer.Reset();
252 _channel_A2B->ResetStats();
253 _channel_B2A->ResetStats();
254
255 char currentTime[500];
Niels Möllerfe3240a2018-09-06 16:47:42 +0200256 int64_t time_ms = rtc::TimeMillis();
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000257 while (!(_inFileA.EndOfFile() || _inFileA.Rewinded())) {
258 Run10ms();
259 _myTimer.Tick10ms();
260 _myTimer.CurrentTimeHMS(currentTime);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000261
262 if ((adaptiveMode) && (_testMode != 0)) {
Niels Möllerfe3240a2018-09-06 16:47:42 +0200263 time_ms += 10;
264 int64_t time_left_ms = time_ms - rtc::TimeMillis();
265 if (time_left_ms > 0) {
266 SleepMs(time_left_ms);
267 }
268
kwiberg1fd4a4a2015-11-03 11:20:50 -0800269 EXPECT_TRUE(_acmA->SendCodec());
270 EXPECT_TRUE(_acmB->SendCodec());
niklase@google.com470e71d2011-07-07 08:21:25 +0000271 }
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000272 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000273
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000274 if (_testMode != 0) {
275 printf("\n\nSide A statistics\n\n");
276 _channel_A2B->PrintStats(_paramISAC32kHz);
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000277
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000278 printf("\n\nSide B statistics\n\n");
279 _channel_B2A->PrintStats(_paramISAC16kHz);
280 }
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000281
andresp@webrtc.orgd0b436a2014-01-13 13:15:59 +0000282 _channel_A2B->ResetStats();
283 _channel_B2A->ResetStats();
284
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000285 _outFileA.Close();
286 _outFileB.Close();
287 _inFileA.Close();
288 _inFileB.Close();
niklase@google.com470e71d2011-07-07 08:21:25 +0000289}
290
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000291void ISACTest::SwitchingSamplingRate(int testNr, int maxSampRateChange) {
292 // Files in Side A
293 _inFileA.Open(file_name_swb_, 32000, "rb");
294 _inFileB.Open(file_name_swb_, 32000, "rb");
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000295
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000296 std::string file_name_out;
Jonas Olsson366a50c2018-09-06 13:41:30 +0200297 rtc::StringBuilder file_stream_a;
298 rtc::StringBuilder file_stream_b;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000299 file_stream_a << webrtc::test::OutputPath();
300 file_stream_b << webrtc::test::OutputPath();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000301 file_stream_a << "out_iSACTest_A_" << testNr << ".pcm";
302 file_stream_b << "out_iSACTest_B_" << testNr << ".pcm";
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000303 file_name_out = file_stream_a.str();
304 _outFileA.Open(file_name_out, 32000, "wb");
305 file_name_out = file_stream_b.str();
306 _outFileB.Open(file_name_out, 32000, "wb");
niklase@google.com470e71d2011-07-07 08:21:25 +0000307
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000308 // Start with side A sending super-wideband and side B seding wideband.
309 // Toggle sending wideband/super-wideband in this test.
310 EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
311 EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000312
313 int numSendCodecChanged = 0;
314 _myTimer.Reset();
315 char currentTime[50];
316 while (numSendCodecChanged < (maxSampRateChange << 1)) {
317 Run10ms();
318 _myTimer.Tick10ms();
319 _myTimer.CurrentTimeHMS(currentTime);
320 if (_testMode == 2)
321 printf("\r%s", currentTime);
322 if (_inFileA.EndOfFile()) {
323 if (_inFileA.SamplingFrequency() == 16000) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000324 // Switch side A to send super-wideband.
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000325 _inFileA.Close();
326 _inFileA.Open(file_name_swb_, 32000, "rb");
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000327 EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000328 } else {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000329 // Switch side A to send wideband.
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000330 _inFileA.Close();
331 _inFileA.Open(file_name_swb_, 32000, "rb");
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000332 EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC16kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000333 }
334 numSendCodecChanged++;
niklase@google.com470e71d2011-07-07 08:21:25 +0000335 }
336
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000337 if (_inFileB.EndOfFile()) {
338 if (_inFileB.SamplingFrequency() == 16000) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000339 // Switch side B to send super-wideband.
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000340 _inFileB.Close();
341 _inFileB.Open(file_name_swb_, 32000, "rb");
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000342 EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC32kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000343 } else {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000344 // Switch side B to send wideband.
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000345 _inFileB.Close();
346 _inFileB.Open(file_name_swb_, 32000, "rb");
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000347 EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000348 }
349 numSendCodecChanged++;
niklase@google.com470e71d2011-07-07 08:21:25 +0000350 }
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000351 }
352 _outFileA.Close();
353 _outFileB.Close();
354 _inFileA.Close();
355 _inFileB.Close();
niklase@google.com470e71d2011-07-07 08:21:25 +0000356}
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000357
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000358} // namespace webrtc