Changes to solve warnings on Mac, issue #178.

Review URL: http://webrtc-codereview.appspot.com/320005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1216 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tina.legrand@webrtc.org 2011-12-16 10:09:04 +00:00
parent 605972edfd
commit 554ae1ad4e
30 changed files with 619 additions and 705 deletions

View File

@ -108,7 +108,6 @@
'../test/APITest.cpp', '../test/APITest.cpp',
'../test/Channel.cpp', '../test/Channel.cpp',
'../test/EncodeDecodeTest.cpp', '../test/EncodeDecodeTest.cpp',
'../test/EncodeToFileTest.cpp',
'../test/iSACTest.cpp', '../test/iSACTest.cpp',
'../test/PCMFile.cpp', '../test/PCMFile.cpp',
'../test/RTPFile.cpp', '../test/RTPFile.cpp',

View File

@ -25,6 +25,8 @@
#include "trace.h" #include "trace.h"
#include "utility.h" #include "utility.h"
namespace webrtc {
#define TEST_DURATION_SEC 600 #define TEST_DURATION_SEC 600
#define NUMBER_OF_SENDER_TESTS 6 #define NUMBER_OF_SENDER_TESTS 6
@ -32,7 +34,6 @@
#define MAX_FILE_NAME_LENGTH_BYTE 500 #define MAX_FILE_NAME_LENGTH_BYTE 500
#define CHECK_THREAD_NULLITY(myThread, S) if(myThread != NULL){unsigned int i; (myThread)->Start(i);}else{throw S; exit(1);} #define CHECK_THREAD_NULLITY(myThread, S) if(myThread != NULL){unsigned int i; (myThread)->Start(i);}else{throw S; exit(1);}
using namespace webrtc;
void void
APITest::Wait(WebRtc_UWord32 waitLengthMs) APITest::Wait(WebRtc_UWord32 waitLengthMs)
@ -1545,3 +1546,6 @@ APITest::LookForDTMF(char side)
_acmB->RegisterIncomingMessagesCallback(NULL); _acmB->RegisterIncomingMessagesCallback(NULL);
} }
} }
} // namespace webrtc

View File

@ -17,6 +17,8 @@
#include "event_wrapper.h" #include "event_wrapper.h"
#include "utility.h" #include "utility.h"
namespace webrtc {
enum APITESTAction {TEST_CHANGE_CODEC_ONLY = 0, DTX_TEST = 1}; enum APITESTAction {TEST_CHANGE_CODEC_ONLY = 0, DTX_TEST = 1};
class APITest : public ACMTest class APITest : public ACMTest
@ -170,5 +172,6 @@ private:
int _testNumB; int _testNumB;
}; };
} // namespace webrtc
#endif #endif

View File

@ -17,7 +17,7 @@
#include "typedefs.h" #include "typedefs.h"
#include "common_types.h" #include "common_types.h"
using namespace webrtc; namespace webrtc {
WebRtc_Word32 WebRtc_Word32
Channel::SendData( Channel::SendData(
@ -479,3 +479,5 @@ Channel::BitRate()
_channelCritSect->Leave(); _channelCritSect->Leave();
return rate; return rate;
} }
} // namespace webrtc

View File

@ -17,6 +17,7 @@
#include "critical_section_wrapper.h" #include "critical_section_wrapper.h"
#include "rw_lock_wrapper.h" #include "rw_lock_wrapper.h"
namespace webrtc {
#define MAX_NUM_PAYLOADS 50 #define MAX_NUM_PAYLOADS 50
#define MAX_NUM_FRAMESIZES 6 #define MAX_NUM_FRAMESIZES 6
@ -43,8 +44,6 @@ struct ACMTestPayloadStats
ACMTestFrameSizeStats frameSizeStats[MAX_NUM_FRAMESIZES]; ACMTestFrameSizeStats frameSizeStats[MAX_NUM_FRAMESIZES];
}; };
using namespace webrtc;
class Channel: public AudioPacketizationCallback class Channel: public AudioPacketizationCallback
{ {
public: public:
@ -121,5 +120,6 @@ private:
WebRtc_UWord64 _totalBytes; WebRtc_UWord64 _totalBytes;
}; };
} // namespace webrtc
#endif #endif

View File

@ -10,33 +10,142 @@
#include "EncodeDecodeTest.h" #include "EncodeDecodeTest.h"
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "audio_coding_module.h"
#include "common_types.h" #include "common_types.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "trace.h" #include "trace.h"
#include "utility.h" #include "utility.h"
Receiver::Receiver() namespace webrtc {
:
_playoutLengthSmpls(WEBRTC_10MS_PCM_AUDIO), TestPacketization::TestPacketization(RTPStream *rtpStream,
_payloadSizeBytes(MAX_INCOMING_PAYLOAD) WebRtc_UWord16 frequency)
{ : _rtpStream(rtpStream),
_frequency(frequency),
_seqNo(0) {
} }
void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream) TestPacketization::~TestPacketization() { }
{
WebRtc_Word32 TestPacketization::SendData(
const FrameType /* frameType */,
const WebRtc_UWord8 payloadType,
const WebRtc_UWord32 timeStamp,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord16 payloadSize,
const RTPFragmentationHeader* /* fragmentation */) {
_rtpStream->Write(payloadType, timeStamp, _seqNo++, payloadData, payloadSize,
_frequency);
return 1;
}
Sender::Sender()
: _acm(NULL),
_pcmFile(),
_audioFrame(),
_payloadSize(0),
_timeStamp(0),
_packetization(NULL) {
}
void Sender::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
acm->InitializeSender();
struct CodecInst sendCodec;
int noOfCodecs = acm->NumberOfCodecs();
int codecNo;
if (testMode == 1) {
// Set the codec, input file, and parameters for the current test.
codecNo = codeId;
// Use same input file for now.
char fileName[] = "./test/data/audio_coding/testfile32kHz.pcm";
_pcmFile.Open(fileName, 32000, "rb");
} else if (testMode == 0) {
// Set the codec, input file, and parameters for the current test.
codecNo = codeId;
acm->Codec(codecNo, sendCodec);
// Use same input file for now.
char fileName[] = "./test/data/audio_coding/testfile32kHz.pcm";
_pcmFile.Open(fileName, 32000, "rb");
} else {
printf("List of supported codec.\n");
for (int n = 0; n < noOfCodecs; n++) {
acm->Codec(n, sendCodec);
printf("%d %s\n", n, sendCodec.plname);
}
printf("Choose your codec:");
ASSERT_GT(scanf("%d", &codecNo), 0);
char fileName[] = "./test/data/audio_coding/testfile32kHz.pcm";
_pcmFile.Open(fileName, 32000, "rb");
}
acm->Codec(codecNo, sendCodec);
acm->RegisterSendCodec(sendCodec);
_packetization = new TestPacketization(rtpStream, sendCodec.plfreq);
if (acm->RegisterTransportCallback(_packetization) < 0) {
printf("Registering Transport Callback failed, for run: codecId: %d: --\n",
codeId);
}
_acm = acm;
}
void Sender::Teardown() {
_pcmFile.Close();
delete _packetization;
}
bool Sender::Add10MsData() {
if (!_pcmFile.EndOfFile()) {
_pcmFile.Read10MsData(_audioFrame);
WebRtc_Word32 ok = _acm->Add10MsData(_audioFrame);
if (ok != 0) {
printf("Error calling Add10MsData: for run: codecId: %d\n", codeId);
exit(1);
}
return true;
}
return false;
}
bool Sender::Process() {
WebRtc_Word32 ok = _acm->Process();
if (ok < 0) {
printf("Error calling Add10MsData: for run: codecId: %d\n", codeId);
exit(1);
}
return true;
}
void Sender::Run() {
while (true) {
if (!Add10MsData()) {
break;
}
if (!Process()) { // This could be done in a processing thread
break;
}
}
}
Receiver::Receiver()
: _playoutLengthSmpls(WEBRTC_10MS_PCM_AUDIO),
_payloadSizeBytes(MAX_INCOMING_PAYLOAD) {
}
void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
struct CodecInst recvCodec; struct CodecInst recvCodec;
int noOfCodecs; int noOfCodecs;
acm->InitializeReceiver(); acm->InitializeReceiver();
noOfCodecs = acm->NumberOfCodecs(); noOfCodecs = acm->NumberOfCodecs();
for (int i=0; i < noOfCodecs; i++) for (int i = 0; i < noOfCodecs; i++) {
{ acm->Codec((WebRtc_UWord8) i, recvCodec);
acm->Codec((WebRtc_UWord8)i, recvCodec); if (acm->RegisterReceiveCodec(recvCodec) != 0) {
if (acm->RegisterReceiveCodec(recvCodec) != 0)
{
printf("Unable to register codec: for run: codecId: %d\n", codeId); printf("Unable to register codec: for run: codecId: %d\n", codeId);
exit(1); exit(1);
} }
@ -46,24 +155,23 @@ void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream)
_rtpStream = rtpStream; _rtpStream = rtpStream;
int playSampFreq; int playSampFreq;
if (testMode == 1) if (testMode == 1) {
{
playSampFreq=recvCodec.plfreq; playSampFreq=recvCodec.plfreq;
//output file for current run //output file for current run
sprintf(filename,"./src/modules/audio_coding/main/test/out%dFile.pcm",codeId); sprintf(filename,"./src/modules/audio_coding/main/test/out%dFile.pcm",
codeId);
_pcmFile.Open(filename, recvCodec.plfreq, "wb+"); _pcmFile.Open(filename, recvCodec.plfreq, "wb+");
} } else if (testMode == 0) {
else if (testMode == 0)
{
playSampFreq=32000; playSampFreq=32000;
//output file for current run //output file for current run
sprintf(filename,"./src/modules/audio_coding/main/test/encodeDecode_out%d.pcm",codeId); sprintf(filename,
"./src/modules/audio_coding/main/test/encodeDecode_out%d.pcm",
codeId);
_pcmFile.Open(filename, 32000/*recvCodec.plfreq*/, "wb+"); _pcmFile.Open(filename, 32000/*recvCodec.plfreq*/, "wb+");
} } else {
else
{
printf("\nValid output frequencies:\n"); printf("\nValid output frequencies:\n");
printf("8000\n16000\n32000\n-1, which means output freq equal to received signal freq"); printf("8000\n16000\n32000\n-1,");
printf("which means output freq equal to received signal freq");
printf("\n\nChoose output sampling frequency: "); printf("\n\nChoose output sampling frequency: ");
ASSERT_GT(scanf("%d", &playSampFreq), 0); ASSERT_GT(scanf("%d", &playSampFreq), 0);
char fileName[] = "./src/modules/audio_coding/main/test/outFile.pcm"; char fileName[] = "./src/modules/audio_coding/main/test/outFile.pcm";
@ -77,138 +185,125 @@ void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream)
_firstTime = true; _firstTime = true;
} }
void Receiver::Teardown() void Receiver::Teardown() {
{
delete [] _playoutBuffer; delete [] _playoutBuffer;
_pcmFile.Close(); _pcmFile.Close();
if (testMode > 1) Trace::ReturnTrace(); if (testMode > 1)
Trace::ReturnTrace();
} }
bool Receiver::IncomingPacket() bool Receiver::IncomingPacket() {
{ if (!_rtpStream->EndOfFile()) {
if (!_rtpStream->EndOfFile()) if (_firstTime) {
{
if (_firstTime)
{
_firstTime = false; _firstTime = false;
_realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload, _payloadSizeBytes, &_nextTime); _realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload,
if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile()) _payloadSizeBytes, &_nextTime);
{ if (_realPayloadSizeBytes < 0) {
_firstTime = true; printf("Error in reading incoming payload.\n");
return true;
}
}
WebRtc_Word32 ok = _acm->IncomingPacket(_incomingPayload, _realPayloadSizeBytes, _rtpInfo);
if (ok != 0)
{
printf("Error when inserting packet to ACM, for run: codecId: %d\n", codeId);
exit(1);
}
_realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload, _payloadSizeBytes, &_nextTime);
if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile())
{
_firstTime = true;
}
}
return true;
}
bool Receiver::PlayoutData()
{
AudioFrame audioFrame;
if (_acm->PlayoutData10Ms(_frequency, audioFrame) != 0)
{
printf("Error when calling PlayoutData10Ms, for run: codecId: %d\n", codeId);
exit(1);
}
if (_playoutLengthSmpls == 0)
{
return false; return false;
} }
_pcmFile.Write10MsData(audioFrame._payloadData, audioFrame._payloadDataLengthInSamples); if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile()) {
_firstTime = true;
return true;
}
}
WebRtc_Word32 ok = _acm->IncomingPacket(_incomingPayload,
_realPayloadSizeBytes, _rtpInfo);
if (ok != 0) {
printf("Error when inserting packet to ACM, for run: codecId: %d\n",
codeId);
exit(1);
}
_realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload,
_payloadSizeBytes, &_nextTime);
if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile()) {
_firstTime = true;
}
}
return true; return true;
} }
void Receiver::Run() bool Receiver::PlayoutData() {
{ AudioFrame audioFrame;
WebRtc_UWord8 counter500Ms = 50;
if (_acm->PlayoutData10Ms(_frequency, audioFrame) != 0) {
printf("Error when calling PlayoutData10Ms, for run: codecId: %d\n",
codeId);
exit(1);
}
if (_playoutLengthSmpls == 0) {
return false;
}
_pcmFile.Write10MsData(audioFrame._payloadData,
audioFrame._payloadDataLengthInSamples);
return true;
}
void Receiver::Run() {
WebRtc_UWord8 counter500Ms = 50;
WebRtc_UWord32 clock = 0; WebRtc_UWord32 clock = 0;
while (counter500Ms > 0) while (counter500Ms > 0) {
{ if (clock == 0 || clock >= _nextTime) {
if (clock == 0 || clock >= _nextTime)
{
IncomingPacket(); IncomingPacket();
if (clock == 0) if (clock == 0) {
{
clock = _nextTime; clock = _nextTime;
} }
} }
if ((clock % 10) == 0) if ((clock % 10) == 0) {
{ if (!PlayoutData()) {
if (!PlayoutData())
{
clock++; clock++;
continue; continue;
} }
} }
if (_rtpStream->EndOfFile()) if (_rtpStream->EndOfFile()) {
{
counter500Ms--; counter500Ms--;
} }
clock++; clock++;
} }
} }
EncodeDecodeTest::EncodeDecodeTest() EncodeDecodeTest::EncodeDecodeTest() {
{
_testMode = 2; _testMode = 2;
Trace::CreateTrace(); Trace::CreateTrace();
Trace::SetTraceFile("acm_encdec_test.txt"); Trace::SetTraceFile("acm_encdec_test.txt");
} }
EncodeDecodeTest::EncodeDecodeTest(int testMode) EncodeDecodeTest::EncodeDecodeTest(int testMode) {
{
//testMode == 0 for autotest //testMode == 0 for autotest
//testMode == 1 for testing all codecs/parameters //testMode == 1 for testing all codecs/parameters
//testMode > 1 for specific user-input test (as it was used before) //testMode > 1 for specific user-input test (as it was used before)
_testMode = testMode; _testMode = testMode;
if(_testMode != 0) if(_testMode != 0) {
{
Trace::CreateTrace(); Trace::CreateTrace();
Trace::SetTraceFile("acm_encdec_test.txt"); Trace::SetTraceFile("acm_encdec_test.txt");
} }
} }
void EncodeDecodeTest::Perform()
{
if(_testMode == 0) void EncodeDecodeTest::Perform() {
{ if (_testMode == 0) {
printf("Running Encode/Decode Test"); printf("Running Encode/Decode Test");
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, "---------- EncodeDecodeTest ----------"); WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1,
"---------- EncodeDecodeTest ----------");
} }
int numCodecs = 1; int numCodecs = 1;
int codePars[3]; //freq, pacsize, rate int codePars[3]; //freq, pacsize, rate
int playoutFreq[3]; //8, 16, 32k int playoutFreq[3]; //8, 16, 32k
int numPars[52]; //number of codec parameters sets (rate,freq,pacsize)to test,
//for a given codec
int numPars[52]; //number of codec parameters sets (rate,freq,pacsize)to test, for a given codec codePars[0] = 0;
codePars[1] = 0;
codePars[2] = 0;
codePars[0]=0; if (_testMode == 1) {
codePars[1]=0;
codePars[2]=0;
if (_testMode == 1)
{
AudioCodingModule *acmTmp = AudioCodingModule::Create(0); AudioCodingModule *acmTmp = AudioCodingModule::Create(0);
struct CodecInst sendCodecTmp; struct CodecInst sendCodecTmp;
numCodecs = acmTmp->NumberOfCodecs(); numCodecs = acmTmp->NumberOfCodecs();
printf("List of supported codec.\n"); printf("List of supported codec.\n");
for(int n = 0; n < numCodecs; n++) for(int n = 0; n < numCodecs; n++) {
{
acmTmp->Codec(n, sendCodecTmp); acmTmp->Codec(n, sendCodecTmp);
if (STR_CASE_CMP(sendCodecTmp.plname, "telephone-event") == 0) { if (STR_CASE_CMP(sendCodecTmp.plname, "telephone-event") == 0) {
numPars[n] = 0; numPars[n] = 0;
@ -222,22 +317,18 @@ void EncodeDecodeTest::Perform()
} }
} }
AudioCodingModule::Destroy(acmTmp); AudioCodingModule::Destroy(acmTmp);
playoutFreq[1]=16000; playoutFreq[1] = 16000;
} } else if (_testMode == 0) {
else if (_testMode == 0)
{
AudioCodingModule *acmTmp = AudioCodingModule::Create(0); AudioCodingModule *acmTmp = AudioCodingModule::Create(0);
numCodecs = acmTmp->NumberOfCodecs(); numCodecs = acmTmp->NumberOfCodecs();
AudioCodingModule::Destroy(acmTmp); AudioCodingModule::Destroy(acmTmp);
struct CodecInst dummyCodec; struct CodecInst dummyCodec;
//chose range of testing for codecs/parameters //chose range of testing for codecs/parameters
for(int i = 0 ; i < numCodecs ; i++) for(int i = 0 ; i < numCodecs ; i++) {
{
numPars[i] = 1; numPars[i] = 1;
acmTmp->Codec(i, dummyCodec); acmTmp->Codec(i, dummyCodec);
if (STR_CASE_CMP(dummyCodec.plname, "telephone-event") == 0) if (STR_CASE_CMP(dummyCodec.plname, "telephone-event") == 0) {
{
numPars[i] = 0; numPars[i] = 0;
} else if (STR_CASE_CMP(dummyCodec.plname, "cn") == 0) { } else if (STR_CASE_CMP(dummyCodec.plname, "cn") == 0) {
numPars[i] = 0; numPars[i] = 0;
@ -246,9 +337,7 @@ void EncodeDecodeTest::Perform()
} }
} }
playoutFreq[1] = 16000; playoutFreq[1] = 16000;
} } else {
else
{
numCodecs = 1; numCodecs = 1;
numPars[0] = 1; numPars[0] = 1;
playoutFreq[1]=16000; playoutFreq[1]=16000;
@ -257,23 +346,18 @@ void EncodeDecodeTest::Perform()
_receiver.testMode = _testMode; _receiver.testMode = _testMode;
//loop over all codecs: //loop over all codecs:
for(int codeId=0;codeId<numCodecs;codeId++) for (int codeId = 0; codeId < numCodecs; codeId++) {
{
//only encode using real encoders, not telephone-event anc cn //only encode using real encoders, not telephone-event anc cn
for(int loopPars=1;loopPars<=numPars[codeId];loopPars++) for (int loopPars = 1; loopPars <= numPars[codeId]; loopPars++) {
{ if (_testMode == 1) {
if (_testMode == 1)
{
printf("\n"); printf("\n");
printf("***FOR RUN: codeId: %d\n",codeId); printf("***FOR RUN: codeId: %d\n", codeId);
printf("\n"); printf("\n");
} } else if (_testMode == 0) {
else if (_testMode == 0)
{
printf("."); printf(".");
} }
EncodeToFileTest::Perform(1, codeId, codePars, _testMode); EncodeToFile(1, codeId, codePars, _testMode);
AudioCodingModule *acm = AudioCodingModule::Create(10); AudioCodingModule *acm = AudioCodingModule::Create(10);
RTPFile rtpFile; RTPFile rtpFile;
@ -289,17 +373,38 @@ void EncodeDecodeTest::Perform()
rtpFile.Close(); rtpFile.Close();
AudioCodingModule::Destroy(acm); AudioCodingModule::Destroy(acm);
if (_testMode == 1) if (_testMode == 1) {
{ printf("***COMPLETED RUN FOR: codecID: %d ***\n", codeId);
printf("***COMPLETED RUN FOR: codecID: %d ***\n",
codeId);
} }
} }
} }
if (_testMode == 0) if (_testMode == 0) {
{
printf("Done!\n"); printf("Done!\n");
} }
if (_testMode == 1) Trace::ReturnTrace(); if (_testMode == 1)
Trace::ReturnTrace();
} }
void EncodeDecodeTest::EncodeToFile(int fileType, int codeId, int* codePars,
int testMode) {
AudioCodingModule *acm = AudioCodingModule::Create(0);
RTPFile rtpFile;
char fileName[] = "outFile.rtp";
rtpFile.Open(fileName, "wb+");
rtpFile.WriteHeader();
//for auto_test and logging
_sender.testMode = testMode;
_sender.codeId = codeId;
_sender.Setup(acm, &rtpFile);
struct CodecInst sendCodecInst;
if (acm->SendCodec(sendCodecInst) >= 0) {
_sender.Run();
}
_sender.Teardown();
rtpFile.Close();
AudioCodingModule::Destroy(acm);
}
} // namespace webrtc

View File

@ -8,17 +8,66 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ENCODEDECODETEST_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_ENCODEDECODETEST_H_
#define ENCODEDECODETEST_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_ENCODEDECODETEST_H_
#include "EncodeToFileTest.h" #include <stdio.h>
#include "ACMTest.h"
#include "audio_coding_module.h"
#include "RTPFile.h"
#include "PCMFile.h"
#include "typedefs.h"
namespace webrtc {
#define MAX_INCOMING_PAYLOAD 8096 #define MAX_INCOMING_PAYLOAD 8096
#include "audio_coding_module.h"
class Receiver // TestPacketization callback which writes the encoded payloads to file
{ class TestPacketization: public AudioPacketizationCallback {
public: public:
TestPacketization(RTPStream *rtpStream, WebRtc_UWord16 frequency);
~TestPacketization();
virtual WebRtc_Word32 SendData(const FrameType frameType,
const WebRtc_UWord8 payloadType,
const WebRtc_UWord32 timeStamp,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord16 payloadSize,
const RTPFragmentationHeader* fragmentation);
private:
static void MakeRTPheader(WebRtc_UWord8* rtpHeader, WebRtc_UWord8 payloadType,
WebRtc_Word16 seqNo, WebRtc_UWord32 timeStamp,
WebRtc_UWord32 ssrc);
RTPStream* _rtpStream;
WebRtc_Word32 _frequency;
WebRtc_Word16 _seqNo;
};
class Sender {
public:
Sender();
void Setup(AudioCodingModule *acm, RTPStream *rtpStream);
void Teardown();
void Run();
bool Add10MsData();
bool Process();
//for auto_test and logging
WebRtc_UWord8 testMode;
WebRtc_UWord8 codeId;
private:
AudioCodingModule* _acm;
PCMFile _pcmFile;
AudioFrame _audioFrame;
WebRtc_UWord16 _payloadSize;
WebRtc_UWord32 _timeStamp;
TestPacketization* _packetization;
};
class Receiver {
public:
Receiver(); Receiver();
void Setup(AudioCodingModule *acm, RTPStream *rtpStream); void Setup(AudioCodingModule *acm, RTPStream *rtpStream);
void Teardown(); void Teardown();
@ -30,7 +79,7 @@ public:
WebRtc_UWord8 codeId; WebRtc_UWord8 codeId;
WebRtc_UWord8 testMode; WebRtc_UWord8 testMode;
private: private:
AudioCodingModule* _acm; AudioCodingModule* _acm;
bool _rtpEOF; bool _rtpEOF;
RTPStream* _rtpStream; RTPStream* _rtpStream;
@ -46,19 +95,23 @@ private:
WebRtc_UWord32 _nextTime; WebRtc_UWord32 _nextTime;
}; };
class EncodeDecodeTest : public EncodeToFileTest class EncodeDecodeTest: public ACMTest {
{ public:
public:
EncodeDecodeTest(); EncodeDecodeTest();
EncodeDecodeTest(int testMode); EncodeDecodeTest(int testMode);
virtual void Perform(); virtual void Perform();
WebRtc_UWord16 _playoutFreq; WebRtc_UWord16 _playoutFreq;
WebRtc_UWord8 _testMode; WebRtc_UWord8 _testMode;
protected:
private:
void EncodeToFile(int fileType, int codeId, int* codePars, int testMode);
protected:
Sender _sender;
Receiver _receiver; Receiver _receiver;
}; };
} // namespace webrtc
#endif #endif

View File

@ -1,188 +0,0 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "EncodeToFileTest.h"
#ifdef WIN32
# include <Winsock2.h>
#else
# include <arpa/inet.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "audio_coding_module.h"
#include "common_types.h"
#include "gtest/gtest.h"
TestPacketization::TestPacketization(RTPStream *rtpStream, WebRtc_UWord16 frequency)
:
_frequency(frequency),
_seqNo(0)
{
_rtpStream = rtpStream;
}
TestPacketization::~TestPacketization()
{
}
WebRtc_Word32 TestPacketization::SendData(
const FrameType /* frameType */,
const WebRtc_UWord8 payloadType,
const WebRtc_UWord32 timeStamp,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord16 payloadSize,
const RTPFragmentationHeader* /* fragmentation */)
{
_rtpStream->Write(payloadType, timeStamp, _seqNo++, payloadData, payloadSize, _frequency);
//delete [] payloadData;
return 1;
}
Sender::Sender()
:
_acm(NULL),
//_payloadData(NULL),
_payloadSize(0),
_timeStamp(0)
{
}
void Sender::Setup(AudioCodingModule *acm, RTPStream *rtpStream)
{
acm->InitializeSender();
struct CodecInst sendCodec;
int noOfCodecs = acm->NumberOfCodecs();
int codecNo;
if (testMode == 1)
{
//set the codec, input file, and parameters for the current test
codecNo = codeId;
//use same input file for now
char fileName[] = "./test/data/audio_coding/testfile32kHz.pcm";
_pcmFile.Open(fileName, 32000, "rb");
}
else if (testMode == 0)
{
//set the codec, input file, and parameters for the current test
codecNo = codeId;
acm->Codec(codecNo, sendCodec);
//use same input file for now
char fileName[] = "./test/data/audio_coding/testfile32kHz.pcm";
_pcmFile.Open(fileName, 32000, "rb");
}
else
{
printf("List of supported codec.\n");
for(int n = 0; n < noOfCodecs; n++)
{
acm->Codec(n, sendCodec);
printf("%d %s\n", n, sendCodec.plname);
}
printf("Choose your codec:");
ASSERT_GT(scanf("%d", &codecNo), 0);
char fileName[] = "./test/data/audio_coding/testfile32kHz.pcm";
_pcmFile.Open(fileName, 32000, "rb");
}
acm->Codec(codecNo, sendCodec);
acm->RegisterSendCodec(sendCodec);
_packetization = new TestPacketization(rtpStream, sendCodec.plfreq);
if(acm->RegisterTransportCallback(_packetization) < 0)
{
printf("Registering Transport Callback failed, for run: codecId: %d: --\n",
codeId);
}
_acm = acm;
}
void Sender::Teardown()
{
_pcmFile.Close();
delete _packetization;
}
bool Sender::Add10MsData()
{
if (!_pcmFile.EndOfFile())
{
_pcmFile.Read10MsData(_audioFrame);
WebRtc_Word32 ok = _acm->Add10MsData(_audioFrame);
if (ok != 0)
{
printf("Error calling Add10MsData: for run: codecId: %d\n",
codeId);
exit(1);
}
//_audioFrame._timeStamp += _pcmFile.PayloadLength10Ms();
return true;
}
return false;
}
bool Sender::Process()
{
WebRtc_Word32 ok = _acm->Process();
if (ok < 0)
{
printf("Error calling Add10MsData: for run: codecId: %d\n",
codeId);
exit(1);
}
return true;
}
void Sender::Run()
{
while (true)
{
if (!Add10MsData())
{
break;
}
if (!Process()) // This could be done in a processing thread
{
break;
}
}
}
EncodeToFileTest::EncodeToFileTest()
{
}
void EncodeToFileTest::Perform(int fileType, int codeId, int* codePars, int testMode)
{
AudioCodingModule *acm = AudioCodingModule::Create(0);
RTPFile rtpFile;
char fileName[] = "outFile.rtp";
rtpFile.Open(fileName, "wb+");
rtpFile.WriteHeader();
//for auto_test and logging
_sender.testMode = testMode;
_sender.codeId = codeId;
_sender.Setup(acm, &rtpFile);
struct CodecInst sendCodecInst;
if(acm->SendCodec(sendCodecInst) >= 0)
{
_sender.Run();
}
_sender.Teardown();
rtpFile.Close();
AudioCodingModule::Destroy(acm);
}

View File

@ -1,79 +0,0 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ENCODETOFILETEST_H
#define ENCODETOFILETEST_H
#include "ACMTest.h"
#include "audio_coding_module.h"
#include "typedefs.h"
#include "RTPFile.h"
#include "PCMFile.h"
#include <stdio.h>
using namespace webrtc;
// TestPacketization callback which writes the encoded payloads to file
class TestPacketization : public AudioPacketizationCallback
{
public:
TestPacketization(RTPStream *rtpStream, WebRtc_UWord16 frequency);
~TestPacketization();
virtual WebRtc_Word32 SendData(const FrameType frameType,
const WebRtc_UWord8 payloadType,
const WebRtc_UWord32 timeStamp,
const WebRtc_UWord8* payloadData,
const WebRtc_UWord16 payloadSize,
const RTPFragmentationHeader* fragmentation);
private:
static void MakeRTPheader(WebRtc_UWord8* rtpHeader,
WebRtc_UWord8 payloadType, WebRtc_Word16 seqNo,
WebRtc_UWord32 timeStamp, WebRtc_UWord32 ssrc);
RTPStream* _rtpStream;
WebRtc_Word32 _frequency;
WebRtc_Word16 _seqNo;
};
class Sender
{
public:
Sender();
void Setup(AudioCodingModule *acm, RTPStream *rtpStream);
void Teardown();
void Run();
bool Add10MsData();
bool Process();
//for auto_test and logging
WebRtc_UWord8 testMode;
WebRtc_UWord8 codeId;
private:
AudioCodingModule* _acm;
PCMFile _pcmFile;
//WebRtc_Word16* _payloadData;
AudioFrame _audioFrame;
WebRtc_UWord16 _payloadSize;
WebRtc_UWord32 _timeStamp;
TestPacketization* _packetization;
};
// Test class
class EncodeToFileTest : public ACMTest
{
public:
EncodeToFileTest();
virtual void Perform(int fileType, int codeId, int* codePars, int testMode);
protected:
Sender _sender;
};
#endif

View File

@ -18,10 +18,10 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "module_common_types.h" #include "module_common_types.h"
namespace webrtc {
#define MAX_FILE_NAME_LENGTH_BYTE 500 #define MAX_FILE_NAME_LENGTH_BYTE 500
PCMFile::PCMFile(): PCMFile::PCMFile():
_pcmFile(NULL), _pcmFile(NULL),
_nSamples10Ms(160), _nSamples10Ms(160),
@ -300,3 +300,5 @@ PCMFile::ReadStereo(
{ {
_readStereo = readStereo; _readStereo = readStereo;
} }
} // namespace webrtc

View File

@ -16,7 +16,7 @@
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
using namespace webrtc; namespace webrtc {
class PCMFile class PCMFile
{ {
@ -60,4 +60,6 @@ private:
bool _saveStereo; bool _saveStereo;
}; };
} // namespace webrtc
#endif #endif

View File

@ -20,9 +20,11 @@
#include "audio_coding_module.h" #include "audio_coding_module.h"
#include "engine_configurations.h" #include "engine_configurations.h"
#include "gtest/gtest.h" #include "gtest/gtest.h" // TODO (tlegrand): Consider removing usage of gtest.
#include "rw_lock_wrapper.h" #include "rw_lock_wrapper.h"
namespace webrtc {
void RTPStream::ParseRTPHeader(WebRtcRTPHeader* rtpInfo, const WebRtc_UWord8* rtpHeader) void RTPStream::ParseRTPHeader(WebRtcRTPHeader* rtpInfo, const WebRtc_UWord8* rtpHeader)
{ {
rtpInfo->header.payloadType = rtpHeader[1]; rtpInfo->header.payloadType = rtpHeader[1];
@ -123,21 +125,10 @@ RTPBuffer::Read(WebRtcRTPHeader* rtpInfo,
} }
else else
{ {
throw "Payload buffer too small"; return -1;
exit(1);
} }
/*#ifdef WEBRTC_CODEC_G722
if(ACMCodecDB::_mycodecs[ACMCodecDB::g722].pltype == packet->payloadType)
{
*offset = (packet->timeStamp/(packet->frequency/1000))<<1;
}
else
{
#endif*/
*offset = (packet->timeStamp/(packet->frequency/1000)); *offset = (packet->timeStamp/(packet->frequency/1000));
/*#ifdef WEBRTC_CODEC_G722
}
#endif*/
return packet->payloadSize; return packet->payloadSize;
} }
@ -189,15 +180,15 @@ void RTPFile::ReadHeader()
WebRtc_UWord16 port, padding; WebRtc_UWord16 port, padding;
char fileHeader[40]; char fileHeader[40];
EXPECT_TRUE(fgets(fileHeader, 40, _rtpFile) != 0); EXPECT_TRUE(fgets(fileHeader, 40, _rtpFile) != 0);
EXPECT_GT(fread(&start_sec, 4, 1, _rtpFile), 0u); EXPECT_EQ(1u, fread(&start_sec, 4, 1, _rtpFile));
start_sec=ntohl(start_sec); start_sec=ntohl(start_sec);
EXPECT_GT(fread(&start_usec, 4, 1, _rtpFile), 0u); EXPECT_EQ(1u, fread(&start_usec, 4, 1, _rtpFile));
start_usec=ntohl(start_usec); start_usec=ntohl(start_usec);
EXPECT_GT(fread(&source, 4, 1, _rtpFile), 0u); EXPECT_EQ(1u, fread(&source, 4, 1, _rtpFile));
source=ntohl(source); source=ntohl(source);
EXPECT_GT(fread(&port, 2, 1, _rtpFile), 0u); EXPECT_EQ(1u, fread(&port, 2, 1, _rtpFile));
port=ntohs(port); port=ntohs(port);
EXPECT_GT(fread(&padding, 2, 1, _rtpFile), 0u); EXPECT_EQ(1u, fread(&padding, 2, 1, _rtpFile));
padding=ntohs(padding); padding=ntohs(padding);
} }
@ -211,18 +202,8 @@ void RTPFile::Write(const WebRtc_UWord8 payloadType, const WebRtc_UWord32 timeSt
WebRtc_UWord16 lengthBytes = htons(12 + payloadSize + 8); WebRtc_UWord16 lengthBytes = htons(12 + payloadSize + 8);
WebRtc_UWord16 plen = htons(12 + payloadSize); WebRtc_UWord16 plen = htons(12 + payloadSize);
WebRtc_UWord32 offsetMs; WebRtc_UWord32 offsetMs;
/*#ifdef WEBRTC_CODEC_G722
if(ACMCodecDB::_mycodecs[ACMCodecDB::g722].pltype == payloadType)
{
offsetMs = (timeStamp/(frequency/1000))<<1;
}
else
{
#endif*/
offsetMs = (timeStamp/(frequency/1000)); offsetMs = (timeStamp/(frequency/1000));
/*#ifdef WEBRTC_CODEC_G722
}
#endif*/
offsetMs = htonl(offsetMs); offsetMs = htonl(offsetMs);
fwrite(&lengthBytes, 2, 1, _rtpFile); fwrite(&lengthBytes, 2, 1, _rtpFile);
fwrite(&plen, 2, 1, _rtpFile); fwrite(&plen, 2, 1, _rtpFile);
@ -239,61 +220,41 @@ WebRtc_UWord16 RTPFile::Read(WebRtcRTPHeader* rtpInfo,
WebRtc_UWord16 lengthBytes; WebRtc_UWord16 lengthBytes;
WebRtc_UWord16 plen; WebRtc_UWord16 plen;
WebRtc_UWord8 rtpHeader[12]; WebRtc_UWord8 rtpHeader[12];
EXPECT_GT(fread(&lengthBytes, 2, 1, _rtpFile), 0u); fread(&lengthBytes, 2, 1, _rtpFile);
if (feof(_rtpFile)) /* Check if we have reached end of file. */
{
_rtpEOF = true;
return 0;
}
EXPECT_GT(fread(&plen, 2, 1, _rtpFile), 0u);
if (feof(_rtpFile))
{
_rtpEOF = true;
return 0;
}
EXPECT_GT(fread(offset, 4, 1, _rtpFile), 0u);
if (feof(_rtpFile)) if (feof(_rtpFile))
{ {
_rtpEOF = true; _rtpEOF = true;
return 0; return 0;
} }
EXPECT_EQ(1u, fread(&plen, 2, 1, _rtpFile));
EXPECT_EQ(1u, fread(offset, 4, 1, _rtpFile));
lengthBytes = ntohs(lengthBytes); lengthBytes = ntohs(lengthBytes);
plen = ntohs(plen); plen = ntohs(plen);
*offset = ntohl(*offset); *offset = ntohl(*offset);
if (plen < 12) EXPECT_GT(plen, 11);
{
throw "Unable to read RTP file"; EXPECT_EQ(1u, fread(rtpHeader, 12, 1, _rtpFile));
exit(1);
}
EXPECT_GT(fread(rtpHeader, 12, 1, _rtpFile), 0u);
if (feof(_rtpFile))
{
_rtpEOF = true;
return 0;
}
ParseRTPHeader(rtpInfo, rtpHeader); ParseRTPHeader(rtpInfo, rtpHeader);
rtpInfo->type.Audio.isCNG = false; rtpInfo->type.Audio.isCNG = false;
rtpInfo->type.Audio.channel = 1; rtpInfo->type.Audio.channel = 1;
if (lengthBytes != plen + 8) EXPECT_EQ(lengthBytes, plen + 8);
{
throw "Length parameters in RTP file doesn't match";
exit(1);
}
if (plen == 0) if (plen == 0)
{ {
return 0; return 0;
} }
else if (lengthBytes - 20 > payloadSize) if (payloadSize < (lengthBytes - 20))
{ {
throw "Payload buffer too small"; return -1;
exit(1);
} }
lengthBytes -= 20; lengthBytes -= 20;
EXPECT_GT(fread(payloadData, 1, lengthBytes, _rtpFile), 0u); if (lengthBytes < 0)
if (feof(_rtpFile))
{ {
_rtpEOF = true; return -1;
} }
EXPECT_EQ(lengthBytes, fread(payloadData, 1, lengthBytes, _rtpFile));
return lengthBytes; return lengthBytes;
} }
} // namespace webrtc

View File

@ -18,7 +18,7 @@
#include <stdio.h> #include <stdio.h>
#include <queue> #include <queue>
using namespace webrtc; namespace webrtc {
class RTPStream class RTPStream
{ {
@ -96,4 +96,5 @@ private:
bool _rtpEOF; bool _rtpEOF;
}; };
} // namespace webrtc
#endif #endif

View File

@ -18,7 +18,7 @@
#include "trace.h" #include "trace.h"
#include "common_types.h" #include "common_types.h"
using namespace webrtc; namespace webrtc {
#define NUM_PANN_COEFFS 10 #define NUM_PANN_COEFFS 10
@ -236,4 +236,4 @@ SpatialAudio::EncodeDecode()
_inFile.Rewind(); _inFile.Rewind();
} }
} // namespace webrtc

View File

@ -19,6 +19,7 @@
#define MAX_FILE_NAME_LENGTH_BYTE 500 #define MAX_FILE_NAME_LENGTH_BYTE 500
namespace webrtc {
class SpatialAudio : public ACMTest class SpatialAudio : public ACMTest
{ {
@ -40,4 +41,7 @@ private:
PCMFile _outFile; PCMFile _outFile;
int _testMode; int _testMode;
}; };
} // namespace webrtc
#endif #endif

View File

@ -18,6 +18,8 @@
#include "trace.h" #include "trace.h"
#include "utility.h" #include "utility.h"
namespace webrtc {
// Class for simulating packet handling // Class for simulating packet handling
TestPack::TestPack(): TestPack::TestPack():
_receiverACM(NULL), _receiverACM(NULL),
@ -114,7 +116,6 @@ _counter(0)
_testMode = testMode; _testMode = testMode;
} }
using namespace std;
TestAllCodecs::~TestAllCodecs() TestAllCodecs::~TestAllCodecs()
{ {
if(_acmA != NULL) if(_acmA != NULL)
@ -143,7 +144,7 @@ void TestAllCodecs::Perform()
if(_testMode == 0) if(_testMode == 0)
{ {
printf("Running All Codecs Test"); printf("Running All Codecs Test");
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- TestAllCodecs ----------"); "---------- TestAllCodecs ----------");
} }
@ -854,3 +855,5 @@ void TestAllCodecs::DisplaySendReceiveCodec()
printf("%s\n", myCodecParam.plname); printf("%s\n", myCodecParam.plname);
} }
} // namespace webrtc

View File

@ -15,6 +15,8 @@
#include "Channel.h" #include "Channel.h"
#include "PCMFile.h" #include "PCMFile.h"
namespace webrtc {
class TestPack : public AudioPacketizationCallback class TestPack : public AudioPacketizationCallback
{ {
public: public:
@ -89,6 +91,6 @@ private:
int _counter; int _counter;
}; };
#endif // TEST_ALL_CODECS_H #endif // TEST_ALL_CODECS_H
} // namespace webrtc

View File

@ -19,6 +19,8 @@
#include "trace.h" #include "trace.h"
#include "utility.h" #include "utility.h"
namespace webrtc {
TestFEC::TestFEC(int testMode): TestFEC::TestFEC(int testMode):
_acmA(NULL), _acmA(NULL),
_acmB(NULL), _acmB(NULL),
@ -28,8 +30,6 @@ _testCntr(0)
_testMode = testMode; _testMode = testMode;
} }
using namespace std;
TestFEC::~TestFEC() TestFEC::~TestFEC()
{ {
if(_acmA != NULL) if(_acmA != NULL)
@ -55,7 +55,7 @@ void TestFEC::Perform()
if(_testMode == 0) if(_testMode == 0)
{ {
printf("Running FEC Test"); printf("Running FEC Test");
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- TestFEC ----------"); "---------- TestFEC ----------");
} }
char fileName[] = "./test/data/audio_coding/testfile32kHz.pcm"; char fileName[] = "./test/data/audio_coding/testfile32kHz.pcm";
@ -527,7 +527,7 @@ WebRtc_Word16 TestFEC::RegisterSendCodec(char side, char* codecName, WebRtc_Word
printf("Registering %s for side %c\n", codecName, side); printf("Registering %s for side %c\n", codecName, side);
} }
} }
cout << flush; std::cout << std::flush;
AudioCodingModule* myACM; AudioCodingModule* myACM;
switch(side) switch(side)
{ {
@ -619,3 +619,5 @@ void TestFEC::DisplaySendReceiveCodec()
_acmB->ReceiveCodec(myCodecParam); _acmB->ReceiveCodec(myCodecParam);
printf("%s\n", myCodecParam.plname); printf("%s\n", myCodecParam.plname);
} }
} // namespace webrtc

View File

@ -15,6 +15,8 @@
#include "Channel.h" #include "Channel.h"
#include "PCMFile.h" #include "PCMFile.h"
namespace webrtc {
class TestFEC : public ACMTest class TestFEC : public ACMTest
{ {
public: public:
@ -42,6 +44,6 @@ private:
int _testMode; int _testMode;
}; };
} // namespace webrtc
#endif #endif

View File

@ -18,6 +18,7 @@
#include <cassert> #include <cassert>
#include "trace.h" #include "trace.h"
namespace webrtc {
// Class for simulating packet handling // Class for simulating packet handling
TestPackStereo::TestPackStereo(): TestPackStereo::TestPackStereo():
@ -167,7 +168,6 @@ _counter(0)
_testMode = testMode; _testMode = testMode;
} }
using namespace std;
TestStereo::~TestStereo() TestStereo::~TestStereo()
{ {
if(_acmA != NULL) if(_acmA != NULL)
@ -195,7 +195,7 @@ void TestStereo::Perform()
if(_testMode == 0) if(_testMode == 0)
{ {
printf("Running Stereo Test"); printf("Running Stereo Test");
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- TestStereo ----------"); "---------- TestStereo ----------");
} }
@ -550,3 +550,4 @@ void TestStereo::DisplaySendReceiveCodec()
} }
} }
} // namespace webrtc

View File

@ -15,6 +15,8 @@
#include "Channel.h" #include "Channel.h"
#include "PCMFile.h" #include "PCMFile.h"
namespace webrtc {
class TestPackStereo : public AudioPacketizationCallback class TestPackStereo : public AudioPacketizationCallback
{ {
public: public:
@ -94,6 +96,7 @@ private:
int _codecType; int _codecType;
}; };
} // namespace webrtc
#endif #endif

View File

@ -17,6 +17,7 @@
#include <iostream> #include <iostream>
#include "trace.h" #include "trace.h"
namespace webrtc {
TestVADDTX::TestVADDTX(int testMode): TestVADDTX::TestVADDTX(int testMode):
_acmA(NULL), _acmA(NULL),
@ -29,7 +30,6 @@ _testResults(0)
_testMode = testMode; _testMode = testMode;
} }
using namespace std;
TestVADDTX::~TestVADDTX() TestVADDTX::~TestVADDTX()
{ {
if(_acmA != NULL) if(_acmA != NULL)
@ -275,7 +275,7 @@ WebRtc_Word16 TestVADDTX::RegisterSendCodec(char side,
{ {
printf("Registering %s for side %c\n", codecName, side); printf("Registering %s for side %c\n", codecName, side);
} }
cout << flush; std::cout << std::flush;
AudioCodingModule* myACM; AudioCodingModule* myACM;
switch(side) switch(side)
{ {
@ -500,3 +500,5 @@ void ActivityMonitor::GetStatistics(WebRtc_UWord32* getCounter)
getCounter[ii] = _counter[ii]; getCounter[ii] = _counter[ii];
} }
} }
} // namespace webrtc

View File

@ -15,6 +15,8 @@
#include "Channel.h" #include "Channel.h"
#include "PCMFile.h" #include "PCMFile.h"
namespace webrtc {
typedef struct typedef struct
{ {
bool statusDTX; bool statusDTX;
@ -83,5 +85,6 @@ private:
VADDTXstruct _getStruct; VADDTXstruct _getStruct;
}; };
} // namespace webrtc
#endif #endif

View File

@ -16,7 +16,6 @@
#include "APITest.h" #include "APITest.h"
#include "EncodeDecodeTest.h" #include "EncodeDecodeTest.h"
#include "EncodeToFileTest.h"
#include "iSACTest.h" #include "iSACTest.h"
#include "SpatialAudio.h" #include "SpatialAudio.h"
#include "TestAllCodecs.h" #include "TestAllCodecs.h"
@ -25,6 +24,9 @@
#include "TestVADDTX.h" #include "TestVADDTX.h"
#include "TwoWayCommunication.h" #include "TwoWayCommunication.h"
using webrtc::AudioCodingModule;
using webrtc::Trace;
// Be sure to create the following directories before running the tests: // Be sure to create the following directories before running the tests:
// ./modules/audio_coding/main/test/res_tests // ./modules/audio_coding/main/test/res_tests
// ./modules/audio_coding/main/test/res_autotests // ./modules/audio_coding/main/test/res_autotests
@ -46,52 +48,52 @@ void PopulateTests(std::vector<ACMTest*>* tests)
{ {
Trace::CreateTrace(); Trace::CreateTrace();
Trace::SetTraceFile("./modules/audio_coding/main/test/res_tests/test_trace.txt"); Trace::SetTraceFile("acm_trace.txt");
printf("The following tests will be executed:\n"); printf("The following tests will be executed:\n");
#ifdef ACM_AUTO_TEST #ifdef ACM_AUTO_TEST
printf(" ACM auto test\n"); printf(" ACM auto test\n");
tests->push_back(new EncodeDecodeTest(0)); tests->push_back(new webrtc::EncodeDecodeTest(0));
tests->push_back(new TwoWayCommunication(0)); tests->push_back(new webrtc::TwoWayCommunication(0));
tests->push_back(new TestAllCodecs(0)); tests->push_back(new webrtc::TestAllCodecs(0));
tests->push_back(new TestStereo(0)); tests->push_back(new webrtc::TestStereo(0));
tests->push_back(new SpatialAudio(0)); tests->push_back(new webrtc::SpatialAudio(0));
tests->push_back(new TestVADDTX(0)); tests->push_back(new webrtc::TestVADDTX(0));
tests->push_back(new TestFEC(0)); tests->push_back(new webrtc::TestFEC(0));
tests->push_back(new ISACTest(0)); tests->push_back(new webrtc::ISACTest(0));
#endif #endif
#ifdef ACM_TEST_ENC_DEC #ifdef ACM_TEST_ENC_DEC
printf(" ACM encode-decode test\n"); printf(" ACM encode-decode test\n");
tests->push_back(new EncodeDecodeTest(2)); tests->push_back(new webrtc::EncodeDecodeTest(2));
#endif #endif
#ifdef ACM_TEST_TWO_WAY #ifdef ACM_TEST_TWO_WAY
printf(" ACM two-way communication test\n"); printf(" ACM two-way communication test\n");
tests->push_back(new TwoWayCommunication(1)); tests->push_back(new webrtc::TwoWayCommunication(1));
#endif #endif
#ifdef ACM_TEST_ALL_ENC_DEC #ifdef ACM_TEST_ALL_ENC_DEC
printf(" ACM all codecs test\n"); printf(" ACM all codecs test\n");
tests->push_back(new TestAllCodecs(1)); tests->push_back(new webrtc::TestAllCodecs(1));
#endif #endif
#ifdef ACM_TEST_STEREO #ifdef ACM_TEST_STEREO
printf(" ACM stereo test\n"); printf(" ACM stereo test\n");
tests->push_back(new TestStereo(1)); tests->push_back(new webrtc::TestStereo(1));
tests->push_back(new SpatialAudio(2)); tests->push_back(new webrtc::SpatialAudio(2));
#endif #endif
#ifdef ACM_TEST_VAD_DTX #ifdef ACM_TEST_VAD_DTX
printf(" ACM VAD-DTX test\n"); printf(" ACM VAD-DTX test\n");
tests->push_back(new TestVADDTX(1)); tests->push_back(new webrtc::TestVADDTX(1));
#endif #endif
#ifdef ACM_TEST_FEC #ifdef ACM_TEST_FEC
printf(" ACM FEC test\n"); printf(" ACM FEC test\n");
tests->push_back(new TestFEC(1)); tests->push_back(new webrtc::TestFEC(1));
#endif #endif
#ifdef ACM_TEST_CODEC_SPEC_API #ifdef ACM_TEST_CODEC_SPEC_API
printf(" ACM codec API test\n"); printf(" ACM codec API test\n");
tests->push_back(new ISACTest(1)); tests->push_back(new webrtc::ISACTest(1));
#endif #endif
#ifdef ACM_TEST_FULL_API #ifdef ACM_TEST_FULL_API
printf(" ACM full API test\n"); printf(" ACM full API test\n");
tests->push_back(new APITest()); tests->push_back(new webrtc::APITest());
#endif #endif
printf("\n"); printf("\n");
} }

View File

@ -25,7 +25,7 @@
#include "trace.h" #include "trace.h"
#include "utility.h" #include "utility.h"
using namespace webrtc; namespace webrtc {
#define MAX_FILE_NAME_LENGTH_BYTE 500 #define MAX_FILE_NAME_LENGTH_BYTE 500
@ -67,7 +67,8 @@ TwoWayCommunication::~TwoWayCommunication()
WebRtc_UWord8 WebRtc_UWord8
TwoWayCommunication::ChooseCodec(WebRtc_UWord8* codecID_A, WebRtc_UWord8* codecID_B) TwoWayCommunication::ChooseCodec(WebRtc_UWord8* codecID_A,
WebRtc_UWord8* codecID_B)
{ {
AudioCodingModule* tmpACM = AudioCodingModule::Create(0); AudioCodingModule* tmpACM = AudioCodingModule::Create(0);
WebRtc_UWord8 noCodec = tmpACM->NumberOfCodecs(); WebRtc_UWord8 noCodec = tmpACM->NumberOfCodecs();
@ -94,7 +95,8 @@ TwoWayCommunication::ChooseCodec(WebRtc_UWord8* codecID_A, WebRtc_UWord8* codecI
} }
WebRtc_Word16 WebRtc_Word16
TwoWayCommunication::ChooseFile(char* fileName, WebRtc_Word16 maxLen, WebRtc_UWord16* frequencyHz) TwoWayCommunication::ChooseFile(char* fileName, WebRtc_Word16 maxLen,
WebRtc_UWord16* frequencyHz)
{ {
WebRtc_Word8 tmpName[MAX_FILE_NAME_LENGTH_BYTE]; WebRtc_Word8 tmpName[MAX_FILE_NAME_LENGTH_BYTE];
//strcpy(_fileName, "in.pcm"); //strcpy(_fileName, "in.pcm");
@ -139,7 +141,8 @@ TwoWayCommunication::ChooseFile(char* fileName, WebRtc_Word16 maxLen, WebRtc_UWo
{ {
strncpy(fileName, tmpName, len+1); strncpy(fileName, tmpName, len+1);
} }
printf("Enter the sampling frequency (in Hz) of the above file [%u]: ", *frequencyHz); printf("Enter the sampling frequency (in Hz) of the above file [%u]: ",
*frequencyHz);
EXPECT_TRUE(fgets(tmpName, 6, stdin) != NULL); EXPECT_TRUE(fgets(tmpName, 6, stdin) != NULL);
WebRtc_UWord16 tmpFreq = (WebRtc_UWord16)atoi(tmpName); WebRtc_UWord16 tmpFreq = (WebRtc_UWord16)atoi(tmpName);
if(tmpFreq > 0) if(tmpFreq > 0)
@ -174,7 +177,8 @@ WebRtc_Word16 TwoWayCommunication::SetUp()
CHECK_ERROR(_acmA->RegisterReceiveCodec(codecInst_B)); CHECK_ERROR(_acmA->RegisterReceiveCodec(codecInst_B));
#ifdef WEBRTC_DTMF_DETECTION #ifdef WEBRTC_DTMF_DETECTION
_dtmfDetectorA = new(DTMFDetector); _dtmfDetectorA = new(DTMFDetector);
CHECK_ERROR(_acmA->RegisterIncomingMessagesCallback(_dtmfDetectorA, ACMUSA)); CHECK_ERROR(_acmA->RegisterIncomingMessagesCallback(_dtmfDetectorA,
ACMUSA));
#endif #endif
//--- Set ref-A codecs //--- Set ref-A codecs
CHECK_ERROR(_acmRefA->RegisterSendCodec(codecInst_A)); CHECK_ERROR(_acmRefA->RegisterSendCodec(codecInst_A));
@ -185,7 +189,8 @@ WebRtc_Word16 TwoWayCommunication::SetUp()
CHECK_ERROR(_acmB->RegisterReceiveCodec(codecInst_A)); CHECK_ERROR(_acmB->RegisterReceiveCodec(codecInst_A));
#ifdef WEBRTC_DTMF_DETECTION #ifdef WEBRTC_DTMF_DETECTION
_dtmfDetectorB = new(DTMFDetector); _dtmfDetectorB = new(DTMFDetector);
CHECK_ERROR(_acmB->RegisterIncomingMessagesCallback(_dtmfDetectorB, ACMUSA)); CHECK_ERROR(_acmB->RegisterIncomingMessagesCallback(_dtmfDetectorB,
ACMUSA));
#endif #endif
//--- Set ref-B codecs //--- Set ref-B codecs
@ -279,7 +284,8 @@ WebRtc_Word16 TwoWayCommunication::SetUpAutotest()
CHECK_ERROR(_acmA->RegisterReceiveCodec(codecInst_B)); CHECK_ERROR(_acmA->RegisterReceiveCodec(codecInst_B));
#ifdef WEBRTC_DTMF_DETECTION #ifdef WEBRTC_DTMF_DETECTION
_dtmfDetectorA = new(DTMFDetector); _dtmfDetectorA = new(DTMFDetector);
CHECK_ERROR(_acmA->RegisterIncomingMessagesCallback(_dtmfDetectorA, ACMUSA)); CHECK_ERROR(_acmA->RegisterIncomingMessagesCallback(_dtmfDetectorA,
ACMUSA));
#endif #endif
//--- Set ref-A codecs //--- Set ref-A codecs
@ -291,7 +297,8 @@ WebRtc_Word16 TwoWayCommunication::SetUpAutotest()
CHECK_ERROR(_acmB->RegisterReceiveCodec(codecInst_A)); CHECK_ERROR(_acmB->RegisterReceiveCodec(codecInst_A));
#ifdef WEBRTC_DTMF_DETECTION #ifdef WEBRTC_DTMF_DETECTION
_dtmfDetectorB = new(DTMFDetector); _dtmfDetectorB = new(DTMFDetector);
CHECK_ERROR(_acmB->RegisterIncomingMessagesCallback(_dtmfDetectorB, ACMUSA)); CHECK_ERROR(_acmB->RegisterIncomingMessagesCallback(_dtmfDetectorB,
ACMUSA));
#endif #endif
//--- Set ref-B codecs //--- Set ref-B codecs
@ -312,7 +319,8 @@ WebRtc_Word16 TwoWayCommunication::SetUpAutotest()
strcpy(fileName, "./src/modules/audio_coding/main/test/outAutotestA.pcm"); strcpy(fileName, "./src/modules/audio_coding/main/test/outAutotestA.pcm");
frequencyHz = 16000; frequencyHz = 16000;
_outFileA.Open(fileName, frequencyHz, "wb"); _outFileA.Open(fileName, frequencyHz, "wb");
strcpy(refFileName, "./src/modules/audio_coding/main/test/ref_outAutotestA.pcm"); strcpy(refFileName,
"./src/modules/audio_coding/main/test/ref_outAutotestA.pcm");
_outFileRefA.Open(refFileName, frequencyHz, "wb"); _outFileRefA.Open(refFileName, frequencyHz, "wb");
//--- Input B //--- Input B
@ -324,7 +332,8 @@ WebRtc_Word16 TwoWayCommunication::SetUpAutotest()
strcpy(fileName, "./src/modules/audio_coding/main/test/outAutotestB.pcm"); strcpy(fileName, "./src/modules/audio_coding/main/test/outAutotestB.pcm");
frequencyHz = 16000; frequencyHz = 16000;
_outFileB.Open(fileName, frequencyHz, "wb"); _outFileB.Open(fileName, frequencyHz, "wb");
strcpy(refFileName, "./src/modules/audio_coding/main/test/ref_outAutotestB.pcm"); strcpy(refFileName,
"./src/modules/audio_coding/main/test/ref_outAutotestB.pcm");
_outFileRefB.Open(refFileName, frequencyHz, "wb"); _outFileRefB.Open(refFileName, frequencyHz, "wb");
//--- Set A-to-B channel //--- Set A-to-B channel
@ -359,7 +368,8 @@ TwoWayCommunication::Perform()
if(_testMode == 0) if(_testMode == 0)
{ {
printf("Running TwoWayCommunication Test"); printf("Running TwoWayCommunication Test");
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, "---------- TwoWayCommunication ----------"); WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- TwoWayCommunication ----------");
SetUpAutotest(); SetUpAutotest();
} }
else else
@ -429,7 +439,8 @@ TwoWayCommunication::Perform()
_acmA->ResetEncoder(); _acmA->ResetEncoder();
if(_testMode == 0) if(_testMode == 0)
{ {
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, "---------- Errors epected"); WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- Errors epected");
printf("."); printf(".");
} }
else else
@ -443,7 +454,8 @@ TwoWayCommunication::Perform()
{ {
if(_testMode == 0) if(_testMode == 0)
{ {
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, "----- END: Errors epected"); WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"----- END: Errors epected");
printf("."); printf(".");
} }
else else
@ -460,7 +472,8 @@ TwoWayCommunication::Perform()
CHECK_ERROR(_acmB->ResetDecoder()); CHECK_ERROR(_acmB->ResetDecoder());
if(_testMode == 0) if(_testMode == 0)
{ {
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, "---------- Errors epected"); WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- Errors epected");
printf("."); printf(".");
} }
else else
@ -475,7 +488,8 @@ TwoWayCommunication::Perform()
{ {
if(_testMode == 0) if(_testMode == 0)
{ {
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, "----- END: Errors epected"); WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"----- END: Errors epected");
printf("."); printf(".");
} }
else else
@ -500,6 +514,6 @@ TwoWayCommunication::Perform()
_dtmfDetectorB->PrintDetectedDigits(); _dtmfDetectorB->PrintDetectedDigits();
#endif #endif
} }
} // namespace webrtc

View File

@ -17,6 +17,7 @@
#include "audio_coding_module.h" #include "audio_coding_module.h"
#include "utility.h" #include "utility.h"
namespace webrtc {
class TwoWayCommunication : public ACMTest class TwoWayCommunication : public ACMTest
{ {
@ -58,5 +59,6 @@ private:
int _testMode; int _testMode;
}; };
} // namespace webrtc
#endif #endif

View File

@ -28,6 +28,7 @@
#include "tick_util.h" #include "tick_util.h"
namespace webrtc {
void SetISACConfigDefault( void SetISACConfigDefault(
ACMTestISACConfig& isacConfig) ACMTestISACConfig& isacConfig)
@ -595,3 +596,5 @@ ISACTest::SwitchingSamplingRate(
_inFileA.Close(); _inFileA.Close();
_inFileB.Close(); _inFileB.Close();
} }
} // namespace webrtc

View File

@ -21,6 +21,8 @@
#define MAX_FILE_NAME_LENGTH_BYTE 500 #define MAX_FILE_NAME_LENGTH_BYTE 500
#define NO_OF_CLIENTS 15 #define NO_OF_CLIENTS 15
namespace webrtc {
struct ACMTestISACConfig struct ACMTestISACConfig
{ {
WebRtc_Word32 currentRateBitPerSec; WebRtc_Word32 currentRateBitPerSec;
@ -96,5 +98,6 @@ private:
PCMFile _clientOutFile[NO_OF_CLIENTS]; PCMFile _clientOutFile[NO_OF_CLIENTS];
}; };
} // namespace webrtc
#endif #endif

View File

@ -20,6 +20,7 @@
#define NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE 13 #define NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE 13
namespace webrtc {
ACMTestTimer::ACMTestTimer() : ACMTestTimer::ACMTestTimer() :
_msec(0), _msec(0),
@ -429,3 +430,5 @@ VADCallback::InFrameType(
_numFrameTypes[frameType]++; _numFrameTypes[frameType]++;
return 0; return 0;
} }
} // namespace webrtc

View File

@ -13,6 +13,8 @@
#include "audio_coding_module.h" #include "audio_coding_module.h"
namespace webrtc {
//----------------------------- //-----------------------------
#define CHECK_ERROR(f) \ #define CHECK_ERROR(f) \
do { \ do { \
@ -88,8 +90,6 @@
} \ } \
} while(0) } while(0)
using namespace webrtc;
class ACMTestTimer class ACMTestTimer
{ {
public: public:
@ -197,6 +197,6 @@ private:
WebRtc_UWord32 _numFrameTypes[6]; WebRtc_UWord32 _numFrameTypes[6];
}; };
} // namespace webrtc
#endif // ACM_TEST_UTILITY_H #endif // ACM_TEST_UTILITY_H