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/Channel.cpp',
'../test/EncodeDecodeTest.cpp',
'../test/EncodeToFileTest.cpp',
'../test/iSACTest.cpp',
'../test/PCMFile.cpp',
'../test/RTPFile.cpp',

View File

@ -25,6 +25,8 @@
#include "trace.h"
#include "utility.h"
namespace webrtc {
#define TEST_DURATION_SEC 600
#define NUMBER_OF_SENDER_TESTS 6
@ -32,7 +34,6 @@
#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);}
using namespace webrtc;
void
APITest::Wait(WebRtc_UWord32 waitLengthMs)
@ -1545,3 +1546,6 @@ APITest::LookForDTMF(char side)
_acmB->RegisterIncomingMessagesCallback(NULL);
}
}
} // namespace webrtc

View File

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

View File

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

View File

@ -17,6 +17,7 @@
#include "critical_section_wrapper.h"
#include "rw_lock_wrapper.h"
namespace webrtc {
#define MAX_NUM_PAYLOADS 50
#define MAX_NUM_FRAMESIZES 6
@ -43,8 +44,6 @@ struct ACMTestPayloadStats
ACMTestFrameSizeStats frameSizeStats[MAX_NUM_FRAMESIZES];
};
using namespace webrtc;
class Channel: public AudioPacketizationCallback
{
public:
@ -96,7 +95,7 @@ public:
private:
void CalcStatistics(
WebRtcRTPHeader& rtpInfo,
WebRtcRTPHeader& rtpInfo,
WebRtc_UWord16 payloadSize);
AudioCodingModule* _receiverACM;
@ -121,5 +120,6 @@ private:
WebRtc_UWord64 _totalBytes;
};
} // namespace webrtc
#endif

View File

@ -10,296 +10,401 @@
#include "EncodeDecodeTest.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "audio_coding_module.h"
#include "common_types.h"
#include "gtest/gtest.h"
#include "trace.h"
#include "utility.h"
Receiver::Receiver()
:
_playoutLengthSmpls(WEBRTC_10MS_PCM_AUDIO),
_payloadSizeBytes(MAX_INCOMING_PAYLOAD)
{
namespace webrtc {
TestPacketization::TestPacketization(RTPStream *rtpStream,
WebRtc_UWord16 frequency)
: _rtpStream(rtpStream),
_frequency(frequency),
_seqNo(0) {
}
void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream)
{
struct CodecInst recvCodec;
int noOfCodecs;
acm->InitializeReceiver();
TestPacketization::~TestPacketization() { }
noOfCodecs = acm->NumberOfCodecs();
for (int i=0; i < noOfCodecs; i++)
{
acm->Codec((WebRtc_UWord8)i, recvCodec);
if (acm->RegisterReceiveCodec(recvCodec) != 0)
{
printf("Unable to register codec: for run: codecId: %d\n", codeId);
exit(1);
}
}
char filename[128];
_rtpStream = rtpStream;
int playSampFreq;
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;
}
if (testMode == 1)
{
playSampFreq=recvCodec.plfreq;
//output file for current run
sprintf(filename,"./src/modules/audio_coding/main/test/out%dFile.pcm",codeId);
_pcmFile.Open(filename, recvCodec.plfreq, "wb+");
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);
}
else if (testMode == 0)
{
playSampFreq=32000;
//output file for current run
sprintf(filename,"./src/modules/audio_coding/main/test/encodeDecode_out%d.pcm",codeId);
_pcmFile.Open(filename, 32000/*recvCodec.plfreq*/, "wb+");
}
else
{
printf("\nValid output frequencies:\n");
printf("8000\n16000\n32000\n-1, which means output freq equal to received signal freq");
printf("\n\nChoose output sampling frequency: ");
ASSERT_GT(scanf("%d", &playSampFreq), 0);
char fileName[] = "./src/modules/audio_coding/main/test/outFile.pcm";
_pcmFile.Open(fileName, 32000, "wb+");
}
_realPayloadSizeBytes = 0;
_playoutBuffer = new WebRtc_Word16[WEBRTC_10MS_PCM_AUDIO];
_frequency = playSampFreq;
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;
_firstTime = true;
}
void Sender::Teardown() {
_pcmFile.Close();
delete _packetization;
}
void Receiver::Teardown()
{
delete [] _playoutBuffer;
_pcmFile.Close();
if (testMode > 1) Trace::ReturnTrace();
}
bool Receiver::IncomingPacket()
{
if (!_rtpStream->EndOfFile())
{
if (_firstTime)
{
_firstTime = false;
_realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload, _payloadSizeBytes, &_nextTime);
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;
}
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 Receiver::PlayoutData()
{
AudioFrame audioFrame;
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;
}
if (_acm->PlayoutData10Ms(_frequency, audioFrame) != 0)
{
printf("Error when calling PlayoutData10Ms, for run: codecId: %d\n", codeId);
exit(1);
void Sender::Run() {
while (true) {
if (!Add10MsData()) {
break;
}
if (_playoutLengthSmpls == 0)
{
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;
int noOfCodecs;
acm->InitializeReceiver();
noOfCodecs = acm->NumberOfCodecs();
for (int i = 0; i < noOfCodecs; i++) {
acm->Codec((WebRtc_UWord8) i, recvCodec);
if (acm->RegisterReceiveCodec(recvCodec) != 0) {
printf("Unable to register codec: for run: codecId: %d\n", codeId);
exit(1);
}
}
char filename[128];
_rtpStream = rtpStream;
int playSampFreq;
if (testMode == 1) {
playSampFreq=recvCodec.plfreq;
//output file for current run
sprintf(filename,"./src/modules/audio_coding/main/test/out%dFile.pcm",
codeId);
_pcmFile.Open(filename, recvCodec.plfreq, "wb+");
} else if (testMode == 0) {
playSampFreq=32000;
//output file for current run
sprintf(filename,
"./src/modules/audio_coding/main/test/encodeDecode_out%d.pcm",
codeId);
_pcmFile.Open(filename, 32000/*recvCodec.plfreq*/, "wb+");
} else {
printf("\nValid output frequencies:\n");
printf("8000\n16000\n32000\n-1,");
printf("which means output freq equal to received signal freq");
printf("\n\nChoose output sampling frequency: ");
ASSERT_GT(scanf("%d", &playSampFreq), 0);
char fileName[] = "./src/modules/audio_coding/main/test/outFile.pcm";
_pcmFile.Open(fileName, 32000, "wb+");
}
_realPayloadSizeBytes = 0;
_playoutBuffer = new WebRtc_Word16[WEBRTC_10MS_PCM_AUDIO];
_frequency = playSampFreq;
_acm = acm;
_firstTime = true;
}
void Receiver::Teardown() {
delete [] _playoutBuffer;
_pcmFile.Close();
if (testMode > 1)
Trace::ReturnTrace();
}
bool Receiver::IncomingPacket() {
if (!_rtpStream->EndOfFile()) {
if (_firstTime) {
_firstTime = false;
_realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload,
_payloadSizeBytes, &_nextTime);
if (_realPayloadSizeBytes < 0) {
printf("Error in reading incoming payload.\n");
return false;
}
_pcmFile.Write10MsData(audioFrame._payloadData, audioFrame._payloadDataLengthInSamples);
return true;
}
void Receiver::Run()
{
WebRtc_UWord8 counter500Ms = 50;
WebRtc_UWord32 clock = 0;
while (counter500Ms > 0)
{
if (clock == 0 || clock >= _nextTime)
{
IncomingPacket();
if (clock == 0)
{
clock = _nextTime;
}
}
if ((clock % 10) == 0)
{
if (!PlayoutData())
{
clock++;
continue;
}
}
if (_rtpStream->EndOfFile())
{
counter500Ms--;
}
clock++;
}
}
EncodeDecodeTest::EncodeDecodeTest()
{
_testMode = 2;
Trace::CreateTrace();
Trace::SetTraceFile("acm_encdec_test.txt");
}
EncodeDecodeTest::EncodeDecodeTest(int testMode)
{
//testMode == 0 for autotest
//testMode == 1 for testing all codecs/parameters
//testMode > 1 for specific user-input test (as it was used before)
_testMode = testMode;
if(_testMode != 0)
{
Trace::CreateTrace();
Trace::SetTraceFile("acm_encdec_test.txt");
}
if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile()) {
_firstTime = true;
return true;
}
}
}
void EncodeDecodeTest::Perform()
{
if(_testMode == 0)
{
printf("Running Encode/Decode Test");
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, "---------- EncodeDecodeTest ----------");
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;
}
int numCodecs = 1;
int codePars[3]; //freq, pacsize, rate
int playoutFreq[3]; //8, 16, 32k
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;
if (_testMode == 1)
{
AudioCodingModule *acmTmp = AudioCodingModule::Create(0);
struct CodecInst sendCodecTmp;
numCodecs = acmTmp->NumberOfCodecs();
printf("List of supported codec.\n");
for(int n = 0; n < numCodecs; n++)
{
acmTmp->Codec(n, sendCodecTmp);
if (STR_CASE_CMP(sendCodecTmp.plname, "telephone-event") == 0) {
numPars[n] = 0;
} else if (STR_CASE_CMP(sendCodecTmp.plname, "cn") == 0) {
numPars[n] = 0;
} else if (STR_CASE_CMP(sendCodecTmp.plname, "red") == 0) {
numPars[n] = 0;
} else {
numPars[n] = 1;
printf("%d %s\n", n, sendCodecTmp.plname);
}
}
AudioCodingModule::Destroy(acmTmp);
playoutFreq[1]=16000;
}
else if (_testMode == 0)
{
AudioCodingModule *acmTmp = AudioCodingModule::Create(0);
numCodecs = acmTmp->NumberOfCodecs();
AudioCodingModule::Destroy(acmTmp);
struct CodecInst dummyCodec;
//chose range of testing for codecs/parameters
for(int i = 0 ; i < numCodecs ; i++)
{
numPars[i] = 1;
acmTmp->Codec(i, dummyCodec);
if (STR_CASE_CMP(dummyCodec.plname, "telephone-event") == 0)
{
numPars[i] = 0;
} else if (STR_CASE_CMP(dummyCodec.plname, "cn") == 0) {
numPars[i] = 0;
} else if (STR_CASE_CMP(dummyCodec.plname, "red") == 0) {
numPars[i] = 0;
}
}
playoutFreq[1] = 16000;
}
else
{
numCodecs = 1;
numPars[0] = 1;
playoutFreq[1]=16000;
}
_receiver.testMode = _testMode;
//loop over all codecs:
for(int codeId=0;codeId<numCodecs;codeId++)
{
//only encode using real encoders, not telephone-event anc cn
for(int loopPars=1;loopPars<=numPars[codeId];loopPars++)
{
if (_testMode == 1)
{
printf("\n");
printf("***FOR RUN: codeId: %d\n",codeId);
printf("\n");
}
else if (_testMode == 0)
{
printf(".");
}
EncodeToFileTest::Perform(1, codeId, codePars, _testMode);
AudioCodingModule *acm = AudioCodingModule::Create(10);
RTPFile rtpFile;
char fileName[] = "outFile.rtp";
rtpFile.Open(fileName, "rb");
_receiver.codeId = codeId;
rtpFile.ReadHeader();
_receiver.Setup(acm, &rtpFile);
_receiver.Run();
_receiver.Teardown();
rtpFile.Close();
AudioCodingModule::Destroy(acm);
if (_testMode == 1)
{
printf("***COMPLETED RUN FOR: codecID: %d ***\n",
codeId);
}
}
}
if (_testMode == 0)
{
printf("Done!\n");
}
if (_testMode == 1) Trace::ReturnTrace();
}
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;
}
_pcmFile.Write10MsData(audioFrame._payloadData,
audioFrame._payloadDataLengthInSamples);
return true;
}
void Receiver::Run() {
WebRtc_UWord8 counter500Ms = 50;
WebRtc_UWord32 clock = 0;
while (counter500Ms > 0) {
if (clock == 0 || clock >= _nextTime) {
IncomingPacket();
if (clock == 0) {
clock = _nextTime;
}
}
if ((clock % 10) == 0) {
if (!PlayoutData()) {
clock++;
continue;
}
}
if (_rtpStream->EndOfFile()) {
counter500Ms--;
}
clock++;
}
}
EncodeDecodeTest::EncodeDecodeTest() {
_testMode = 2;
Trace::CreateTrace();
Trace::SetTraceFile("acm_encdec_test.txt");
}
EncodeDecodeTest::EncodeDecodeTest(int testMode) {
//testMode == 0 for autotest
//testMode == 1 for testing all codecs/parameters
//testMode > 1 for specific user-input test (as it was used before)
_testMode = testMode;
if(_testMode != 0) {
Trace::CreateTrace();
Trace::SetTraceFile("acm_encdec_test.txt");
}
}
void EncodeDecodeTest::Perform() {
if (_testMode == 0) {
printf("Running Encode/Decode Test");
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1,
"---------- EncodeDecodeTest ----------");
}
int numCodecs = 1;
int codePars[3]; //freq, pacsize, rate
int playoutFreq[3]; //8, 16, 32k
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;
if (_testMode == 1) {
AudioCodingModule *acmTmp = AudioCodingModule::Create(0);
struct CodecInst sendCodecTmp;
numCodecs = acmTmp->NumberOfCodecs();
printf("List of supported codec.\n");
for(int n = 0; n < numCodecs; n++) {
acmTmp->Codec(n, sendCodecTmp);
if (STR_CASE_CMP(sendCodecTmp.plname, "telephone-event") == 0) {
numPars[n] = 0;
} else if (STR_CASE_CMP(sendCodecTmp.plname, "cn") == 0) {
numPars[n] = 0;
} else if (STR_CASE_CMP(sendCodecTmp.plname, "red") == 0) {
numPars[n] = 0;
} else {
numPars[n] = 1;
printf("%d %s\n", n, sendCodecTmp.plname);
}
}
AudioCodingModule::Destroy(acmTmp);
playoutFreq[1] = 16000;
} else if (_testMode == 0) {
AudioCodingModule *acmTmp = AudioCodingModule::Create(0);
numCodecs = acmTmp->NumberOfCodecs();
AudioCodingModule::Destroy(acmTmp);
struct CodecInst dummyCodec;
//chose range of testing for codecs/parameters
for(int i = 0 ; i < numCodecs ; i++) {
numPars[i] = 1;
acmTmp->Codec(i, dummyCodec);
if (STR_CASE_CMP(dummyCodec.plname, "telephone-event") == 0) {
numPars[i] = 0;
} else if (STR_CASE_CMP(dummyCodec.plname, "cn") == 0) {
numPars[i] = 0;
} else if (STR_CASE_CMP(dummyCodec.plname, "red") == 0) {
numPars[i] = 0;
}
}
playoutFreq[1] = 16000;
} else {
numCodecs = 1;
numPars[0] = 1;
playoutFreq[1]=16000;
}
_receiver.testMode = _testMode;
//loop over all codecs:
for (int codeId = 0; codeId < numCodecs; codeId++) {
//only encode using real encoders, not telephone-event anc cn
for (int loopPars = 1; loopPars <= numPars[codeId]; loopPars++) {
if (_testMode == 1) {
printf("\n");
printf("***FOR RUN: codeId: %d\n", codeId);
printf("\n");
} else if (_testMode == 0) {
printf(".");
}
EncodeToFile(1, codeId, codePars, _testMode);
AudioCodingModule *acm = AudioCodingModule::Create(10);
RTPFile rtpFile;
char fileName[] = "outFile.rtp";
rtpFile.Open(fileName, "rb");
_receiver.codeId = codeId;
rtpFile.ReadHeader();
_receiver.Setup(acm, &rtpFile);
_receiver.Run();
_receiver.Teardown();
rtpFile.Close();
AudioCodingModule::Destroy(acm);
if (_testMode == 1) {
printf("***COMPLETED RUN FOR: codecID: %d ***\n", codeId);
}
}
}
if (_testMode == 0) {
printf("Done!\n");
}
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,57 +8,110 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ENCODEDECODETEST_H
#define ENCODEDECODETEST_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_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
#include "audio_coding_module.h"
class Receiver
{
public:
Receiver();
void Setup(AudioCodingModule *acm, RTPStream *rtpStream);
void Teardown();
void Run();
bool IncomingPacket();
bool PlayoutData();
// 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);
//for auto_test and logging
WebRtc_UWord8 codeId;
WebRtc_UWord8 testMode;
private:
AudioCodingModule* _acm;
bool _rtpEOF;
RTPStream* _rtpStream;
PCMFile _pcmFile;
WebRtc_Word16* _playoutBuffer;
WebRtc_UWord16 _playoutLengthSmpls;
WebRtc_Word8 _incomingPayload[MAX_INCOMING_PAYLOAD];
WebRtc_UWord16 _payloadSizeBytes;
WebRtc_UWord16 _realPayloadSizeBytes;
WebRtc_Word32 _frequency;
bool _firstTime;
WebRtcRTPHeader _rtpInfo;
WebRtc_UWord32 _nextTime;
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 EncodeDecodeTest : public EncodeToFileTest
{
public:
EncodeDecodeTest();
EncodeDecodeTest(int testMode);
virtual void Perform();
WebRtc_UWord16 _playoutFreq;
WebRtc_UWord8 _testMode;
protected:
Receiver _receiver;
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();
void Setup(AudioCodingModule *acm, RTPStream *rtpStream);
void Teardown();
void Run();
bool IncomingPacket();
bool PlayoutData();
//for auto_test and logging
WebRtc_UWord8 codeId;
WebRtc_UWord8 testMode;
private:
AudioCodingModule* _acm;
bool _rtpEOF;
RTPStream* _rtpStream;
PCMFile _pcmFile;
WebRtc_Word16* _playoutBuffer;
WebRtc_UWord16 _playoutLengthSmpls;
WebRtc_Word8 _incomingPayload[MAX_INCOMING_PAYLOAD];
WebRtc_UWord16 _payloadSizeBytes;
WebRtc_UWord16 _realPayloadSizeBytes;
WebRtc_Word32 _frequency;
bool _firstTime;
WebRtcRTPHeader _rtpInfo;
WebRtc_UWord32 _nextTime;
};
class EncodeDecodeTest: public ACMTest {
public:
EncodeDecodeTest();
EncodeDecodeTest(int testMode);
virtual void Perform();
WebRtc_UWord16 _playoutFreq;
WebRtc_UWord8 _testMode;
private:
void EncodeToFile(int fileType, int codeId, int* codePars, int testMode);
protected:
Sender _sender;
Receiver _receiver;
};
} // namespace webrtc
#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 "module_common_types.h"
namespace webrtc {
#define MAX_FILE_NAME_LENGTH_BYTE 500
PCMFile::PCMFile():
_pcmFile(NULL),
_nSamples10Ms(160),
@ -300,3 +300,5 @@ PCMFile::ReadStereo(
{
_readStereo = readStereo;
}
} // namespace webrtc

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -19,6 +19,8 @@
#include "trace.h"
#include "utility.h"
namespace webrtc {
TestFEC::TestFEC(int testMode):
_acmA(NULL),
_acmB(NULL),
@ -28,8 +30,6 @@ _testCntr(0)
_testMode = testMode;
}
using namespace std;
TestFEC::~TestFEC()
{
if(_acmA != NULL)
@ -55,7 +55,7 @@ void TestFEC::Perform()
if(_testMode == 0)
{
printf("Running FEC Test");
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1,
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- TestFEC ----------");
}
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);
}
}
cout << flush;
std::cout << std::flush;
AudioCodingModule* myACM;
switch(side)
{
@ -619,3 +619,5 @@ void TestFEC::DisplaySendReceiveCodec()
_acmB->ReceiveCodec(myCodecParam);
printf("%s\n", myCodecParam.plname);
}
} // namespace webrtc

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -25,7 +25,7 @@
#include "trace.h"
#include "utility.h"
using namespace webrtc;
namespace webrtc {
#define MAX_FILE_NAME_LENGTH_BYTE 500
@ -67,7 +67,8 @@ TwoWayCommunication::~TwoWayCommunication()
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);
WebRtc_UWord8 noCodec = tmpACM->NumberOfCodecs();
@ -94,7 +95,8 @@ TwoWayCommunication::ChooseCodec(WebRtc_UWord8* codecID_A, WebRtc_UWord8* codecI
}
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];
//strcpy(_fileName, "in.pcm");
@ -139,7 +141,8 @@ TwoWayCommunication::ChooseFile(char* fileName, WebRtc_Word16 maxLen, WebRtc_UWo
{
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);
WebRtc_UWord16 tmpFreq = (WebRtc_UWord16)atoi(tmpName);
if(tmpFreq > 0)
@ -174,7 +177,8 @@ WebRtc_Word16 TwoWayCommunication::SetUp()
CHECK_ERROR(_acmA->RegisterReceiveCodec(codecInst_B));
#ifdef WEBRTC_DTMF_DETECTION
_dtmfDetectorA = new(DTMFDetector);
CHECK_ERROR(_acmA->RegisterIncomingMessagesCallback(_dtmfDetectorA, ACMUSA));
CHECK_ERROR(_acmA->RegisterIncomingMessagesCallback(_dtmfDetectorA,
ACMUSA));
#endif
//--- Set ref-A codecs
CHECK_ERROR(_acmRefA->RegisterSendCodec(codecInst_A));
@ -185,7 +189,8 @@ WebRtc_Word16 TwoWayCommunication::SetUp()
CHECK_ERROR(_acmB->RegisterReceiveCodec(codecInst_A));
#ifdef WEBRTC_DTMF_DETECTION
_dtmfDetectorB = new(DTMFDetector);
CHECK_ERROR(_acmB->RegisterIncomingMessagesCallback(_dtmfDetectorB, ACMUSA));
CHECK_ERROR(_acmB->RegisterIncomingMessagesCallback(_dtmfDetectorB,
ACMUSA));
#endif
//--- Set ref-B codecs
@ -279,7 +284,8 @@ WebRtc_Word16 TwoWayCommunication::SetUpAutotest()
CHECK_ERROR(_acmA->RegisterReceiveCodec(codecInst_B));
#ifdef WEBRTC_DTMF_DETECTION
_dtmfDetectorA = new(DTMFDetector);
CHECK_ERROR(_acmA->RegisterIncomingMessagesCallback(_dtmfDetectorA, ACMUSA));
CHECK_ERROR(_acmA->RegisterIncomingMessagesCallback(_dtmfDetectorA,
ACMUSA));
#endif
//--- Set ref-A codecs
@ -291,7 +297,8 @@ WebRtc_Word16 TwoWayCommunication::SetUpAutotest()
CHECK_ERROR(_acmB->RegisterReceiveCodec(codecInst_A));
#ifdef WEBRTC_DTMF_DETECTION
_dtmfDetectorB = new(DTMFDetector);
CHECK_ERROR(_acmB->RegisterIncomingMessagesCallback(_dtmfDetectorB, ACMUSA));
CHECK_ERROR(_acmB->RegisterIncomingMessagesCallback(_dtmfDetectorB,
ACMUSA));
#endif
//--- Set ref-B codecs
@ -312,7 +319,8 @@ WebRtc_Word16 TwoWayCommunication::SetUpAutotest()
strcpy(fileName, "./src/modules/audio_coding/main/test/outAutotestA.pcm");
frequencyHz = 16000;
_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");
//--- Input B
@ -324,7 +332,8 @@ WebRtc_Word16 TwoWayCommunication::SetUpAutotest()
strcpy(fileName, "./src/modules/audio_coding/main/test/outAutotestB.pcm");
frequencyHz = 16000;
_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");
//--- Set A-to-B channel
@ -359,7 +368,8 @@ TwoWayCommunication::Perform()
if(_testMode == 0)
{
printf("Running TwoWayCommunication Test");
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, "---------- TwoWayCommunication ----------");
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- TwoWayCommunication ----------");
SetUpAutotest();
}
else
@ -382,8 +392,8 @@ TwoWayCommunication::Perform()
if(_testMode != 0)
{
printf("\n");
printf("sec:msec A B\n");
printf("-------- ----- -----\n");
printf("sec:msec A B\n");
printf("-------- ----- -----\n");
}
while(!_inFileA.EndOfFile() && !_inFileB.EndOfFile())
@ -429,7 +439,8 @@ TwoWayCommunication::Perform()
_acmA->ResetEncoder();
if(_testMode == 0)
{
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, "---------- Errors epected");
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- Errors epected");
printf(".");
}
else
@ -443,7 +454,8 @@ TwoWayCommunication::Perform()
{
if(_testMode == 0)
{
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, "----- END: Errors epected");
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"----- END: Errors epected");
printf(".");
}
else
@ -460,7 +472,8 @@ TwoWayCommunication::Perform()
CHECK_ERROR(_acmB->ResetDecoder());
if(_testMode == 0)
{
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, "---------- Errors epected");
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- Errors epected");
printf(".");
}
else
@ -475,7 +488,8 @@ TwoWayCommunication::Perform()
{
if(_testMode == 0)
{
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, "----- END: Errors epected");
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"----- END: Errors epected");
printf(".");
}
else
@ -500,6 +514,6 @@ TwoWayCommunication::Perform()
_dtmfDetectorB->PrintDetectedDigits();
#endif
}
} // namespace webrtc

View File

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

View File

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

View File

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

View File

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

View File

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