blob: eca8bc869f6ea322b2f71b44a4dbf7f8685fdc9c [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"
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000018#include "webrtc/base/scoped_ptr.h"
tina.legrand@webrtc.org73222cf2013-03-15 13:29:17 +000019#include "webrtc/common_types.h"
20#include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
turaj@webrtc.org532f3dc2013-09-19 00:12:23 +000021#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
tina.legrand@webrtc.org73222cf2013-03-15 13:29:17 +000022#include "webrtc/modules/audio_coding/main/test/utility.h"
Henrik Kjellander98f53512015-10-28 18:17:40 +010023#include "webrtc/system_wrappers/include/trace.h"
tina.legrand@webrtc.org73222cf2013-03-15 13:29:17 +000024#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,
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +000040 const size_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 struct CodecInst sendCodec;
57 int noOfCodecs = acm->NumberOfCodecs();
58 int codecNo;
59
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +000060 // Open input file
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000061 const std::string file_name = webrtc::test::ResourcePath(in_file_name, "pcm");
62 _pcmFile.Open(file_name, sample_rate, "rb");
63 if (channels == 2) {
64 _pcmFile.ReadStereo(true);
65 }
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +000066
67 // Set the codec for the current test.
68 if ((testMode == 0) || (testMode == 1)) {
69 // Set the codec id.
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000070 codecNo = codeId;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000071 } else {
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +000072 // Choose codec on command line.
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000073 printf("List of supported codec.\n");
74 for (int n = 0; n < noOfCodecs; n++) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000075 EXPECT_EQ(0, acm->Codec(n, &sendCodec));
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000076 printf("%d %s\n", n, sendCodec.plname);
niklase@google.com470e71d2011-07-07 08:21:25 +000077 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000078 printf("Choose your codec:");
79 ASSERT_GT(scanf("%d", &codecNo), 0);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000080 }
81
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000082 EXPECT_EQ(0, acm->Codec(codecNo, &sendCodec));
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000083
84 sendCodec.channels = channels;
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000085
86 EXPECT_EQ(0, acm->RegisterSendCodec(sendCodec));
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000087 _packetization = new TestPacketization(rtpStream, sendCodec.plfreq);
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000088 EXPECT_EQ(0, acm->RegisterTransportCallback(_packetization));
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000089
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +000090 _acm = acm;
91}
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000092
93void Sender::Teardown() {
94 _pcmFile.Close();
95 delete _packetization;
niklase@google.com470e71d2011-07-07 08:21:25 +000096}
97
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000098bool Sender::Add10MsData() {
99 if (!_pcmFile.EndOfFile()) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000100 EXPECT_GT(_pcmFile.Read10MsData(_audioFrame), 0);
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000101 int32_t ok = _acm->Add10MsData(_audioFrame);
henrik.lundin@webrtc.orgf56c1622015-03-02 12:29:30 +0000102 EXPECT_GE(ok, 0);
103 return ok >= 0 ? true : false;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000104 }
105 return false;
niklase@google.com470e71d2011-07-07 08:21:25 +0000106}
107
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000108void Sender::Run() {
109 while (true) {
110 if (!Add10MsData()) {
111 break;
niklase@google.com470e71d2011-07-07 08:21:25 +0000112 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000113 }
114}
115
116Receiver::Receiver()
117 : _playoutLengthSmpls(WEBRTC_10MS_PCM_AUDIO),
118 _payloadSizeBytes(MAX_INCOMING_PAYLOAD) {
119}
120
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000121void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream,
122 std::string out_file_name, int channels) {
henrike@webrtc.org6ac22e62014-08-11 21:06:30 +0000123 struct CodecInst recvCodec = CodecInst();
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000124 int noOfCodecs;
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000125 EXPECT_EQ(0, acm->InitializeReceiver());
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000126
127 noOfCodecs = acm->NumberOfCodecs();
128 for (int i = 0; i < noOfCodecs; i++) {
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000129 EXPECT_EQ(0, acm->Codec(i, &recvCodec));
130 if (recvCodec.channels == channels)
131 EXPECT_EQ(0, acm->RegisterReceiveCodec(recvCodec));
132 // Forces mono/stereo for Opus.
133 if (!strcmp(recvCodec.plname, "opus")) {
134 recvCodec.channels = channels;
135 EXPECT_EQ(0, acm->RegisterReceiveCodec(recvCodec));
136 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000137 }
phoglund@webrtc.orgd1a860b2012-01-26 14:49:28 +0000138
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000139 int playSampFreq;
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000140 std::string file_name;
141 std::stringstream file_stream;
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000142 file_stream << webrtc::test::OutputPath() << out_file_name
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000143 << static_cast<int>(codeId) << ".pcm";
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000144 file_name = file_stream.str();
145 _rtpStream = rtpStream;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000146
147 if (testMode == 1) {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000148 playSampFreq = recvCodec.plfreq;
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000149 _pcmFile.Open(file_name, recvCodec.plfreq, "wb+");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000150 } else if (testMode == 0) {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000151 playSampFreq = 32000;
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000152 _pcmFile.Open(file_name, 32000, "wb+");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000153 } else {
154 printf("\nValid output frequencies:\n");
155 printf("8000\n16000\n32000\n-1,");
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000156 printf("which means output frequency equal to received signal frequency");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000157 printf("\n\nChoose output sampling frequency: ");
158 ASSERT_GT(scanf("%d", &playSampFreq), 0);
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000159 file_name = webrtc::test::OutputPath() + out_file_name + ".pcm";
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000160 _pcmFile.Open(file_name, playSampFreq, "wb+");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000161 }
phoglund@webrtc.orgd1a860b2012-01-26 14:49:28 +0000162
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000163 _realPayloadSizeBytes = 0;
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000164 _playoutBuffer = new int16_t[WEBRTC_10MS_PCM_AUDIO];
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000165 _frequency = playSampFreq;
166 _acm = acm;
167 _firstTime = true;
168}
169
170void Receiver::Teardown() {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000171 delete[] _playoutBuffer;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000172 _pcmFile.Close();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000173 if (testMode > 1) {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000174 Trace::ReturnTrace();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000175 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000176}
177
178bool Receiver::IncomingPacket() {
179 if (!_rtpStream->EndOfFile()) {
180 if (_firstTime) {
181 _firstTime = false;
182 _realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload,
183 _payloadSizeBytes, &_nextTime);
andrew@webrtc.org975e4a32012-01-17 19:27:33 +0000184 if (_realPayloadSizeBytes == 0) {
185 if (_rtpStream->EndOfFile()) {
186 _firstTime = true;
187 return true;
188 } else {
andrew@webrtc.org975e4a32012-01-17 19:27:33 +0000189 return false;
190 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000191 }
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000192 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000193
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000194 EXPECT_EQ(0, _acm->IncomingPacket(_incomingPayload, _realPayloadSizeBytes,
195 _rtpInfo));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000196 _realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload,
197 _payloadSizeBytes, &_nextTime);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000198 if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile()) {
199 _firstTime = true;
niklase@google.com470e71d2011-07-07 08:21:25 +0000200 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000201 }
202 return true;
niklase@google.com470e71d2011-07-07 08:21:25 +0000203}
204
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000205bool Receiver::PlayoutData() {
206 AudioFrame audioFrame;
207
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000208 int32_t ok =_acm->PlayoutData10Ms(_frequency, &audioFrame);
209 EXPECT_EQ(0, ok);
210 if (ok < 0){
211 return false;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000212 }
213 if (_playoutLengthSmpls == 0) {
214 return false;
215 }
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000216 _pcmFile.Write10MsData(audioFrame.data_,
217 audioFrame.samples_per_channel_ * audioFrame.num_channels_);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000218 return true;
219}
220
221void Receiver::Run() {
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000222 uint8_t counter500Ms = 50;
223 uint32_t clock = 0;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000224
225 while (counter500Ms > 0) {
226 if (clock == 0 || clock >= _nextTime) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000227 EXPECT_TRUE(IncomingPacket());
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000228 if (clock == 0) {
229 clock = _nextTime;
230 }
231 }
232 if ((clock % 10) == 0) {
233 if (!PlayoutData()) {
234 clock++;
235 continue;
236 }
237 }
238 if (_rtpStream->EndOfFile()) {
239 counter500Ms--;
240 }
241 clock++;
242 }
243}
244
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +0000245EncodeDecodeTest::EncodeDecodeTest() {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000246 _testMode = 2;
247 Trace::CreateTrace();
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000248 Trace::SetTraceFile(
249 (webrtc::test::OutputPath() + "acm_encdec_trace.txt").c_str());
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000250}
251
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +0000252EncodeDecodeTest::EncodeDecodeTest(int testMode) {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000253 //testMode == 0 for autotest
254 //testMode == 1 for testing all codecs/parameters
255 //testMode > 1 for specific user-input test (as it was used before)
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000256 _testMode = testMode;
257 if (_testMode != 0) {
258 Trace::CreateTrace();
259 Trace::SetTraceFile(
260 (webrtc::test::OutputPath() + "acm_encdec_trace.txt").c_str());
261 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000262}
263
264void EncodeDecodeTest::Perform() {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000265 int numCodecs = 1;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000266 int codePars[3]; // Frequency, packet size, rate.
267 int numPars[52]; // Number of codec parameters sets (freq, pacsize, rate)
268 // to test, for a given codec.
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000269
270 codePars[0] = 0;
271 codePars[1] = 0;
272 codePars[2] = 0;
273
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000274 rtc::scoped_ptr<AudioCodingModule> acm(AudioCodingModule::Create(0));
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000275 struct CodecInst sendCodecTmp;
tina.legrand@webrtc.org5b4f36d2012-06-01 14:51:28 +0000276 numCodecs = acm->NumberOfCodecs();
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000277
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000278 if (_testMode != 2) {
279 for (int n = 0; n < numCodecs; n++) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000280 EXPECT_EQ(0, acm->Codec(n, &sendCodecTmp));
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000281 if (STR_CASE_CMP(sendCodecTmp.plname, "telephone-event") == 0) {
282 numPars[n] = 0;
283 } else if (STR_CASE_CMP(sendCodecTmp.plname, "cn") == 0) {
284 numPars[n] = 0;
285 } else if (STR_CASE_CMP(sendCodecTmp.plname, "red") == 0) {
286 numPars[n] = 0;
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000287 } else if (sendCodecTmp.channels == 2) {
288 numPars[n] = 0;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000289 } else {
290 numPars[n] = 1;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000291 }
292 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000293 } else {
294 numCodecs = 1;
295 numPars[0] = 1;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000296 }
297
298 _receiver.testMode = _testMode;
299
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000300 // Loop over all mono codecs:
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000301 for (int codeId = 0; codeId < numCodecs; codeId++) {
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000302 // Only encode using real mono encoders, not telephone-event and cng.
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000303 for (int loopPars = 1; loopPars <= numPars[codeId]; loopPars++) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000304 // Encode all data to file.
pbos@webrtc.orgc86e45d2014-10-01 10:05:40 +0000305 std::string fileName = EncodeToFile(1, codeId, codePars, _testMode);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000306
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000307 RTPFile rtpFile;
kjellander@webrtc.org5490c712011-12-21 13:34:18 +0000308 rtpFile.Open(fileName.c_str(), "rb");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000309
310 _receiver.codeId = codeId;
311
312 rtpFile.ReadHeader();
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000313 _receiver.Setup(acm.get(), &rtpFile, "encodeDecode_out", 1);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000314 _receiver.Run();
315 _receiver.Teardown();
316 rtpFile.Close();
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000317 }
318 }
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000319
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000320 // End tracing.
321 if (_testMode == 1) {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000322 Trace::ReturnTrace();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000323 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000324}
325
pbos@webrtc.orgc86e45d2014-10-01 10:05:40 +0000326std::string EncodeDecodeTest::EncodeToFile(int fileType,
327 int codeId,
328 int* codePars,
329 int testMode) {
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000330 rtc::scoped_ptr<AudioCodingModule> acm(AudioCodingModule::Create(1));
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000331 RTPFile rtpFile;
pbos@webrtc.orgc86e45d2014-10-01 10:05:40 +0000332 std::string fileName = webrtc::test::TempFilename(webrtc::test::OutputPath(),
333 "encode_decode_rtp");
kjellander@webrtc.org5490c712011-12-21 13:34:18 +0000334 rtpFile.Open(fileName.c_str(), "wb+");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000335 rtpFile.WriteHeader();
336
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000337 // Store for auto_test and logging.
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000338 _sender.testMode = testMode;
339 _sender.codeId = codeId;
340
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000341 _sender.Setup(acm.get(), &rtpFile, "audio_coding/testfile32kHz", 32000, 1);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000342 struct CodecInst sendCodecInst;
tina.legrand@webrtc.org7a7a0082013-02-21 10:27:48 +0000343 if (acm->SendCodec(&sendCodecInst) >= 0) {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000344 _sender.Run();
345 }
346 _sender.Teardown();
347 rtpFile.Close();
pbos@webrtc.orgc86e45d2014-10-01 10:05:40 +0000348
349 return fileName;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000350}
351
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000352} // namespace webrtc