Formatting ACM tests

Pure formatting of all files located in /webrtc/modules/audio_coding/main/test/

Smaller manual modifications done after using Eclipse formatting tool, like wrapping long lines (mostly comments).

BUG=issue1024

Review URL: https://webrtc-codereview.appspot.com/1342004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3946 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tina.legrand@webrtc.org 2013-05-03 07:34:12 +00:00
parent 03efc89151
commit d5726a1286
34 changed files with 4385 additions and 5230 deletions

View File

@ -10,7 +10,5 @@
#include "ACMTest.h" #include "ACMTest.h"
ACMTest::~ACMTest() ACMTest::~ACMTest() {}
{
}

View File

@ -11,8 +11,7 @@
#ifndef ACMTEST_H #ifndef ACMTEST_H
#define ACMTEST_H #define ACMTEST_H
class ACMTest class ACMTest {
{
public: public:
virtual ~ACMTest() = 0; virtual ~ACMTest() = 0;
virtual void Perform() = 0; virtual void Perform() = 0;

File diff suppressed because it is too large Load Diff

View File

@ -19,10 +19,12 @@
namespace webrtc { 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 {
{
public: public:
APITest(); APITest();
~APITest(); ~APITest();
@ -79,8 +81,6 @@ private:
bool ProcessRunB(); bool ProcessRunB();
bool APIRunB(); bool APIRunB();
//--- ACMs //--- ACMs
AudioCodingModule* _acmA; AudioCodingModule* _acmA;
AudioCodingModule* _acmB; AudioCodingModule* _acmB;
@ -147,7 +147,6 @@ private:
ACMBackgroundNoiseMode _bgnModeA; ACMBackgroundNoiseMode _bgnModeA;
ACMBackgroundNoiseMode _bgnModeB; ACMBackgroundNoiseMode _bgnModeB;
int _receiveVADActivityA[3]; int _receiveVADActivityA[3];
int _receiveVADActivityB[3]; int _receiveVADActivityB[3];
bool _verbose; bool _verbose;

View File

@ -19,15 +19,10 @@
namespace webrtc { namespace webrtc {
int32_t int32_t Channel::SendData(const FrameType frameType, const uint8_t payloadType,
Channel::SendData( const uint32_t timeStamp, const uint8_t* payloadData,
const FrameType frameType,
const uint8_t payloadType,
const uint32_t timeStamp,
const uint8_t* payloadData,
const uint16_t payloadSize, const uint16_t payloadSize,
const RTPFragmentationHeader* fragmentation) const RTPFragmentationHeader* fragmentation) {
{
WebRtcRTPHeader rtpInfo; WebRtcRTPHeader rtpInfo;
int32_t status; int32_t status;
uint16_t payloadDataSize = payloadSize; uint16_t payloadDataSize = payloadSize;
@ -37,30 +32,26 @@ Channel::SendData(
rtpInfo.header.sequenceNumber = _seqNo++; rtpInfo.header.sequenceNumber = _seqNo++;
rtpInfo.header.payloadType = payloadType; rtpInfo.header.payloadType = payloadType;
rtpInfo.header.timestamp = timeStamp; rtpInfo.header.timestamp = timeStamp;
if(frameType == kAudioFrameCN) if (frameType == kAudioFrameCN) {
{
rtpInfo.type.Audio.isCNG = true; rtpInfo.type.Audio.isCNG = true;
} } else {
else
{
rtpInfo.type.Audio.isCNG = false; rtpInfo.type.Audio.isCNG = false;
} }
if(frameType == kFrameEmpty) if (frameType == kFrameEmpty) {
{
// Skip this frame // Skip this frame
return 0; return 0;
} }
rtpInfo.type.Audio.channel = 1; rtpInfo.type.Audio.channel = 1;
// Treat fragmentation separately // Treat fragmentation separately
if(fragmentation != NULL) if (fragmentation != NULL) {
{ // If silence for too long, send only new data.
if((fragmentation->fragmentationTimeDiff[1] <= 0x3fff) && // silence for too long send only new data if ((fragmentation->fragmentationTimeDiff[1] <= 0x3fff) &&
(fragmentation->fragmentationVectorSize == 2)) (fragmentation->fragmentationVectorSize == 2)) {
{
// only 0x80 if we have multiple blocks // only 0x80 if we have multiple blocks
_payloadData[0] = 0x80 + fragmentation->fragmentationPlType[1]; _payloadData[0] = 0x80 + fragmentation->fragmentationPlType[1];
uint32_t REDheader = (((uint32_t)fragmentation->fragmentationTimeDiff[1]) << 10) + fragmentation->fragmentationLength[1]; uint32_t REDheader = (((uint32_t) fragmentation->fragmentationTimeDiff[1])
<< 10) + fragmentation->fragmentationLength[1];
_payloadData[1] = uint8_t((REDheader >> 16) & 0x000000FF); _payloadData[1] = uint8_t((REDheader >> 16) & 0x000000FF);
_payloadData[2] = uint8_t((REDheader >> 8) & 0x000000FF); _payloadData[2] = uint8_t((REDheader >> 8) & 0x000000FF);
_payloadData[3] = uint8_t(REDheader & 0x000000FF); _payloadData[3] = uint8_t(REDheader & 0x000000FF);
@ -75,29 +66,21 @@ Channel::SendData(
payloadData + fragmentation->fragmentationOffset[0], payloadData + fragmentation->fragmentationOffset[0],
fragmentation->fragmentationLength[0]); fragmentation->fragmentationLength[0]);
payloadDataSize += 5; payloadDataSize += 5;
} else } else {
{
// single block (newest one) // single block (newest one)
memcpy(_payloadData, memcpy(_payloadData, payloadData + fragmentation->fragmentationOffset[0],
payloadData + fragmentation->fragmentationOffset[0],
fragmentation->fragmentationLength[0]); fragmentation->fragmentationLength[0]);
payloadDataSize = uint16_t(fragmentation->fragmentationLength[0]); payloadDataSize = uint16_t(fragmentation->fragmentationLength[0]);
rtpInfo.header.payloadType = fragmentation->fragmentationPlType[0]; rtpInfo.header.payloadType = fragmentation->fragmentationPlType[0];
} }
} } else {
else
{
memcpy(_payloadData, payloadData, payloadDataSize); memcpy(_payloadData, payloadData, payloadDataSize);
if(_isStereo) if (_isStereo) {
{ if (_leftChannel) {
if(_leftChannel)
{
memcpy(&_rtpInfo, &rtpInfo, sizeof(WebRtcRTPHeader)); memcpy(&_rtpInfo, &rtpInfo, sizeof(WebRtcRTPHeader));
_leftChannel = false; _leftChannel = false;
rtpInfo.type.Audio.channel = 1; rtpInfo.type.Audio.channel = 1;
} } else {
else
{
memcpy(&rtpInfo, &_rtpInfo, sizeof(WebRtcRTPHeader)); memcpy(&rtpInfo, &_rtpInfo, sizeof(WebRtcRTPHeader));
_leftChannel = true; _leftChannel = true;
rtpInfo.type.Audio.channel = 2; rtpInfo.type.Audio.channel = 2;
@ -106,52 +89,40 @@ Channel::SendData(
} }
_channelCritSect->Enter(); _channelCritSect->Enter();
if(_saveBitStream) if (_saveBitStream) {
{
//fwrite(payloadData, sizeof(uint8_t), payloadSize, _bitStreamFile); //fwrite(payloadData, sizeof(uint8_t), payloadSize, _bitStreamFile);
} }
if(!_isStereo) if (!_isStereo) {
{
CalcStatistics(rtpInfo, payloadSize); CalcStatistics(rtpInfo, payloadSize);
} }
_lastInTimestamp = timeStamp; _lastInTimestamp = timeStamp;
_totalBytes += payloadDataSize; _totalBytes += payloadDataSize;
_channelCritSect->Leave(); _channelCritSect->Leave();
if(_useFECTestWithPacketLoss) if (_useFECTestWithPacketLoss) {
{
_packetLoss += 1; _packetLoss += 1;
if(_packetLoss == 3) if (_packetLoss == 3) {
{
_packetLoss = 0; _packetLoss = 0;
return 0; return 0;
} }
} }
status = _receiverACM->IncomingPacket(_payloadData, payloadDataSize, status = _receiverACM->IncomingPacket(_payloadData, payloadDataSize, rtpInfo);
rtpInfo);
return status; return status;
} }
void void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, uint16_t payloadSize) {
Channel::CalcStatistics(
WebRtcRTPHeader& rtpInfo,
uint16_t payloadSize)
{
int n; int n;
if((rtpInfo.header.payloadType != _lastPayloadType) && if ((rtpInfo.header.payloadType != _lastPayloadType)
(_lastPayloadType != -1)) && (_lastPayloadType != -1)) {
{
// payload-type is changed. // payload-type is changed.
// we have to terminate the calculations on the previous payload type // we have to terminate the calculations on the previous payload type
// we ignore the last packet in that payload type just to make things // we ignore the last packet in that payload type just to make things
// easier. // easier.
for(n = 0; n < MAX_NUM_PAYLOADS; n++) for (n = 0; n < MAX_NUM_PAYLOADS; n++) {
{ if (_lastPayloadType == _payloadStats[n].payloadType) {
if(_lastPayloadType == _payloadStats[n].payloadType)
{
_payloadStats[n].newPacket = true; _payloadStats[n].newPacket = true;
break; break;
} }
@ -161,70 +132,59 @@ Channel::CalcStatistics(
bool newPayload = true; bool newPayload = true;
ACMTestPayloadStats* currentPayloadStr = NULL; ACMTestPayloadStats* currentPayloadStr = NULL;
for(n = 0; n < MAX_NUM_PAYLOADS; n++) for (n = 0; n < MAX_NUM_PAYLOADS; n++) {
{ if (rtpInfo.header.payloadType == _payloadStats[n].payloadType) {
if(rtpInfo.header.payloadType == _payloadStats[n].payloadType)
{
newPayload = false; newPayload = false;
currentPayloadStr = &_payloadStats[n]; currentPayloadStr = &_payloadStats[n];
break; break;
} }
} }
if(!newPayload) if (!newPayload) {
{ if (!currentPayloadStr->newPacket) {
if(!currentPayloadStr->newPacket) uint32_t lastFrameSizeSample = (uint32_t)(
{ (uint32_t) rtpInfo.header.timestamp
uint32_t lastFrameSizeSample = (uint32_t)((uint32_t)rtpInfo.header.timestamp - - (uint32_t) currentPayloadStr->lastTimestamp);
(uint32_t)currentPayloadStr->lastTimestamp);
assert(lastFrameSizeSample > 0); assert(lastFrameSizeSample > 0);
int k = 0; int k = 0;
while((currentPayloadStr->frameSizeStats[k].frameSizeSample != while ((currentPayloadStr->frameSizeStats[k].frameSizeSample
lastFrameSizeSample) && != lastFrameSizeSample)
(currentPayloadStr->frameSizeStats[k].frameSizeSample != 0)) && (currentPayloadStr->frameSizeStats[k].frameSizeSample != 0)) {
{
k++; k++;
} }
ACMTestFrameSizeStats* currentFrameSizeStats = ACMTestFrameSizeStats* currentFrameSizeStats = &(currentPayloadStr
&(currentPayloadStr->frameSizeStats[k]); ->frameSizeStats[k]);
currentFrameSizeStats->frameSizeSample = (int16_t) lastFrameSizeSample; currentFrameSizeStats->frameSizeSample = (int16_t) lastFrameSizeSample;
// increment the number of encoded samples. // increment the number of encoded samples.
currentFrameSizeStats->totalEncodedSamples += currentFrameSizeStats->totalEncodedSamples += lastFrameSizeSample;
lastFrameSizeSample;
// increment the number of recveived packets // increment the number of recveived packets
currentFrameSizeStats->numPackets++; currentFrameSizeStats->numPackets++;
// increment the total number of bytes (this is based on // increment the total number of bytes (this is based on
// the previous payload we don't know the frame-size of // the previous payload we don't know the frame-size of
// the current payload. // the current payload.
currentFrameSizeStats->totalPayloadLenByte += currentFrameSizeStats->totalPayloadLenByte += currentPayloadStr
currentPayloadStr->lastPayloadLenByte; ->lastPayloadLenByte;
// store the maximum payload-size (this is based on // store the maximum payload-size (this is based on
// the previous payload we don't know the frame-size of // the previous payload we don't know the frame-size of
// the current payload. // the current payload.
if(currentFrameSizeStats->maxPayloadLen < if (currentFrameSizeStats->maxPayloadLen
currentPayloadStr->lastPayloadLenByte) < currentPayloadStr->lastPayloadLenByte) {
{ currentFrameSizeStats->maxPayloadLen = currentPayloadStr
currentFrameSizeStats->maxPayloadLen = ->lastPayloadLenByte;
currentPayloadStr->lastPayloadLenByte;
} }
// store the current values for the next time // store the current values for the next time
currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp; currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp;
currentPayloadStr->lastPayloadLenByte = payloadSize; currentPayloadStr->lastPayloadLenByte = payloadSize;
} } else {
else
{
currentPayloadStr->newPacket = false; currentPayloadStr->newPacket = false;
currentPayloadStr->lastPayloadLenByte = payloadSize; currentPayloadStr->lastPayloadLenByte = payloadSize;
currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp; currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp;
currentPayloadStr->payloadType = rtpInfo.header.payloadType; currentPayloadStr->payloadType = rtpInfo.header.payloadType;
} }
} } else {
else
{
n = 0; n = 0;
while(_payloadStats[n].payloadType != -1) while (_payloadStats[n].payloadType != -1) {
{
n++; n++;
} }
// first packet // first packet
@ -235,8 +195,8 @@ Channel::CalcStatistics(
} }
} }
Channel::Channel(int16_t chID) : Channel::Channel(int16_t chID)
_receiverACM(NULL), : _receiverACM(NULL),
_seqNo(0), _seqNo(0),
_channelCritSect(CriticalSectionWrapper::CreateCriticalSection()), _channelCritSect(CriticalSectionWrapper::CreateCriticalSection()),
_bitStreamFile(NULL), _bitStreamFile(NULL),
@ -248,16 +208,13 @@ _lastInTimestamp(0),
_packetLoss(0), _packetLoss(0),
_useFECTestWithPacketLoss(false), _useFECTestWithPacketLoss(false),
_beginTime(TickTime::MillisecondTimestamp()), _beginTime(TickTime::MillisecondTimestamp()),
_totalBytes(0) _totalBytes(0) {
{
int n; int n;
int k; int k;
for(n = 0; n < MAX_NUM_PAYLOADS; n++) for (n = 0; n < MAX_NUM_PAYLOADS; n++) {
{
_payloadStats[n].payloadType = -1; _payloadStats[n].payloadType = -1;
_payloadStats[n].newPacket = true; _payloadStats[n].newPacket = true;
for(k = 0; k < MAX_NUM_FRAMESIZES; k++) for (k = 0; k < MAX_NUM_FRAMESIZES; k++) {
{
_payloadStats[n].frameSizeStats[k].frameSizeSample = 0; _payloadStats[n].frameSizeStats[k].frameSizeSample = 0;
_payloadStats[n].frameSizeStats[k].maxPayloadLen = 0; _payloadStats[n].frameSizeStats[k].maxPayloadLen = 0;
_payloadStats[n].frameSizeStats[k].numPackets = 0; _payloadStats[n].frameSizeStats[k].numPackets = 0;
@ -265,44 +222,34 @@ _totalBytes(0)
_payloadStats[n].frameSizeStats[k].totalEncodedSamples = 0; _payloadStats[n].frameSizeStats[k].totalEncodedSamples = 0;
} }
} }
if(chID >= 0) if (chID >= 0) {
{
_saveBitStream = true; _saveBitStream = true;
char bitStreamFileName[500]; char bitStreamFileName[500];
sprintf(bitStreamFileName, "bitStream_%d.dat", chID); sprintf(bitStreamFileName, "bitStream_%d.dat", chID);
_bitStreamFile = fopen(bitStreamFileName, "wb"); _bitStreamFile = fopen(bitStreamFileName, "wb");
} } else {
else
{
_saveBitStream = false; _saveBitStream = false;
} }
} }
Channel::~Channel() Channel::~Channel() {
{
delete _channelCritSect; delete _channelCritSect;
} }
void void Channel::RegisterReceiverACM(AudioCodingModule* acm) {
Channel::RegisterReceiverACM(AudioCodingModule* acm)
{
_receiverACM = acm; _receiverACM = acm;
return; return;
} }
void void Channel::ResetStats() {
Channel::ResetStats()
{
int n; int n;
int k; int k;
_channelCritSect->Enter(); _channelCritSect->Enter();
_lastPayloadType = -1; _lastPayloadType = -1;
for(n = 0; n < MAX_NUM_PAYLOADS; n++) for (n = 0; n < MAX_NUM_PAYLOADS; n++) {
{
_payloadStats[n].payloadType = -1; _payloadStats[n].payloadType = -1;
_payloadStats[n].newPacket = true; _payloadStats[n].newPacket = true;
for(k = 0; k < MAX_NUM_FRAMESIZES; k++) for (k = 0; k < MAX_NUM_FRAMESIZES; k++) {
{
_payloadStats[n].frameSizeStats[k].frameSizeSample = 0; _payloadStats[n].frameSizeStats[k].frameSizeSample = 0;
_payloadStats[n].frameSizeStats[k].maxPayloadLen = 0; _payloadStats[n].frameSizeStats[k].maxPayloadLen = 0;
_payloadStats[n].frameSizeStats[k].numPackets = 0; _payloadStats[n].frameSizeStats[k].numPackets = 0;
@ -315,123 +262,94 @@ Channel::ResetStats()
_channelCritSect->Leave(); _channelCritSect->Leave();
} }
int16_t int16_t Channel::Stats(CodecInst& codecInst,
Channel::Stats(CodecInst& codecInst, ACMTestPayloadStats& payloadStats) ACMTestPayloadStats& payloadStats) {
{
_channelCritSect->Enter(); _channelCritSect->Enter();
int n; int n;
payloadStats.payloadType = -1; payloadStats.payloadType = -1;
for(n = 0; n < MAX_NUM_PAYLOADS; n++) for (n = 0; n < MAX_NUM_PAYLOADS; n++) {
{ if (_payloadStats[n].payloadType == codecInst.pltype) {
if(_payloadStats[n].payloadType == codecInst.pltype)
{
memcpy(&payloadStats, &_payloadStats[n], sizeof(ACMTestPayloadStats)); memcpy(&payloadStats, &_payloadStats[n], sizeof(ACMTestPayloadStats));
break; break;
} }
} }
if(payloadStats.payloadType == -1) if (payloadStats.payloadType == -1) {
{
_channelCritSect->Leave(); _channelCritSect->Leave();
return -1; return -1;
} }
for(n = 0; n < MAX_NUM_FRAMESIZES; n++) for (n = 0; n < MAX_NUM_FRAMESIZES; n++) {
{ if (payloadStats.frameSizeStats[n].frameSizeSample == 0) {
if(payloadStats.frameSizeStats[n].frameSizeSample == 0)
{
_channelCritSect->Leave(); _channelCritSect->Leave();
return 0; return 0;
} }
payloadStats.frameSizeStats[n].usageLenSec = payloadStats.frameSizeStats[n].usageLenSec = (double) payloadStats
(double)payloadStats.frameSizeStats[n].totalEncodedSamples .frameSizeStats[n].totalEncodedSamples / (double) codecInst.plfreq;
/ (double)codecInst.plfreq;
payloadStats.frameSizeStats[n].rateBitPerSec = payloadStats.frameSizeStats[n].rateBitPerSec =
payloadStats.frameSizeStats[n].totalPayloadLenByte * 8 / payloadStats.frameSizeStats[n].totalPayloadLenByte * 8
payloadStats.frameSizeStats[n].usageLenSec; / payloadStats.frameSizeStats[n].usageLenSec;
} }
_channelCritSect->Leave(); _channelCritSect->Leave();
return 0; return 0;
} }
void void Channel::Stats(uint32_t* numPackets) {
Channel::Stats(uint32_t* numPackets)
{
_channelCritSect->Enter(); _channelCritSect->Enter();
int k; int k;
int n; int n;
memset(numPackets, 0, MAX_NUM_PAYLOADS * sizeof(uint32_t)); memset(numPackets, 0, MAX_NUM_PAYLOADS * sizeof(uint32_t));
for(k = 0; k < MAX_NUM_PAYLOADS; k++) for (k = 0; k < MAX_NUM_PAYLOADS; k++) {
{ if (_payloadStats[k].payloadType == -1) {
if(_payloadStats[k].payloadType == -1)
{
break; break;
} }
numPackets[k] = 0; numPackets[k] = 0;
for(n = 0; n < MAX_NUM_FRAMESIZES; n++) for (n = 0; n < MAX_NUM_FRAMESIZES; n++) {
{ if (_payloadStats[k].frameSizeStats[n].frameSizeSample == 0) {
if(_payloadStats[k].frameSizeStats[n].frameSizeSample == 0)
{
break; break;
} }
numPackets[k] += numPackets[k] += _payloadStats[k].frameSizeStats[n].numPackets;
_payloadStats[k].frameSizeStats[n].numPackets;
} }
} }
_channelCritSect->Leave(); _channelCritSect->Leave();
} }
void void Channel::Stats(uint8_t* payloadType, uint32_t* payloadLenByte) {
Channel::Stats(uint8_t* payloadType, uint32_t* payloadLenByte)
{
_channelCritSect->Enter(); _channelCritSect->Enter();
int k; int k;
int n; int n;
memset(payloadLenByte, 0, MAX_NUM_PAYLOADS * sizeof(uint32_t)); memset(payloadLenByte, 0, MAX_NUM_PAYLOADS * sizeof(uint32_t));
for(k = 0; k < MAX_NUM_PAYLOADS; k++) for (k = 0; k < MAX_NUM_PAYLOADS; k++) {
{ if (_payloadStats[k].payloadType == -1) {
if(_payloadStats[k].payloadType == -1)
{
break; break;
} }
payloadType[k] = (uint8_t) _payloadStats[k].payloadType; payloadType[k] = (uint8_t) _payloadStats[k].payloadType;
payloadLenByte[k] = 0; payloadLenByte[k] = 0;
for(n = 0; n < MAX_NUM_FRAMESIZES; n++) for (n = 0; n < MAX_NUM_FRAMESIZES; n++) {
{ if (_payloadStats[k].frameSizeStats[n].frameSizeSample == 0) {
if(_payloadStats[k].frameSizeStats[n].frameSizeSample == 0)
{
break; break;
} }
payloadLenByte[k] += (uint16_t) payloadLenByte[k] += (uint16_t) _payloadStats[k].frameSizeStats[n]
_payloadStats[k].frameSizeStats[n].totalPayloadLenByte; .totalPayloadLenByte;
} }
} }
_channelCritSect->Leave(); _channelCritSect->Leave();
} }
void Channel::PrintStats(CodecInst& codecInst) {
void
Channel::PrintStats(CodecInst& codecInst)
{
ACMTestPayloadStats payloadStats; ACMTestPayloadStats payloadStats;
Stats(codecInst, payloadStats); Stats(codecInst, payloadStats);
printf("%s %d kHz\n", printf("%s %d kHz\n", codecInst.plname, codecInst.plfreq / 1000);
codecInst.plname,
codecInst.plfreq / 1000);
printf("=====================================================\n"); printf("=====================================================\n");
if(payloadStats.payloadType == -1) if (payloadStats.payloadType == -1) {
{
printf("No Packets are sent with payload-type %d (%s)\n\n", printf("No Packets are sent with payload-type %d (%s)\n\n",
codecInst.pltype, codecInst.pltype, codecInst.plname);
codecInst.plname);
return; return;
} }
for(int k = 0; k < MAX_NUM_FRAMESIZES; k++) for (int k = 0; k < MAX_NUM_FRAMESIZES; k++) {
{ if (payloadStats.frameSizeStats[k].frameSizeSample == 0) {
if(payloadStats.frameSizeStats[k].frameSizeSample == 0)
{
break; break;
} }
printf("Frame-size.................... %d samples\n", printf("Frame-size.................... %d samples\n",
@ -440,10 +358,11 @@ Channel::PrintStats(CodecInst& codecInst)
payloadStats.frameSizeStats[k].rateBitPerSec); payloadStats.frameSizeStats[k].rateBitPerSec);
printf("Maximum Payload-Size.......... %d Bytes\n", printf("Maximum Payload-Size.......... %d Bytes\n",
payloadStats.frameSizeStats[k].maxPayloadLen); payloadStats.frameSizeStats[k].maxPayloadLen);
printf("Maximum Instantaneous Rate.... %.0f bits/sec\n", printf(
((double)payloadStats.frameSizeStats[k].maxPayloadLen * 8.0 * "Maximum Instantaneous Rate.... %.0f bits/sec\n",
(double)codecInst.plfreq) / ((double) payloadStats.frameSizeStats[k].maxPayloadLen * 8.0
(double)payloadStats.frameSizeStats[k].frameSizeSample); * (double) codecInst.plfreq)
/ (double) payloadStats.frameSizeStats[k].frameSizeSample);
printf("Number of Packets............. %u\n", printf("Number of Packets............. %u\n",
(unsigned int) payloadStats.frameSizeStats[k].numPackets); (unsigned int) payloadStats.frameSizeStats[k].numPackets);
printf("Duration...................... %0.3f sec\n\n", printf("Duration...................... %0.3f sec\n\n",
@ -453,9 +372,7 @@ Channel::PrintStats(CodecInst& codecInst)
} }
uint32_t uint32_t Channel::LastInTimestamp() {
Channel::LastInTimestamp()
{
uint32_t timestamp; uint32_t timestamp;
_channelCritSect->Enter(); _channelCritSect->Enter();
timestamp = _lastInTimestamp; timestamp = _lastInTimestamp;
@ -463,9 +380,7 @@ Channel::LastInTimestamp()
return timestamp; return timestamp;
} }
double double Channel::BitRate() {
Channel::BitRate()
{
double rate; double rate;
uint64_t currTime = TickTime::MillisecondTimestamp(); uint64_t currTime = TickTime::MillisecondTimestamp();
_channelCritSect->Enter(); _channelCritSect->Enter();

View File

@ -23,9 +23,7 @@ namespace webrtc {
#define MAX_NUM_PAYLOADS 50 #define MAX_NUM_PAYLOADS 50
#define MAX_NUM_FRAMESIZES 6 #define MAX_NUM_FRAMESIZES 6
struct ACMTestFrameSizeStats {
struct ACMTestFrameSizeStats
{
uint16_t frameSizeSample; uint16_t frameSizeSample;
int16_t maxPayloadLen; int16_t maxPayloadLen;
uint32_t numPackets; uint32_t numPackets;
@ -33,11 +31,9 @@ struct ACMTestFrameSizeStats
uint64_t totalEncodedSamples; uint64_t totalEncodedSamples;
double rateBitPerSec; double rateBitPerSec;
double usageLenSec; double usageLenSec;
}; };
struct ACMTestPayloadStats struct ACMTestPayloadStats {
{
bool newPacket; bool newPacket;
int16_t payloadType; int16_t payloadType;
int16_t lastPayloadLenByte; int16_t lastPayloadLenByte;
@ -45,59 +41,43 @@ struct ACMTestPayloadStats
ACMTestFrameSizeStats frameSizeStats[MAX_NUM_FRAMESIZES]; ACMTestFrameSizeStats frameSizeStats[MAX_NUM_FRAMESIZES];
}; };
class Channel: public AudioPacketizationCallback class Channel : public AudioPacketizationCallback {
{
public: public:
Channel( Channel(int16_t chID = -1);
int16_t chID = -1);
~Channel(); ~Channel();
int32_t SendData( int32_t SendData(const FrameType frameType, const uint8_t payloadType,
const FrameType frameType, const uint32_t timeStamp, const uint8_t* payloadData,
const uint8_t payloadType,
const uint32_t timeStamp,
const uint8_t* payloadData,
const uint16_t payloadSize, const uint16_t payloadSize,
const RTPFragmentationHeader* fragmentation); const RTPFragmentationHeader* fragmentation);
void RegisterReceiverACM( void RegisterReceiverACM(AudioCodingModule *acm);
AudioCodingModule *acm);
void ResetStats(); void ResetStats();
int16_t Stats( int16_t Stats(CodecInst& codecInst, ACMTestPayloadStats& payloadStats);
CodecInst& codecInst,
ACMTestPayloadStats& payloadStats);
void Stats( void Stats(uint32_t* numPackets);
uint32_t* numPackets);
void Stats( void Stats(uint8_t* payloadLenByte, uint32_t* payloadType);
uint8_t* payloadLenByte,
uint32_t* payloadType);
void PrintStats( void PrintStats(CodecInst& codecInst);
CodecInst& codecInst);
void SetIsStereo(bool isStereo) void SetIsStereo(bool isStereo) {
{
_isStereo = isStereo; _isStereo = isStereo;
} }
uint32_t LastInTimestamp(); uint32_t LastInTimestamp();
void SetFECTestWithPacketLoss(bool usePacketLoss) void SetFECTestWithPacketLoss(bool usePacketLoss) {
{
_useFECTestWithPacketLoss = usePacketLoss; _useFECTestWithPacketLoss = usePacketLoss;
} }
double BitRate(); double BitRate();
private: private:
void CalcStatistics( void CalcStatistics(WebRtcRTPHeader& rtpInfo, uint16_t payloadSize);
WebRtcRTPHeader& rtpInfo,
uint16_t payloadSize);
AudioCodingModule* _receiverACM; AudioCodingModule* _receiverACM;
uint16_t _seqNo; uint16_t _seqNo;

View File

@ -27,20 +27,18 @@
namespace webrtc { namespace webrtc {
TestPacketization::TestPacketization(RTPStream *rtpStream, TestPacketization::TestPacketization(RTPStream *rtpStream, uint16_t frequency)
uint16_t frequency)
: _rtpStream(rtpStream), : _rtpStream(rtpStream),
_frequency(frequency), _frequency(frequency),
_seqNo(0) { _seqNo(0) {
} }
TestPacketization::~TestPacketization() { } TestPacketization::~TestPacketization() {
}
int32_t TestPacketization::SendData( int32_t TestPacketization::SendData(
const FrameType /* frameType */, const FrameType /* frameType */, const uint8_t payloadType,
const uint8_t payloadType, const uint32_t timeStamp, const uint8_t* payloadData,
const uint32_t timeStamp,
const uint8_t* payloadData,
const uint16_t payloadSize, const uint16_t payloadSize,
const RTPFragmentationHeader* /* fragmentation */) { const RTPFragmentationHeader* /* fragmentation */) {
_rtpStream->Write(payloadType, timeStamp, _seqNo++, payloadData, payloadSize, _rtpStream->Write(payloadType, timeStamp, _seqNo++, payloadData, payloadSize,
@ -62,8 +60,8 @@ void Sender::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
int codecNo; int codecNo;
// Open input file // Open input file
const std::string file_name = const std::string file_name = webrtc::test::ResourcePath(
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); "audio_coding/testfile32kHz", "pcm");
_pcmFile.Open(file_name, 32000, "rb"); _pcmFile.Open(file_name, 32000, "rb");
// Set the codec for the current test. // Set the codec for the current test.
@ -155,8 +153,8 @@ void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
int playSampFreq; int playSampFreq;
std::string file_name; std::string file_name;
std::stringstream file_stream; std::stringstream file_stream;
file_stream << webrtc::test::OutputPath() << "encodeDecode_out" << file_stream << webrtc::test::OutputPath() << "encodeDecode_out"
static_cast<int>(codeId) << ".pcm"; << static_cast<int>(codeId) << ".pcm";
file_name = file_stream.str(); file_name = file_stream.str();
_rtpStream = rtpStream; _rtpStream = rtpStream;
@ -207,8 +205,8 @@ bool Receiver::IncomingPacket() {
} }
} }
int32_t ok = _acm->IncomingPacket(_incomingPayload, int32_t ok = _acm->IncomingPacket(_incomingPayload, _realPayloadSizeBytes,
_realPayloadSizeBytes, _rtpInfo); _rtpInfo);
if (ok != 0) { if (ok != 0) {
printf("Error when inserting packet to ACM, for run: codecId: %d\n", printf("Error when inserting packet to ACM, for run: codecId: %d\n",
codeId); codeId);
@ -233,8 +231,7 @@ bool Receiver::PlayoutData() {
if (_playoutLengthSmpls == 0) { if (_playoutLengthSmpls == 0) {
return false; return false;
} }
_pcmFile.Write10MsData(audioFrame.data_, _pcmFile.Write10MsData(audioFrame.data_, audioFrame.samples_per_channel_);
audioFrame.samples_per_channel_);
return true; return true;
} }
@ -265,8 +262,8 @@ void Receiver::Run() {
EncodeDecodeTest::EncodeDecodeTest() { EncodeDecodeTest::EncodeDecodeTest() {
_testMode = 2; _testMode = 2;
Trace::CreateTrace(); Trace::CreateTrace();
Trace::SetTraceFile((webrtc::test::OutputPath() + Trace::SetTraceFile(
"acm_encdec_trace.txt").c_str()); (webrtc::test::OutputPath() + "acm_encdec_trace.txt").c_str());
} }
EncodeDecodeTest::EncodeDecodeTest(int testMode) { EncodeDecodeTest::EncodeDecodeTest(int testMode) {
@ -276,8 +273,8 @@ EncodeDecodeTest::EncodeDecodeTest(int testMode) {
_testMode = testMode; _testMode = testMode;
if (_testMode != 0) { if (_testMode != 0) {
Trace::CreateTrace(); Trace::CreateTrace();
Trace::SetTraceFile((webrtc::test::OutputPath() + Trace::SetTraceFile(
"acm_encdec_trace.txt").c_str()); (webrtc::test::OutputPath() + "acm_encdec_trace.txt").c_str());
} }
} }

View File

@ -28,17 +28,14 @@ class TestPacketization: public AudioPacketizationCallback {
public: public:
TestPacketization(RTPStream *rtpStream, uint16_t frequency); TestPacketization(RTPStream *rtpStream, uint16_t frequency);
~TestPacketization(); ~TestPacketization();
virtual int32_t SendData(const FrameType frameType, virtual int32_t SendData(const FrameType frameType, const uint8_t payloadType,
const uint8_t payloadType, const uint32_t timeStamp, const uint8_t* payloadData,
const uint32_t timeStamp,
const uint8_t* payloadData,
const uint16_t payloadSize, const uint16_t payloadSize,
const RTPFragmentationHeader* fragmentation); const RTPFragmentationHeader* fragmentation);
private: private:
static void MakeRTPheader(uint8_t* rtpHeader, uint8_t payloadType, static void MakeRTPheader(uint8_t* rtpHeader, uint8_t payloadType,
int16_t seqNo, uint32_t timeStamp, int16_t seqNo, uint32_t timeStamp, uint32_t ssrc);
uint32_t ssrc);
RTPStream* _rtpStream; RTPStream* _rtpStream;
int32_t _frequency; int32_t _frequency;
int16_t _seqNo; int16_t _seqNo;

View File

@ -84,8 +84,7 @@ int16_t PCMFile::ChooseFile(std::string* file_name, int16_t max_len) {
return 0; return 0;
} }
int16_t PCMFile::ChooseFile(std::string* file_name, int16_t PCMFile::ChooseFile(std::string* file_name, int16_t max_len,
int16_t max_len,
uint16_t* frequency_hz) { uint16_t* frequency_hz) {
char tmp_name[MAX_FILE_NAME_LENGTH_BYTE]; char tmp_name[MAX_FILE_NAME_LENGTH_BYTE];
@ -158,10 +157,8 @@ int32_t PCMFile::Read10MsData(AudioFrame& audio_frame) {
channels = 2; channels = 2;
} }
int32_t payload_size = (int32_t) fread(audio_frame.data_, int32_t payload_size = (int32_t) fread(audio_frame.data_, sizeof(uint16_t),
sizeof(uint16_t), samples_10ms_ * channels, pcm_file_);
samples_10ms_ * channels,
pcm_file_);
if (payload_size < samples_10ms_ * channels) { if (payload_size < samples_10ms_ * channels) {
for (int k = payload_size; k < samples_10ms_ * channels; k++) { for (int k = payload_size; k < samples_10ms_ * channels; k++) {
audio_frame.data_[k] = 0; audio_frame.data_[k] = 0;
@ -190,8 +187,7 @@ void PCMFile::Write10MsData(AudioFrame& audio_frame) {
return; return;
} }
} else { } else {
int16_t* stereo_audio = int16_t* stereo_audio = new int16_t[2 * audio_frame.samples_per_channel_];
new int16_t[2 * audio_frame.samples_per_channel_];
int k; int k;
for (k = 0; k < audio_frame.samples_per_channel_; k++) { for (k = 0; k < audio_frame.samples_per_channel_; k++) {
stereo_audio[k << 1] = audio_frame.data_[k]; stereo_audio[k << 1] = audio_frame.data_[k];
@ -207,17 +203,17 @@ void PCMFile::Write10MsData(AudioFrame& audio_frame) {
} else { } else {
if (fwrite(audio_frame.data_, sizeof(int16_t), if (fwrite(audio_frame.data_, sizeof(int16_t),
audio_frame.num_channels_ * audio_frame.samples_per_channel_, audio_frame.num_channels_ * audio_frame.samples_per_channel_,
pcm_file_) != static_cast<size_t>( pcm_file_) !=
audio_frame.num_channels_ * audio_frame.samples_per_channel_)) { static_cast<size_t>(audio_frame.num_channels_ *
audio_frame.samples_per_channel_)) {
return; return;
} }
} }
} }
void PCMFile::Write10MsData(int16_t* playout_buffer, void PCMFile::Write10MsData(int16_t* playout_buffer, uint16_t length_smpls) {
uint16_t length_smpls) { if (fwrite(playout_buffer, sizeof(uint16_t), length_smpls, pcm_file_) !=
if (fwrite(playout_buffer, sizeof(uint16_t), length_smpls) {
length_smpls, pcm_file_) != length_smpls) {
return; return;
} }
} }

View File

@ -30,13 +30,12 @@ class PCMFile {
} }
} }
void Open(const std::string& filename, uint16_t frequency, void Open(const std::string& filename, uint16_t frequency, const char* mode,
const char* mode, bool auto_rewind = false); bool auto_rewind = false);
int32_t Read10MsData(AudioFrame& audio_frame); int32_t Read10MsData(AudioFrame& audio_frame);
void Write10MsData(int16_t *playout_buffer, void Write10MsData(int16_t *playout_buffer, uint16_t length_smpls);
uint16_t length_smpls);
void Write10MsData(AudioFrame& audio_frame); void Write10MsData(AudioFrame& audio_frame);
uint16_t PayloadLength10Ms() const; uint16_t PayloadLength10Ms() const;
@ -46,11 +45,9 @@ class PCMFile {
return end_of_file_; return end_of_file_;
} }
void Rewind(); void Rewind();
static int16_t ChooseFile(std::string* file_name, static int16_t ChooseFile(std::string* file_name, int16_t max_len,
int16_t max_len,
uint16_t* frequency_hz); uint16_t* frequency_hz);
static int16_t ChooseFile(std::string* file_name, static int16_t ChooseFile(std::string* file_name, int16_t max_len);
int16_t max_len);
bool Rewinded(); bool Rewinded();
void SaveStereo(bool is_stereo = true); void SaveStereo(bool is_stereo = true);
void ReadStereo(bool is_stereo = true); void ReadStereo(bool is_stereo = true);

View File

@ -25,24 +25,22 @@
namespace webrtc { namespace webrtc {
void RTPStream::ParseRTPHeader(WebRtcRTPHeader* rtpInfo, const uint8_t* rtpHeader) void RTPStream::ParseRTPHeader(WebRtcRTPHeader* rtpInfo,
{ const uint8_t* rtpHeader) {
rtpInfo->header.payloadType = rtpHeader[1]; rtpInfo->header.payloadType = rtpHeader[1];
rtpInfo->header.sequenceNumber = (static_cast<uint16_t>(rtpHeader[2])<<8) | rtpHeader[3]; rtpInfo->header.sequenceNumber = (static_cast<uint16_t>(rtpHeader[2]) << 8) |
rtpHeader[3];
rtpInfo->header.timestamp = (static_cast<uint32_t>(rtpHeader[4]) << 24) | rtpInfo->header.timestamp = (static_cast<uint32_t>(rtpHeader[4]) << 24) |
(static_cast<uint32_t>(rtpHeader[5]) << 16) | (static_cast<uint32_t>(rtpHeader[5]) << 16) |
(static_cast<uint32_t>(rtpHeader[6])<<8) | (static_cast<uint32_t>(rtpHeader[6]) << 8) | rtpHeader[7];
rtpHeader[7];
rtpInfo->header.ssrc = (static_cast<uint32_t>(rtpHeader[8]) << 24) | rtpInfo->header.ssrc = (static_cast<uint32_t>(rtpHeader[8]) << 24) |
(static_cast<uint32_t>(rtpHeader[9]) << 16) | (static_cast<uint32_t>(rtpHeader[9]) << 16) |
(static_cast<uint32_t>(rtpHeader[10])<<8) | (static_cast<uint32_t>(rtpHeader[10]) << 8) | rtpHeader[11];
rtpHeader[11];
} }
void RTPStream::MakeRTPheader(uint8_t* rtpHeader, void RTPStream::MakeRTPheader(uint8_t* rtpHeader, uint8_t payloadType,
uint8_t payloadType, int16_t seqNo, int16_t seqNo, uint32_t timeStamp,
uint32_t timeStamp, uint32_t ssrc) uint32_t ssrc) {
{
rtpHeader[0] = (unsigned char) 0x80; rtpHeader[0] = (unsigned char) 0x80;
rtpHeader[1] = (unsigned char) (payloadType & 0xFF); rtpHeader[1] = (unsigned char) (payloadType & 0xFF);
rtpHeader[2] = (unsigned char) ((seqNo >> 8) & 0xFF); rtpHeader[2] = (unsigned char) ((seqNo >> 8) & 0xFF);
@ -60,56 +58,44 @@ void RTPStream::MakeRTPheader(uint8_t* rtpHeader,
rtpHeader[11] = (unsigned char) (ssrc & 0xFF); rtpHeader[11] = (unsigned char) (ssrc & 0xFF);
} }
RTPPacket::RTPPacket(uint8_t payloadType, uint32_t timeStamp, int16_t seqNo,
RTPPacket::RTPPacket(uint8_t payloadType, uint32_t timeStamp, const uint8_t* payloadData, uint16_t payloadSize,
int16_t seqNo, const uint8_t* payloadData, uint32_t frequency)
uint16_t payloadSize, uint32_t frequency) : payloadType(payloadType),
:
payloadType(payloadType),
timeStamp(timeStamp), timeStamp(timeStamp),
seqNo(seqNo), seqNo(seqNo),
payloadSize(payloadSize), payloadSize(payloadSize),
frequency(frequency) frequency(frequency) {
{ if (payloadSize > 0) {
if (payloadSize > 0)
{
this->payloadData = new uint8_t[payloadSize]; this->payloadData = new uint8_t[payloadSize];
memcpy(this->payloadData, payloadData, payloadSize); memcpy(this->payloadData, payloadData, payloadSize);
} }
} }
RTPPacket::~RTPPacket() RTPPacket::~RTPPacket() {
{
delete[] payloadData; delete[] payloadData;
} }
RTPBuffer::RTPBuffer() RTPBuffer::RTPBuffer() {
{
_queueRWLock = RWLockWrapper::CreateRWLock(); _queueRWLock = RWLockWrapper::CreateRWLock();
} }
RTPBuffer::~RTPBuffer() RTPBuffer::~RTPBuffer() {
{
delete _queueRWLock; delete _queueRWLock;
} }
void void RTPBuffer::Write(const uint8_t payloadType, const uint32_t timeStamp,
RTPBuffer::Write(const uint8_t payloadType, const uint32_t timeStamp,
const int16_t seqNo, const uint8_t* payloadData, const int16_t seqNo, const uint8_t* payloadData,
const uint16_t payloadSize, uint32_t frequency) const uint16_t payloadSize, uint32_t frequency) {
{ RTPPacket *packet = new RTPPacket(payloadType, timeStamp, seqNo, payloadData,
RTPPacket *packet = new RTPPacket(payloadType, timeStamp, seqNo, payloadData, payloadSize, frequency); payloadSize, frequency);
_queueRWLock->AcquireLockExclusive(); _queueRWLock->AcquireLockExclusive();
_rtpQueue.push(packet); _rtpQueue.push(packet);
_queueRWLock->ReleaseLockExclusive(); _queueRWLock->ReleaseLockExclusive();
} }
uint16_t uint16_t RTPBuffer::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
RTPBuffer::Read(WebRtcRTPHeader* rtpInfo, uint16_t payloadSize, uint32_t* offset) {
uint8_t* payloadData,
uint16_t payloadSize,
uint32_t* offset)
{
_queueRWLock->AcquireLockShared(); _queueRWLock->AcquireLockShared();
RTPPacket *packet = _rtpQueue.front(); RTPPacket *packet = _rtpQueue.front();
_rtpQueue.pop(); _rtpQueue.pop();
@ -119,12 +105,9 @@ RTPBuffer::Read(WebRtcRTPHeader* rtpInfo,
rtpInfo->header.sequenceNumber = packet->seqNo; rtpInfo->header.sequenceNumber = packet->seqNo;
rtpInfo->header.ssrc = 0; rtpInfo->header.ssrc = 0;
rtpInfo->header.timestamp = packet->timeStamp; rtpInfo->header.timestamp = packet->timeStamp;
if (packet->payloadSize > 0 && payloadSize >= packet->payloadSize) if (packet->payloadSize > 0 && payloadSize >= packet->payloadSize) {
{
memcpy(payloadData, packet->payloadData, packet->payloadSize); memcpy(payloadData, packet->payloadData, packet->payloadSize);
} } else {
else
{
return 0; return 0;
} }
*offset = (packet->timeStamp / (packet->frequency / 1000)); *offset = (packet->timeStamp / (packet->frequency / 1000));
@ -132,37 +115,29 @@ RTPBuffer::Read(WebRtcRTPHeader* rtpInfo,
return packet->payloadSize; return packet->payloadSize;
} }
bool bool RTPBuffer::EndOfFile() const {
RTPBuffer::EndOfFile() const
{
_queueRWLock->AcquireLockShared(); _queueRWLock->AcquireLockShared();
bool eof = _rtpQueue.empty(); bool eof = _rtpQueue.empty();
_queueRWLock->ReleaseLockShared(); _queueRWLock->ReleaseLockShared();
return eof; return eof;
} }
void RTPFile::Open(const char *filename, const char *mode) void RTPFile::Open(const char *filename, const char *mode) {
{ if ((_rtpFile = fopen(filename, mode)) == NULL) {
if ((_rtpFile = fopen(filename, mode)) == NULL)
{
printf("Cannot write file %s.\n", filename); printf("Cannot write file %s.\n", filename);
ADD_FAILURE() << "Unable to write file"; ADD_FAILURE() << "Unable to write file";
exit(1); exit(1);
} }
} }
void RTPFile::Close() void RTPFile::Close() {
{ if (_rtpFile != NULL) {
if (_rtpFile != NULL)
{
fclose(_rtpFile); fclose(_rtpFile);
_rtpFile = NULL; _rtpFile = NULL;
} }
} }
void RTPFile::WriteHeader() {
void RTPFile::WriteHeader()
{
// Write data in a format that NetEQ and RTP Play can parse // Write data in a format that NetEQ and RTP Play can parse
fprintf(_rtpFile, "#!RTPencode%s\n", "1.0"); fprintf(_rtpFile, "#!RTPencode%s\n", "1.0");
uint32_t dummy_variable = 0; uint32_t dummy_variable = 0;
@ -185,8 +160,7 @@ void RTPFile::WriteHeader()
fflush(_rtpFile); fflush(_rtpFile);
} }
void RTPFile::ReadHeader() void RTPFile::ReadHeader() {
{
uint32_t start_sec, start_usec, source; uint32_t start_sec, start_usec, source;
uint16_t port, padding; uint16_t port, padding;
char fileHeader[40]; char fileHeader[40];
@ -205,8 +179,7 @@ void RTPFile::ReadHeader()
void RTPFile::Write(const uint8_t payloadType, const uint32_t timeStamp, void RTPFile::Write(const uint8_t payloadType, const uint32_t timeStamp,
const int16_t seqNo, const uint8_t* payloadData, const int16_t seqNo, const uint8_t* payloadData,
const uint16_t payloadSize, uint32_t frequency) const uint16_t payloadSize, uint32_t frequency) {
{
/* write RTP packet to file */ /* write RTP packet to file */
uint8_t rtpHeader[12]; uint8_t rtpHeader[12];
MakeRTPheader(rtpHeader, payloadType, seqNo, timeStamp, 0); MakeRTPheader(rtpHeader, payloadType, seqNo, timeStamp, 0);
@ -233,18 +206,14 @@ void RTPFile::Write(const uint8_t payloadType, const uint32_t timeStamp,
} }
} }
uint16_t RTPFile::Read(WebRtcRTPHeader* rtpInfo, uint16_t RTPFile::Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
uint8_t* payloadData, uint16_t payloadSize, uint32_t* offset) {
uint16_t payloadSize,
uint32_t* offset)
{
uint16_t lengthBytes; uint16_t lengthBytes;
uint16_t plen; uint16_t plen;
uint8_t rtpHeader[12]; uint8_t rtpHeader[12];
size_t read_len = fread(&lengthBytes, 2, 1, _rtpFile); size_t read_len = fread(&lengthBytes, 2, 1, _rtpFile);
/* Check if we have reached end of file. */ /* Check if we have reached end of file. */
if ((read_len == 0) && feof(_rtpFile)) if ((read_len == 0) && feof(_rtpFile)) {
{
_rtpEOF = true; _rtpEOF = true;
return 0; return 0;
} }
@ -261,16 +230,13 @@ uint16_t RTPFile::Read(WebRtcRTPHeader* rtpInfo,
rtpInfo->type.Audio.channel = 1; rtpInfo->type.Audio.channel = 1;
EXPECT_EQ(lengthBytes, plen + 8); EXPECT_EQ(lengthBytes, plen + 8);
if (plen == 0) if (plen == 0) {
{
return 0; return 0;
} }
if (payloadSize < (lengthBytes - 20)) if (payloadSize < (lengthBytes - 20)) {
{
return -1; return -1;
} }
if (lengthBytes < 20) if (lengthBytes < 20) {
{
return -1; return -1;
} }
lengthBytes -= 20; lengthBytes -= 20;

View File

@ -20,10 +20,10 @@
namespace webrtc { namespace webrtc {
class RTPStream class RTPStream {
{
public: public:
virtual ~RTPStream(){} virtual ~RTPStream() {
}
virtual void Write(const uint8_t payloadType, const uint32_t timeStamp, virtual void Write(const uint8_t payloadType, const uint32_t timeStamp,
const int16_t seqNo, const uint8_t* payloadData, const int16_t seqNo, const uint8_t* payloadData,
@ -31,26 +31,25 @@ public:
// Returns the packet's payload size. Zero should be treated as an // Returns the packet's payload size. Zero should be treated as an
// end-of-stream (in the case that EndOfFile() is true) or an error. // end-of-stream (in the case that EndOfFile() is true) or an error.
virtual uint16_t Read(WebRtcRTPHeader* rtpInfo, virtual uint16_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
uint8_t* payloadData, uint16_t payloadSize, uint32_t* offset) = 0;
uint16_t payloadSize,
uint32_t* offset) = 0;
virtual bool EndOfFile() const = 0; virtual bool EndOfFile() const = 0;
protected: protected:
void MakeRTPheader(uint8_t* rtpHeader, void MakeRTPheader(uint8_t* rtpHeader, uint8_t payloadType, int16_t seqNo,
uint8_t payloadType, int16_t seqNo,
uint32_t timeStamp, uint32_t ssrc); uint32_t timeStamp, uint32_t ssrc);
void ParseRTPHeader(WebRtcRTPHeader* rtpInfo, const uint8_t* rtpHeader); void ParseRTPHeader(WebRtcRTPHeader* rtpInfo, const uint8_t* rtpHeader);
}; };
class RTPPacket class RTPPacket {
{
public: public:
RTPPacket(uint8_t payloadType, uint32_t timeStamp, RTPPacket(uint8_t payloadType, uint32_t timeStamp, int16_t seqNo,
int16_t seqNo, const uint8_t* payloadData, const uint8_t* payloadData, uint16_t payloadSize,
uint16_t payloadSize, uint32_t frequency); uint32_t frequency);
~RTPPacket(); ~RTPPacket();
uint8_t payloadType; uint8_t payloadType;
uint32_t timeStamp; uint32_t timeStamp;
int16_t seqNo; int16_t seqNo;
@ -59,41 +58,55 @@ public:
uint32_t frequency; uint32_t frequency;
}; };
class RTPBuffer : public RTPStream class RTPBuffer : public RTPStream {
{
public: public:
RTPBuffer(); RTPBuffer();
~RTPBuffer(); ~RTPBuffer();
void Write(const uint8_t payloadType, const uint32_t timeStamp, void Write(const uint8_t payloadType, const uint32_t timeStamp,
const int16_t seqNo, const uint8_t* payloadData, const int16_t seqNo, const uint8_t* payloadData,
const uint16_t payloadSize, uint32_t frequency); const uint16_t payloadSize, uint32_t frequency);
uint16_t Read(WebRtcRTPHeader* rtpInfo,
uint8_t* payloadData, uint16_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
uint16_t payloadSize, uint16_t payloadSize, uint32_t* offset);
uint32_t* offset);
virtual bool EndOfFile() const; virtual bool EndOfFile() const;
private: private:
RWLockWrapper* _queueRWLock; RWLockWrapper* _queueRWLock;
std::queue<RTPPacket *> _rtpQueue; std::queue<RTPPacket *> _rtpQueue;
}; };
class RTPFile : public RTPStream class RTPFile : public RTPStream {
{
public: public:
~RTPFile(){} ~RTPFile() {
RTPFile() : _rtpFile(NULL),_rtpEOF(false) {} }
RTPFile()
: _rtpFile(NULL),
_rtpEOF(false) {
}
void Open(const char *outFilename, const char *mode); void Open(const char *outFilename, const char *mode);
void Close(); void Close();
void WriteHeader(); void WriteHeader();
void ReadHeader(); void ReadHeader();
void Write(const uint8_t payloadType, const uint32_t timeStamp, void Write(const uint8_t payloadType, const uint32_t timeStamp,
const int16_t seqNo, const uint8_t* payloadData, const int16_t seqNo, const uint8_t* payloadData,
const uint16_t payloadSize, uint32_t frequency); const uint16_t payloadSize, uint32_t frequency);
uint16_t Read(WebRtcRTPHeader* rtpInfo,
uint8_t* payloadData, uint16_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
uint16_t payloadSize, uint16_t payloadSize, uint32_t* offset);
uint32_t* offset);
bool EndOfFile() const { return _rtpEOF; } bool EndOfFile() const {
return _rtpEOF;
}
private: private:
FILE* _rtpFile; FILE* _rtpFile;
bool _rtpEOF; bool _rtpEOF;

View File

@ -23,13 +23,11 @@ namespace webrtc {
#define NUM_PANN_COEFFS 10 #define NUM_PANN_COEFFS 10
SpatialAudio::SpatialAudio(int testMode) SpatialAudio::SpatialAudio(int testMode) {
{
_testMode = testMode; _testMode = testMode;
} }
SpatialAudio::~SpatialAudio() SpatialAudio::~SpatialAudio() {
{
AudioCodingModule::Destroy(_acmLeft); AudioCodingModule::Destroy(_acmLeft);
AudioCodingModule::Destroy(_acmRight); AudioCodingModule::Destroy(_acmRight);
AudioCodingModule::Destroy(_acmReceiver); AudioCodingModule::Destroy(_acmReceiver);
@ -38,9 +36,7 @@ SpatialAudio::~SpatialAudio()
_outFile.Close(); _outFile.Close();
} }
int16_t int16_t SpatialAudio::Setup() {
SpatialAudio::Setup()
{
// Create ACMs and the Channel; // Create ACMs and the Channel;
_acmLeft = AudioCodingModule::Create(1); _acmLeft = AudioCodingModule::Create(1);
_acmRight = AudioCodingModule::Create(2); _acmRight = AudioCodingModule::Create(2);
@ -55,22 +51,18 @@ SpatialAudio::Setup()
uint16_t sampFreqHz = 32000; uint16_t sampFreqHz = 32000;
const std::string file_name = const std::string file_name = webrtc::test::ResourcePath(
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); "audio_coding/testfile32kHz", "pcm");
_inFile.Open(file_name, sampFreqHz, "rb", false); _inFile.Open(file_name, sampFreqHz, "rb", false);
std::string output_file = webrtc::test::OutputPath() + std::string output_file = webrtc::test::OutputPath()
"out_spatial_autotest.pcm"; + "out_spatial_autotest.pcm";
if(_testMode == 1) if (_testMode == 1) {
{
output_file = webrtc::test::OutputPath() + "testspatial_out.pcm"; output_file = webrtc::test::OutputPath() + "testspatial_out.pcm";
printf("\n"); printf("\n");
printf("Enter the output file [%s]: ", output_file.c_str()); printf("Enter the output file [%s]: ", output_file.c_str());
PCMFile::ChooseFile(&output_file, MAX_FILE_NAME_LENGTH_BYTE, PCMFile::ChooseFile(&output_file, MAX_FILE_NAME_LENGTH_BYTE, &sampFreqHz);
&sampFreqHz); } else {
}
else
{
output_file = webrtc::test::OutputPath() + "testspatial_out.pcm"; output_file = webrtc::test::OutputPath() + "testspatial_out.pcm";
} }
_outFile.Open(output_file, sampFreqHz, "wb", false); _outFile.Open(output_file, sampFreqHz, "wb", false);
@ -96,11 +88,8 @@ SpatialAudio::Setup()
return 0; return 0;
} }
void void SpatialAudio::Perform() {
SpatialAudio::Perform() if (_testMode == 0) {
{
if(_testMode == 0)
{
printf("Running SpatialAudio Test"); printf("Running SpatialAudio Test");
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1,
"---------- SpatialAudio ----------"); "---------- SpatialAudio ----------");
@ -115,13 +104,12 @@ SpatialAudio::Perform()
int16_t pannCntr = 0; int16_t pannCntr = 0;
double leftPanning[NUM_PANN_COEFFS] = double leftPanning[NUM_PANN_COEFFS] = { 1.00, 0.95, 0.90, 0.85, 0.80, 0.75,
{1.00, 0.95, 0.90, 0.85, 0.80, 0.75, 0.70, 0.60, 0.55, 0.50}; 0.70, 0.60, 0.55, 0.50 };
double rightPanning[NUM_PANN_COEFFS] = double rightPanning[NUM_PANN_COEFFS] = { 0.50, 0.55, 0.60, 0.70, 0.75, 0.80,
{0.50, 0.55, 0.60, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.00}; 0.85, 0.90, 0.95, 1.00 };
while((pannCntr + 1) < NUM_PANN_COEFFS) while ((pannCntr + 1) < NUM_PANN_COEFFS) {
{
_acmLeft->Codec((uint8_t) 0, &codecInst); _acmLeft->Codec((uint8_t) 0, &codecInst);
codecInst.pacsize = 480; codecInst.pacsize = 480;
CHECK_ERROR(_acmLeft->RegisterSendCodec(codecInst)); CHECK_ERROR(_acmLeft->RegisterSendCodec(codecInst));
@ -138,8 +126,7 @@ SpatialAudio::Perform()
EncodeDecode(leftPanning[pannCntr], rightPanning[pannCntr]); EncodeDecode(leftPanning[pannCntr], rightPanning[pannCntr]);
pannCntr++; pannCntr++;
if(_testMode == 0) if (_testMode == 0) {
{
printf("."); printf(".");
} }
} }
@ -153,26 +140,20 @@ SpatialAudio::Perform()
CHECK_ERROR(_acmLeft->RegisterSendCodec(codecInst)); CHECK_ERROR(_acmLeft->RegisterSendCodec(codecInst));
CHECK_ERROR(_acmRight->RegisterSendCodec(codecInst)); CHECK_ERROR(_acmRight->RegisterSendCodec(codecInst));
pannCntr = NUM_PANN_COEFFS - 1; pannCntr = NUM_PANN_COEFFS - 1;
while(pannCntr >= 0) while (pannCntr >= 0) {
{
EncodeDecode(leftPanning[pannCntr], rightPanning[pannCntr]); EncodeDecode(leftPanning[pannCntr], rightPanning[pannCntr]);
pannCntr--; pannCntr--;
if(_testMode == 0) if (_testMode == 0) {
{
printf("."); printf(".");
} }
} }
if(_testMode == 0) if (_testMode == 0) {
{
printf("Done!\n"); printf("Done!\n");
} }
} }
void void SpatialAudio::EncodeDecode(const double leftPanning,
SpatialAudio::EncodeDecode( const double rightPanning) {
const double leftPanning,
const double rightPanning)
{
AudioFrame audioFrame; AudioFrame audioFrame;
int32_t outFileSampFreq = _outFile.SamplingFrequency(); int32_t outFileSampFreq = _outFile.SamplingFrequency();
@ -180,18 +161,15 @@ SpatialAudio::EncodeDecode(
_channel->SetIsStereo(true); _channel->SetIsStereo(true);
while(!_inFile.EndOfFile()) while (!_inFile.EndOfFile()) {
{
_inFile.Read10MsData(audioFrame); _inFile.Read10MsData(audioFrame);
for(int n = 0; n < audioFrame.samples_per_channel_; n++) for (int n = 0; n < audioFrame.samples_per_channel_; n++) {
{
audioFrame.data_[n] = (int16_t) floor( audioFrame.data_[n] = (int16_t) floor(
audioFrame.data_[n] * leftPanning + 0.5); audioFrame.data_[n] * leftPanning + 0.5);
} }
CHECK_ERROR(_acmLeft->Add10MsData(audioFrame)); CHECK_ERROR(_acmLeft->Add10MsData(audioFrame));
for(int n = 0; n < audioFrame.samples_per_channel_; n++) for (int n = 0; n < audioFrame.samples_per_channel_; n++) {
{
audioFrame.data_[n] = (int16_t) floor( audioFrame.data_[n] = (int16_t) floor(
audioFrame.data_[n] * rightToLeftRatio + 0.5); audioFrame.data_[n] * rightToLeftRatio + 0.5);
} }
@ -200,30 +178,25 @@ SpatialAudio::EncodeDecode(
CHECK_ERROR(_acmLeft->Process()); CHECK_ERROR(_acmLeft->Process());
CHECK_ERROR(_acmRight->Process()); CHECK_ERROR(_acmRight->Process());
CHECK_ERROR(_acmReceiver->PlayoutData10Ms(outFileSampFreq, CHECK_ERROR(_acmReceiver->PlayoutData10Ms(outFileSampFreq, &audioFrame));
&audioFrame));
_outFile.Write10MsData(audioFrame); _outFile.Write10MsData(audioFrame);
} }
_inFile.Rewind(); _inFile.Rewind();
} }
void void SpatialAudio::EncodeDecode() {
SpatialAudio::EncodeDecode()
{
AudioFrame audioFrame; AudioFrame audioFrame;
int32_t outFileSampFreq = _outFile.SamplingFrequency(); int32_t outFileSampFreq = _outFile.SamplingFrequency();
_channel->SetIsStereo(false); _channel->SetIsStereo(false);
while(!_inFile.EndOfFile()) while (!_inFile.EndOfFile()) {
{
_inFile.Read10MsData(audioFrame); _inFile.Read10MsData(audioFrame);
CHECK_ERROR(_acmLeft->Add10MsData(audioFrame)); CHECK_ERROR(_acmLeft->Add10MsData(audioFrame));
CHECK_ERROR(_acmLeft->Process()); CHECK_ERROR(_acmLeft->Process());
CHECK_ERROR(_acmReceiver->PlayoutData10Ms(outFileSampFreq, CHECK_ERROR(_acmReceiver->PlayoutData10Ms(outFileSampFreq, &audioFrame));
&audioFrame));
_outFile.Write10MsData(audioFrame); _outFile.Write10MsData(audioFrame);
} }
_inFile.Rewind(); _inFile.Rewind();

View File

@ -21,8 +21,7 @@
namespace webrtc { namespace webrtc {
class SpatialAudio : public ACMTest class SpatialAudio : public ACMTest {
{
public: public:
SpatialAudio(int testMode); SpatialAudio(int testMode);
~SpatialAudio(); ~SpatialAudio();

View File

@ -78,8 +78,7 @@ int32_t TestPack::SendData(FrameType frame_type, uint8_t payload_type,
rtp_info.type.Audio.channel = 1; rtp_info.type.Audio.channel = 1;
memcpy(payload_data_, payload_data, payload_size); memcpy(payload_data_, payload_data, payload_size);
status = receiver_acm_->IncomingPacket(payload_data_, payload_size, status = receiver_acm_->IncomingPacket(payload_data_, payload_size, rtp_info);
rtp_info);
payload_size_ = payload_size; payload_size_ = payload_size;
timestamp_diff_ = timestamp - last_in_timestamp_; timestamp_diff_ = timestamp - last_in_timestamp_;
@ -127,8 +126,8 @@ TestAllCodecs::~TestAllCodecs() {
} }
void TestAllCodecs::Perform() { void TestAllCodecs::Perform() {
const std::string file_name = const std::string file_name = webrtc::test::ResourcePath(
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); "audio_coding/testfile32kHz", "pcm");
infile_a_.Open(file_name, 32000, "rb"); infile_a_.Open(file_name, 32000, "rb");
if (test_mode_ == 0) { if (test_mode_ == 0) {
@ -725,9 +724,9 @@ void TestAllCodecs::RegisterSendCodec(char side, char* codec_name,
// packet. If variable rate codec (extra_byte == -1), set to -1 (65535). // packet. If variable rate codec (extra_byte == -1), set to -1 (65535).
if (extra_byte != -1) { if (extra_byte != -1) {
// Add 0.875 to always round up to a whole byte // Add 0.875 to always round up to a whole byte
packet_size_bytes_ = packet_size_bytes_ = static_cast<uint16_t>(static_cast<float>(packet_size
static_cast<uint16_t>(static_cast<float>(packet_size * rate) / * rate) / static_cast<float>(sampling_freq_hz * 8) + 0.875)
static_cast<float>(sampling_freq_hz * 8) + 0.875) + extra_byte; + extra_byte;
} else { } else {
// Packets will have a variable size. // Packets will have a variable size.
packet_size_bytes_ = -1; packet_size_bytes_ = -1;

View File

@ -22,45 +22,38 @@
namespace webrtc { namespace webrtc {
TestFEC::TestFEC(int testMode): TestFEC::TestFEC(int testMode)
_acmA(NULL), : _acmA(NULL),
_acmB(NULL), _acmB(NULL),
_channelA2B(NULL), _channelA2B(NULL),
_testCntr(0) _testCntr(0) {
{
_testMode = testMode; _testMode = testMode;
} }
TestFEC::~TestFEC() TestFEC::~TestFEC() {
{ if (_acmA != NULL) {
if(_acmA != NULL)
{
AudioCodingModule::Destroy(_acmA); AudioCodingModule::Destroy(_acmA);
_acmA = NULL; _acmA = NULL;
} }
if(_acmB != NULL) if (_acmB != NULL) {
{
AudioCodingModule::Destroy(_acmB); AudioCodingModule::Destroy(_acmB);
_acmB = NULL; _acmB = NULL;
} }
if(_channelA2B != NULL) if (_channelA2B != NULL) {
{
delete _channelA2B; delete _channelA2B;
_channelA2B = NULL; _channelA2B = NULL;
} }
} }
void TestFEC::Perform() void TestFEC::Perform() {
{
if(_testMode == 0) if (_testMode == 0) {
{
printf("Running FEC Test"); printf("Running FEC Test");
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1, WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- TestFEC ----------"); "---------- TestFEC ----------");
} }
const std::string file_name = const std::string file_name = webrtc::test::ResourcePath(
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); "audio_coding/testfile32kHz", "pcm");
_inFileA.Open(file_name, 32000, "rb"); _inFileA.Open(file_name, 32000, "rb");
bool fecEnabled; bool fecEnabled;
@ -73,15 +66,12 @@ void TestFEC::Perform()
uint8_t numEncoders = _acmA->NumberOfCodecs(); uint8_t numEncoders = _acmA->NumberOfCodecs();
CodecInst myCodecParam; CodecInst myCodecParam;
if(_testMode != 0) if (_testMode != 0) {
{
printf("Registering codecs at receiver... \n"); printf("Registering codecs at receiver... \n");
} }
for(uint8_t n = 0; n < numEncoders; n++) for (uint8_t n = 0; n < numEncoders; n++) {
{
_acmB->Codec(n, &myCodecParam); _acmB->Codec(n, &myCodecParam);
if(_testMode != 0) if (_testMode != 0) {
{
printf("%s\n", myCodecParam.plname); printf("%s\n", myCodecParam.plname);
} }
_acmB->RegisterReceiveCodec(myCodecParam); _acmB->RegisterReceiveCodec(myCodecParam);
@ -92,13 +82,10 @@ void TestFEC::Perform()
_acmA->RegisterTransportCallback(_channelA2B); _acmA->RegisterTransportCallback(_channelA2B);
_channelA2B->RegisterReceiverACM(_acmB); _channelA2B->RegisterReceiverACM(_acmB);
if(_testMode != 0) if (_testMode != 0) {
{ printf("===============================================================\n");
printf("=======================================================================\n");
printf("%d ", _testCntr++); printf("%d ", _testCntr++);
} } else {
else
{
printf("."); printf(".");
} }
#ifndef WEBRTC_CODEC_G722 #ifndef WEBRTC_CODEC_G722
@ -115,27 +102,22 @@ void TestFEC::Perform()
SetVAD(true, true, VADAggr); SetVAD(true, true, VADAggr);
_acmA->SetFECStatus(false); _acmA->SetFECStatus(false);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
Run(); Run();
_outFileB.Close(); _outFileB.Close();
if(_testMode != 0) if (_testMode != 0) {
{ printf("===============================================================\n");
printf("=======================================================================\n");
printf("%d ", _testCntr++); printf("%d ", _testCntr++);
} } else {
else
{
printf("."); printf(".");
} }
_acmA->SetFECStatus(true); _acmA->SetFECStatus(true);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
@ -143,15 +125,10 @@ void TestFEC::Perform()
Run(); Run();
_outFileB.Close(); _outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
if(_testMode != 0)
{
printf("=======================================================================\n");
printf("%d ", _testCntr++); printf("%d ", _testCntr++);
} } else {
else
{
printf("."); printf(".");
} }
char nameISAC[] = "iSAC"; char nameISAC[] = "iSAC";
@ -160,29 +137,22 @@ void TestFEC::Perform()
SetVAD(true, true, VADVeryAggr); SetVAD(true, true, VADVeryAggr);
_acmA->SetFECStatus(false); _acmA->SetFECStatus(false);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
Run(); Run();
_outFileB.Close(); _outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
if(_testMode != 0)
{
printf("=======================================================================\n");
printf("%d ", _testCntr++); printf("%d ", _testCntr++);
} } else {
else
{
printf("."); printf(".");
} }
_acmA->SetFECStatus(true); _acmA->SetFECStatus(true);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
@ -190,15 +160,10 @@ void TestFEC::Perform()
Run(); Run();
_outFileB.Close(); _outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
if(_testMode != 0)
{
printf("=======================================================================\n");
printf("%d ", _testCntr++); printf("%d ", _testCntr++);
} } else {
else
{
printf("."); printf(".");
} }
@ -207,29 +172,22 @@ void TestFEC::Perform()
SetVAD(true, true, VADVeryAggr); SetVAD(true, true, VADVeryAggr);
_acmA->SetFECStatus(false); _acmA->SetFECStatus(false);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
Run(); Run();
_outFileB.Close(); _outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
if(_testMode != 0)
{
printf("=======================================================================\n");
printf("%d ", _testCntr++); printf("%d ", _testCntr++);
} } else {
else
{
printf("."); printf(".");
} }
_acmA->SetFECStatus(true); _acmA->SetFECStatus(true);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
@ -237,16 +195,10 @@ void TestFEC::Perform()
Run(); Run();
_outFileB.Close(); _outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
if(_testMode != 0)
{
printf("=======================================================================\n");
printf("%d ", _testCntr++); printf("%d ", _testCntr++);
} } else {
else
{
printf("."); printf(".");
} }
@ -255,18 +207,15 @@ void TestFEC::Perform()
SetVAD(false, false, VADNormal); SetVAD(false, false, VADNormal);
_acmA->SetFECStatus(true); _acmA->SetFECStatus(true);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
Run(); Run();
RegisterSendCodec('A', nameISAC, 16000); RegisterSendCodec('A', nameISAC, 16000);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
@ -274,8 +223,7 @@ void TestFEC::Perform()
RegisterSendCodec('A', nameISAC, 32000); RegisterSendCodec('A', nameISAC, 32000);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
@ -283,31 +231,19 @@ void TestFEC::Perform()
RegisterSendCodec('A', nameISAC, 16000); RegisterSendCodec('A', nameISAC, 16000);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
Run(); Run();
_outFileB.Close(); _outFileB.Close();
_channelA2B->SetFECTestWithPacketLoss(true); _channelA2B->SetFECTestWithPacketLoss(true);
if (_testMode != 0) {
printf("===============================================================\n");
if(_testMode != 0)
{
printf("=======================================================================\n");
printf("%d ", _testCntr++); printf("%d ", _testCntr++);
} } else {
else
{
printf("."); printf(".");
} }
@ -317,29 +253,22 @@ void TestFEC::Perform()
SetVAD(true, true, VADAggr); SetVAD(true, true, VADAggr);
_acmA->SetFECStatus(false); _acmA->SetFECStatus(false);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
Run(); Run();
_outFileB.Close(); _outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
if(_testMode != 0)
{
printf("=======================================================================\n");
printf("%d ", _testCntr++); printf("%d ", _testCntr++);
} } else {
else
{
printf("."); printf(".");
} }
_acmA->SetFECStatus(true); _acmA->SetFECStatus(true);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
@ -347,15 +276,10 @@ void TestFEC::Perform()
Run(); Run();
_outFileB.Close(); _outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
if(_testMode != 0)
{
printf("=======================================================================\n");
printf("%d ", _testCntr++); printf("%d ", _testCntr++);
} } else {
else
{
printf("."); printf(".");
} }
RegisterSendCodec('A', nameISAC, 16000); RegisterSendCodec('A', nameISAC, 16000);
@ -363,29 +287,22 @@ void TestFEC::Perform()
SetVAD(true, true, VADVeryAggr); SetVAD(true, true, VADVeryAggr);
_acmA->SetFECStatus(false); _acmA->SetFECStatus(false);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
Run(); Run();
_outFileB.Close(); _outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
if(_testMode != 0)
{
printf("=======================================================================\n");
printf("%d ", _testCntr++); printf("%d ", _testCntr++);
} } else {
else
{
printf("."); printf(".");
} }
_acmA->SetFECStatus(true); _acmA->SetFECStatus(true);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
@ -393,16 +310,10 @@ void TestFEC::Perform()
Run(); Run();
_outFileB.Close(); _outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
if(_testMode != 0)
{
printf("=======================================================================\n");
printf("%d ", _testCntr++); printf("%d ", _testCntr++);
} } else {
else
{
printf("."); printf(".");
} }
RegisterSendCodec('A', nameISAC, 32000); RegisterSendCodec('A', nameISAC, 32000);
@ -410,29 +321,22 @@ void TestFEC::Perform()
SetVAD(true, true, VADVeryAggr); SetVAD(true, true, VADVeryAggr);
_acmA->SetFECStatus(false); _acmA->SetFECStatus(false);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
Run(); Run();
_outFileB.Close(); _outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
if(_testMode != 0)
{
printf("=======================================================================\n");
printf("%d ", _testCntr++); printf("%d ", _testCntr++);
} } else {
else
{
printf("."); printf(".");
} }
_acmA->SetFECStatus(true); _acmA->SetFECStatus(true);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
@ -440,18 +344,10 @@ void TestFEC::Perform()
Run(); Run();
_outFileB.Close(); _outFileB.Close();
if (_testMode != 0) {
printf("===============================================================\n");
if(_testMode != 0)
{
printf("=======================================================================\n");
printf("%d ", _testCntr++); printf("%d ", _testCntr++);
} } else {
else
{
printf("."); printf(".");
} }
RegisterSendCodec('A', nameISAC, 32000); RegisterSendCodec('A', nameISAC, 32000);
@ -459,18 +355,15 @@ void TestFEC::Perform()
SetVAD(false, false, VADNormal); SetVAD(false, false, VADNormal);
_acmA->SetFECStatus(true); _acmA->SetFECStatus(true);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
Run(); Run();
RegisterSendCodec('A', nameISAC, 16000); RegisterSendCodec('A', nameISAC, 16000);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
@ -478,8 +371,7 @@ void TestFEC::Perform()
RegisterSendCodec('A', nameISAC, 32000); RegisterSendCodec('A', nameISAC, 32000);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
@ -487,58 +379,44 @@ void TestFEC::Perform()
RegisterSendCodec('A', nameISAC, 16000); RegisterSendCodec('A', nameISAC, 16000);
fecEnabled = _acmA->FECStatus(); fecEnabled = _acmA->FECStatus();
if(_testMode != 0) if (_testMode != 0) {
{
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF")); printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
DisplaySendReceiveCodec(); DisplaySendReceiveCodec();
} }
Run(); Run();
_outFileB.Close(); _outFileB.Close();
if (_testMode == 0) {
if(_testMode == 0)
{
printf("Done!\n"); printf("Done!\n");
} }
} }
int32_t TestFEC::SetVAD(bool enableDTX, bool enableVAD, ACMVADMode vadMode) int32_t TestFEC::SetVAD(bool enableDTX, bool enableVAD, ACMVADMode vadMode) {
{ if (_testMode != 0) {
if(_testMode != 0) printf("DTX %s; VAD %s; VAD-Mode %d\n", enableDTX ? "ON" : "OFF",
{ enableVAD ? "ON" : "OFF", (int16_t) vadMode);
printf("DTX %s; VAD %s; VAD-Mode %d\n",
enableDTX? "ON":"OFF",
enableVAD? "ON":"OFF",
(int16_t)vadMode);
} }
return _acmA->SetVAD(enableDTX, enableVAD, vadMode); return _acmA->SetVAD(enableDTX, enableVAD, vadMode);
} }
int16_t TestFEC::RegisterSendCodec(char side, char* codecName, int32_t samplingFreqHz) int16_t TestFEC::RegisterSendCodec(char side, char* codecName,
{ int32_t samplingFreqHz) {
if(_testMode != 0) if (_testMode != 0) {
{ if (samplingFreqHz > 0) {
if(samplingFreqHz > 0) printf("Registering %s-%d for side %c\n", codecName, samplingFreqHz,
{ side);
printf("Registering %s-%d for side %c\n", codecName, samplingFreqHz, side); } else {
}
else
{
printf("Registering %s for side %c\n", codecName, side); printf("Registering %s for side %c\n", codecName, side);
} }
} }
std::cout << std::flush; std::cout << std::flush;
AudioCodingModule* myACM; AudioCodingModule* myACM;
switch(side) switch (side) {
{ case 'A': {
case 'A':
{
myACM = _acmA; myACM = _acmA;
break; break;
} }
case 'B': case 'B': {
{
myACM = _acmB; myACM = _acmB;
break; break;
} }
@ -546,15 +424,14 @@ int16_t TestFEC::RegisterSendCodec(char side, char* codecName, int32_t samplingF
return -1; return -1;
} }
if(myACM == NULL) if (myACM == NULL) {
{
assert(false); assert(false);
return -1; return -1;
} }
CodecInst myCodecParam; CodecInst myCodecParam;
CHECK_ERROR(AudioCodingModule::Codec(codecName, &myCodecParam, CHECK_ERROR(
samplingFreqHz, 1)); AudioCodingModule::Codec(codecName, &myCodecParam, samplingFreqHz, 1));
CHECK_ERROR(myACM->RegisterSendCodec(myCodecParam)); CHECK_ERROR(myACM->RegisterSendCodec(myCodecParam));
@ -562,35 +439,30 @@ int16_t TestFEC::RegisterSendCodec(char side, char* codecName, int32_t samplingF
return 0; return 0;
} }
void TestFEC::Run() void TestFEC::Run() {
{
AudioFrame audioFrame; AudioFrame audioFrame;
uint16_t msecPassed = 0; uint16_t msecPassed = 0;
uint32_t secPassed = 0; uint32_t secPassed = 0;
int32_t outFreqHzB = _outFileB.SamplingFrequency(); int32_t outFreqHzB = _outFileB.SamplingFrequency();
while(!_inFileA.EndOfFile()) while (!_inFileA.EndOfFile()) {
{
_inFileA.Read10MsData(audioFrame); _inFileA.Read10MsData(audioFrame);
CHECK_ERROR(_acmA->Add10MsData(audioFrame)); CHECK_ERROR(_acmA->Add10MsData(audioFrame));
CHECK_ERROR(_acmA->Process()); CHECK_ERROR(_acmA->Process());
CHECK_ERROR(_acmB->PlayoutData10Ms(outFreqHzB, &audioFrame)); CHECK_ERROR(_acmB->PlayoutData10Ms(outFreqHzB, &audioFrame));
_outFileB.Write10MsData(audioFrame.data_, audioFrame.samples_per_channel_); _outFileB.Write10MsData(audioFrame.data_, audioFrame.samples_per_channel_);
msecPassed += 10; msecPassed += 10;
if(msecPassed >= 1000) if (msecPassed >= 1000) {
{
msecPassed = 0; msecPassed = 0;
secPassed++; secPassed++;
} }
if(((secPassed%5) == 4) && (msecPassed == 0) && (_testCntr > 14)) if (((secPassed % 5) == 4) && (msecPassed == 0) && (_testCntr > 14)) {
{
printf("%3u:%3u ", secPassed, msecPassed); printf("%3u:%3u ", secPassed, msecPassed);
_acmA->SetFECStatus(false); _acmA->SetFECStatus(false);
printf("FEC currently %s\n", (_acmA->FECStatus() ? "ON" : "OFF")); printf("FEC currently %s\n", (_acmA->FECStatus() ? "ON" : "OFF"));
} }
if(((secPassed%5) == 4) && (msecPassed >= 990) && (_testCntr > 14)) if (((secPassed % 5) == 4) && (msecPassed >= 990) && (_testCntr > 14)) {
{
printf("%3u:%3u ", secPassed, msecPassed); printf("%3u:%3u ", secPassed, msecPassed);
_acmA->SetFECStatus(true); _acmA->SetFECStatus(true);
printf("FEC currently %s\n", (_acmA->FECStatus() ? "ON" : "OFF")); printf("FEC currently %s\n", (_acmA->FECStatus() ? "ON" : "OFF"));
@ -613,8 +485,7 @@ void TestFEC::OpenOutFile(int16_t test_number) {
_outFileB.Open(file_name, 16000, "wb"); _outFileB.Open(file_name, 16000, "wb");
} }
void TestFEC::DisplaySendReceiveCodec() void TestFEC::DisplaySendReceiveCodec() {
{
CodecInst myCodecParam; CodecInst myCodecParam;
_acmA->SendCodec(&myCodecParam); _acmA->SendCodec(&myCodecParam);
printf("%s -> ", myCodecParam.plname); printf("%s -> ", myCodecParam.plname);

View File

@ -17,18 +17,18 @@
namespace webrtc { namespace webrtc {
class TestFEC : public ACMTest class TestFEC : public ACMTest {
{
public: public:
TestFEC(int testMode); TestFEC(int testMode);
~TestFEC(); ~TestFEC();
void Perform(); void Perform();
private: private:
// The default value of '-1' indicates that the registration is based only on codec name // The default value of '-1' indicates that the registration is based only on
// and a sampling frequncy matching is not required. This is useful for codecs which support // codec name and a sampling frequency matching is not required. This is
// several sampling frequency. // useful for codecs which support several sampling frequency.
int16_t RegisterSendCodec(char side, char* codecName, int32_t sampFreqHz = -1); int16_t RegisterSendCodec(char side, char* codecName,
int32_t sampFreqHz = -1);
void Run(); void Run();
void OpenOutFile(int16_t testNumber); void OpenOutFile(int16_t testNumber);
void DisplaySendReceiveCodec(); void DisplaySendReceiveCodec();

View File

@ -33,17 +33,18 @@ TestPackStereo::TestPackStereo()
total_bytes_(0), total_bytes_(0),
payload_size_(0), payload_size_(0),
codec_mode_(kNotSet), codec_mode_(kNotSet),
lost_packet_(false) {} lost_packet_(false) {
}
TestPackStereo::~TestPackStereo() {} TestPackStereo::~TestPackStereo() {
}
void TestPackStereo::RegisterReceiverACM(AudioCodingModule* acm) { void TestPackStereo::RegisterReceiverACM(AudioCodingModule* acm) {
receiver_acm_ = acm; receiver_acm_ = acm;
return; return;
} }
int32_t TestPackStereo::SendData( int32_t TestPackStereo::SendData(const FrameType frame_type,
const FrameType frame_type,
const uint8_t payload_type, const uint8_t payload_type,
const uint32_t timestamp, const uint32_t timestamp,
const uint8_t* payload_data, const uint8_t* payload_data,
@ -159,10 +160,10 @@ void TestStereo::Perform() {
} }
// Open both mono and stereo test files in 32 kHz. // Open both mono and stereo test files in 32 kHz.
const std::string file_name_stereo = const std::string file_name_stereo = webrtc::test::ResourcePath(
webrtc::test::ResourcePath("audio_coding/teststereo32kHz", "pcm"); "audio_coding/teststereo32kHz", "pcm");
const std::string file_name_mono = const std::string file_name_mono = webrtc::test::ResourcePath(
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); "audio_coding/testfile32kHz", "pcm");
frequency_hz = 32000; frequency_hz = 32000;
in_file_stereo_ = new PCMFile(); in_file_stereo_ = new PCMFile();
in_file_mono_ = new PCMFile(); in_file_mono_ = new PCMFile();
@ -599,7 +600,6 @@ void TestStereo::Perform() {
RegisterSendCodec('A', codec_g722, 16000, 64000, 160, codec_channels, RegisterSendCodec('A', codec_g722, 16000, 64000, 160, codec_channels,
g722_pltype_); g722_pltype_);
// Make sure it is possible to set VAD/CNG, now that we are sending mono // Make sure it is possible to set VAD/CNG, now that we are sending mono
// again. // again.
EXPECT_EQ(0, acm_a_->SetVAD(true, true, VADNormal)); EXPECT_EQ(0, acm_a_->SetVAD(true, true, VADNormal));
@ -795,8 +795,7 @@ void TestStereo::RegisterSendCodec(char side, char* codec_name,
if (!strcmp(codec_name, "CELT")) { if (!strcmp(codec_name, "CELT")) {
pack_size_bytes_ = (uint16_t)( pack_size_bytes_ = (uint16_t)(
static_cast<float>(pack_size * rate) / static_cast<float>(pack_size * rate) /
static_cast<float>(sampling_freq_hz * 8) + 0.875) static_cast<float>(sampling_freq_hz * 8) + 0.875) / channels;
/ channels;
} else { } else {
pack_size_bytes_ = (uint16_t)( pack_size_bytes_ = (uint16_t)(
static_cast<float>(pack_size * rate) / static_cast<float>(pack_size * rate) /
@ -911,8 +910,8 @@ void TestStereo::Run(TestPackStereo* channel, int in_channels, int out_channels,
void TestStereo::OpenOutFile(int16_t test_number) { void TestStereo::OpenOutFile(int16_t test_number) {
std::string file_name; std::string file_name;
std::stringstream file_stream; std::stringstream file_stream;
file_stream << webrtc::test::OutputPath() << "teststereo_out_" file_stream << webrtc::test::OutputPath() << "teststereo_out_" << test_number
<< test_number << ".pcm"; << ".pcm";
file_name = file_stream.str(); file_name = file_stream.str();
out_file_.Open(file_name, 32000, "wb"); out_file_.Open(file_name, 32000, "wb");
} }

View File

@ -67,19 +67,17 @@ class TestStereo : public ACMTest {
// The default value of '-1' indicates that the registration is based only on // The default value of '-1' indicates that the registration is based only on
// codec name and a sampling frequncy matching is not required. This is useful // codec name and a sampling frequncy matching is not required. This is useful
// for codecs which support several sampling frequency. // for codecs which support several sampling frequency.
void RegisterSendCodec(char side, char* codec_name, void RegisterSendCodec(char side, char* codec_name, int32_t samp_freq_hz,
int32_t samp_freq_hz, int rate, int pack_size, int rate, int pack_size, int channels,
int channels, int payload_type); int payload_type);
void Run(TestPackStereo* channel, int in_channels, int out_channels, void Run(TestPackStereo* channel, int in_channels, int out_channels,
int percent_loss = 0); int percent_loss = 0);
void OpenOutFile(int16_t test_number); void OpenOutFile(int16_t test_number);
void DisplaySendReceiveCodec(); void DisplaySendReceiveCodec();
int32_t SendData(const FrameType frame_type, int32_t SendData(const FrameType frame_type, const uint8_t payload_type,
const uint8_t payload_type, const uint32_t timestamp, const uint8_t* payload_data,
const uint32_t timestamp,
const uint8_t* payload_data,
const uint16_t payload_size, const uint16_t payload_size,
const RTPFragmentationHeader* fragmentation); const RTPFragmentationHeader* fragmentation);

View File

@ -22,47 +22,40 @@
namespace webrtc { namespace webrtc {
TestVADDTX::TestVADDTX(int testMode): TestVADDTX::TestVADDTX(int testMode)
_acmA(NULL), : _acmA(NULL),
_acmB(NULL), _acmB(NULL),
_channelA2B(NULL), _channelA2B(NULL),
_testResults(0) _testResults(0) {
{
//testMode == 1 for more extensive testing //testMode == 1 for more extensive testing
//testMode == 0 for quick test (autotest) //testMode == 0 for quick test (autotest)
_testMode = testMode; _testMode = testMode;
} }
TestVADDTX::~TestVADDTX() TestVADDTX::~TestVADDTX() {
{ if (_acmA != NULL) {
if(_acmA != NULL)
{
AudioCodingModule::Destroy(_acmA); AudioCodingModule::Destroy(_acmA);
_acmA = NULL; _acmA = NULL;
} }
if(_acmB != NULL) if (_acmB != NULL) {
{
AudioCodingModule::Destroy(_acmB); AudioCodingModule::Destroy(_acmB);
_acmB = NULL; _acmB = NULL;
} }
if(_channelA2B != NULL) if (_channelA2B != NULL) {
{
delete _channelA2B; delete _channelA2B;
_channelA2B = NULL; _channelA2B = NULL;
} }
} }
void TestVADDTX::Perform() void TestVADDTX::Perform() {
{ if (_testMode == 0) {
if(_testMode == 0)
{
printf("Running VAD/DTX Test"); printf("Running VAD/DTX Test");
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1,
"---------- TestVADDTX ----------"); "---------- TestVADDTX ----------");
} }
const std::string file_name = const std::string file_name = webrtc::test::ResourcePath(
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); "audio_coding/testfile32kHz", "pcm");
_inFileA.Open(file_name, 32000, "rb"); _inFileA.Open(file_name, 32000, "rb");
_acmA = AudioCodingModule::Create(0); _acmA = AudioCodingModule::Create(0);
@ -73,15 +66,12 @@ void TestVADDTX::Perform()
uint8_t numEncoders = _acmA->NumberOfCodecs(); uint8_t numEncoders = _acmA->NumberOfCodecs();
CodecInst myCodecParam; CodecInst myCodecParam;
if(_testMode != 0) if (_testMode != 0) {
{
printf("Registering codecs at receiver... \n"); printf("Registering codecs at receiver... \n");
} }
for(uint8_t n = 0; n < numEncoders; n++) for (uint8_t n = 0; n < numEncoders; n++) {
{
_acmB->Codec(n, &myCodecParam); _acmB->Codec(n, &myCodecParam);
if(_testMode != 0) if (_testMode != 0) {
{
printf("%s\n", myCodecParam.plname); printf("%s\n", myCodecParam.plname);
} }
if (!strcmp(myCodecParam.plname, "opus")) { if (!strcmp(myCodecParam.plname, "opus")) {
@ -98,7 +88,6 @@ void TestVADDTX::Perform()
_acmA->RegisterVADCallback(&_monitor); _acmA->RegisterVADCallback(&_monitor);
int16_t testCntr = 1; int16_t testCntr = 1;
int16_t testResults = 0; int16_t testResults = 0;
@ -163,23 +152,18 @@ void TestVADDTX::Perform()
} }
printf("VAD/DTX test completed with %d subtests failed\n", testResults); printf("VAD/DTX test completed with %d subtests failed\n", testResults);
if (testResults > 0) if (testResults > 0) {
{
printf("Press return\n\n"); printf("Press return\n\n");
getchar(); getchar();
} }
} }
void TestVADDTX::runTestCases() void TestVADDTX::runTestCases() {
{ if (_testMode != 0) {
if(_testMode != 0)
{
CodecInst myCodecParam; CodecInst myCodecParam;
_acmA->SendCodec(&myCodecParam); _acmA->SendCodec(&myCodecParam);
printf("%s\n", myCodecParam.plname); printf("%s\n", myCodecParam.plname);
} } else {
else
{
printf("."); printf(".");
} }
// #1 DTX = OFF, VAD = ON, VADNormal // #1 DTX = OFF, VAD = ON, VADNormal
@ -218,8 +202,7 @@ void TestVADDTX::runTestCases()
_testResults += VerifyTest(); _testResults += VerifyTest();
} }
void TestVADDTX::runTestInternalDTX() void TestVADDTX::runTestInternalDTX() {
{
// #6 DTX = ON, VAD = ON, VADNormal // #6 DTX = ON, VAD = ON, VADNormal
if (_testMode != 0) if (_testMode != 0)
printf("Test #6 "); printf("Test #6 ");
@ -232,8 +215,7 @@ void TestVADDTX::runTestInternalDTX()
_testResults += VerifyTest(); _testResults += VerifyTest();
} }
void TestVADDTX::SetVAD(bool statusDTX, bool statusVAD, int16_t vadMode) void TestVADDTX::SetVAD(bool statusDTX, bool statusVAD, int16_t vadMode) {
{
bool dtxEnabled, vadEnabled; bool dtxEnabled, vadEnabled;
ACMVADMode vadModeSet; ACMVADMode vadModeSet;
@ -244,22 +226,18 @@ void TestVADDTX::SetVAD(bool statusDTX, bool statusVAD, int16_t vadMode)
assert(false); assert(false);
} }
if(_testMode != 0) if (_testMode != 0) {
{ if (statusDTX != dtxEnabled) {
if(statusDTX != dtxEnabled)
{
printf("DTX: %s not the same as requested: %s\n", printf("DTX: %s not the same as requested: %s\n",
dtxEnabled ? "ON" : "OFF", dtxEnabled ? "OFF" : "ON"); dtxEnabled ? "ON" : "OFF", dtxEnabled ? "OFF" : "ON");
} }
if (((statusVAD == true) && (vadEnabled == false)) || if (((statusVAD == true) && (vadEnabled == false)) ||
((statusVAD == false) && (vadEnabled == false) && ((statusVAD == false) && (vadEnabled == false) &&
(statusDTX == true))) (statusDTX == true))) {
{
printf("VAD: %s not the same as requested: %s\n", printf("VAD: %s not the same as requested: %s\n",
vadEnabled ? "ON" : "OFF", vadEnabled ? "OFF" : "ON"); vadEnabled ? "ON" : "OFF", vadEnabled ? "OFF" : "ON");
} }
if(vadModeSet != vadMode) if (vadModeSet != vadMode) {
{
printf("VAD mode: %d not the same as requested: %d\n", printf("VAD mode: %d not the same as requested: %d\n",
(int16_t) vadModeSet, (int16_t) vadMode); (int16_t) vadModeSet, (int16_t) vadMode);
} }
@ -277,8 +255,7 @@ void TestVADDTX::SetVAD(bool statusDTX, bool statusVAD, int16_t vadMode)
} }
VADDTXstruct TestVADDTX::GetVAD() VADDTXstruct TestVADDTX::GetVAD() {
{
VADDTXstruct retStruct; VADDTXstruct retStruct;
bool dtxEnabled, vadEnabled; bool dtxEnabled, vadEnabled;
ACMVADMode vadModeSet; ACMVADMode vadModeSet;
@ -293,26 +270,20 @@ VADDTXstruct TestVADDTX::GetVAD()
return retStruct; return retStruct;
} }
int16_t TestVADDTX::RegisterSendCodec(char side, int16_t TestVADDTX::RegisterSendCodec(char side, char* codecName,
char* codecName,
int32_t samplingFreqHz, int32_t samplingFreqHz,
int32_t rateKbps) int32_t rateKbps) {
{ if (_testMode != 0) {
if(_testMode != 0)
{
printf("Registering %s for side %c\n", codecName, side); printf("Registering %s for side %c\n", codecName, side);
} }
std::cout << std::flush; std::cout << std::flush;
AudioCodingModule* myACM; AudioCodingModule* myACM;
switch(side) switch (side) {
{ case 'A': {
case 'A':
{
myACM = _acmA; myACM = _acmA;
break; break;
} }
case 'B': case 'B': {
{
myACM = _acmB; myACM = _acmB;
break; break;
} }
@ -320,22 +291,17 @@ int16_t TestVADDTX::RegisterSendCodec(char side,
return -1; return -1;
} }
if(myACM == NULL) if (myACM == NULL) {
{
return -1; return -1;
} }
CodecInst myCodecParam; CodecInst myCodecParam;
for (int16_t codecCntr = 0; codecCntr < myACM->NumberOfCodecs(); for (int16_t codecCntr = 0; codecCntr < myACM->NumberOfCodecs();
codecCntr++) codecCntr++) {
{
CHECK_ERROR(myACM->Codec((uint8_t) codecCntr, &myCodecParam)); CHECK_ERROR(myACM->Codec((uint8_t) codecCntr, &myCodecParam));
if(!STR_CASE_CMP(myCodecParam.plname, codecName)) if (!STR_CASE_CMP(myCodecParam.plname, codecName)) {
{ if ((samplingFreqHz == -1) || (myCodecParam.plfreq == samplingFreqHz)) {
if((samplingFreqHz == -1) || (myCodecParam.plfreq == samplingFreqHz)) if ((rateKbps == -1) || (myCodecParam.rate == rateKbps)) {
{
if((rateKbps == -1) || (myCodecParam.rate == rateKbps))
{
break; break;
} }
} }
@ -350,16 +316,14 @@ int16_t TestVADDTX::RegisterSendCodec(char side,
return 0; return 0;
} }
void TestVADDTX::Run() void TestVADDTX::Run() {
{
AudioFrame audioFrame; AudioFrame audioFrame;
uint16_t SamplesIn10MsecA = _inFileA.PayloadLength10Ms(); uint16_t SamplesIn10MsecA = _inFileA.PayloadLength10Ms();
uint32_t timestampA = 1; uint32_t timestampA = 1;
int32_t outFreqHzB = _outFileB.SamplingFrequency(); int32_t outFreqHzB = _outFileB.SamplingFrequency();
while(!_inFileA.EndOfFile()) while (!_inFileA.EndOfFile()) {
{
_inFileA.Read10MsData(audioFrame); _inFileA.Read10MsData(audioFrame);
audioFrame.timestamp_ = timestampA; audioFrame.timestamp_ = timestampA;
timestampA += SamplesIn10MsecA; timestampA += SamplesIn10MsecA;
@ -392,9 +356,7 @@ void TestVADDTX::OpenOutFile(int16_t test_number) {
_outFileB.Open(file_name, 16000, "wb"); _outFileB.Open(file_name, 16000, "wb");
} }
int16_t TestVADDTX::VerifyTest() {
int16_t TestVADDTX::VerifyTest()
{
// Verify empty frame result // Verify empty frame result
uint8_t statusEF = 0; uint8_t statusEF = 0;
uint8_t vadPattern = 0; uint8_t vadPattern = 0;
@ -403,15 +365,13 @@ int16_t TestVADDTX::VerifyTest()
_acmA->SendCodec(&myCodecParam); _acmA->SendCodec(&myCodecParam);
bool dtxInUse = true; bool dtxInUse = true;
bool isReplaced = false; bool isReplaced = false;
if ((STR_CASE_CMP(myCodecParam.plname,"G729") == 0) || if ((STR_CASE_CMP(myCodecParam.plname, "G729") == 0)
(STR_CASE_CMP(myCodecParam.plname,"G723") == 0) || || (STR_CASE_CMP(myCodecParam.plname, "G723") == 0)
(STR_CASE_CMP(myCodecParam.plname,"AMR") == 0) || || (STR_CASE_CMP(myCodecParam.plname, "AMR") == 0)
(STR_CASE_CMP(myCodecParam.plname,"AMR-wb") == 0) || || (STR_CASE_CMP(myCodecParam.plname, "AMR-wb") == 0)
(STR_CASE_CMP(myCodecParam.plname,"speex") == 0)) || (STR_CASE_CMP(myCodecParam.plname, "speex") == 0)) {
{
_acmA->IsInternalDTXReplacedWithWebRtc(&isReplaced); _acmA->IsInternalDTXReplacedWithWebRtc(&isReplaced);
if (!isReplaced) if (!isReplaced) {
{
dtxInUse = false; dtxInUse = false;
} }
} }
@ -422,8 +382,8 @@ int16_t TestVADDTX::VerifyTest()
vadPattern |= 4; vadPattern |= 4;
} }
if (_getStruct.statusDTX) { if (_getStruct.statusDTX) {
if ((!_getStruct.statusVAD && dtxInUse) || (!dtxInUse && (_getStruct.statusVAD !=_setStruct.statusVAD))) if ((!_getStruct.statusVAD && dtxInUse)
{ || (!dtxInUse && (_getStruct.statusVAD != _setStruct.statusVAD))) {
// Missmatch in VAD setting // Missmatch in VAD setting
vadPattern |= 2; vadPattern |= 2;
} }
@ -443,89 +403,84 @@ int16_t TestVADDTX::VerifyTest()
for (ii = 0; ii < 6; ii++) { for (ii = 0; ii < 6; ii++) {
emptyFramePattern[ii] = 0; emptyFramePattern[ii] = 0;
} }
emptyFramePattern[0] = 1; // "kNoEncoding", not important to check. Codecs with packetsize != 80 samples will get this output. // 0 - "kNoEncoding", not important to check.
emptyFramePattern[1] = 1; // Expect to always receive some frames labeled "kActiveNormalEncoded" // Codecs with packetsize != 80 samples will get this output.
emptyFramePattern[2] = (((!_getStruct.statusDTX && _getStruct.statusVAD) || (!dtxInUse && _getStruct.statusDTX))); // "kPassiveNormalEncoded" // 1 - "kActiveNormalEncoded", expect to receive some frames with this label .
emptyFramePattern[3] = ((_getStruct.statusDTX && dtxInUse && (_acmA->SendFrequency() == 8000))); // "kPassiveDTXNB" // 2 - "kPassiveNormalEncoded".
emptyFramePattern[4] = ((_getStruct.statusDTX && dtxInUse && (_acmA->SendFrequency() == 16000))); // "kPassiveDTXWB" // 3 - "kPassiveDTXNB".
emptyFramePattern[5] = ((_getStruct.statusDTX && dtxInUse && (_acmA->SendFrequency() == 32000))); // "kPassiveDTXSWB" // 4 - "kPassiveDTXWB".
// 5 - "kPassiveDTXSWB".
emptyFramePattern[0] = 1;
emptyFramePattern[1] = 1;
emptyFramePattern[2] = (((!_getStruct.statusDTX && _getStruct.statusVAD)
|| (!dtxInUse && _getStruct.statusDTX)));
emptyFramePattern[3] = ((_getStruct.statusDTX && dtxInUse
&& (_acmA->SendFrequency() == 8000)));
emptyFramePattern[4] = ((_getStruct.statusDTX && dtxInUse
&& (_acmA->SendFrequency() == 16000)));
emptyFramePattern[5] = ((_getStruct.statusDTX && dtxInUse
&& (_acmA->SendFrequency() == 32000)));
// Check pattern 1-5 (skip 0) // Check pattern 1-5 (skip 0)
for (int ii = 1; ii < 6; ii++) for (int ii = 1; ii < 6; ii++) {
{ if (emptyFramePattern[ii]) {
if (emptyFramePattern[ii])
{
statusEF |= (_statCounter[ii] == 0); statusEF |= (_statCounter[ii] == 0);
} } else {
else
{
statusEF |= (_statCounter[ii] > 0); statusEF |= (_statCounter[ii] > 0);
} }
} }
if ((statusEF == 0) && (vadPattern == 0)) if ((statusEF == 0) && (vadPattern == 0)) {
{ if (_testMode != 0) {
if(_testMode != 0)
{
printf(" Test OK!\n"); printf(" Test OK!\n");
} }
return 0; return 0;
} } else {
else if (statusEF) {
{
if (statusEF)
{
printf("\t\t\tUnexpected empty frame result!\n"); printf("\t\t\tUnexpected empty frame result!\n");
} }
if (vadPattern) if (vadPattern) {
{ printf("\t\t\tUnexpected SetVAD() result!\tDTX: %d\tVAD: %d\tMode: %d\n",
printf("\t\t\tUnexpected SetVAD() result!\tDTX: %d\tVAD: %d\tMode: %d\n", (vadPattern >> 2) & 1, (vadPattern >> 1) & 1, vadPattern & 1); (vadPattern >> 2) & 1, (vadPattern >> 1) & 1, vadPattern & 1);
} }
return 1; return 1;
} }
} }
ActivityMonitor::ActivityMonitor() ActivityMonitor::ActivityMonitor() {
{ _counter[0] = _counter[1] = _counter[2] = _counter[3] = _counter[4] =
_counter[0] = _counter[1] = _counter[2] = _counter[3] = _counter[4] = _counter[5] = 0; _counter[5] = 0;
} }
ActivityMonitor::~ActivityMonitor() ActivityMonitor::~ActivityMonitor() {
{
} }
int32_t ActivityMonitor::InFrameType(int16_t frameType) int32_t ActivityMonitor::InFrameType(int16_t frameType) {
{
_counter[frameType]++; _counter[frameType]++;
return 0; return 0;
} }
void ActivityMonitor::PrintStatistics(int testMode) void ActivityMonitor::PrintStatistics(int testMode) {
{ if (testMode != 0) {
if(testMode != 0)
{
printf("\n"); printf("\n");
printf("kActiveNormalEncoded kPassiveNormalEncoded kPassiveDTXWB kPassiveDTXNB kPassiveDTXSWB kFrameEmpty\n"); printf("kActiveNormalEncoded kPassiveNormalEncoded kPassiveDTXWB ");
printf("kPassiveDTXNB kPassiveDTXSWB kFrameEmpty\n");
printf("%19u", _counter[1]); printf("%19u", _counter[1]);
printf("%22u", _counter[2]); printf("%22u", _counter[2]);
printf("%14u", _counter[3]); printf("%14u", _counter[3]);
printf("%14u", _counter[4]); printf("%14u", _counter[4]);
printf("%14u", _counter[5]); printf("%14u", _counter[5]);
printf("%11u", _counter[0]); printf("%11u", _counter[0]);
printf("\n\n"); printf("\n\n");
} }
} }
void ActivityMonitor::ResetStatistics() void ActivityMonitor::ResetStatistics() {
{ _counter[0] = _counter[1] = _counter[2] = _counter[3] = _counter[4] =
_counter[0] = _counter[1] = _counter[2] = _counter[3] = _counter[4] = _counter[5] = 0; _counter[5] = 0;
} }
void ActivityMonitor::GetStatistics(uint32_t* getCounter) void ActivityMonitor::GetStatistics(uint32_t* getCounter) {
{ for (int ii = 0; ii < 6; ii++) {
for (int ii = 0; ii < 6; ii++)
{
getCounter[ii] = _counter[ii]; getCounter[ii] = _counter[ii];
} }
} }

View File

@ -17,15 +17,13 @@
namespace webrtc { namespace webrtc {
typedef struct typedef struct {
{
bool statusDTX; bool statusDTX;
bool statusVAD; bool statusVAD;
ACMVADMode vadMode; ACMVADMode vadMode;
} VADDTXstruct; } VADDTXstruct;
class ActivityMonitor : public ACMVADCallback class ActivityMonitor : public ACMVADCallback {
{
public: public:
ActivityMonitor(); ActivityMonitor();
~ActivityMonitor(); ~ActivityMonitor();
@ -34,29 +32,27 @@ public:
void ResetStatistics(); void ResetStatistics();
void GetStatistics(uint32_t* getCounter); void GetStatistics(uint32_t* getCounter);
private: private:
// counting according to // Counting according to
/*enum WebRtcACMEncodingType // enum WebRtcACMEncodingType {
{ // kNoEncoding,
kNoEncoding, // kActiveNormalEncoded,
kActiveNormalEncoded, // kPassiveNormalEncoded,
kPassiveNormalEncoded, // kPassiveDTXNB,
kPassiveDTXNB, // kPassiveDTXWB,
kPassiveDTXWB, // kPassiveDTXSWB
kPassiveDTXSWB // };
};*/
uint32_t _counter[6]; uint32_t _counter[6];
}; };
class TestVADDTX : public ACMTest class TestVADDTX : public ACMTest {
{
public: public:
TestVADDTX(int testMode); TestVADDTX(int testMode);
~TestVADDTX(); ~TestVADDTX();
void Perform(); void Perform();
private: private:
// Registration can be based on codec name only, codec name and sampling frequency, or // Registration can be based on codec name only, codec name and sampling
// codec name, sampling frequency and rate. // frequency, or codec name, sampling frequency and rate.
int16_t RegisterSendCodec(char side, int16_t RegisterSendCodec(char side,
char* codecName, char* codecName,
int32_t samplingFreqHz = -1, int32_t samplingFreqHz = -1,
@ -67,7 +63,7 @@ private:
void runTestInternalDTX(); void runTestInternalDTX();
void SetVAD(bool statusDTX, bool statusVAD, int16_t vadMode); void SetVAD(bool statusDTX, bool statusVAD, int16_t vadMode);
VADDTXstruct GetVAD(); VADDTXstruct GetVAD();
int16_t VerifyTest();//VADDTXstruct setDTX, VADDTXstruct getDTX); int16_t VerifyTest();
AudioCodingModule* _acmA; AudioCodingModule* _acmA;
AudioCodingModule* _acmB; AudioCodingModule* _acmB;

View File

@ -14,64 +14,45 @@
double TimedTrace::_timeEllapsedSec = 0; double TimedTrace::_timeEllapsedSec = 0;
FILE* TimedTrace::_timedTraceFile = NULL; FILE* TimedTrace::_timedTraceFile = NULL;
TimedTrace::TimedTrace() TimedTrace::TimedTrace() {
{
} }
TimedTrace::~TimedTrace() TimedTrace::~TimedTrace() {
{ if (_timedTraceFile != NULL) {
if(_timedTraceFile != NULL)
{
fclose(_timedTraceFile); fclose(_timedTraceFile);
} }
_timedTraceFile = NULL; _timedTraceFile = NULL;
} }
int16_t int16_t TimedTrace::SetUp(char* fileName) {
TimedTrace::SetUp(char* fileName) if (_timedTraceFile == NULL) {
{
if(_timedTraceFile == NULL)
{
_timedTraceFile = fopen(fileName, "w"); _timedTraceFile = fopen(fileName, "w");
} }
if(_timedTraceFile == NULL) if (_timedTraceFile == NULL) {
{
return -1; return -1;
} }
return 0; return 0;
} }
void void TimedTrace::SetTimeEllapsed(double timeEllapsedSec) {
TimedTrace::SetTimeEllapsed(double timeEllapsedSec)
{
_timeEllapsedSec = timeEllapsedSec; _timeEllapsedSec = timeEllapsedSec;
} }
double double TimedTrace::TimeEllapsed() {
TimedTrace::TimeEllapsed()
{
return _timeEllapsedSec; return _timeEllapsedSec;
} }
void void TimedTrace::Tick10Msec() {
TimedTrace::Tick10Msec()
{
_timeEllapsedSec += 0.010; _timeEllapsedSec += 0.010;
} }
void void TimedTrace::TimedLogg(char* message) {
TimedTrace::TimedLogg(char* message)
{
unsigned int minutes = (uint32_t) floor(_timeEllapsedSec / 60.0); unsigned int minutes = (uint32_t) floor(_timeEllapsedSec / 60.0);
double seconds = _timeEllapsedSec - minutes * 60; double seconds = _timeEllapsedSec - minutes * 60;
//char myFormat[100] = "%8.2f, %3u:%05.2f: %s\n"; //char myFormat[100] = "%8.2f, %3u:%05.2f: %s\n";
if(_timedTraceFile != NULL) if (_timedTraceFile != NULL) {
{ fprintf(_timedTraceFile, "%8.2f, %3u:%05.2f: %s\n", _timeEllapsedSec,
fprintf(_timedTraceFile, "%8.2f, %3u:%05.2f: %s\n", minutes, seconds, message);
_timeEllapsedSec,
minutes,
seconds,
message);
} }
} }

View File

@ -16,9 +16,7 @@
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
class TimedTrace {
class TimedTrace
{
public: public:
TimedTrace(); TimedTrace();
~TimedTrace(); ~TimedTrace();

View File

@ -30,13 +30,11 @@ namespace webrtc {
#define MAX_FILE_NAME_LENGTH_BYTE 500 #define MAX_FILE_NAME_LENGTH_BYTE 500
TwoWayCommunication::TwoWayCommunication(int testMode) TwoWayCommunication::TwoWayCommunication(int testMode) {
{
_testMode = testMode; _testMode = testMode;
} }
TwoWayCommunication::~TwoWayCommunication() TwoWayCommunication::~TwoWayCommunication() {
{
AudioCodingModule::Destroy(_acmA); AudioCodingModule::Destroy(_acmA);
AudioCodingModule::Destroy(_acmB); AudioCodingModule::Destroy(_acmB);
@ -66,18 +64,14 @@ TwoWayCommunication::~TwoWayCommunication()
_outFileRefB.Close(); _outFileRefB.Close();
} }
uint8_t TwoWayCommunication::ChooseCodec(uint8_t* codecID_A,
uint8_t uint8_t* codecID_B) {
TwoWayCommunication::ChooseCodec(uint8_t* codecID_A,
uint8_t* codecID_B)
{
AudioCodingModule* tmpACM = AudioCodingModule::Create(0); AudioCodingModule* tmpACM = AudioCodingModule::Create(0);
uint8_t noCodec = tmpACM->NumberOfCodecs(); uint8_t noCodec = tmpACM->NumberOfCodecs();
CodecInst codecInst; CodecInst codecInst;
printf("List of Supported Codecs\n"); printf("List of Supported Codecs\n");
printf("========================\n"); printf("========================\n");
for(uint8_t codecCntr = 0; codecCntr < noCodec; codecCntr++) for (uint8_t codecCntr = 0; codecCntr < noCodec; codecCntr++) {
{
tmpACM->Codec(codecCntr, &codecInst); tmpACM->Codec(codecCntr, &codecInst);
printf("%d- %s\n", codecCntr, codecInst.plname); printf("%d- %s\n", codecCntr, codecInst.plname);
} }
@ -95,8 +89,7 @@ TwoWayCommunication::ChooseCodec(uint8_t* codecID_A,
return 0; return 0;
} }
int16_t TwoWayCommunication::SetUp() int16_t TwoWayCommunication::SetUp() {
{
_acmA = AudioCodingModule::Create(1); _acmA = AudioCodingModule::Create(1);
_acmB = AudioCodingModule::Create(2); _acmB = AudioCodingModule::Create(2);
@ -143,8 +136,8 @@ int16_t TwoWayCommunication::SetUp()
uint16_t frequencyHz; uint16_t frequencyHz;
//--- Input A //--- Input A
std::string in_file_name = std::string in_file_name = webrtc::test::ResourcePath(
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); "audio_coding/testfile32kHz", "pcm");
frequencyHz = 32000; frequencyHz = 32000;
printf("Enter input file at side A [%s]: ", in_file_name.c_str()); printf("Enter input file at side A [%s]: ", in_file_name.c_str());
PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz); PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz);
@ -153,15 +146,14 @@ int16_t TwoWayCommunication::SetUp()
//--- Output A //--- Output A
std::string out_file_a = webrtc::test::OutputPath() + "outA.pcm"; std::string out_file_a = webrtc::test::OutputPath() + "outA.pcm";
printf("Output file at side A: %s\n", out_file_a.c_str()); printf("Output file at side A: %s\n", out_file_a.c_str());
printf("Sampling frequency (in Hz) of the above file: %u\n", printf("Sampling frequency (in Hz) of the above file: %u\n", frequencyHz);
frequencyHz);
_outFileA.Open(out_file_a, frequencyHz, "wb"); _outFileA.Open(out_file_a, frequencyHz, "wb");
std::string ref_file_name = webrtc::test::OutputPath() + "ref_outA.pcm"; std::string ref_file_name = webrtc::test::OutputPath() + "ref_outA.pcm";
_outFileRefA.Open(ref_file_name, frequencyHz, "wb"); _outFileRefA.Open(ref_file_name, frequencyHz, "wb");
//--- Input B //--- Input B
in_file_name = in_file_name = webrtc::test::ResourcePath("audio_coding/testfile32kHz",
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); "pcm");
frequencyHz = 32000; frequencyHz = 32000;
printf("\n\nEnter input file at side B [%s]: ", in_file_name.c_str()); printf("\n\nEnter input file at side B [%s]: ", in_file_name.c_str());
PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz); PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz);
@ -170,8 +162,7 @@ int16_t TwoWayCommunication::SetUp()
//--- Output B //--- Output B
std::string out_file_b = webrtc::test::OutputPath() + "outB.pcm"; std::string out_file_b = webrtc::test::OutputPath() + "outB.pcm";
printf("Output file at side B: %s\n", out_file_b.c_str()); printf("Output file at side B: %s\n", out_file_b.c_str());
printf("Sampling frequency (in Hz) of the above file: %u\n", printf("Sampling frequency (in Hz) of the above file: %u\n", frequencyHz);
frequencyHz);
_outFileB.Open(out_file_b, frequencyHz, "wb"); _outFileB.Open(out_file_b, frequencyHz, "wb");
ref_file_name = webrtc::test::OutputPath() + "ref_outB.pcm"; ref_file_name = webrtc::test::OutputPath() + "ref_outB.pcm";
_outFileRefB.Open(ref_file_name, frequencyHz, "wb"); _outFileRefB.Open(ref_file_name, frequencyHz, "wb");
@ -202,8 +193,7 @@ int16_t TwoWayCommunication::SetUp()
return 0; return 0;
} }
int16_t TwoWayCommunication::SetUpAutotest() int16_t TwoWayCommunication::SetUpAutotest() {
{
_acmA = AudioCodingModule::Create(1); _acmA = AudioCodingModule::Create(1);
_acmB = AudioCodingModule::Create(2); _acmB = AudioCodingModule::Create(2);
@ -247,8 +237,8 @@ int16_t TwoWayCommunication::SetUpAutotest()
uint16_t frequencyHz; uint16_t frequencyHz;
//--- Input A and B //--- Input A and B
std::string in_file_name = std::string in_file_name = webrtc::test::ResourcePath(
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); "audio_coding/testfile32kHz", "pcm");
frequencyHz = 16000; frequencyHz = 16000;
_inFileA.Open(in_file_name, frequencyHz, "rb"); _inFileA.Open(in_file_name, frequencyHz, "rb");
_inFileB.Open(in_file_name, frequencyHz, "rb"); _inFileB.Open(in_file_name, frequencyHz, "rb");
@ -257,16 +247,16 @@ int16_t TwoWayCommunication::SetUpAutotest()
std::string output_file_a = webrtc::test::OutputPath() + "outAutotestA.pcm"; std::string output_file_a = webrtc::test::OutputPath() + "outAutotestA.pcm";
frequencyHz = 16000; frequencyHz = 16000;
_outFileA.Open(output_file_a, frequencyHz, "wb"); _outFileA.Open(output_file_a, frequencyHz, "wb");
std::string output_ref_file_a = webrtc::test::OutputPath() + std::string output_ref_file_a = webrtc::test::OutputPath()
"ref_outAutotestA.pcm"; + "ref_outAutotestA.pcm";
_outFileRefA.Open(output_ref_file_a, frequencyHz, "wb"); _outFileRefA.Open(output_ref_file_a, frequencyHz, "wb");
//--- Output B //--- Output B
std::string output_file_b = webrtc::test::OutputPath() + "outAutotestB.pcm"; std::string output_file_b = webrtc::test::OutputPath() + "outAutotestB.pcm";
frequencyHz = 16000; frequencyHz = 16000;
_outFileB.Open(output_file_b, frequencyHz, "wb"); _outFileB.Open(output_file_b, frequencyHz, "wb");
std::string output_ref_file_b = webrtc::test::OutputPath() + std::string output_ref_file_b = webrtc::test::OutputPath()
"ref_outAutotestB.pcm"; + "ref_outAutotestB.pcm";
_outFileRefB.Open(output_ref_file_b, frequencyHz, "wb"); _outFileRefB.Open(output_ref_file_b, frequencyHz, "wb");
//--- Set A-to-B channel //--- Set A-to-B channel
@ -295,18 +285,13 @@ int16_t TwoWayCommunication::SetUpAutotest()
return 0; return 0;
} }
void void TwoWayCommunication::Perform() {
TwoWayCommunication::Perform() if (_testMode == 0) {
{
if(_testMode == 0)
{
printf("Running TwoWayCommunication Test"); printf("Running TwoWayCommunication Test");
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1, WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- TwoWayCommunication ----------"); "---------- TwoWayCommunication ----------");
SetUpAutotest(); SetUpAutotest();
} } else {
else
{
SetUp(); SetUp();
} }
unsigned int msecPassed = 0; unsigned int msecPassed = 0;
@ -322,15 +307,13 @@ TwoWayCommunication::Perform()
_acmB->SendCodec(&codecInst_B); _acmB->SendCodec(&codecInst_B);
if(_testMode != 0) if (_testMode != 0) {
{
printf("\n"); printf("\n");
printf("sec:msec A B\n"); printf("sec:msec A B\n");
printf("-------- ----- -----\n"); printf("-------- ----- -----\n");
} }
while(!_inFileA.EndOfFile() && !_inFileB.EndOfFile()) while (!_inFileA.EndOfFile() && !_inFileB.EndOfFile()) {
{
_inFileA.Read10MsData(audioFrame); _inFileA.Read10MsData(audioFrame);
_acmA->Add10MsData(audioFrame); _acmA->Add10MsData(audioFrame);
_acmRefA->Add10MsData(audioFrame); _acmRefA->Add10MsData(audioFrame);
@ -339,7 +322,6 @@ TwoWayCommunication::Perform()
_acmB->Add10MsData(audioFrame); _acmB->Add10MsData(audioFrame);
_acmRefB->Add10MsData(audioFrame); _acmRefB->Add10MsData(audioFrame);
_acmA->Process(); _acmA->Process();
_acmB->Process(); _acmB->Process();
_acmRefA->Process(); _acmRefA->Process();
@ -358,41 +340,31 @@ TwoWayCommunication::Perform()
_outFileRefB.Write10MsData(audioFrame); _outFileRefB.Write10MsData(audioFrame);
msecPassed += 10; msecPassed += 10;
if(msecPassed >= 1000) if (msecPassed >= 1000) {
{
msecPassed = 0; msecPassed = 0;
secPassed++; secPassed++;
} }
if(((secPassed%5) == 4) && (msecPassed == 0)) if (((secPassed % 5) == 4) && (msecPassed == 0)) {
{ if (_testMode != 0) {
if(_testMode != 0)
{
printf("%3u:%3u ", secPassed, msecPassed); printf("%3u:%3u ", secPassed, msecPassed);
} }
_acmA->ResetEncoder(); _acmA->ResetEncoder();
if(_testMode == 0) if (_testMode == 0) {
{
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1, WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- Errors expected"); "---------- Errors expected");
printf("."); printf(".");
} } else {
else
{
printf("Reset Encoder (click in side B) "); printf("Reset Encoder (click in side B) ");
printf("Initialize Sender (no audio in side A)\n"); printf("Initialize Sender (no audio in side A)\n");
} }
CHECK_ERROR(_acmB->InitializeSender()); CHECK_ERROR(_acmB->InitializeSender());
} }
if(((secPassed%5) == 4) && (msecPassed >= 990)) if (((secPassed % 5) == 4) && (msecPassed >= 990)) {
{ if (_testMode == 0) {
if(_testMode == 0)
{
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1, WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"----- END: Errors expected"); "----- END: Errors expected");
printf("."); printf(".");
} } else {
else
{
printf("%3u:%3u ", secPassed, msecPassed); printf("%3u:%3u ", secPassed, msecPassed);
printf(" "); printf(" ");
printf("Register Send Codec (audio back in side A)\n"); printf("Register Send Codec (audio back in side A)\n");
@ -400,33 +372,25 @@ TwoWayCommunication::Perform()
CHECK_ERROR(_acmB->RegisterSendCodec(codecInst_B)); CHECK_ERROR(_acmB->RegisterSendCodec(codecInst_B));
CHECK_ERROR(_acmB->SendCodec(&dummy)); CHECK_ERROR(_acmB->SendCodec(&dummy));
} }
if(((secPassed%7) == 6) && (msecPassed == 0)) if (((secPassed % 7) == 6) && (msecPassed == 0)) {
{
CHECK_ERROR(_acmB->ResetDecoder()); CHECK_ERROR(_acmB->ResetDecoder());
if(_testMode == 0) if (_testMode == 0) {
{
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1, WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"---------- Errors expected"); "---------- Errors expected");
printf("."); printf(".");
} } else {
else
{
printf("%3u:%3u ", secPassed, msecPassed); printf("%3u:%3u ", secPassed, msecPassed);
printf("Initialize Receiver (no audio in side A) "); printf("Initialize Receiver (no audio in side A) ");
printf("Reset Decoder\n"); printf("Reset Decoder\n");
} }
CHECK_ERROR(_acmA->InitializeReceiver()); CHECK_ERROR(_acmA->InitializeReceiver());
} }
if(((secPassed%7) == 6) && (msecPassed >= 990)) if (((secPassed % 7) == 6) && (msecPassed >= 990)) {
{ if (_testMode == 0) {
if(_testMode == 0)
{
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1, WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
"----- END: Errors expected"); "----- END: Errors expected");
printf("."); printf(".");
} } else {
else
{
printf("%3u:%3u ", secPassed, msecPassed); printf("%3u:%3u ", secPassed, msecPassed);
printf("Register Receive Coded (audio back in side A)\n"); printf("Register Receive Coded (audio back in side A)\n");
} }
@ -434,8 +398,7 @@ TwoWayCommunication::Perform()
} }
//Sleep(9); //Sleep(9);
} }
if(_testMode == 0) if (_testMode == 0) {
{
printf("Done!\n"); printf("Done!\n");
} }

View File

@ -19,8 +19,7 @@
namespace webrtc { namespace webrtc {
class TwoWayCommunication : public ACMTest class TwoWayCommunication : public ACMTest {
{
public: public:
TwoWayCommunication(int testMode = 1); TwoWayCommunication(int testMode = 1);
~TwoWayCommunication(); ~TwoWayCommunication();

View File

@ -67,8 +67,7 @@ class DelayTest {
acm_b_(NULL), acm_b_(NULL),
channel_a2b_(NULL), channel_a2b_(NULL),
test_cntr_(0), test_cntr_(0),
encoding_sample_rate_hz_(8000) { encoding_sample_rate_hz_(8000) {}
}
~DelayTest() {} ~DelayTest() {}
@ -89,8 +88,8 @@ class DelayTest {
void SetUp() { void SetUp() {
test_cntr_ = 0; test_cntr_ = 0;
std::string file_name = std::string file_name = webrtc::test::ResourcePath(
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); "audio_coding/testfile32kHz", "pcm");
if (FLAGS_input_file.size() > 0) if (FLAGS_input_file.size() > 0)
file_name = FLAGS_input_file; file_name = FLAGS_input_file;
in_file_a_.Open(file_name, 32000, "rb"); in_file_a_.Open(file_name, 32000, "rb");
@ -144,8 +143,7 @@ class DelayTest {
"Codec: %s, %d kHz, %d channel(s)\n" "Codec: %s, %d kHz, %d channel(s)\n"
"ACM: DTX %s, FEC %s\n" "ACM: DTX %s, FEC %s\n"
"Channel: %s\n", "Channel: %s\n",
++test_cntr_, ++test_cntr_, config.codec.name, config.codec.sample_rate_hz,
config.codec.name, config.codec.sample_rate_hz,
config.codec.num_channels, config.acm.dtx ? "on" : "off", config.codec.num_channels, config.acm.dtx ? "on" : "off",
config.acm.fec ? "on" : "off", config.acm.fec ? "on" : "off",
config.packet_loss ? "with packet-loss" : "no packet-loss"); config.packet_loss ? "with packet-loss" : "no packet-loss");
@ -156,9 +154,10 @@ class DelayTest {
void SendCodec(const CodecConfig& config) { void SendCodec(const CodecConfig& config) {
CodecInst my_codec_param; CodecInst my_codec_param;
ASSERT_EQ(0, AudioCodingModule::Codec(config.name, &my_codec_param, ASSERT_EQ(
config.sample_rate_hz, 0,
config.num_channels)); AudioCodingModule::Codec(config.name, &my_codec_param,
config.sample_rate_hz, config.num_channels));
encoding_sample_rate_hz_ = my_codec_param.plfreq; encoding_sample_rate_hz_ = my_codec_param.plfreq;
ASSERT_EQ(0, acm_a_->RegisterSendCodec(my_codec_param)); ASSERT_EQ(0, acm_a_->RegisterSendCodec(my_codec_param));
} }
@ -174,10 +173,8 @@ class DelayTest {
void OpenOutFile(const char* output_id) { void OpenOutFile(const char* output_id) {
std::stringstream file_stream; std::stringstream file_stream;
file_stream << "delay_test_" << FLAGS_codec << "_" file_stream << "delay_test_" << FLAGS_codec << "_" << FLAGS_sample_rate_hz
<< FLAGS_sample_rate_hz << "Hz" << "_" << "Hz" << "_" << FLAGS_init_delay << "ms_" << FLAGS_delay << "ms.pcm";
<< FLAGS_init_delay << "ms_"
<< FLAGS_delay << "ms.pcm";
std::cout << "Output file: " << file_stream.str() << std::endl << std::endl; std::cout << "Output file: " << file_stream.str() << std::endl << std::endl;
std::string file_name = webrtc::test::OutputPath() + file_stream.str(); std::string file_name = webrtc::test::OutputPath() + file_stream.str();
out_file_b_.Open(file_name.c_str(), 32000, "wb"); out_file_b_.Open(file_name.c_str(), 32000, "wb");
@ -206,12 +203,9 @@ class DelayTest {
fprintf(stdout, "delay: min=%3d max=%3d mean=%3d median=%3d" fprintf(stdout, "delay: min=%3d max=%3d mean=%3d median=%3d"
" ts-based average = %6.3f, " " ts-based average = %6.3f, "
"curr buff-lev = %4u opt buff-lev = %4u \n", "curr buff-lev = %4u opt buff-lev = %4u \n",
statistics.minWaitingTimeMs, statistics.minWaitingTimeMs, statistics.maxWaitingTimeMs,
statistics.maxWaitingTimeMs, statistics.meanWaitingTimeMs, statistics.medianWaitingTimeMs,
statistics.meanWaitingTimeMs, average_delay, statistics.currentBufferSize,
statistics.medianWaitingTimeMs,
average_delay,
statistics.currentBufferSize,
statistics.preferredBufferSize); statistics.preferredBufferSize);
fflush (stdout); fflush (stdout);
} }
@ -220,13 +214,13 @@ class DelayTest {
ASSERT_EQ(0, acm_a_->Add10MsData(audio_frame)); ASSERT_EQ(0, acm_a_->Add10MsData(audio_frame));
ASSERT_LE(0, acm_a_->Process()); ASSERT_LE(0, acm_a_->Process());
ASSERT_EQ(0, acm_b_->PlayoutData10Ms(out_freq_hz_b, &audio_frame)); ASSERT_EQ(0, acm_b_->PlayoutData10Ms(out_freq_hz_b, &audio_frame));
out_file_b_.Write10MsData(audio_frame.data_, out_file_b_.Write10MsData(
audio_frame.samples_per_channel_ * audio_frame.data_,
audio_frame.num_channels_); audio_frame.samples_per_channel_ * audio_frame.num_channels_);
acm_b_->PlayoutTimestamp(&playout_ts); acm_b_->PlayoutTimestamp(&playout_ts);
received_ts = channel_a2b_->LastInTimestamp(); received_ts = channel_a2b_->LastInTimestamp();
inst_delay_sec = static_cast<uint32_t>(received_ts - playout_ts) / inst_delay_sec = static_cast<uint32_t>(received_ts - playout_ts)
static_cast<double>(encoding_sample_rate_hz_); / static_cast<double>(encoding_sample_rate_hz_);
if (num_frames > 10) if (num_frames > 10)
average_delay = 0.95 * average_delay + 0.05 * inst_delay_sec; average_delay = 0.95 * average_delay + 0.05 * inst_delay_sec;

View File

@ -17,30 +17,27 @@
#include "testsupport/fileutils.h" #include "testsupport/fileutils.h"
#include "typedefs.h" #include "typedefs.h"
namespace webrtc { namespace webrtc {
class DualStreamTest : public AudioPacketizationCallback, class DualStreamTest :
public AudioPacketizationCallback,
public ::testing::Test { public ::testing::Test {
protected: protected:
DualStreamTest(); DualStreamTest();
~DualStreamTest(); ~DualStreamTest();
int32_t SendData(FrameType frameType, uint8_t payload_type, int32_t SendData(FrameType frameType, uint8_t payload_type,
uint32_t timestamp, uint32_t timestamp, const uint8_t* payload_data,
const uint8_t* payload_data,
uint16_t payload_size, uint16_t payload_size,
const RTPFragmentationHeader* fragmentation); const RTPFragmentationHeader* fragmentation);
void Perform(bool start_in_sync, int num_channels_input); void Perform(bool start_in_sync, int num_channels_input);
void InitializeSender(int frame_size_primary_samples, void InitializeSender(int frame_size_primary_samples,
int num_channels_primary, int num_channels_primary, int sampling_rate);
int sampling_rate);
void PopulateCodecInstances(int frame_size_primary_ms, void PopulateCodecInstances(int frame_size_primary_ms,
int num_channels_primary, int num_channels_primary, int sampling_rate);
int sampling_rate);
void Validate(bool start_in_sync, int tolerance); void Validate(bool start_in_sync, int tolerance);
bool EqualTimestamp(int stream, int position); bool EqualTimestamp(int stream, int position);
@ -49,7 +46,11 @@ public ::testing::Test {
static const int kMaxNumStoredPayloads = 2; static const int kMaxNumStoredPayloads = 2;
enum {kPrimary = 0, kSecondary, kMaxNumStreams}; enum {
kPrimary = 0,
kSecondary,
kMaxNumStreams
};
AudioCodingModule* acm_dual_stream_; AudioCodingModule* acm_dual_stream_;
AudioCodingModule* acm_ref_primary_; AudioCodingModule* acm_ref_primary_;
@ -69,10 +70,10 @@ public ::testing::Test {
int payload_len_ref_[kMaxNumStreams][kMaxNumStoredPayloads]; int payload_len_ref_[kMaxNumStreams][kMaxNumStoredPayloads];
int payload_len_dual_[kMaxNumStreams][kMaxNumStoredPayloads]; int payload_len_dual_[kMaxNumStreams][kMaxNumStoredPayloads];
uint8_t payload_data_ref_[kMaxNumStreams] uint8_t payload_data_ref_[kMaxNumStreams][MAX_PAYLOAD_SIZE_BYTE
[MAX_PAYLOAD_SIZE_BYTE * kMaxNumStoredPayloads]; * kMaxNumStoredPayloads];
uint8_t payload_data_dual_[kMaxNumStreams] uint8_t payload_data_dual_[kMaxNumStreams][MAX_PAYLOAD_SIZE_BYTE
[MAX_PAYLOAD_SIZE_BYTE * kMaxNumStoredPayloads]; * kMaxNumStoredPayloads];
int num_received_payloads_dual_[kMaxNumStreams]; int num_received_payloads_dual_[kMaxNumStreams];
int num_received_payloads_ref_[kMaxNumStreams]; int num_received_payloads_ref_[kMaxNumStreams];
@ -92,7 +93,8 @@ DualStreamTest::DualStreamTest()
num_received_payloads_ref_(), num_received_payloads_ref_(),
num_compared_payloads_(), num_compared_payloads_(),
last_timestamp_(), last_timestamp_(),
received_payload_() {} received_payload_() {
}
DualStreamTest::~DualStreamTest() { DualStreamTest::~DualStreamTest() {
AudioCodingModule::Destroy(acm_dual_stream_); AudioCodingModule::Destroy(acm_dual_stream_);
@ -112,14 +114,14 @@ void DualStreamTest::PopulateCodecInstances(int frame_size_primary_ms,
for (int n = 0; n < AudioCodingModule::NumberOfCodecs(); n++) { for (int n = 0; n < AudioCodingModule::NumberOfCodecs(); n++) {
AudioCodingModule::Codec(n, &my_codec); AudioCodingModule::Codec(n, &my_codec);
if (strcmp(my_codec.plname, "ISAC") == 0 && if (strcmp(my_codec.plname, "ISAC") == 0
my_codec.plfreq == sampling_rate) { && my_codec.plfreq == sampling_rate) {
my_codec.rate = 32000; my_codec.rate = 32000;
my_codec.pacsize = 30 * sampling_rate / 1000; my_codec.pacsize = 30 * sampling_rate / 1000;
memcpy(&secondary_encoder_, &my_codec, sizeof(my_codec)); memcpy(&secondary_encoder_, &my_codec, sizeof(my_codec));
} else if (strcmp(my_codec.plname, "L16") == 0 && } else if (strcmp(my_codec.plname, "L16") == 0
my_codec.channels == num_channels_primary && && my_codec.channels == num_channels_primary
my_codec.plfreq == sampling_rate) { && my_codec.plfreq == sampling_rate) {
my_codec.pacsize = frame_size_primary_ms * sampling_rate / 1000; my_codec.pacsize = frame_size_primary_ms * sampling_rate / 1000;
memcpy(&primary_encoder_, &my_codec, sizeof(my_codec)); memcpy(&primary_encoder_, &my_codec, sizeof(my_codec));
} else if (strcmp(my_codec.plname, "red") == 0) { } else if (strcmp(my_codec.plname, "red") == 0) {
@ -160,15 +162,16 @@ void DualStreamTest::InitializeSender(int frame_size_primary_samples,
void DualStreamTest::Perform(bool start_in_sync, int num_channels_input) { void DualStreamTest::Perform(bool start_in_sync, int num_channels_input) {
PCMFile pcm_file; PCMFile pcm_file;
std::string file_name = test::ResourcePath( std::string file_name = test::ResourcePath(
(num_channels_input == 1) ? "audio_coding/testfile32kHz" : (num_channels_input == 1) ?
"audio_coding/teststereo32kHz", "pcm"); "audio_coding/testfile32kHz" : "audio_coding/teststereo32kHz",
"pcm");
pcm_file.Open(file_name, 32000, "rb"); pcm_file.Open(file_name, 32000, "rb");
pcm_file.ReadStereo(num_channels_input == 2); pcm_file.ReadStereo(num_channels_input == 2);
AudioFrame audio_frame; AudioFrame audio_frame;
int tolerance = 0; int tolerance = 0;
if (num_channels_input == 2 && primary_encoder_.channels == 2 && if (num_channels_input == 2 && primary_encoder_.channels == 2
secondary_encoder_.channels == 1) { && secondary_encoder_.channels == 1) {
tolerance = 12; tolerance = 12;
} }
@ -215,10 +218,11 @@ void DualStreamTest::Perform(bool start_in_sync, int num_channels_input) {
// later and the input file may end before the "next" payload . // later and the input file may end before the "next" payload .
EXPECT_EQ(num_received_payloads_ref_[kPrimary], EXPECT_EQ(num_received_payloads_ref_[kPrimary],
num_received_payloads_dual_[kPrimary]); num_received_payloads_dual_[kPrimary]);
EXPECT_TRUE(num_received_payloads_ref_[kSecondary] == EXPECT_TRUE(
num_received_payloads_dual_[kSecondary] || num_received_payloads_ref_[kSecondary]
num_received_payloads_ref_[kSecondary] == == num_received_payloads_dual_[kSecondary]
(num_received_payloads_dual_[kSecondary] + 1)); || num_received_payloads_ref_[kSecondary]
== (num_received_payloads_dual_[kSecondary] + 1));
// Make sure all received payloads are compared. // Make sure all received payloads are compared.
if (start_in_sync) { if (start_in_sync) {
@ -237,25 +241,27 @@ void DualStreamTest::Perform(bool start_in_sync, int num_channels_input) {
} }
bool DualStreamTest::EqualTimestamp(int stream_index, int position) { bool DualStreamTest::EqualTimestamp(int stream_index, int position) {
if (timestamp_dual_[stream_index][position] != if (timestamp_dual_[stream_index][position]
timestamp_ref_[stream_index][position]) { != timestamp_ref_[stream_index][position]) {
return false; return false;
} }
return true; return true;
} }
int DualStreamTest::EqualPayloadLength(int stream_index, int position) { int DualStreamTest::EqualPayloadLength(int stream_index, int position) {
return abs(payload_len_dual_[stream_index][position] - return abs(
payload_len_ref_[stream_index][position]); payload_len_dual_[stream_index][position]
- payload_len_ref_[stream_index][position]);
} }
bool DualStreamTest::EqualPayloadData(int stream_index, int position) { bool DualStreamTest::EqualPayloadData(int stream_index, int position) {
assert(payload_len_dual_[stream_index][position] == assert(
payload_len_ref_[stream_index][position]); payload_len_dual_[stream_index][position]
== payload_len_ref_[stream_index][position]);
int offset = position * MAX_PAYLOAD_SIZE_BYTE; int offset = position * MAX_PAYLOAD_SIZE_BYTE;
for (int n = 0; n < payload_len_dual_[stream_index][position]; n++) { for (int n = 0; n < payload_len_dual_[stream_index][position]; n++) {
if (payload_data_dual_[stream_index][offset + n] != if (payload_data_dual_[stream_index][offset + n]
payload_data_ref_[stream_index][offset + n]) { != payload_data_ref_[stream_index][offset + n]) {
return false; return false;
} }
} }
@ -266,8 +272,8 @@ void DualStreamTest::Validate(bool start_in_sync, int tolerance) {
for (int stream_index = 0; stream_index < kMaxNumStreams; stream_index++) { for (int stream_index = 0; stream_index < kMaxNumStreams; stream_index++) {
int my_tolerance = stream_index == kPrimary ? 0 : tolerance; int my_tolerance = stream_index == kPrimary ? 0 : tolerance;
for (int position = 0; position < kMaxNumStoredPayloads; position++) { for (int position = 0; position < kMaxNumStoredPayloads; position++) {
if (payload_ref_is_stored_[stream_index][position] == 1 && if (payload_ref_is_stored_[stream_index][position] == 1
payload_dual_is_stored_[stream_index][position] == 1) { && payload_dual_is_stored_[stream_index][position] == 1) {
// Check timestamps only if codecs started in sync or it is primary. // Check timestamps only if codecs started in sync or it is primary.
if (start_in_sync || stream_index == 0) if (start_in_sync || stream_index == 0)
EXPECT_TRUE(EqualTimestamp(stream_index, position)); EXPECT_TRUE(EqualTimestamp(stream_index, position));
@ -282,9 +288,10 @@ void DualStreamTest::Validate(bool start_in_sync, int tolerance) {
} }
} }
int32_t DualStreamTest::SendData( int32_t DualStreamTest::SendData(FrameType frameType, uint8_t payload_type,
FrameType frameType, uint8_t payload_type, uint32_t timestamp, uint32_t timestamp,
const uint8_t* payload_data, uint16_t payload_size, const uint8_t* payload_data,
uint16_t payload_size,
const RTPFragmentationHeader* fragmentation) { const RTPFragmentationHeader* fragmentation) {
int position; int position;
int stream_index; int stream_index;
@ -301,8 +308,8 @@ int32_t DualStreamTest::SendData(
if (fragmentation->fragmentationPlType[n] == primary_encoder_.pltype) { if (fragmentation->fragmentationPlType[n] == primary_encoder_.pltype) {
// Received primary payload from dual stream. // Received primary payload from dual stream.
stream_index = kPrimary; stream_index = kPrimary;
} else if (fragmentation->fragmentationPlType[n] == } else if (fragmentation->fragmentationPlType[n]
secondary_encoder_.pltype) { == secondary_encoder_.pltype) {
// Received secondary payload from dual stream. // Received secondary payload from dual stream.
stream_index = kSecondary; stream_index = kSecondary;
} else { } else {
@ -318,10 +325,10 @@ int32_t DualStreamTest::SendData(
assert(false); assert(false);
return -1; return -1;
} }
timestamp_dual_[stream_index][position] = timestamp - timestamp_dual_[stream_index][position] = timestamp
fragmentation->fragmentationTimeDiff[n]; - fragmentation->fragmentationTimeDiff[n];
payload_len_dual_[stream_index][position] = payload_len_dual_[stream_index][position] = fragmentation
fragmentation->fragmentationLength[n]; ->fragmentationLength[n];
memcpy( memcpy(
&payload_data_dual_[stream_index][position * MAX_PAYLOAD_SIZE_BYTE], &payload_data_dual_[stream_index][position * MAX_PAYLOAD_SIZE_BYTE],
&payload_data[fragmentation->fragmentationOffset[n]], &payload_data[fragmentation->fragmentationOffset[n]],
@ -329,8 +336,8 @@ int32_t DualStreamTest::SendData(
payload_dual_is_stored_[stream_index][position] = 1; payload_dual_is_stored_[stream_index][position] = 1;
// Check if timestamps are incremented correctly. // Check if timestamps are incremented correctly.
if (received_payload_[stream_index]) { if (received_payload_[stream_index]) {
int t = timestamp_dual_[stream_index][position] - int t = timestamp_dual_[stream_index][position]
last_timestamp_[stream_index]; - last_timestamp_[stream_index];
if ((stream_index == kPrimary) && (t != primary_encoder_.pacsize)) { if ((stream_index == kPrimary) && (t != primary_encoder_.pacsize)) {
assert(false); assert(false);
return -1; return -1;
@ -460,7 +467,6 @@ TEST_F(DualStreamTest, BitExactAsyncMonoInputMonoPrimaryWb40Ms) {
Perform(false, 1); Perform(false, 1);
} }
TEST_F(DualStreamTest, Api) { TEST_F(DualStreamTest, Api) {
PopulateCodecInstances(20, 1, 16000); PopulateCodecInstances(20, 1, 16000);
CodecInst my_codec; CodecInst my_codec;
@ -512,4 +518,5 @@ TEST_F(DualStreamTest, Api) {
EXPECT_EQ(VADVeryAggr, vad_mode); EXPECT_EQ(VADVeryAggr, vad_mode);
} }
} // namespace webrtc }
// namespace webrtc

View File

@ -32,9 +32,7 @@
namespace webrtc { namespace webrtc {
void SetISACConfigDefault( void SetISACConfigDefault(ACMTestISACConfig& isacConfig) {
ACMTestISACConfig& isacConfig)
{
isacConfig.currentRateBitPerSec = 0; isacConfig.currentRateBitPerSec = 0;
isacConfig.currentFrameSizeMsec = 0; isacConfig.currentFrameSizeMsec = 0;
isacConfig.maxRateBitPerSec = 0; isacConfig.maxRateBitPerSec = 0;
@ -46,43 +44,31 @@ void SetISACConfigDefault(
return; return;
} }
int16_t SetISAConfig(ACMTestISACConfig& isacConfig, AudioCodingModule* acm,
int testMode) {
int16_t SetISAConfig( if ((isacConfig.currentRateBitPerSec != 0)
ACMTestISACConfig& isacConfig, || (isacConfig.currentFrameSizeMsec != 0)) {
AudioCodingModule* acm,
int testMode)
{
if((isacConfig.currentRateBitPerSec != 0) ||
(isacConfig.currentFrameSizeMsec != 0))
{
CodecInst sendCodec; CodecInst sendCodec;
acm->SendCodec(&sendCodec); acm->SendCodec(&sendCodec);
if(isacConfig.currentRateBitPerSec < 0) if (isacConfig.currentRateBitPerSec < 0) {
{
sendCodec.rate = -1; sendCodec.rate = -1;
CHECK_ERROR(acm->RegisterSendCodec(sendCodec)); CHECK_ERROR(acm->RegisterSendCodec(sendCodec));
if(testMode != 0) if (testMode != 0) {
{
printf("ISAC-%s Registered in adaptive (channel-dependent) mode.\n", printf("ISAC-%s Registered in adaptive (channel-dependent) mode.\n",
(sendCodec.plfreq == 32000) ? "swb" : "wb"); (sendCodec.plfreq == 32000) ? "swb" : "wb");
} }
} } else {
else
{
if(isacConfig.currentRateBitPerSec != 0) if (isacConfig.currentRateBitPerSec != 0) {
{
sendCodec.rate = isacConfig.currentRateBitPerSec; sendCodec.rate = isacConfig.currentRateBitPerSec;
} }
if(isacConfig.currentFrameSizeMsec != 0) if (isacConfig.currentFrameSizeMsec != 0) {
{ sendCodec.pacsize = isacConfig.currentFrameSizeMsec
sendCodec.pacsize = isacConfig.currentFrameSizeMsec * * (sendCodec.plfreq / 1000);
(sendCodec.plfreq / 1000);
} }
CHECK_ERROR(acm->RegisterSendCodec(sendCodec)); CHECK_ERROR(acm->RegisterSendCodec(sendCodec));
if(testMode != 0) if (testMode != 0) {
{
printf("Target rate is set to %d bit/sec with frame-size %d ms \n", printf("Target rate is set to %d bit/sec with frame-size %d ms \n",
(int) isacConfig.currentRateBitPerSec, (int) isacConfig.currentRateBitPerSec,
(int) sendCodec.pacsize / (sendCodec.plfreq / 1000)); (int) sendCodec.pacsize / (sendCodec.plfreq / 1000));
@ -90,38 +76,31 @@ int16_t SetISAConfig(
} }
} }
if(isacConfig.maxRateBitPerSec > 0) if (isacConfig.maxRateBitPerSec > 0) {
{
CHECK_ERROR(acm->SetISACMaxRate(isacConfig.maxRateBitPerSec)); CHECK_ERROR(acm->SetISACMaxRate(isacConfig.maxRateBitPerSec));
if(testMode != 0) if (testMode != 0) {
{ printf("Max rate is set to %u bit/sec\n", isacConfig.maxRateBitPerSec);
printf("Max rate is set to %u bit/sec\n",
isacConfig.maxRateBitPerSec);
} }
} }
if(isacConfig.maxPayloadSizeByte > 0) if (isacConfig.maxPayloadSizeByte > 0) {
{
CHECK_ERROR(acm->SetISACMaxPayloadSize(isacConfig.maxPayloadSizeByte)); CHECK_ERROR(acm->SetISACMaxPayloadSize(isacConfig.maxPayloadSizeByte));
if(testMode != 0) if (testMode != 0) {
{
printf("Max payload-size is set to %u bit/sec\n", printf("Max payload-size is set to %u bit/sec\n",
isacConfig.maxPayloadSizeByte); isacConfig.maxPayloadSizeByte);
} }
} }
if((isacConfig.initFrameSizeInMsec != 0) || if ((isacConfig.initFrameSizeInMsec != 0)
(isacConfig.initRateBitPerSec != 0)) || (isacConfig.initRateBitPerSec != 0)) {
{ CHECK_ERROR(
CHECK_ERROR(acm->ConfigISACBandwidthEstimator( acm->ConfigISACBandwidthEstimator(
(uint8_t) isacConfig.initFrameSizeInMsec, (uint8_t) isacConfig.initFrameSizeInMsec,
(uint16_t) isacConfig.initRateBitPerSec, (uint16_t) isacConfig.initRateBitPerSec,
isacConfig.enforceFrameSize)); isacConfig.enforceFrameSize));
if((isacConfig.initFrameSizeInMsec != 0) && (testMode != 0)) if ((isacConfig.initFrameSizeInMsec != 0) && (testMode != 0)) {
{
printf("Initialize BWE to %d msec frame-size\n", printf("Initialize BWE to %d msec frame-size\n",
isacConfig.initFrameSizeInMsec); isacConfig.initFrameSizeInMsec);
} }
if((isacConfig.initRateBitPerSec != 0) && (testMode != 0)) if ((isacConfig.initRateBitPerSec != 0) && (testMode != 0)) {
{
printf("Initialize BWE to %u bit/sec send-bandwidth\n", printf("Initialize BWE to %u bit/sec send-bandwidth\n",
isacConfig.initRateBitPerSec); isacConfig.initRateBitPerSec);
} }
@ -130,14 +109,11 @@ int16_t SetISAConfig(
return 0; return 0;
} }
ISACTest::ISACTest(int testMode) {
ISACTest::ISACTest(int testMode)
{
_testMode = testMode; _testMode = testMode;
} }
ISACTest::~ISACTest() ISACTest::~ISACTest() {
{
AudioCodingModule::Destroy(_acmA); AudioCodingModule::Destroy(_acmA);
AudioCodingModule::Destroy(_acmB); AudioCodingModule::Destroy(_acmB);
@ -145,26 +121,23 @@ ISACTest::~ISACTest()
delete _channel_B2A; delete _channel_B2A;
} }
int16_t ISACTest::Setup() {
int16_t
ISACTest::Setup()
{
int codecCntr; int codecCntr;
CodecInst codecParam; CodecInst codecParam;
_acmA = AudioCodingModule::Create(1); _acmA = AudioCodingModule::Create(1);
_acmB = AudioCodingModule::Create(2); _acmB = AudioCodingModule::Create(2);
for(codecCntr = 0; codecCntr < AudioCodingModule::NumberOfCodecs(); codecCntr++) for (codecCntr = 0; codecCntr < AudioCodingModule::NumberOfCodecs();
{ codecCntr++) {
AudioCodingModule::Codec(codecCntr, &codecParam); AudioCodingModule::Codec(codecCntr, &codecParam);
if(!STR_CASE_CMP(codecParam.plname, "ISAC") && codecParam.plfreq == 16000) if (!STR_CASE_CMP(codecParam.plname, "ISAC")
{ && codecParam.plfreq == 16000) {
memcpy(&_paramISAC16kHz, &codecParam, sizeof(CodecInst)); memcpy(&_paramISAC16kHz, &codecParam, sizeof(CodecInst));
_idISAC16kHz = codecCntr; _idISAC16kHz = codecCntr;
} }
if(!STR_CASE_CMP(codecParam.plname, "ISAC") && codecParam.plfreq == 32000) if (!STR_CASE_CMP(codecParam.plname, "ISAC")
{ && codecParam.plfreq == 32000) {
memcpy(&_paramISAC32kHz, &codecParam, sizeof(CodecInst)); memcpy(&_paramISAC32kHz, &codecParam, sizeof(CodecInst));
_idISAC32kHz = codecCntr; _idISAC32kHz = codecCntr;
} }
@ -186,14 +159,13 @@ ISACTest::Setup()
CHECK_ERROR(_acmB->RegisterTransportCallback(_channel_B2A)); CHECK_ERROR(_acmB->RegisterTransportCallback(_channel_B2A));
_channel_B2A->RegisterReceiverACM(_acmA); _channel_B2A->RegisterReceiverACM(_acmA);
file_name_swb_ = file_name_swb_ = webrtc::test::ResourcePath("audio_coding/testfile32kHz",
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm"); "pcm");
_acmB->RegisterSendCodec(_paramISAC16kHz); _acmB->RegisterSendCodec(_paramISAC16kHz);
_acmA->RegisterSendCodec(_paramISAC32kHz); _acmA->RegisterSendCodec(_paramISAC32kHz);
if(_testMode != 0) if (_testMode != 0) {
{
printf("Side A Send Codec\n"); printf("Side A Send Codec\n");
printf("%s %d\n", _paramISAC32kHz.plname, _paramISAC32kHz.plfreq); printf("%s %d\n", _paramISAC32kHz.plname, _paramISAC32kHz.plfreq);
@ -207,21 +179,18 @@ ISACTest::Setup()
_outFileA.Open(fileNameA, 32000, "wb"); _outFileA.Open(fileNameA, 32000, "wb");
_outFileB.Open(fileNameB, 32000, "wb"); _outFileB.Open(fileNameB, 32000, "wb");
while(!_inFileA.EndOfFile()) while (!_inFileA.EndOfFile()) {
{
Run10ms(); Run10ms();
} }
CodecInst receiveCodec; CodecInst receiveCodec;
CHECK_ERROR(_acmA->ReceiveCodec(&receiveCodec)); CHECK_ERROR(_acmA->ReceiveCodec(&receiveCodec));
if(_testMode != 0) if (_testMode != 0) {
{
printf("Side A Receive Codec\n"); printf("Side A Receive Codec\n");
printf("%s %d\n", receiveCodec.plname, receiveCodec.plfreq); printf("%s %d\n", receiveCodec.plname, receiveCodec.plfreq);
} }
CHECK_ERROR(_acmB->ReceiveCodec(&receiveCodec)); CHECK_ERROR(_acmB->ReceiveCodec(&receiveCodec));
if(_testMode != 0) if (_testMode != 0) {
{
printf("Side B Receive Codec\n"); printf("Side B Receive Codec\n");
printf("%s %d\n", receiveCodec.plname, receiveCodec.plfreq); printf("%s %d\n", receiveCodec.plname, receiveCodec.plfreq);
} }
@ -233,14 +202,11 @@ ISACTest::Setup()
return 0; return 0;
} }
void ISACTest::Perform() {
void if (_testMode == 0) {
ISACTest::Perform()
{
if(_testMode == 0)
{
printf("Running iSAC Test"); printf("Running iSAC Test");
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, "---------- iSACTest ----------"); WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1,
"---------- iSACTest ----------");
} }
Setup(); Setup();
@ -257,8 +223,7 @@ ISACTest::Perform()
testNr++; testNr++;
EncodeDecode(testNr, wbISACConfig, swbISACConfig); EncodeDecode(testNr, wbISACConfig, swbISACConfig);
if (_testMode != 0) if (_testMode != 0) {
{
SetISACConfigDefault(wbISACConfig); SetISACConfigDefault(wbISACConfig);
SetISACConfigDefault(swbISACConfig); SetISACConfigDefault(swbISACConfig);
@ -292,13 +257,10 @@ ISACTest::Perform()
EncodeDecode(testNr, wbISACConfig, swbISACConfig); EncodeDecode(testNr, wbISACConfig, swbISACConfig);
int user_input; int user_input;
if((_testMode == 0) || (_testMode == 1)) if ((_testMode == 0) || (_testMode == 1)) {
{
swbISACConfig.maxPayloadSizeByte = (uint16_t) 200; swbISACConfig.maxPayloadSizeByte = (uint16_t) 200;
wbISACConfig.maxPayloadSizeByte = (uint16_t) 200; wbISACConfig.maxPayloadSizeByte = (uint16_t) 200;
} } else {
else
{
printf("Enter the max payload-size for side A: "); printf("Enter the max payload-size for side A: ");
CHECK_ERROR(scanf("%d", &user_input)); CHECK_ERROR(scanf("%d", &user_input));
swbISACConfig.maxPayloadSizeByte = (uint16_t) user_input; swbISACConfig.maxPayloadSizeByte = (uint16_t) user_input;
@ -314,13 +276,10 @@ ISACTest::Perform()
SetISACConfigDefault(wbISACConfig); SetISACConfigDefault(wbISACConfig);
SetISACConfigDefault(swbISACConfig); SetISACConfigDefault(swbISACConfig);
if((_testMode == 0) || (_testMode == 1)) if ((_testMode == 0) || (_testMode == 1)) {
{
swbISACConfig.maxRateBitPerSec = (uint32_t) 48000; swbISACConfig.maxRateBitPerSec = (uint32_t) 48000;
wbISACConfig.maxRateBitPerSec = (uint32_t) 48000; wbISACConfig.maxRateBitPerSec = (uint32_t) 48000;
} } else {
else
{
printf("Enter the max rate for side A: "); printf("Enter the max rate for side A: ");
CHECK_ERROR(scanf("%d", &user_input)); CHECK_ERROR(scanf("%d", &user_input));
swbISACConfig.maxRateBitPerSec = (uint32_t) user_input; swbISACConfig.maxRateBitPerSec = (uint32_t) user_input;
@ -332,23 +291,16 @@ ISACTest::Perform()
testNr++; testNr++;
EncodeDecode(testNr, wbISACConfig, swbISACConfig); EncodeDecode(testNr, wbISACConfig, swbISACConfig);
testNr++; testNr++;
if(_testMode == 0) if (_testMode == 0) {
{
SwitchingSamplingRate(testNr, 4); SwitchingSamplingRate(testNr, 4);
printf("Done!\n"); printf("Done!\n");
} } else {
else
{
SwitchingSamplingRate(testNr, 80); SwitchingSamplingRate(testNr, 80);
} }
} }
void ISACTest::Run10ms() {
void
ISACTest::Run10ms()
{
AudioFrame audioFrame; AudioFrame audioFrame;
_inFileA.Read10MsData(audioFrame); _inFileA.Read10MsData(audioFrame);
@ -366,18 +318,11 @@ ISACTest::Run10ms()
_outFileB.Write10MsData(audioFrame); _outFileB.Write10MsData(audioFrame);
} }
void void ISACTest::EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig,
ISACTest::EncodeDecode( ACMTestISACConfig& swbISACConfig) {
int testNr, if (_testMode == 0) {
ACMTestISACConfig& wbISACConfig,
ACMTestISACConfig& swbISACConfig)
{
if(_testMode == 0)
{
printf("."); printf(".");
} } else {
else
{
printf("\nTest %d:\n\n", testNr); printf("\nTest %d:\n\n", testNr);
} }
@ -390,14 +335,11 @@ ISACTest::EncodeDecode(
std::stringstream file_stream_b; std::stringstream file_stream_b;
file_stream_a << webrtc::test::OutputPath(); file_stream_a << webrtc::test::OutputPath();
file_stream_b << webrtc::test::OutputPath(); file_stream_b << webrtc::test::OutputPath();
if(_testMode == 0) if (_testMode == 0) {
{
file_stream_a << "out_iSACTest_A_" << testNr << ".pcm"; file_stream_a << "out_iSACTest_A_" << testNr << ".pcm";
file_stream_b << "out_iSACTest_B_" << testNr << ".pcm"; file_stream_b << "out_iSACTest_B_" << testNr << ".pcm";
} } else {
else
{
file_stream_a << "outA_" << testNr << ".pcm"; file_stream_a << "outA_" << testNr << ".pcm";
file_stream_b << "outB_" << testNr << ".pcm"; file_stream_b << "outB_" << testNr << ".pcm";
} }
@ -411,8 +353,7 @@ ISACTest::EncodeDecode(
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC32kHz)); CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC32kHz));
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC16kHz)); CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC16kHz));
if(_testMode != 0) if (_testMode != 0) {
{
printf("Side A Sending Super-Wideband \n"); printf("Side A Sending Super-Wideband \n");
printf("Side B Sending Wideband\n\n"); printf("Side B Sending Wideband\n\n");
} }
@ -421,9 +362,8 @@ ISACTest::EncodeDecode(
SetISAConfig(wbISACConfig, _acmB, _testMode); SetISAConfig(wbISACConfig, _acmB, _testMode);
bool adaptiveMode = false; bool adaptiveMode = false;
if((swbISACConfig.currentRateBitPerSec == -1) || if ((swbISACConfig.currentRateBitPerSec == -1)
(wbISACConfig.currentRateBitPerSec == -1)) || (wbISACConfig.currentRateBitPerSec == -1)) {
{
adaptiveMode = true; adaptiveMode = true;
} }
_myTimer.Reset(); _myTimer.Reset();
@ -431,30 +371,31 @@ ISACTest::EncodeDecode(
_channel_B2A->ResetStats(); _channel_B2A->ResetStats();
char currentTime[500]; char currentTime[500];
if(_testMode == 2) printf("\n"); if (_testMode == 2)
printf("\n");
CodecInst sendCodec; CodecInst sendCodec;
EventWrapper* myEvent = EventWrapper::Create(); EventWrapper* myEvent = EventWrapper::Create();
myEvent->StartTimer(true, 10); myEvent->StartTimer(true, 10);
while(!(_inFileA.EndOfFile() || _inFileA.Rewinded())) while (!(_inFileA.EndOfFile() || _inFileA.Rewinded())) {
{
Run10ms(); Run10ms();
_myTimer.Tick10ms(); _myTimer.Tick10ms();
_myTimer.CurrentTimeHMS(currentTime); _myTimer.CurrentTimeHMS(currentTime);
if(_testMode == 2) printf("\r%s ", currentTime); if (_testMode == 2)
printf("\r%s ", currentTime);
if((adaptiveMode) && (_testMode != 0)) if ((adaptiveMode) && (_testMode != 0)) {
{
myEvent->Wait(5000); myEvent->Wait(5000);
_acmA->SendCodec(&sendCodec); _acmA->SendCodec(&sendCodec);
if(_testMode == 2) printf("[%d] ", sendCodec.rate); if (_testMode == 2)
printf("[%d] ", sendCodec.rate);
_acmB->SendCodec(&sendCodec); _acmB->SendCodec(&sendCodec);
if(_testMode == 2) printf("[%d] ", sendCodec.rate); if (_testMode == 2)
printf("[%d] ", sendCodec.rate);
} }
} }
if(_testMode != 0) if (_testMode != 0) {
{
printf("\n\nSide A statistics\n\n"); printf("\n\nSide A statistics\n\n");
_channel_A2B->PrintStats(_paramISAC32kHz); _channel_A2B->PrintStats(_paramISAC32kHz);
@ -465,18 +406,15 @@ ISACTest::EncodeDecode(
_channel_A2B->ResetStats(); _channel_A2B->ResetStats();
_channel_B2A->ResetStats(); _channel_B2A->ResetStats();
if(_testMode != 0) printf("\n"); if (_testMode != 0)
printf("\n");
_outFileA.Close(); _outFileA.Close();
_outFileB.Close(); _outFileB.Close();
_inFileA.Close(); _inFileA.Close();
_inFileB.Close(); _inFileB.Close();
} }
void void ISACTest::SwitchingSamplingRate(int testNr, int maxSampRateChange) {
ISACTest::SwitchingSamplingRate(
int testNr,
int maxSampRateChange)
{
// Files in Side A // Files in Side A
_inFileA.Open(file_name_swb_, 32000, "rb"); _inFileA.Open(file_name_swb_, 32000, "rb");
_inFileB.Open(file_name_swb_, 32000, "rb"); _inFileB.Open(file_name_swb_, 32000, "rb");
@ -486,13 +424,10 @@ ISACTest::SwitchingSamplingRate(
std::stringstream file_stream_b; std::stringstream file_stream_b;
file_stream_a << webrtc::test::OutputPath(); file_stream_a << webrtc::test::OutputPath();
file_stream_b << webrtc::test::OutputPath(); file_stream_b << webrtc::test::OutputPath();
if(_testMode == 0) if (_testMode == 0) {
{
file_stream_a << "out_iSACTest_A_" << testNr << ".pcm"; file_stream_a << "out_iSACTest_A_" << testNr << ".pcm";
file_stream_b << "out_iSACTest_B_" << testNr << ".pcm"; file_stream_b << "out_iSACTest_B_" << testNr << ".pcm";
} } else {
else
{
printf("\nTest %d", testNr); printf("\nTest %d", testNr);
printf(" Alternate between WB and SWB at the sender Side\n\n"); printf(" Alternate between WB and SWB at the sender Side\n\n");
file_stream_a << "outA_" << testNr << ".pcm"; file_stream_a << "outA_" << testNr << ".pcm";
@ -505,8 +440,7 @@ ISACTest::SwitchingSamplingRate(
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC32kHz)); CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC32kHz));
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC16kHz)); CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC16kHz));
if(_testMode != 0) if (_testMode != 0) {
{
printf("Side A Sending Super-Wideband \n"); printf("Side A Sending Super-Wideband \n");
printf("Side B Sending Wideband\n"); printf("Side B Sending Wideband\n");
} }
@ -514,24 +448,22 @@ ISACTest::SwitchingSamplingRate(
int numSendCodecChanged = 0; int numSendCodecChanged = 0;
_myTimer.Reset(); _myTimer.Reset();
char currentTime[50]; char currentTime[50];
while(numSendCodecChanged < (maxSampRateChange<<1)) while (numSendCodecChanged < (maxSampRateChange << 1)) {
{
Run10ms(); Run10ms();
_myTimer.Tick10ms(); _myTimer.Tick10ms();
_myTimer.CurrentTimeHMS(currentTime); _myTimer.CurrentTimeHMS(currentTime);
if(_testMode == 2) printf("\r%s", currentTime); if (_testMode == 2)
if(_inFileA.EndOfFile()) printf("\r%s", currentTime);
{ if (_inFileA.EndOfFile()) {
if(_inFileA.SamplingFrequency() == 16000) if (_inFileA.SamplingFrequency() == 16000) {
{ if (_testMode != 0)
if(_testMode != 0) printf("\nSide A switched to Send Super-Wideband\n"); printf("\nSide A switched to Send Super-Wideband\n");
_inFileA.Close(); _inFileA.Close();
_inFileA.Open(file_name_swb_, 32000, "rb"); _inFileA.Open(file_name_swb_, 32000, "rb");
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC32kHz)); CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC32kHz));
} } else {
else if (_testMode != 0)
{ printf("\nSide A switched to Send Wideband\n");
if(_testMode != 0) printf("\nSide A switched to Send Wideband\n");
_inFileA.Close(); _inFileA.Close();
_inFileA.Open(file_name_swb_, 32000, "rb"); _inFileA.Open(file_name_swb_, 32000, "rb");
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC16kHz)); CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC16kHz));
@ -539,18 +471,16 @@ ISACTest::SwitchingSamplingRate(
numSendCodecChanged++; numSendCodecChanged++;
} }
if(_inFileB.EndOfFile()) if (_inFileB.EndOfFile()) {
{ if (_inFileB.SamplingFrequency() == 16000) {
if(_inFileB.SamplingFrequency() == 16000) if (_testMode != 0)
{ printf("\nSide B switched to Send Super-Wideband\n");
if(_testMode != 0) printf("\nSide B switched to Send Super-Wideband\n");
_inFileB.Close(); _inFileB.Close();
_inFileB.Open(file_name_swb_, 32000, "rb"); _inFileB.Open(file_name_swb_, 32000, "rb");
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC32kHz)); CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC32kHz));
} } else {
else if (_testMode != 0)
{ printf("\nSide B switched to Send Wideband\n");
if(_testMode != 0) printf("\nSide B switched to Send Wideband\n");
_inFileB.Close(); _inFileB.Close();
_inFileB.Open(file_name_swb_, 32000, "rb"); _inFileB.Open(file_name_swb_, 32000, "rb");
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC16kHz)); CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC16kHz));

View File

@ -25,8 +25,7 @@
namespace webrtc { namespace webrtc {
struct ACMTestISACConfig struct ACMTestISACConfig {
{
int32_t currentRateBitPerSec; int32_t currentRateBitPerSec;
int16_t currentFrameSizeMsec; int16_t currentFrameSizeMsec;
uint32_t maxRateBitPerSec; uint32_t maxRateBitPerSec;
@ -37,10 +36,7 @@ struct ACMTestISACConfig
bool enforceFrameSize; bool enforceFrameSize;
}; };
class ISACTest : public ACMTest {
class ISACTest : public ACMTest
{
public: public:
ISACTest(int testMode); ISACTest(int testMode);
~ISACTest(); ~ISACTest();
@ -51,20 +47,14 @@ private:
int16_t SetupConference(); int16_t SetupConference();
int16_t RunConference(); int16_t RunConference();
void Run10ms(); void Run10ms();
void EncodeDecode( void EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig,
int testNr,
ACMTestISACConfig& wbISACConfig,
ACMTestISACConfig& swbISACConfig); ACMTestISACConfig& swbISACConfig);
void TestBWE( void TestBWE(int testNr);
int testNr);
void SwitchingSamplingRate( void SwitchingSamplingRate(int testNr, int maxSampRateChange);
int testNr,
int maxSampRateChange);
AudioCodingModule* _acmA; AudioCodingModule* _acmA;
AudioCodingModule* _acmB; AudioCodingModule* _acmB;

View File

@ -50,7 +50,8 @@ class InitialPlayoutDelayTest : public ::testing::Test {
channel_a2b_(NULL) { channel_a2b_(NULL) {
} }
~InitialPlayoutDelayTest() {} ~InitialPlayoutDelayTest() {
}
void TearDown() { void TearDown() {
if (acm_a_ != NULL) { if (acm_a_ != NULL) {
@ -128,7 +129,6 @@ class InitialPlayoutDelayTest : public ::testing::Test {
Channel* channel_a2b_; Channel* channel_a2b_;
}; };
TEST_F( InitialPlayoutDelayTest, NbMono) { TEST_F( InitialPlayoutDelayTest, NbMono) {
CodecInst codec; CodecInst codec;
AudioCodingModule::Codec("L16", &codec, 8000, 1); AudioCodingModule::Codec("L16", &codec, 8000, 1);
@ -167,4 +167,5 @@ TEST_F( InitialPlayoutDelayTest, SwbStereo) {
// PCM16 super-wideband. // PCM16 super-wideband.
} }
} // namespace webrtc }
// namespace webrtc

View File

@ -23,68 +23,57 @@
namespace webrtc { namespace webrtc {
ACMTestTimer::ACMTestTimer() : ACMTestTimer::ACMTestTimer()
_msec(0), : _msec(0),
_sec(0), _sec(0),
_min(0), _min(0),
_hour(0) _hour(0) {
{
return; return;
} }
ACMTestTimer::~ACMTestTimer() ACMTestTimer::~ACMTestTimer() {
{
return; return;
} }
void ACMTestTimer::Reset() void ACMTestTimer::Reset() {
{
_msec = 0; _msec = 0;
_sec = 0; _sec = 0;
_min = 0; _min = 0;
_hour = 0; _hour = 0;
return; return;
} }
void ACMTestTimer::Tick10ms() void ACMTestTimer::Tick10ms() {
{
_msec += 10; _msec += 10;
Adjust(); Adjust();
return; return;
} }
void ACMTestTimer::Tick1ms() void ACMTestTimer::Tick1ms() {
{
_msec++; _msec++;
Adjust(); Adjust();
return; return;
} }
void ACMTestTimer::Tick100ms() void ACMTestTimer::Tick100ms() {
{
_msec += 100; _msec += 100;
Adjust(); Adjust();
return; return;
} }
void ACMTestTimer::Tick1sec() void ACMTestTimer::Tick1sec() {
{
_sec++; _sec++;
Adjust(); Adjust();
return; return;
} }
void ACMTestTimer::CurrentTimeHMS(char* currTime) void ACMTestTimer::CurrentTimeHMS(char* currTime) {
{ sprintf(currTime, "%4lu:%02u:%06.3f", _hour, _min,
sprintf(currTime, "%4lu:%02u:%06.3f", _hour, _min, (double)_sec + (double)_msec / 1000.); (double) _sec + (double) _msec / 1000.);
return; return;
} }
void ACMTestTimer::CurrentTime( void ACMTestTimer::CurrentTime(unsigned long& h, unsigned char& m,
unsigned long& h, unsigned char& s, unsigned short& ms) {
unsigned char& m,
unsigned char& s,
unsigned short& ms)
{
h = _hour; h = _hour;
m = _min; m = _min;
s = _sec; s = _sec;
@ -92,34 +81,26 @@ void ACMTestTimer::CurrentTime(
return; return;
} }
void ACMTestTimer::Adjust() void ACMTestTimer::Adjust() {
{
unsigned int n; unsigned int n;
if(_msec >= 1000) if (_msec >= 1000) {
{
n = _msec / 1000; n = _msec / 1000;
_msec -= (1000 * n); _msec -= (1000 * n);
_sec += n; _sec += n;
} }
if(_sec >= 60) if (_sec >= 60) {
{
n = _sec / 60; n = _sec / 60;
_sec -= (n * 60); _sec -= (n * 60);
_min += n; _min += n;
} }
if(_min >= 60) if (_min >= 60) {
{
n = _min / 60; n = _min / 60;
_min -= (n * 60); _min -= (n * 60);
_hour += n; _hour += n;
} }
} }
int16_t ChooseCodec(CodecInst& codecInst) {
int16_t
ChooseCodec(
CodecInst& codecInst)
{
PrintCodecs(); PrintCodecs();
//AudioCodingModule* tmpACM = AudioCodingModule::Create(0); //AudioCodingModule* tmpACM = AudioCodingModule::Create(0);
@ -127,13 +108,11 @@ ChooseCodec(
int8_t codecID; int8_t codecID;
bool outOfRange = false; bool outOfRange = false;
char myStr[15] = ""; char myStr[15] = "";
do do {
{
printf("\nChoose a codec [0]: "); printf("\nChoose a codec [0]: ");
EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL); EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL);
codecID = atoi(myStr); codecID = atoi(myStr);
if((codecID < 0) || (codecID >= noCodec)) if ((codecID < 0) || (codecID >= noCodec)) {
{
printf("\nOut of range.\n"); printf("\nOut of range.\n");
outOfRange = true; outOfRange = true;
} }
@ -143,59 +122,46 @@ ChooseCodec(
return 0; return 0;
} }
void void PrintCodecs() {
PrintCodecs()
{
uint8_t noCodec = AudioCodingModule::NumberOfCodecs(); uint8_t noCodec = AudioCodingModule::NumberOfCodecs();
CodecInst codecInst; CodecInst codecInst;
printf("No Name [Hz] [bps]\n"); printf("No Name [Hz] [bps]\n");
for(uint8_t codecCntr = 0; codecCntr < noCodec; codecCntr++) for (uint8_t codecCntr = 0; codecCntr < noCodec; codecCntr++) {
{
AudioCodingModule::Codec(codecCntr, &codecInst); AudioCodingModule::Codec(codecCntr, &codecInst);
printf("%2d- %-18s %5d %6d\n", printf("%2d- %-18s %5d %6d\n", codecCntr, codecInst.plname,
codecCntr, codecInst.plname, codecInst.plfreq, codecInst.rate); codecInst.plfreq, codecInst.rate);
} }
} }
CircularBuffer::CircularBuffer(uint32_t len): CircularBuffer::CircularBuffer(uint32_t len)
_buff(NULL), : _buff(NULL),
_idx(0), _idx(0),
_buffIsFull(false), _buffIsFull(false),
_calcAvg(false), _calcAvg(false),
_calcVar(false), _calcVar(false),
_sum(0), _sum(0),
_sumSqr(0) _sumSqr(0) {
{
_buff = new double[len]; _buff = new double[len];
if(_buff == NULL) if (_buff == NULL) {
{
_buffLen = 0; _buffLen = 0;
} } else {
else for (uint32_t n = 0; n < len; n++) {
{
for(uint32_t n = 0; n < len; n++)
{
_buff[n] = 0; _buff[n] = 0;
} }
_buffLen = len; _buffLen = len;
} }
} }
CircularBuffer::~CircularBuffer() CircularBuffer::~CircularBuffer() {
{ if (_buff != NULL) {
if(_buff != NULL)
{
delete[] _buff; delete[] _buff;
_buff = NULL; _buff = NULL;
} }
} }
void void CircularBuffer::Update(const double newVal) {
CircularBuffer::Update(
const double newVal)
{
assert(_buffLen > 0); assert(_buffLen > 0);
// store the value that is going to be overwritten // store the value that is going to be overwritten
@ -207,8 +173,7 @@ CircularBuffer::Update(
_idx++; _idx++;
// it is a circular buffer, if we are at the end // it is a circular buffer, if we are at the end
// we have to cycle to the beginning // we have to cycle to the beginning
if(_idx >= _buffLen) if (_idx >= _buffLen) {
{
// flag that the buffer is filled up. // flag that the buffer is filled up.
_buffIsFull = true; _buffIsFull = true;
_idx = 0; _idx = 0;
@ -216,179 +181,121 @@ CircularBuffer::Update(
// Update // Update
if(_calcAvg) if (_calcAvg) {
{
// for the average we have to update // for the average we have to update
// the sum // the sum
_sum += (newVal - oldVal); _sum += (newVal - oldVal);
} }
if(_calcVar) if (_calcVar) {
{
// to calculate variance we have to update // to calculate variance we have to update
// the sum of squares // the sum of squares
_sumSqr += (double) (newVal - oldVal) * (double) (newVal + oldVal); _sumSqr += (double) (newVal - oldVal) * (double) (newVal + oldVal);
} }
} }
void void CircularBuffer::SetArithMean(bool enable) {
CircularBuffer::SetArithMean(
bool enable)
{
assert(_buffLen > 0); assert(_buffLen > 0);
if(enable && !_calcAvg) if (enable && !_calcAvg) {
{
uint32_t lim; uint32_t lim;
if(_buffIsFull) if (_buffIsFull) {
{
lim = _buffLen; lim = _buffLen;
} } else {
else
{
lim = _idx; lim = _idx;
} }
_sum = 0; _sum = 0;
for(uint32_t n = 0; n < lim; n++) for (uint32_t n = 0; n < lim; n++) {
{
_sum += _buff[n]; _sum += _buff[n];
} }
} }
_calcAvg = enable; _calcAvg = enable;
} }
void void CircularBuffer::SetVariance(bool enable) {
CircularBuffer::SetVariance(
bool enable)
{
assert(_buffLen > 0); assert(_buffLen > 0);
if(enable && !_calcVar) if (enable && !_calcVar) {
{
uint32_t lim; uint32_t lim;
if(_buffIsFull) if (_buffIsFull) {
{
lim = _buffLen; lim = _buffLen;
} } else {
else
{
lim = _idx; lim = _idx;
} }
_sumSqr = 0; _sumSqr = 0;
for(uint32_t n = 0; n < lim; n++) for (uint32_t n = 0; n < lim; n++) {
{
_sumSqr += _buff[n] * _buff[n]; _sumSqr += _buff[n] * _buff[n];
} }
} }
_calcAvg = enable; _calcAvg = enable;
} }
int16_t int16_t CircularBuffer::ArithMean(double& mean) {
CircularBuffer::ArithMean(double& mean)
{
assert(_buffLen > 0); assert(_buffLen > 0);
if(_buffIsFull) if (_buffIsFull) {
{
mean = _sum / (double) _buffLen; mean = _sum / (double) _buffLen;
return 0; return 0;
} } else {
else if (_idx > 0) {
{
if(_idx > 0)
{
mean = _sum / (double) _idx; mean = _sum / (double) _idx;
return 0; return 0;
} } else {
else
{
return -1; return -1;
} }
} }
} }
int16_t int16_t CircularBuffer::Variance(double& var) {
CircularBuffer::Variance(double& var)
{
assert(_buffLen > 0); assert(_buffLen > 0);
if(_buffIsFull) if (_buffIsFull) {
{
var = _sumSqr / (double) _buffLen; var = _sumSqr / (double) _buffLen;
return 0; return 0;
} } else {
else if (_idx > 0) {
{
if(_idx > 0)
{
var = _sumSqr / (double) _idx; var = _sumSqr / (double) _idx;
return 0; return 0;
} } else {
else
{
return -1; return -1;
} }
} }
} }
bool FixedPayloadTypeCodec(const char* payloadName) {
char fixPayloadTypeCodecs[NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE][32] = { "PCMU",
"PCMA", "GSM", "G723", "DVI4", "LPC", "PCMA", "G722", "QCELP", "CN",
"MPA", "G728", "G729" };
for (int n = 0; n < NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE; n++) {
bool if (!STR_CASE_CMP(payloadName, fixPayloadTypeCodecs[n])) {
FixedPayloadTypeCodec(const char* payloadName)
{
char fixPayloadTypeCodecs[NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE][32] = {
"PCMU",
"PCMA",
"GSM",
"G723",
"DVI4",
"LPC",
"PCMA",
"G722",
"QCELP",
"CN",
"MPA",
"G728",
"G729"
};
for(int n = 0; n < NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE; n++)
{
if(!STR_CASE_CMP(payloadName, fixPayloadTypeCodecs[n]))
{
return true; return true;
} }
} }
return false; return false;
} }
DTMFDetector::DTMFDetector() DTMFDetector::DTMFDetector() {
{ for (int16_t n = 0; n < 1000; n++) {
for(int16_t n = 0; n < 1000; n++)
{
_toneCntr[n] = 0; _toneCntr[n] = 0;
} }
} }
DTMFDetector::~DTMFDetector() DTMFDetector::~DTMFDetector() {
{
} }
int32_t DTMFDetector::IncomingDtmf(const uint8_t digitDtmf, const bool /* toneEnded */) int32_t DTMFDetector::IncomingDtmf(const uint8_t digitDtmf,
{ const bool /* toneEnded */) {
fprintf(stdout, "%d-", digitDtmf); fprintf(stdout, "%d-", digitDtmf);
_toneCntr[digitDtmf]++; _toneCntr[digitDtmf]++;
return 0; return 0;
} }
void DTMFDetector::PrintDetectedDigits() void DTMFDetector::PrintDetectedDigits() {
{ for (int16_t n = 0; n < 1000; n++) {
for(int16_t n = 0; n < 1000; n++) if (_toneCntr[n] > 0) {
{
if(_toneCntr[n] > 0)
{
fprintf(stdout, "%d %u msec, \n", n, _toneCntr[n] * 10); fprintf(stdout, "%d %u msec, \n", n, _toneCntr[n] * 10);
} }
} }
@ -396,26 +303,19 @@ void DTMFDetector::PrintDetectedDigits()
return; return;
} }
void void VADCallback::Reset() {
VADCallback::Reset() for (int n = 0; n < 6; n++) {
{
for(int n = 0; n < 6; n++)
{
_numFrameTypes[n] = 0; _numFrameTypes[n] = 0;
} }
} }
VADCallback::VADCallback() VADCallback::VADCallback() {
{ for (int n = 0; n < 6; n++) {
for(int n = 0; n < 6; n++)
{
_numFrameTypes[n] = 0; _numFrameTypes[n] = 0;
} }
} }
void void VADCallback::PrintFrameTypes() {
VADCallback::PrintFrameTypes()
{
fprintf(stdout, "No encoding.................. %d\n", _numFrameTypes[0]); fprintf(stdout, "No encoding.................. %d\n", _numFrameTypes[0]);
fprintf(stdout, "Active normal encoded........ %d\n", _numFrameTypes[1]); fprintf(stdout, "Active normal encoded........ %d\n", _numFrameTypes[1]);
fprintf(stdout, "Passive normal encoded....... %d\n", _numFrameTypes[2]); fprintf(stdout, "Passive normal encoded....... %d\n", _numFrameTypes[2]);
@ -424,10 +324,7 @@ VADCallback::PrintFrameTypes()
fprintf(stdout, "Passive DTX super-wideband... %d\n", _numFrameTypes[5]); fprintf(stdout, "Passive DTX super-wideband... %d\n", _numFrameTypes[5]);
} }
int32_t int32_t VADCallback::InFrameType(int16_t frameType) {
VADCallback::InFrameType(
int16_t frameType)
{
_numFrameTypes[frameType]++; _numFrameTypes[frameType]++;
return 0; return 0;
} }

View File

@ -27,8 +27,7 @@ namespace webrtc {
do { \ do { \
if (f >= 0) { \ if (f >= 0) { \
ADD_FAILURE() << "Error Calling API"; \ ADD_FAILURE() << "Error Calling API"; \
} \ } else { \
else { \
printf("An expected error is caught.\n"); \ printf("An expected error is caught.\n"); \
} \ } \
} while(0) } while(0)
@ -48,13 +47,11 @@ namespace webrtc {
if (f >= 0) { \ if (f >= 0) { \
fprintf(stderr, "Error Calling API in file %s at line %d \n", \ fprintf(stderr, "Error Calling API in file %s at line %d \n", \
__FILE__, __LINE__); \ __FILE__, __LINE__); \
} \ } else { \
else { \
printf("An expected error is caught.\n"); \ printf("An expected error is caught.\n"); \
} \ } \
} while(0) } while(0)
#define DESTROY_ACM(acm) \ #define DESTROY_ACM(acm) \
do { \ do { \
if (acm != NULL) { \ if (acm != NULL) { \
@ -63,7 +60,6 @@ namespace webrtc {
} \ } \
} while(0) } while(0)
#define DELETE_POINTER(p) \ #define DELETE_POINTER(p) \
do { \ do { \
if (p != NULL) { \ if (p != NULL) { \
@ -72,8 +68,7 @@ namespace webrtc {
} \ } \
} while(0) } while(0)
class ACMTestTimer class ACMTestTimer {
{
public: public:
ACMTestTimer(); ACMTestTimer();
~ACMTestTimer(); ~ACMTestTimer();
@ -83,12 +78,8 @@ public:
void Tick1ms(); void Tick1ms();
void Tick100ms(); void Tick100ms();
void Tick1sec(); void Tick1sec();
void CurrentTimeHMS( void CurrentTimeHMS(char* currTime);
char* currTime); void CurrentTime(unsigned long& h, unsigned char& m, unsigned char& s,
void CurrentTime(
unsigned long& h,
unsigned char& m,
unsigned char& s,
unsigned short& ms); unsigned short& ms);
private: private:
@ -100,21 +91,15 @@ private:
unsigned long _hour; unsigned long _hour;
}; };
class CircularBuffer {
class CircularBuffer
{
public: public:
CircularBuffer(uint32_t len); CircularBuffer(uint32_t len);
~CircularBuffer(); ~CircularBuffer();
void SetArithMean( void SetArithMean(bool enable);
bool enable); void SetVariance(bool enable);
void SetVariance(
bool enable);
void Update( void Update(const double newVal);
const double newVal);
void IsBufferFull(); void IsBufferFull();
int16_t Variance(double& var); int16_t Variance(double& var);
@ -132,22 +117,13 @@ protected:
double _sumSqr; double _sumSqr;
}; };
int16_t ChooseCodec(CodecInst& codecInst);
int16_t ChooseCodec(
CodecInst& codecInst);
void PrintCodecs(); void PrintCodecs();
bool FixedPayloadTypeCodec(const char* payloadName); bool FixedPayloadTypeCodec(const char* payloadName);
class DTMFDetector : public AudioCodingFeedback {
class DTMFDetector: public AudioCodingFeedback
{
public: public:
DTMFDetector(); DTMFDetector();
~DTMFDetector(); ~DTMFDetector();
@ -160,17 +136,13 @@ private:
}; };
class VADCallback : public ACMVADCallback {
class VADCallback : public ACMVADCallback
{
public: public:
VADCallback(); VADCallback();
~VADCallback(){} ~VADCallback() {
}
int32_t InFrameType( int32_t InFrameType(int16_t frameType);
int16_t frameType);
void PrintFrameTypes(); void PrintFrameTypes();
void Reset(); void Reset();