blob: a84713274164b58060a2a47db283898a111193a9 [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"
29#include "system_wrappers/include/event_wrapper.h"
30#include "test/testsupport/fileutils.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000031
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000032namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000033
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000034void SetISACConfigDefault(ACMTestISACConfig& isacConfig) {
35 isacConfig.currentRateBitPerSec = 0;
36 isacConfig.currentFrameSizeMsec = 0;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000037 isacConfig.encodingMode = -1;
38 isacConfig.initRateBitPerSec = 0;
39 isacConfig.initFrameSizeInMsec = 0;
40 isacConfig.enforceFrameSize = false;
41 return;
niklase@google.com470e71d2011-07-07 08:21:25 +000042}
43
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000044int16_t SetISAConfig(ACMTestISACConfig& isacConfig, AudioCodingModule* acm,
45 int testMode) {
niklase@google.com470e71d2011-07-07 08:21:25 +000046
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000047 if ((isacConfig.currentRateBitPerSec != 0)
48 || (isacConfig.currentFrameSizeMsec != 0)) {
kwiberg1fd4a4a2015-11-03 11:20:50 -080049 auto sendCodec = acm->SendCodec();
50 EXPECT_TRUE(sendCodec);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000051 if (isacConfig.currentRateBitPerSec < 0) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000052 // Register iSAC in adaptive (channel-dependent) mode.
kwiberg1fd4a4a2015-11-03 11:20:50 -080053 sendCodec->rate = -1;
54 EXPECT_EQ(0, acm->RegisterSendCodec(*sendCodec));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000055 } else {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000056 if (isacConfig.currentRateBitPerSec != 0) {
kwiberg1fd4a4a2015-11-03 11:20:50 -080057 sendCodec->rate = isacConfig.currentRateBitPerSec;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000058 }
59 if (isacConfig.currentFrameSizeMsec != 0) {
kwiberg1fd4a4a2015-11-03 11:20:50 -080060 sendCodec->pacsize = isacConfig.currentFrameSizeMsec
61 * (sendCodec->plfreq / 1000);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000062 }
kwiberg1fd4a4a2015-11-03 11:20:50 -080063 EXPECT_EQ(0, acm->RegisterSendCodec(*sendCodec));
niklase@google.com470e71d2011-07-07 08:21:25 +000064 }
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000065 }
niklase@google.com470e71d2011-07-07 08:21:25 +000066
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000067 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000068}
69
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +000070ISACTest::ISACTest(int testMode)
Karl Wiberg5817d3d2018-04-06 10:06:42 +020071 : _acmA(AudioCodingModule::Create(
72 AudioCodingModule::Config(CreateBuiltinAudioDecoderFactory()))),
73 _acmB(AudioCodingModule::Create(
74 AudioCodingModule::Config(CreateBuiltinAudioDecoderFactory()))),
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +000075 _testMode(testMode) {}
niklase@google.com470e71d2011-07-07 08:21:25 +000076
turaj@webrtc.org55e17232013-10-29 04:40:09 +000077ISACTest::~ISACTest() {}
niklase@google.com470e71d2011-07-07 08:21:25 +000078
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000079void ISACTest::Setup() {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000080 int codecCntr;
81 CodecInst codecParam;
niklase@google.com470e71d2011-07-07 08:21:25 +000082
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000083 for (codecCntr = 0; codecCntr < AudioCodingModule::NumberOfCodecs();
84 codecCntr++) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000085 EXPECT_EQ(0, AudioCodingModule::Codec(codecCntr, &codecParam));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000086 if (!STR_CASE_CMP(codecParam.plname, "ISAC")
87 && codecParam.plfreq == 16000) {
88 memcpy(&_paramISAC16kHz, &codecParam, sizeof(CodecInst));
89 _idISAC16kHz = codecCntr;
niklase@google.com470e71d2011-07-07 08:21:25 +000090 }
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000091 if (!STR_CASE_CMP(codecParam.plname, "ISAC")
92 && codecParam.plfreq == 32000) {
93 memcpy(&_paramISAC32kHz, &codecParam, sizeof(CodecInst));
94 _idISAC32kHz = codecCntr;
niklase@google.com470e71d2011-07-07 08:21:25 +000095 }
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000096 }
niklase@google.com470e71d2011-07-07 08:21:25 +000097
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000098 // Register both iSAC-wb & iSAC-swb in both sides as receiver codecs.
kwibergda2bf4e2016-10-24 13:47:09 -070099 EXPECT_EQ(true, _acmA->RegisterReceiveCodec(_paramISAC16kHz.pltype,
100 CodecInstToSdp(_paramISAC16kHz)));
101 EXPECT_EQ(true, _acmA->RegisterReceiveCodec(_paramISAC32kHz.pltype,
102 CodecInstToSdp(_paramISAC32kHz)));
103 EXPECT_EQ(true, _acmB->RegisterReceiveCodec(_paramISAC16kHz.pltype,
104 CodecInstToSdp(_paramISAC16kHz)));
105 EXPECT_EQ(true, _acmB->RegisterReceiveCodec(_paramISAC32kHz.pltype,
106 CodecInstToSdp(_paramISAC32kHz)));
niklase@google.com470e71d2011-07-07 08:21:25 +0000107
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000108 //--- Set A-to-B channel
turaj@webrtc.org55e17232013-10-29 04:40:09 +0000109 _channel_A2B.reset(new Channel);
110 EXPECT_EQ(0, _acmA->RegisterTransportCallback(_channel_A2B.get()));
111 _channel_A2B->RegisterReceiverACM(_acmB.get());
niklase@google.com470e71d2011-07-07 08:21:25 +0000112
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000113 //--- Set B-to-A channel
turaj@webrtc.org55e17232013-10-29 04:40:09 +0000114 _channel_B2A.reset(new Channel);
115 EXPECT_EQ(0, _acmB->RegisterTransportCallback(_channel_B2A.get()));
116 _channel_B2A->RegisterReceiverACM(_acmA.get());
niklase@google.com470e71d2011-07-07 08:21:25 +0000117
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000118 file_name_swb_ = webrtc::test::ResourcePath("audio_coding/testfile32kHz",
119 "pcm");
niklase@google.com470e71d2011-07-07 08:21:25 +0000120
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000121 EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
122 EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000123
124 _inFileA.Open(file_name_swb_, 32000, "rb");
Henrik Lundin4d682082015-12-10 16:24:39 +0100125 // Set test length to 500 ms (50 blocks of 10 ms each).
126 _inFileA.SetNum10MsBlocksToRead(50);
127 // Fast-forward 1 second (100 blocks) since the files start with silence.
128 _inFileA.FastForward(100);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000129 std::string fileNameA = webrtc::test::OutputPath() + "testisac_a.pcm";
130 std::string fileNameB = webrtc::test::OutputPath() + "testisac_b.pcm";
131 _outFileA.Open(fileNameA, 32000, "wb");
132 _outFileB.Open(fileNameB, 32000, "wb");
133
134 while (!_inFileA.EndOfFile()) {
135 Run10ms();
136 }
137 CodecInst receiveCodec;
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000138 EXPECT_EQ(0, _acmA->ReceiveCodec(&receiveCodec));
139 EXPECT_EQ(0, _acmB->ReceiveCodec(&receiveCodec));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000140
141 _inFileA.Close();
142 _outFileA.Close();
143 _outFileB.Close();
niklase@google.com470e71d2011-07-07 08:21:25 +0000144}
145
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000146void ISACTest::Perform() {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000147 Setup();
niklase@google.com470e71d2011-07-07 08:21:25 +0000148
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000149 int16_t testNr = 0;
150 ACMTestISACConfig wbISACConfig;
151 ACMTestISACConfig swbISACConfig;
niklase@google.com470e71d2011-07-07 08:21:25 +0000152
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000153 SetISACConfigDefault(wbISACConfig);
154 SetISACConfigDefault(swbISACConfig);
niklase@google.com470e71d2011-07-07 08:21:25 +0000155
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000156 wbISACConfig.currentRateBitPerSec = -1;
157 swbISACConfig.currentRateBitPerSec = -1;
158 testNr++;
159 EncodeDecode(testNr, wbISACConfig, swbISACConfig);
160
161 if (_testMode != 0) {
niklase@google.com470e71d2011-07-07 08:21:25 +0000162 SetISACConfigDefault(wbISACConfig);
163 SetISACConfigDefault(swbISACConfig);
164
165 wbISACConfig.currentRateBitPerSec = -1;
166 swbISACConfig.currentRateBitPerSec = -1;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000167 wbISACConfig.initRateBitPerSec = 13000;
168 wbISACConfig.initFrameSizeInMsec = 60;
169 swbISACConfig.initRateBitPerSec = 20000;
170 swbISACConfig.initFrameSizeInMsec = 30;
niklase@google.com470e71d2011-07-07 08:21:25 +0000171 testNr++;
172 EncodeDecode(testNr, wbISACConfig, swbISACConfig);
173
niklase@google.com470e71d2011-07-07 08:21:25 +0000174 SetISACConfigDefault(wbISACConfig);
175 SetISACConfigDefault(swbISACConfig);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000176
177 wbISACConfig.currentRateBitPerSec = 20000;
178 swbISACConfig.currentRateBitPerSec = 48000;
niklase@google.com470e71d2011-07-07 08:21:25 +0000179 testNr++;
180 EncodeDecode(testNr, wbISACConfig, swbISACConfig);
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000181
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000182 wbISACConfig.currentRateBitPerSec = 16000;
183 swbISACConfig.currentRateBitPerSec = 30000;
184 wbISACConfig.currentFrameSizeMsec = 60;
niklase@google.com470e71d2011-07-07 08:21:25 +0000185 testNr++;
186 EncodeDecode(testNr, wbISACConfig, swbISACConfig);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000187 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000188
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000189 SetISACConfigDefault(wbISACConfig);
190 SetISACConfigDefault(swbISACConfig);
191 testNr++;
192 EncodeDecode(testNr, wbISACConfig, swbISACConfig);
niklase@google.com470e71d2011-07-07 08:21:25 +0000193
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000194 testNr++;
195 if (_testMode == 0) {
196 SwitchingSamplingRate(testNr, 4);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000197 } else {
198 SwitchingSamplingRate(testNr, 80);
199 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000200}
201
andresp@webrtc.orgd0b436a2014-01-13 13:15:59 +0000202void ISACTest::Run10ms() {
203 AudioFrame audioFrame;
204 EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0);
henrik.lundin@webrtc.orgf56c1622015-03-02 12:29:30 +0000205 EXPECT_GE(_acmA->Add10MsData(audioFrame), 0);
206 EXPECT_GE(_acmB->Add10MsData(audioFrame), 0);
henrik.lundind4ccb002016-05-17 12:21:55 -0700207 bool muted;
208 EXPECT_EQ(0, _acmA->PlayoutData10Ms(32000, &audioFrame, &muted));
209 ASSERT_FALSE(muted);
andresp@webrtc.orgd0b436a2014-01-13 13:15:59 +0000210 _outFileA.Write10MsData(audioFrame);
henrik.lundind4ccb002016-05-17 12:21:55 -0700211 EXPECT_EQ(0, _acmB->PlayoutData10Ms(32000, &audioFrame, &muted));
212 ASSERT_FALSE(muted);
andresp@webrtc.orgd0b436a2014-01-13 13:15:59 +0000213 _outFileB.Write10MsData(audioFrame);
214}
215
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000216void ISACTest::EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig,
217 ACMTestISACConfig& swbISACConfig) {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000218 // Files in Side A and B
219 _inFileA.Open(file_name_swb_, 32000, "rb", true);
220 _inFileB.Open(file_name_swb_, 32000, "rb", true);
221
222 std::string file_name_out;
223 std::stringstream file_stream_a;
224 std::stringstream file_stream_b;
225 file_stream_a << webrtc::test::OutputPath();
226 file_stream_b << webrtc::test::OutputPath();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000227 file_stream_a << "out_iSACTest_A_" << testNr << ".pcm";
228 file_stream_b << "out_iSACTest_B_" << testNr << ".pcm";
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000229 file_name_out = file_stream_a.str();
230 _outFileA.Open(file_name_out, 32000, "wb");
231 file_name_out = file_stream_b.str();
232 _outFileB.Open(file_name_out, 32000, "wb");
233
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000234 EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC16kHz));
235 EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
236 EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC32kHz));
237 EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000238
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000239 // Side A is sending super-wideband, and side B is sending wideband.
turaj@webrtc.org55e17232013-10-29 04:40:09 +0000240 SetISAConfig(swbISACConfig, _acmA.get(), _testMode);
241 SetISAConfig(wbISACConfig, _acmB.get(), _testMode);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000242
243 bool adaptiveMode = false;
244 if ((swbISACConfig.currentRateBitPerSec == -1)
245 || (wbISACConfig.currentRateBitPerSec == -1)) {
246 adaptiveMode = true;
247 }
248 _myTimer.Reset();
249 _channel_A2B->ResetStats();
250 _channel_B2A->ResetStats();
251
252 char currentTime[500];
Peter Boström64c03662015-04-08 11:24:19 +0200253 EventTimerWrapper* myEvent = EventTimerWrapper::Create();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000254 EXPECT_TRUE(myEvent->StartTimer(true, 10));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000255 while (!(_inFileA.EndOfFile() || _inFileA.Rewinded())) {
256 Run10ms();
257 _myTimer.Tick10ms();
258 _myTimer.CurrentTimeHMS(currentTime);
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000259
260 if ((adaptiveMode) && (_testMode != 0)) {
261 myEvent->Wait(5000);
kwiberg1fd4a4a2015-11-03 11:20:50 -0800262 EXPECT_TRUE(_acmA->SendCodec());
263 EXPECT_TRUE(_acmB->SendCodec());
niklase@google.com470e71d2011-07-07 08:21:25 +0000264 }
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000265 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000266
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000267 if (_testMode != 0) {
268 printf("\n\nSide A statistics\n\n");
269 _channel_A2B->PrintStats(_paramISAC32kHz);
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000270
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000271 printf("\n\nSide B statistics\n\n");
272 _channel_B2A->PrintStats(_paramISAC16kHz);
273 }
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000274
andresp@webrtc.orgd0b436a2014-01-13 13:15:59 +0000275 _channel_A2B->ResetStats();
276 _channel_B2A->ResetStats();
277
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000278 _outFileA.Close();
279 _outFileB.Close();
280 _inFileA.Close();
281 _inFileB.Close();
niklase@google.com470e71d2011-07-07 08:21:25 +0000282}
283
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000284void ISACTest::SwitchingSamplingRate(int testNr, int maxSampRateChange) {
285 // Files in Side A
286 _inFileA.Open(file_name_swb_, 32000, "rb");
287 _inFileB.Open(file_name_swb_, 32000, "rb");
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000288
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000289 std::string file_name_out;
290 std::stringstream file_stream_a;
291 std::stringstream file_stream_b;
292 file_stream_a << webrtc::test::OutputPath();
293 file_stream_b << webrtc::test::OutputPath();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000294 file_stream_a << "out_iSACTest_A_" << testNr << ".pcm";
295 file_stream_b << "out_iSACTest_B_" << testNr << ".pcm";
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000296 file_name_out = file_stream_a.str();
297 _outFileA.Open(file_name_out, 32000, "wb");
298 file_name_out = file_stream_b.str();
299 _outFileB.Open(file_name_out, 32000, "wb");
niklase@google.com470e71d2011-07-07 08:21:25 +0000300
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000301 // Start with side A sending super-wideband and side B seding wideband.
302 // Toggle sending wideband/super-wideband in this test.
303 EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
304 EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000305
306 int numSendCodecChanged = 0;
307 _myTimer.Reset();
308 char currentTime[50];
309 while (numSendCodecChanged < (maxSampRateChange << 1)) {
310 Run10ms();
311 _myTimer.Tick10ms();
312 _myTimer.CurrentTimeHMS(currentTime);
313 if (_testMode == 2)
314 printf("\r%s", currentTime);
315 if (_inFileA.EndOfFile()) {
316 if (_inFileA.SamplingFrequency() == 16000) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000317 // Switch side A to send super-wideband.
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000318 _inFileA.Close();
319 _inFileA.Open(file_name_swb_, 32000, "rb");
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000320 EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC32kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000321 } else {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000322 // Switch side A to send wideband.
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000323 _inFileA.Close();
324 _inFileA.Open(file_name_swb_, 32000, "rb");
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000325 EXPECT_EQ(0, _acmA->RegisterSendCodec(_paramISAC16kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000326 }
327 numSendCodecChanged++;
niklase@google.com470e71d2011-07-07 08:21:25 +0000328 }
329
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000330 if (_inFileB.EndOfFile()) {
331 if (_inFileB.SamplingFrequency() == 16000) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000332 // Switch side B to send super-wideband.
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000333 _inFileB.Close();
334 _inFileB.Open(file_name_swb_, 32000, "rb");
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000335 EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC32kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000336 } else {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000337 // Switch side B to send wideband.
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000338 _inFileB.Close();
339 _inFileB.Open(file_name_swb_, 32000, "rb");
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000340 EXPECT_EQ(0, _acmB->RegisterSendCodec(_paramISAC16kHz));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000341 }
342 numSendCodecChanged++;
niklase@google.com470e71d2011-07-07 08:21:25 +0000343 }
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000344 }
345 _outFileA.Close();
346 _outFileB.Close();
347 _inFileA.Close();
348 _inFileB.Close();
niklase@google.com470e71d2011-07-07 08:21:25 +0000349}
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000350
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000351} // namespace webrtc