blob: ba3c8d9ad2e053605b0cbfb88d9457fcd2595f33 [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
kjellander3e6db232015-11-26 04:44:54 -080011#include "webrtc/modules/audio_coding/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"
kjellander3e6db232015-11-26 04:44:54 -080020#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
21#include "webrtc/modules/audio_coding/acm2/acm_common_defs.h"
22#include "webrtc/modules/audio_coding/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,
Peter Kasting69558702016-01-12 16:26:35 -080055 std::string in_file_name, int sample_rate, size_t 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 }
Henrik Lundin4d682082015-12-10 16:24:39 +010066 // Set test length to 500 ms (50 blocks of 10 ms each).
67 _pcmFile.SetNum10MsBlocksToRead(50);
68 // Fast-forward 1 second (100 blocks) since the file starts with silence.
69 _pcmFile.FastForward(100);
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +000070
71 // Set the codec for the current test.
72 if ((testMode == 0) || (testMode == 1)) {
73 // Set the codec id.
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000074 codecNo = codeId;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000075 } else {
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +000076 // Choose codec on command line.
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000077 printf("List of supported codec.\n");
78 for (int n = 0; n < noOfCodecs; n++) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000079 EXPECT_EQ(0, acm->Codec(n, &sendCodec));
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000080 printf("%d %s\n", n, sendCodec.plname);
niklase@google.com470e71d2011-07-07 08:21:25 +000081 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000082 printf("Choose your codec:");
83 ASSERT_GT(scanf("%d", &codecNo), 0);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000084 }
85
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000086 EXPECT_EQ(0, acm->Codec(codecNo, &sendCodec));
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +000087
88 sendCodec.channels = channels;
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000089
90 EXPECT_EQ(0, acm->RegisterSendCodec(sendCodec));
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000091 _packetization = new TestPacketization(rtpStream, sendCodec.plfreq);
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +000092 EXPECT_EQ(0, acm->RegisterTransportCallback(_packetization));
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000093
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +000094 _acm = acm;
95}
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +000096
97void Sender::Teardown() {
98 _pcmFile.Close();
99 delete _packetization;
niklase@google.com470e71d2011-07-07 08:21:25 +0000100}
101
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000102bool Sender::Add10MsData() {
103 if (!_pcmFile.EndOfFile()) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000104 EXPECT_GT(_pcmFile.Read10MsData(_audioFrame), 0);
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000105 int32_t ok = _acm->Add10MsData(_audioFrame);
henrik.lundin@webrtc.orgf56c1622015-03-02 12:29:30 +0000106 EXPECT_GE(ok, 0);
107 return ok >= 0 ? true : false;
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.org554ae1a2011-12-16 10:09:04 +0000117 }
118}
119
120Receiver::Receiver()
121 : _playoutLengthSmpls(WEBRTC_10MS_PCM_AUDIO),
122 _payloadSizeBytes(MAX_INCOMING_PAYLOAD) {
123}
124
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000125void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream,
Peter Kasting69558702016-01-12 16:26:35 -0800126 std::string out_file_name, size_t channels) {
henrike@webrtc.org6ac22e62014-08-11 21:06:30 +0000127 struct CodecInst recvCodec = CodecInst();
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000128 int noOfCodecs;
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000129 EXPECT_EQ(0, acm->InitializeReceiver());
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000130
131 noOfCodecs = acm->NumberOfCodecs();
132 for (int i = 0; i < noOfCodecs; i++) {
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000133 EXPECT_EQ(0, acm->Codec(i, &recvCodec));
134 if (recvCodec.channels == channels)
135 EXPECT_EQ(0, acm->RegisterReceiveCodec(recvCodec));
136 // Forces mono/stereo for Opus.
137 if (!strcmp(recvCodec.plname, "opus")) {
138 recvCodec.channels = channels;
139 EXPECT_EQ(0, acm->RegisterReceiveCodec(recvCodec));
140 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000141 }
phoglund@webrtc.orgd1a860b2012-01-26 14:49:28 +0000142
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000143 int playSampFreq;
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000144 std::string file_name;
145 std::stringstream file_stream;
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000146 file_stream << webrtc::test::OutputPath() << out_file_name
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000147 << static_cast<int>(codeId) << ".pcm";
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000148 file_name = file_stream.str();
149 _rtpStream = rtpStream;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000150
151 if (testMode == 1) {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000152 playSampFreq = recvCodec.plfreq;
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000153 _pcmFile.Open(file_name, recvCodec.plfreq, "wb+");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000154 } else if (testMode == 0) {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000155 playSampFreq = 32000;
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000156 _pcmFile.Open(file_name, 32000, "wb+");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000157 } else {
158 printf("\nValid output frequencies:\n");
159 printf("8000\n16000\n32000\n-1,");
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000160 printf("which means output frequency equal to received signal frequency");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000161 printf("\n\nChoose output sampling frequency: ");
162 ASSERT_GT(scanf("%d", &playSampFreq), 0);
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000163 file_name = webrtc::test::OutputPath() + out_file_name + ".pcm";
tina.legrand@webrtc.orgba468042012-08-17 10:38:28 +0000164 _pcmFile.Open(file_name, playSampFreq, "wb+");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000165 }
phoglund@webrtc.orgd1a860b2012-01-26 14:49:28 +0000166
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000167 _realPayloadSizeBytes = 0;
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000168 _playoutBuffer = new int16_t[WEBRTC_10MS_PCM_AUDIO];
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000169 _frequency = playSampFreq;
170 _acm = acm;
171 _firstTime = true;
172}
173
174void Receiver::Teardown() {
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000175 delete[] _playoutBuffer;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000176 _pcmFile.Close();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000177 if (testMode > 1) {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000178 Trace::ReturnTrace();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000179 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000180}
181
182bool Receiver::IncomingPacket() {
183 if (!_rtpStream->EndOfFile()) {
184 if (_firstTime) {
185 _firstTime = false;
186 _realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload,
187 _payloadSizeBytes, &_nextTime);
andrew@webrtc.org975e4a32012-01-17 19:27:33 +0000188 if (_realPayloadSizeBytes == 0) {
189 if (_rtpStream->EndOfFile()) {
190 _firstTime = true;
191 return true;
192 } else {
andrew@webrtc.org975e4a32012-01-17 19:27:33 +0000193 return false;
194 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000195 }
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000196 }
niklase@google.com470e71d2011-07-07 08:21:25 +0000197
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000198 EXPECT_EQ(0, _acm->IncomingPacket(_incomingPayload, _realPayloadSizeBytes,
199 _rtpInfo));
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000200 _realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload,
201 _payloadSizeBytes, &_nextTime);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000202 if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile()) {
203 _firstTime = true;
niklase@google.com470e71d2011-07-07 08:21:25 +0000204 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000205 }
206 return true;
niklase@google.com470e71d2011-07-07 08:21:25 +0000207}
208
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000209bool Receiver::PlayoutData() {
210 AudioFrame audioFrame;
211
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000212 int32_t ok =_acm->PlayoutData10Ms(_frequency, &audioFrame);
213 EXPECT_EQ(0, ok);
214 if (ok < 0){
215 return false;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000216 }
217 if (_playoutLengthSmpls == 0) {
218 return false;
219 }
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000220 _pcmFile.Write10MsData(audioFrame.data_,
221 audioFrame.samples_per_channel_ * audioFrame.num_channels_);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000222 return true;
223}
224
225void Receiver::Run() {
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000226 uint8_t counter500Ms = 50;
227 uint32_t clock = 0;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000228
229 while (counter500Ms > 0) {
230 if (clock == 0 || clock >= _nextTime) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000231 EXPECT_TRUE(IncomingPacket());
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000232 if (clock == 0) {
233 clock = _nextTime;
234 }
235 }
236 if ((clock % 10) == 0) {
237 if (!PlayoutData()) {
238 clock++;
239 continue;
240 }
241 }
242 if (_rtpStream->EndOfFile()) {
243 counter500Ms--;
244 }
245 clock++;
246 }
247}
248
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +0000249EncodeDecodeTest::EncodeDecodeTest() {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000250 _testMode = 2;
251 Trace::CreateTrace();
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000252 Trace::SetTraceFile(
253 (webrtc::test::OutputPath() + "acm_encdec_trace.txt").c_str());
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000254}
255
henrik.lundin@webrtc.orgadaf8092014-04-17 08:29:10 +0000256EncodeDecodeTest::EncodeDecodeTest(int testMode) {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000257 //testMode == 0 for autotest
258 //testMode == 1 for testing all codecs/parameters
259 //testMode > 1 for specific user-input test (as it was used before)
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000260 _testMode = testMode;
261 if (_testMode != 0) {
262 Trace::CreateTrace();
263 Trace::SetTraceFile(
264 (webrtc::test::OutputPath() + "acm_encdec_trace.txt").c_str());
265 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000266}
267
268void EncodeDecodeTest::Perform() {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000269 int numCodecs = 1;
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000270 int codePars[3]; // Frequency, packet size, rate.
271 int numPars[52]; // Number of codec parameters sets (freq, pacsize, rate)
272 // to test, for a given codec.
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000273
274 codePars[0] = 0;
275 codePars[1] = 0;
276 codePars[2] = 0;
277
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000278 rtc::scoped_ptr<AudioCodingModule> acm(AudioCodingModule::Create(0));
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000279 struct CodecInst sendCodecTmp;
tina.legrand@webrtc.org5b4f36d2012-06-01 14:51:28 +0000280 numCodecs = acm->NumberOfCodecs();
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000281
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000282 if (_testMode != 2) {
283 for (int n = 0; n < numCodecs; n++) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000284 EXPECT_EQ(0, acm->Codec(n, &sendCodecTmp));
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000285 if (STR_CASE_CMP(sendCodecTmp.plname, "telephone-event") == 0) {
286 numPars[n] = 0;
287 } else if (STR_CASE_CMP(sendCodecTmp.plname, "cn") == 0) {
288 numPars[n] = 0;
289 } else if (STR_CASE_CMP(sendCodecTmp.plname, "red") == 0) {
290 numPars[n] = 0;
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000291 } else if (sendCodecTmp.channels == 2) {
292 numPars[n] = 0;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000293 } else {
294 numPars[n] = 1;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000295 }
296 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000297 } else {
298 numCodecs = 1;
299 numPars[0] = 1;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000300 }
301
302 _receiver.testMode = _testMode;
303
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000304 // Loop over all mono codecs:
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000305 for (int codeId = 0; codeId < numCodecs; codeId++) {
tina.legrand@webrtc.org45175852012-06-01 09:27:35 +0000306 // Only encode using real mono encoders, not telephone-event and cng.
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000307 for (int loopPars = 1; loopPars <= numPars[codeId]; loopPars++) {
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000308 // Encode all data to file.
pbos@webrtc.orgc86e45d2014-10-01 10:05:40 +0000309 std::string fileName = EncodeToFile(1, codeId, codePars, _testMode);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000310
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000311 RTPFile rtpFile;
kjellander@webrtc.org5490c712011-12-21 13:34:18 +0000312 rtpFile.Open(fileName.c_str(), "rb");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000313
314 _receiver.codeId = codeId;
315
316 rtpFile.ReadHeader();
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000317 _receiver.Setup(acm.get(), &rtpFile, "encodeDecode_out", 1);
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000318 _receiver.Run();
319 _receiver.Teardown();
320 rtpFile.Close();
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000321 }
322 }
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000323
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000324 // End tracing.
325 if (_testMode == 1) {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000326 Trace::ReturnTrace();
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000327 }
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000328}
329
pbos@webrtc.orgc86e45d2014-10-01 10:05:40 +0000330std::string EncodeDecodeTest::EncodeToFile(int fileType,
331 int codeId,
332 int* codePars,
333 int testMode) {
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000334 rtc::scoped_ptr<AudioCodingModule> acm(AudioCodingModule::Create(1));
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000335 RTPFile rtpFile;
pbos@webrtc.orgc86e45d2014-10-01 10:05:40 +0000336 std::string fileName = webrtc::test::TempFilename(webrtc::test::OutputPath(),
337 "encode_decode_rtp");
kjellander@webrtc.org5490c712011-12-21 13:34:18 +0000338 rtpFile.Open(fileName.c_str(), "wb+");
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000339 rtpFile.WriteHeader();
340
tina.legrand@webrtc.orgee92b662013-08-27 07:33:51 +0000341 // Store for auto_test and logging.
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000342 _sender.testMode = testMode;
343 _sender.codeId = codeId;
344
minyue@webrtc.orgaa5ea1c2014-05-23 15:16:51 +0000345 _sender.Setup(acm.get(), &rtpFile, "audio_coding/testfile32kHz", 32000, 1);
kwiberg1fd4a4a2015-11-03 11:20:50 -0800346 if (acm->SendCodec()) {
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000347 _sender.Run();
348 }
349 _sender.Teardown();
350 rtpFile.Close();
pbos@webrtc.orgc86e45d2014-10-01 10:05:40 +0000351
352 return fileName;
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:04 +0000353}
354
tina.legrand@webrtc.orgd5726a12013-05-03 07:34:12 +0000355} // namespace webrtc