blob: d06cc0709c2daedf850158d9274af6b5daf1892a [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
tina.legrand@webrtc.orgae1c4542012-03-12 08:41:30 +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
tina.legrand@webrtc.org73222cf2013-03-15 13:29:17 +000011#include "webrtc/modules/audio_coding/main/test/EncodeDecodeTest.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000012
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000013#include <sstream>
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000014#include <stdio.h>
niklase@google.com470e71d2011-07-07 08:21:25 +000015#include <stdlib.h>
tina.legrand@webrtc.org5e7ca602012-06-12 07:16:24 +000016
tina.legrand@webrtc.org73222cf2013-03-15 13:29:17 +000017#include "testing/gtest/include/gtest/gtest.h"
18#include "webrtc/common_types.h"
19#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
turaj@webrtc.org532f3dc2013-09-19 00:12:23 +000020#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
tina.legrand@webrtc.org73222cf2013-03-15 13:29:17 +000021#include "webrtc/modules/audio_coding/main/test/utility.h"
andrew@webrtc.org89df0922013-09-12 01:27:43 +000022#include "webrtc/system_wrappers/interface/scoped_ptr.h"
tina.legrand@webrtc.org73222cf2013-03-15 13:29:17 +000023#include "webrtc/system_wrappers/interface/trace.h"
24#include "webrtc/test/testsupport/fileutils.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000025
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000026namespace webrtc {
27
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000028TestPacketization::TestPacketization(RTPStream *rtpStream, uint16_t frequency)
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000029 : _rtpStream(rtpStream),
30 _frequency(frequency),
31 _seqNo(0) {
niklase@google.com470e71d2011-07-07 08:21:25 +000032}
33
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000034TestPacketization::~TestPacketization() {
35}
niklase@google.com470e71d2011-07-07 08:21:25 +000036
pbos@webrtc.org0946a562013-04-09 00:28:06 +000037int32_t TestPacketization::SendData(
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +000038 const FrameType /* frameType */, const uint8_t payloadType,
39 const uint32_t timeStamp, const uint8_t* payloadData,
pbos@webrtc.org0946a562013-04-09 00:28:06 +000040 const uint16_t payloadSize,
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000041 const RTPFragmentationHeader* /* fragmentation */) {
42 _rtpStream->Write(payloadType, timeStamp, _seqNo++, payloadData, payloadSize,
43 _frequency);
44 return 1;
45}
niklase@google.com470e71d2011-07-07 08:21:25 +000046
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000047Sender::Sender()
48 : _acm(NULL),
49 _pcmFile(),
50 _audioFrame(),
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000051 _packetization(NULL) {
52}
53
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000054void Sender::Setup(AudioCodingModule *acm, RTPStream *rtpStream,
55 std::string in_file_name, int sample_rate, int channels) {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000056 acm->InitializeSender();
57 struct CodecInst sendCodec;
58 int noOfCodecs = acm->NumberOfCodecs();
59 int codecNo;
60
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +000061 // Open input file
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000062 const std::string file_name = webrtc::test::ResourcePath(in_file_name, "pcm");
63 _pcmFile.Open(file_name, sample_rate, "rb");
64 if (channels == 2) {
65 _pcmFile.ReadStereo(true);
66 }
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +000067
68 // Set the codec for the current test.
69 if ((testMode == 0) || (testMode == 1)) {
70 // Set the codec id.
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000071 codecNo = codeId;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000072 } else {
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +000073 // Choose codec on command line.
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000074 printf("List of supported codec.\n");
75 for (int n = 0; n < noOfCodecs; n++) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000076 EXPECT_EQ(0, acm->Codec(n, &sendCodec));
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000077 printf("%d %s\n", n, sendCodec.plname);
niklase@google.com470e71d2011-07-07 08:21:25 +000078 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000079 printf("Choose your codec:");
80 ASSERT_GT(scanf("%d", &codecNo), 0);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000081 }
82
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000083 EXPECT_EQ(0, acm->Codec(codecNo, &sendCodec));
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000084
85 sendCodec.channels = channels;
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000086
87 EXPECT_EQ(0, acm->RegisterSendCodec(sendCodec));
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000088 _packetization = new TestPacketization(rtpStream, sendCodec.plfreq);
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000089 EXPECT_EQ(0, acm->RegisterTransportCallback(_packetization));
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000090
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +000091 _acm = acm;
92}
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000093
94void Sender::Teardown() {
95 _pcmFile.Close();
96 delete _packetization;
niklase@google.com470e71d2011-07-07 08:21:25 +000097}
98
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000099bool Sender::Add10MsData() {
100 if (!_pcmFile.EndOfFile()) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000101 EXPECT_GT(_pcmFile.Read10MsData(_audioFrame), 0);
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000102 int32_t ok = _acm->Add10MsData(_audioFrame);
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000103 EXPECT_EQ(0, ok);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000104 if (ok != 0) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000105 return false;
niklase@google.com470e71d2011-07-07 08:21:25 +0000106 }
107 return true;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000108 }
109 return false;
niklase@google.com470e71d2011-07-07 08:21:25 +0000110}
111
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000112void Sender::Run() {
113 while (true) {
114 if (!Add10MsData()) {
115 break;
niklase@google.com470e71d2011-07-07 08:21:25 +0000116 }
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000117 EXPECT_GT(_acm->Process(), -1);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000118 }
119}
120
121Receiver::Receiver()
122 : _playoutLengthSmpls(WEBRTC_10MS_PCM_AUDIO),
123 _payloadSizeBytes(MAX_INCOMING_PAYLOAD) {
124}
125
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000126void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream,
127 std::string out_file_name, int channels) {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000128 struct CodecInst recvCodec;
129 int noOfCodecs;
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000130 EXPECT_EQ(0, acm->InitializeReceiver());
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000131
132 noOfCodecs = acm->NumberOfCodecs();
133 for (int i = 0; i < noOfCodecs; i++) {
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000134 EXPECT_EQ(0, acm->Codec(i, &recvCodec));
135 if (recvCodec.channels == channels)
136 EXPECT_EQ(0, acm->RegisterReceiveCodec(recvCodec));
137 // Forces mono/stereo for Opus.
138 if (!strcmp(recvCodec.plname, "opus")) {
139 recvCodec.channels = channels;
140 EXPECT_EQ(0, acm->RegisterReceiveCodec(recvCodec));
141 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000142 }
phoglund@webrtc.orgd1a860b2012-01-26 14:49:28 +0000143
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000144 int playSampFreq;
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000145 std::string file_name;
146 std::stringstream file_stream;
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000147 file_stream << webrtc::test::OutputPath() << out_file_name
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000148 << static_cast<int>(codeId) << ".pcm";
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000149 file_name = file_stream.str();
150 _rtpStream = rtpStream;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000151
152 if (testMode == 1) {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000153 playSampFreq = recvCodec.plfreq;
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000154 _pcmFile.Open(file_name, recvCodec.plfreq, "wb+");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000155 } else if (testMode == 0) {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000156 playSampFreq = 32000;
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000157 _pcmFile.Open(file_name, 32000, "wb+");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000158 } else {
159 printf("\nValid output frequencies:\n");
160 printf("8000\n16000\n32000\n-1,");
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000161 printf("which means output frequency equal to received signal frequency");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000162 printf("\n\nChoose output sampling frequency: ");
163 ASSERT_GT(scanf("%d", &playSampFreq), 0);
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000164 file_name = webrtc::test::OutputPath() + out_file_name + ".pcm";
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000165 _pcmFile.Open(file_name, playSampFreq, "wb+");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000166 }
phoglund@webrtc.orgd1a860b2012-01-26 14:49:28 +0000167
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000168 _realPayloadSizeBytes = 0;
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000169 _playoutBuffer = new int16_t[WEBRTC_10MS_PCM_AUDIO];
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000170 _frequency = playSampFreq;
171 _acm = acm;
172 _firstTime = true;
173}
174
175void Receiver::Teardown() {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000176 delete[] _playoutBuffer;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000177 _pcmFile.Close();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000178 if (testMode > 1) {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000179 Trace::ReturnTrace();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000180 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000181}
182
183bool Receiver::IncomingPacket() {
184 if (!_rtpStream->EndOfFile()) {
185 if (_firstTime) {
186 _firstTime = false;
187 _realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload,
188 _payloadSizeBytes, &_nextTime);
andrew@webrtc.org975e4a32012-01-17 19:27:33 +0000189 if (_realPayloadSizeBytes == 0) {
190 if (_rtpStream->EndOfFile()) {
191 _firstTime = true;
192 return true;
193 } else {
andrew@webrtc.org975e4a32012-01-17 19:27:33 +0000194 return false;
195 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000196 }
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000197 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000198
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000199 EXPECT_EQ(0, _acm->IncomingPacket(_incomingPayload, _realPayloadSizeBytes,
200 _rtpInfo));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000201 _realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload,
202 _payloadSizeBytes, &_nextTime);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000203 if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile()) {
204 _firstTime = true;
niklase@google.com470e71d2011-07-07 08:21:25 +0000205 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000206 }
207 return true;
niklase@google.com470e71d2011-07-07 08:21:25 +0000208}
209
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000210bool Receiver::PlayoutData() {
211 AudioFrame audioFrame;
212
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000213 int32_t ok =_acm->PlayoutData10Ms(_frequency, &audioFrame);
214 EXPECT_EQ(0, ok);
215 if (ok < 0){
216 return false;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000217 }
218 if (_playoutLengthSmpls == 0) {
219 return false;
220 }
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000221 _pcmFile.Write10MsData(audioFrame.data_,
222 audioFrame.samples_per_channel_ * audioFrame.num_channels_);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000223 return true;
224}
225
226void Receiver::Run() {
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000227 uint8_t counter500Ms = 50;
228 uint32_t clock = 0;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000229
230 while (counter500Ms > 0) {
231 if (clock == 0 || clock >= _nextTime) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000232 EXPECT_TRUE(IncomingPacket());
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000233 if (clock == 0) {
234 clock = _nextTime;
235 }
236 }
237 if ((clock % 10) == 0) {
238 if (!PlayoutData()) {
239 clock++;
240 continue;
241 }
242 }
243 if (_rtpStream->EndOfFile()) {
244 counter500Ms--;
245 }
246 clock++;
247 }
248}
249
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +0000250EncodeDecodeTest::EncodeDecodeTest() {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000251 _testMode = 2;
252 Trace::CreateTrace();
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000253 Trace::SetTraceFile(
254 (webrtc::test::OutputPath() + "acm_encdec_trace.txt").c_str());
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000255}
256
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +0000257EncodeDecodeTest::EncodeDecodeTest(int testMode) {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000258 //testMode == 0 for autotest
259 //testMode == 1 for testing all codecs/parameters
260 //testMode > 1 for specific user-input test (as it was used before)
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000261 _testMode = testMode;
262 if (_testMode != 0) {
263 Trace::CreateTrace();
264 Trace::SetTraceFile(
265 (webrtc::test::OutputPath() + "acm_encdec_trace.txt").c_str());
266 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000267}
268
269void EncodeDecodeTest::Perform() {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000270 int numCodecs = 1;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000271 int codePars[3]; // Frequency, packet size, rate.
272 int numPars[52]; // Number of codec parameters sets (freq, pacsize, rate)
273 // to test, for a given codec.
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000274
275 codePars[0] = 0;
276 codePars[1] = 0;
277 codePars[2] = 0;
278
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +0000279 scoped_ptr<AudioCodingModule> acm(AudioCodingModule::Create(0));
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000280 struct CodecInst sendCodecTmp;
tina.legrand@webrtc.org5b4f36d2012-06-01 14:51:28 +0000281 numCodecs = acm->NumberOfCodecs();
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000282
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000283 if (_testMode != 2) {
284 for (int n = 0; n < numCodecs; n++) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000285 EXPECT_EQ(0, acm->Codec(n, &sendCodecTmp));
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000286 if (STR_CASE_CMP(sendCodecTmp.plname, "telephone-event") == 0) {
287 numPars[n] = 0;
288 } else if (STR_CASE_CMP(sendCodecTmp.plname, "cn") == 0) {
289 numPars[n] = 0;
290 } else if (STR_CASE_CMP(sendCodecTmp.plname, "red") == 0) {
291 numPars[n] = 0;
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000292 } else if (sendCodecTmp.channels == 2) {
293 numPars[n] = 0;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000294 } else {
295 numPars[n] = 1;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000296 }
297 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000298 } else {
299 numCodecs = 1;
300 numPars[0] = 1;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000301 }
302
303 _receiver.testMode = _testMode;
304
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000305 // Loop over all mono codecs:
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000306 for (int codeId = 0; codeId < numCodecs; codeId++) {
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000307 // Only encode using real mono encoders, not telephone-event and cng.
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000308 for (int loopPars = 1; loopPars <= numPars[codeId]; loopPars++) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000309 // Encode all data to file.
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000310 EncodeToFile(1, codeId, codePars, _testMode);
311
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000312 RTPFile rtpFile;
kjellander@webrtc.org5490c712011-12-21 13:34:18 +0000313 std::string fileName = webrtc::test::OutputPath() + "outFile.rtp";
314 rtpFile.Open(fileName.c_str(), "rb");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000315
316 _receiver.codeId = codeId;
317
318 rtpFile.ReadHeader();
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000319 _receiver.Setup(acm.get(), &rtpFile, "encodeDecode_out", 1);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000320 _receiver.Run();
321 _receiver.Teardown();
322 rtpFile.Close();
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000323 }
324 }
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000325
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000326 // End tracing.
327 if (_testMode == 1) {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000328 Trace::ReturnTrace();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000329 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000330}
331
332void EncodeDecodeTest::EncodeToFile(int fileType, int codeId, int* codePars,
333 int testMode) {
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +0000334 scoped_ptr<AudioCodingModule> acm(AudioCodingModule::Create(1));
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000335 RTPFile rtpFile;
kjellander@webrtc.org5490c712011-12-21 13:34:18 +0000336 std::string fileName = webrtc::test::OutputPath() + "outFile.rtp";
337 rtpFile.Open(fileName.c_str(), "wb+");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000338 rtpFile.WriteHeader();
339
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000340 // Store for auto_test and logging.
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000341 _sender.testMode = testMode;
342 _sender.codeId = codeId;
343
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000344 _sender.Setup(acm.get(), &rtpFile, "audio_coding/testfile32kHz", 32000, 1);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000345 struct CodecInst sendCodecInst;
tina.legrand@webrtc.org7a7a0082013-02-21 10:27:48 +0000346 if (acm->SendCodec(&sendCodecInst) >= 0) {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000347 _sender.Run();
348 }
349 _sender.Teardown();
350 rtpFile.Close();
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000351}
352
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000353} // namespace webrtc