blob: 009b76c8c43dd8745f5c86ab46934335c833177d [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"
Niels Moller85e6e822018-09-04 11:49:57 +000030#include "system_wrappers/include/event_wrapper.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020031#include "test/testsupport/fileutils.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000032
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000033namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000034
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000035void SetISACConfigDefault(ACMTestISACConfig& isacConfig) {
36 isacConfig.currentRateBitPerSec = 0;
37 isacConfig.currentFrameSizeMsec = 0;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000038 isacConfig.encodingMode = -1;
39 isacConfig.initRateBitPerSec = 0;
40 isacConfig.initFrameSizeInMsec = 0;
41 isacConfig.enforceFrameSize = false;
42 return;
niklase@google.com470e71d2011-07-07 08:21:25 +000043}
44
Yves Gerey665174f2018-06-19 15:03:05 +020045int16_t SetISAConfig(ACMTestISACConfig& isacConfig,
46 AudioCodingModule* acm,
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000047 int testMode) {
Yves Gerey665174f2018-06-19 15:03:05 +020048 if ((isacConfig.currentRateBitPerSec != 0) ||
49 (isacConfig.currentFrameSizeMsec != 0)) {
kwiberg1fd4a4a2015-11-03 11:20:50 -080050 auto sendCodec = acm->SendCodec();
51 EXPECT_TRUE(sendCodec);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000052 if (isacConfig.currentRateBitPerSec < 0) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000053 // Register iSAC in adaptive (channel-dependent) mode.
kwiberg1fd4a4a2015-11-03 11:20:50 -080054 sendCodec->rate = -1;
55 EXPECT_EQ(0, acm->RegisterSendCodec(*sendCodec));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000056 } else {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000057 if (isacConfig.currentRateBitPerSec != 0) {
kwiberg1fd4a4a2015-11-03 11:20:50 -080058 sendCodec->rate = isacConfig.currentRateBitPerSec;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000059 }
60 if (isacConfig.currentFrameSizeMsec != 0) {
Yves Gerey665174f2018-06-19 15:03:05 +020061 sendCodec->pacsize =
62 isacConfig.currentFrameSizeMsec * (sendCodec->plfreq / 1000);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000063 }
kwiberg1fd4a4a2015-11-03 11:20:50 -080064 EXPECT_EQ(0, acm->RegisterSendCodec(*sendCodec));
niklase@google.com470e71d2011-07-07 08:21:25 +000065 }
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000066 }
niklase@google.com470e71d2011-07-07 08:21:25 +000067
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000068 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000069}
70
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +000071ISACTest::ISACTest(int testMode)
Karl Wiberg5817d3d2018-04-06 10:06:42 +020072 : _acmA(AudioCodingModule::Create(
73 AudioCodingModule::Config(CreateBuiltinAudioDecoderFactory()))),
74 _acmB(AudioCodingModule::Create(
75 AudioCodingModule::Config(CreateBuiltinAudioDecoderFactory()))),
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +000076 _testMode(testMode) {}
niklase@google.com470e71d2011-07-07 08:21:25 +000077
turaj@webrtc.org55e17232013-10-29 04:40:09 +000078ISACTest::~ISACTest() {}
niklase@google.com470e71d2011-07-07 08:21:25 +000079
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000080void ISACTest::Setup() {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000081 int codecCntr;
82 CodecInst codecParam;
niklase@google.com470e71d2011-07-07 08:21:25 +000083
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000084 for (codecCntr = 0; codecCntr < AudioCodingModule::NumberOfCodecs();
Yves Gerey665174f2018-06-19 15:03:05 +020085 codecCntr++) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000086 EXPECT_EQ(0, AudioCodingModule::Codec(codecCntr, &codecParam));
Yves Gerey665174f2018-06-19 15:03:05 +020087 if (!STR_CASE_CMP(codecParam.plname, "ISAC") &&
88 codecParam.plfreq == 16000) {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000089 memcpy(&_paramISAC16kHz, &codecParam, sizeof(CodecInst));
90 _idISAC16kHz = codecCntr;
niklase@google.com470e71d2011-07-07 08:21:25 +000091 }
Yves Gerey665174f2018-06-19 15:03:05 +020092 if (!STR_CASE_CMP(codecParam.plname, "ISAC") &&
93 codecParam.plfreq == 32000) {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000094 memcpy(&_paramISAC32kHz, &codecParam, sizeof(CodecInst));
95 _idISAC32kHz = codecCntr;
niklase@google.com470e71d2011-07-07 08:21:25 +000096 }
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000097 }
niklase@google.com470e71d2011-07-07 08:21:25 +000098
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000099 // Register both iSAC-wb & iSAC-swb in both sides as receiver codecs.
kwibergda2bf4e2016-10-24 13:47:09 -0700100 EXPECT_EQ(true, _acmA->RegisterReceiveCodec(_paramISAC16kHz.pltype,
101 CodecInstToSdp(_paramISAC16kHz)));
102 EXPECT_EQ(true, _acmA->RegisterReceiveCodec(_paramISAC32kHz.pltype,
103 CodecInstToSdp(_paramISAC32kHz)));
104 EXPECT_EQ(true, _acmB->RegisterReceiveCodec(_paramISAC16kHz.pltype,
105 CodecInstToSdp(_paramISAC16kHz)));
106 EXPECT_EQ(true, _acmB->RegisterReceiveCodec(_paramISAC32kHz.pltype,
107 CodecInstToSdp(_paramISAC32kHz)));
niklase@google.com470e71d2011-07-07 08:21:25 +0000108
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000109 //--- Set A-to-B channel
turaj@webrtc.org55e17232013-10-29 04:40:09 +0000110 _channel_A2B.reset(new Channel);
111 EXPECT_EQ(0, _acmA->RegisterTransportCallback(_channel_A2B.get()));
112 _channel_A2B->RegisterReceiverACM(_acmB.get());
niklase@google.com470e71d2011-07-07 08:21:25 +0000113
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000114 //--- Set B-to-A channel
turaj@webrtc.org55e17232013-10-29 04:40:09 +0000115 _channel_B2A.reset(new Channel);
116 EXPECT_EQ(0, _acmB->RegisterTransportCallback(_channel_B2A.get()));
117 _channel_B2A->RegisterReceiverACM(_acmA.get());
niklase@google.com470e71d2011-07-07 08:21:25 +0000118
Yves Gerey665174f2018-06-19 15:03:05 +0200119 file_name_swb_ =
120 webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
niklase@google.com470e71d2011-07-07 08:21:25 +0000121
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000122 EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
123 EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000124
125 _inFileA.Open(file_name_swb_, 32000, "rb");
Henrik Lundin4d682082015-12-10 16:24:39 +0100126 // Set test length to 500 ms (50 blocks of 10 ms each).
127 _inFileA.SetNum10MsBlocksToRead(50);
128 // Fast-forward 1 second (100 blocks) since the files start with silence.
129 _inFileA.FastForward(100);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000130 std::string fileNameA = webrtc::test::OutputPath() + "testisac_a.pcm";
131 std::string fileNameB = webrtc::test::OutputPath() + "testisac_b.pcm";
132 _outFileA.Open(fileNameA, 32000, "wb");
133 _outFileB.Open(fileNameB, 32000, "wb");
134
135 while (!_inFileA.EndOfFile()) {
136 Run10ms();
137 }
138 CodecInst receiveCodec;
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000139 EXPECT_EQ(0, _acmA->ReceiveCodec(&receiveCodec));
140 EXPECT_EQ(0, _acmB->ReceiveCodec(&receiveCodec));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000141
142 _inFileA.Close();
143 _outFileA.Close();
144 _outFileB.Close();
niklase@google.com470e71d2011-07-07 08:21:25 +0000145}
146
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000147void ISACTest::Perform() {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000148 Setup();
niklase@google.com470e71d2011-07-07 08:21:25 +0000149
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000150 int16_t testNr = 0;
151 ACMTestISACConfig wbISACConfig;
152 ACMTestISACConfig swbISACConfig;
niklase@google.com470e71d2011-07-07 08:21:25 +0000153
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000154 SetISACConfigDefault(wbISACConfig);
155 SetISACConfigDefault(swbISACConfig);
niklase@google.com470e71d2011-07-07 08:21:25 +0000156
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000157 wbISACConfig.currentRateBitPerSec = -1;
158 swbISACConfig.currentRateBitPerSec = -1;
159 testNr++;
160 EncodeDecode(testNr, wbISACConfig, swbISACConfig);
161
162 if (_testMode != 0) {
niklase@google.com470e71d2011-07-07 08:21:25 +0000163 SetISACConfigDefault(wbISACConfig);
164 SetISACConfigDefault(swbISACConfig);
165
166 wbISACConfig.currentRateBitPerSec = -1;
167 swbISACConfig.currentRateBitPerSec = -1;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000168 wbISACConfig.initRateBitPerSec = 13000;
169 wbISACConfig.initFrameSizeInMsec = 60;
170 swbISACConfig.initRateBitPerSec = 20000;
171 swbISACConfig.initFrameSizeInMsec = 30;
niklase@google.com470e71d2011-07-07 08:21:25 +0000172 testNr++;
173 EncodeDecode(testNr, wbISACConfig, swbISACConfig);
174
niklase@google.com470e71d2011-07-07 08:21:25 +0000175 SetISACConfigDefault(wbISACConfig);
176 SetISACConfigDefault(swbISACConfig);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000177
178 wbISACConfig.currentRateBitPerSec = 20000;
179 swbISACConfig.currentRateBitPerSec = 48000;
niklase@google.com470e71d2011-07-07 08:21:25 +0000180 testNr++;
181 EncodeDecode(testNr, wbISACConfig, swbISACConfig);
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000182
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000183 wbISACConfig.currentRateBitPerSec = 16000;
184 swbISACConfig.currentRateBitPerSec = 30000;
185 wbISACConfig.currentFrameSizeMsec = 60;
niklase@google.com470e71d2011-07-07 08:21:25 +0000186 testNr++;
187 EncodeDecode(testNr, wbISACConfig, swbISACConfig);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000188 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000189
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000190 SetISACConfigDefault(wbISACConfig);
191 SetISACConfigDefault(swbISACConfig);
192 testNr++;
193 EncodeDecode(testNr, wbISACConfig, swbISACConfig);
niklase@google.com470e71d2011-07-07 08:21:25 +0000194
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000195 testNr++;
196 if (_testMode == 0) {
197 SwitchingSamplingRate(testNr, 4);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000198 } else {
199 SwitchingSamplingRate(testNr, 80);
200 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000201}
202
andresp@webrtc.orgd0b436a2014-01-13 13:15:59 +0000203void ISACTest::Run10ms() {
204 AudioFrame audioFrame;
205 EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0);
henrik.lundin@webrtc.orgf56c1622015-03-02 12:29:30 +0000206 EXPECT_GE(_acmA->Add10MsData(audioFrame), 0);
207 EXPECT_GE(_acmB->Add10MsData(audioFrame), 0);
henrik.lundind4ccb002016-05-17 12:21:55 -0700208 bool muted;
209 EXPECT_EQ(0, _acmA->PlayoutData10Ms(32000, &audioFrame, &muted));
210 ASSERT_FALSE(muted);
andresp@webrtc.orgd0b436a2014-01-13 13:15:59 +0000211 _outFileA.Write10MsData(audioFrame);
henrik.lundind4ccb002016-05-17 12:21:55 -0700212 EXPECT_EQ(0, _acmB->PlayoutData10Ms(32000, &audioFrame, &muted));
213 ASSERT_FALSE(muted);
andresp@webrtc.orgd0b436a2014-01-13 13:15:59 +0000214 _outFileB.Write10MsData(audioFrame);
215}
216
Yves Gerey665174f2018-06-19 15:03:05 +0200217void ISACTest::EncodeDecode(int testNr,
218 ACMTestISACConfig& wbISACConfig,
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000219 ACMTestISACConfig& swbISACConfig) {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000220 // Files in Side A and B
221 _inFileA.Open(file_name_swb_, 32000, "rb", true);
222 _inFileB.Open(file_name_swb_, 32000, "rb", true);
223
224 std::string file_name_out;
Jonas Olsson366a50c2018-09-06 13:41:30 +0200225 rtc::StringBuilder file_stream_a;
226 rtc::StringBuilder file_stream_b;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000227 file_stream_a << webrtc::test::OutputPath();
228 file_stream_b << webrtc::test::OutputPath();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000229 file_stream_a << "out_iSACTest_A_" << testNr << ".pcm";
230 file_stream_b << "out_iSACTest_B_" << testNr << ".pcm";
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000231 file_name_out = file_stream_a.str();
232 _outFileA.Open(file_name_out, 32000, "wb");
233 file_name_out = file_stream_b.str();
234 _outFileB.Open(file_name_out, 32000, "wb");
235
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000236 EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC16kHz));
237 EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
238 EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC32kHz));
239 EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000240
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000241 // Side A is sending super-wideband, and side B is sending wideband.
turaj@webrtc.org55e17232013-10-29 04:40:09 +0000242 SetISAConfig(swbISACConfig, _acmA.get(), _testMode);
243 SetISAConfig(wbISACConfig, _acmB.get(), _testMode);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000244
245 bool adaptiveMode = false;
Yves Gerey665174f2018-06-19 15:03:05 +0200246 if ((swbISACConfig.currentRateBitPerSec == -1) ||
247 (wbISACConfig.currentRateBitPerSec == -1)) {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000248 adaptiveMode = true;
249 }
250 _myTimer.Reset();
251 _channel_A2B->ResetStats();
252 _channel_B2A->ResetStats();
253
254 char currentTime[500];
Niels Moller85e6e822018-09-04 11:49:57 +0000255 EventTimerWrapper* myEvent = EventTimerWrapper::Create();
256 EXPECT_TRUE(myEvent->StartTimer(true, 10));
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 Moller85e6e822018-09-04 11:49:57 +0000263 myEvent->Wait(5000);
kwiberg1fd4a4a2015-11-03 11:20:50 -0800264 EXPECT_TRUE(_acmA->SendCodec());
265 EXPECT_TRUE(_acmB->SendCodec());
niklase@google.com470e71d2011-07-07 08:21:25 +0000266 }
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000267 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000268
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000269 if (_testMode != 0) {
270 printf("\n\nSide A statistics\n\n");
271 _channel_A2B->PrintStats(_paramISAC32kHz);
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000272
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000273 printf("\n\nSide B statistics\n\n");
274 _channel_B2A->PrintStats(_paramISAC16kHz);
275 }
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000276
andresp@webrtc.orgd0b436a2014-01-13 13:15:59 +0000277 _channel_A2B->ResetStats();
278 _channel_B2A->ResetStats();
279
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000280 _outFileA.Close();
281 _outFileB.Close();
282 _inFileA.Close();
283 _inFileB.Close();
niklase@google.com470e71d2011-07-07 08:21:25 +0000284}
285
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000286void ISACTest::SwitchingSamplingRate(int testNr, int maxSampRateChange) {
287 // Files in Side A
288 _inFileA.Open(file_name_swb_, 32000, "rb");
289 _inFileB.Open(file_name_swb_, 32000, "rb");
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000290
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000291 std::string file_name_out;
Jonas Olsson366a50c2018-09-06 13:41:30 +0200292 rtc::StringBuilder file_stream_a;
293 rtc::StringBuilder file_stream_b;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000294 file_stream_a << webrtc::test::OutputPath();
295 file_stream_b << webrtc::test::OutputPath();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000296 file_stream_a << "out_iSACTest_A_" << testNr << ".pcm";
297 file_stream_b << "out_iSACTest_B_" << testNr << ".pcm";
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000298 file_name_out = file_stream_a.str();
299 _outFileA.Open(file_name_out, 32000, "wb");
300 file_name_out = file_stream_b.str();
301 _outFileB.Open(file_name_out, 32000, "wb");
niklase@google.com470e71d2011-07-07 08:21:25 +0000302
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000303 // Start with side A sending super-wideband and side B seding wideband.
304 // Toggle sending wideband/super-wideband in this test.
305 EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
306 EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000307
308 int numSendCodecChanged = 0;
309 _myTimer.Reset();
310 char currentTime[50];
311 while (numSendCodecChanged < (maxSampRateChange << 1)) {
312 Run10ms();
313 _myTimer.Tick10ms();
314 _myTimer.CurrentTimeHMS(currentTime);
315 if (_testMode == 2)
316 printf("\r%s", currentTime);
317 if (_inFileA.EndOfFile()) {
318 if (_inFileA.SamplingFrequency() == 16000) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000319 // Switch side A to send super-wideband.
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000320 _inFileA.Close();
321 _inFileA.Open(file_name_swb_, 32000, "rb");
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000322 EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000323 } else {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000324 // Switch side A to send 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(_paramISAC16kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000328 }
329 numSendCodecChanged++;
niklase@google.com470e71d2011-07-07 08:21:25 +0000330 }
331
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000332 if (_inFileB.EndOfFile()) {
333 if (_inFileB.SamplingFrequency() == 16000) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000334 // Switch side B to send super-wideband.
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000335 _inFileB.Close();
336 _inFileB.Open(file_name_swb_, 32000, "rb");
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000337 EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC32kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000338 } else {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000339 // Switch side B to send 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(_paramISAC16kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000343 }
344 numSendCodecChanged++;
niklase@google.com470e71d2011-07-07 08:21:25 +0000345 }
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000346 }
347 _outFileA.Close();
348 _outFileB.Close();
349 _inFileA.Close();
350 _inFileB.Close();
niklase@google.com470e71d2011-07-07 08:21:25 +0000351}
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000352
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000353} // namespace webrtc