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:
parent
03efc89151
commit
d5726a1286
@ -10,7 +10,5 @@
|
|||||||
|
|
||||||
#include "ACMTest.h"
|
#include "ACMTest.h"
|
||||||
|
|
||||||
ACMTest::~ACMTest()
|
ACMTest::~ACMTest() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -11,11 +11,10 @@
|
|||||||
#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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -19,155 +19,154 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
enum APITESTAction {TEST_CHANGE_CODEC_ONLY = 0, DTX_TEST = 1};
|
enum APITESTAction {
|
||||||
|
TEST_CHANGE_CODEC_ONLY = 0,
|
||||||
class APITest : public ACMTest
|
DTX_TEST = 1
|
||||||
{
|
|
||||||
public:
|
|
||||||
APITest();
|
|
||||||
~APITest();
|
|
||||||
|
|
||||||
void Perform();
|
|
||||||
private:
|
|
||||||
int16_t SetUp();
|
|
||||||
|
|
||||||
static bool PushAudioThreadA(void* obj);
|
|
||||||
static bool PullAudioThreadA(void* obj);
|
|
||||||
static bool ProcessThreadA(void* obj);
|
|
||||||
static bool APIThreadA(void* obj);
|
|
||||||
|
|
||||||
static bool PushAudioThreadB(void* obj);
|
|
||||||
static bool PullAudioThreadB(void* obj);
|
|
||||||
static bool ProcessThreadB(void* obj);
|
|
||||||
static bool APIThreadB(void* obj);
|
|
||||||
|
|
||||||
void CheckVADStatus(char side);
|
|
||||||
|
|
||||||
// Set Min delay, get delay, playout timestamp
|
|
||||||
void TestDelay(char side);
|
|
||||||
|
|
||||||
// Unregister a codec & register again.
|
|
||||||
void TestRegisteration(char side);
|
|
||||||
|
|
||||||
// Playout Mode, background noise mode.
|
|
||||||
// Receiver Frequency, playout frequency.
|
|
||||||
void TestPlayout(char receiveSide);
|
|
||||||
|
|
||||||
// set/get receiver VAD status & mode.
|
|
||||||
void TestReceiverVAD(char side);
|
|
||||||
|
|
||||||
//
|
|
||||||
void TestSendVAD(char side);
|
|
||||||
|
|
||||||
void CurrentCodec(char side);
|
|
||||||
|
|
||||||
void ChangeCodec(char side);
|
|
||||||
|
|
||||||
void Wait(uint32_t waitLengthMs);
|
|
||||||
|
|
||||||
void LookForDTMF(char side);
|
|
||||||
|
|
||||||
void RunTest(char thread);
|
|
||||||
|
|
||||||
bool PushAudioRunA();
|
|
||||||
bool PullAudioRunA();
|
|
||||||
bool ProcessRunA();
|
|
||||||
bool APIRunA();
|
|
||||||
|
|
||||||
bool PullAudioRunB();
|
|
||||||
bool PushAudioRunB();
|
|
||||||
bool ProcessRunB();
|
|
||||||
bool APIRunB();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--- ACMs
|
|
||||||
AudioCodingModule* _acmA;
|
|
||||||
AudioCodingModule* _acmB;
|
|
||||||
|
|
||||||
//--- Channels
|
|
||||||
Channel* _channel_A2B;
|
|
||||||
Channel* _channel_B2A;
|
|
||||||
|
|
||||||
//--- I/O files
|
|
||||||
// A
|
|
||||||
PCMFile _inFileA;
|
|
||||||
PCMFile _outFileA;
|
|
||||||
// B
|
|
||||||
PCMFile _outFileB;
|
|
||||||
PCMFile _inFileB;
|
|
||||||
|
|
||||||
//--- I/O params
|
|
||||||
// A
|
|
||||||
int32_t _outFreqHzA;
|
|
||||||
// B
|
|
||||||
int32_t _outFreqHzB;
|
|
||||||
|
|
||||||
// Should we write to file.
|
|
||||||
// we might skip writing to file if we
|
|
||||||
// run the test for a long time.
|
|
||||||
bool _writeToFile;
|
|
||||||
//--- Events
|
|
||||||
// A
|
|
||||||
EventWrapper* _pullEventA; // pulling data from ACM
|
|
||||||
EventWrapper* _pushEventA; // pushing data to ACM
|
|
||||||
EventWrapper* _processEventA; // process
|
|
||||||
EventWrapper* _apiEventA; // API calls
|
|
||||||
// B
|
|
||||||
EventWrapper* _pullEventB; // pulling data from ACM
|
|
||||||
EventWrapper* _pushEventB; // pushing data to ACM
|
|
||||||
EventWrapper* _processEventB; // process
|
|
||||||
EventWrapper* _apiEventB; // API calls
|
|
||||||
|
|
||||||
// keep track of the codec in either side.
|
|
||||||
uint8_t _codecCntrA;
|
|
||||||
uint8_t _codecCntrB;
|
|
||||||
|
|
||||||
// Is set to true if there is no encoder in either side
|
|
||||||
bool _thereIsEncoderA;
|
|
||||||
bool _thereIsEncoderB;
|
|
||||||
bool _thereIsDecoderA;
|
|
||||||
bool _thereIsDecoderB;
|
|
||||||
|
|
||||||
bool _sendVADA;
|
|
||||||
bool _sendDTXA;
|
|
||||||
ACMVADMode _sendVADModeA;
|
|
||||||
|
|
||||||
bool _sendVADB;
|
|
||||||
bool _sendDTXB;
|
|
||||||
ACMVADMode _sendVADModeB;
|
|
||||||
|
|
||||||
int32_t _minDelayA;
|
|
||||||
int32_t _minDelayB;
|
|
||||||
bool _payloadUsed[32];
|
|
||||||
|
|
||||||
AudioPlayoutMode _playoutModeA;
|
|
||||||
AudioPlayoutMode _playoutModeB;
|
|
||||||
|
|
||||||
ACMBackgroundNoiseMode _bgnModeA;
|
|
||||||
ACMBackgroundNoiseMode _bgnModeB;
|
|
||||||
|
|
||||||
|
|
||||||
int _receiveVADActivityA[3];
|
|
||||||
int _receiveVADActivityB[3];
|
|
||||||
bool _verbose;
|
|
||||||
|
|
||||||
int _dotPositionA;
|
|
||||||
int _dotMoveDirectionA;
|
|
||||||
int _dotPositionB;
|
|
||||||
int _dotMoveDirectionB;
|
|
||||||
|
|
||||||
char _movingDot[41];
|
|
||||||
|
|
||||||
DTMFDetector* _dtmfCallback;
|
|
||||||
VADCallback* _vadCallbackA;
|
|
||||||
VADCallback* _vadCallbackB;
|
|
||||||
RWLockWrapper& _apiTestRWLock;
|
|
||||||
bool _randomTest;
|
|
||||||
int _testNumA;
|
|
||||||
int _testNumB;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
class APITest : public ACMTest {
|
||||||
|
public:
|
||||||
|
APITest();
|
||||||
|
~APITest();
|
||||||
|
|
||||||
|
void Perform();
|
||||||
|
private:
|
||||||
|
int16_t SetUp();
|
||||||
|
|
||||||
|
static bool PushAudioThreadA(void* obj);
|
||||||
|
static bool PullAudioThreadA(void* obj);
|
||||||
|
static bool ProcessThreadA(void* obj);
|
||||||
|
static bool APIThreadA(void* obj);
|
||||||
|
|
||||||
|
static bool PushAudioThreadB(void* obj);
|
||||||
|
static bool PullAudioThreadB(void* obj);
|
||||||
|
static bool ProcessThreadB(void* obj);
|
||||||
|
static bool APIThreadB(void* obj);
|
||||||
|
|
||||||
|
void CheckVADStatus(char side);
|
||||||
|
|
||||||
|
// Set Min delay, get delay, playout timestamp
|
||||||
|
void TestDelay(char side);
|
||||||
|
|
||||||
|
// Unregister a codec & register again.
|
||||||
|
void TestRegisteration(char side);
|
||||||
|
|
||||||
|
// Playout Mode, background noise mode.
|
||||||
|
// Receiver Frequency, playout frequency.
|
||||||
|
void TestPlayout(char receiveSide);
|
||||||
|
|
||||||
|
// set/get receiver VAD status & mode.
|
||||||
|
void TestReceiverVAD(char side);
|
||||||
|
|
||||||
|
//
|
||||||
|
void TestSendVAD(char side);
|
||||||
|
|
||||||
|
void CurrentCodec(char side);
|
||||||
|
|
||||||
|
void ChangeCodec(char side);
|
||||||
|
|
||||||
|
void Wait(uint32_t waitLengthMs);
|
||||||
|
|
||||||
|
void LookForDTMF(char side);
|
||||||
|
|
||||||
|
void RunTest(char thread);
|
||||||
|
|
||||||
|
bool PushAudioRunA();
|
||||||
|
bool PullAudioRunA();
|
||||||
|
bool ProcessRunA();
|
||||||
|
bool APIRunA();
|
||||||
|
|
||||||
|
bool PullAudioRunB();
|
||||||
|
bool PushAudioRunB();
|
||||||
|
bool ProcessRunB();
|
||||||
|
bool APIRunB();
|
||||||
|
|
||||||
|
//--- ACMs
|
||||||
|
AudioCodingModule* _acmA;
|
||||||
|
AudioCodingModule* _acmB;
|
||||||
|
|
||||||
|
//--- Channels
|
||||||
|
Channel* _channel_A2B;
|
||||||
|
Channel* _channel_B2A;
|
||||||
|
|
||||||
|
//--- I/O files
|
||||||
|
// A
|
||||||
|
PCMFile _inFileA;
|
||||||
|
PCMFile _outFileA;
|
||||||
|
// B
|
||||||
|
PCMFile _outFileB;
|
||||||
|
PCMFile _inFileB;
|
||||||
|
|
||||||
|
//--- I/O params
|
||||||
|
// A
|
||||||
|
int32_t _outFreqHzA;
|
||||||
|
// B
|
||||||
|
int32_t _outFreqHzB;
|
||||||
|
|
||||||
|
// Should we write to file.
|
||||||
|
// we might skip writing to file if we
|
||||||
|
// run the test for a long time.
|
||||||
|
bool _writeToFile;
|
||||||
|
//--- Events
|
||||||
|
// A
|
||||||
|
EventWrapper* _pullEventA; // pulling data from ACM
|
||||||
|
EventWrapper* _pushEventA; // pushing data to ACM
|
||||||
|
EventWrapper* _processEventA; // process
|
||||||
|
EventWrapper* _apiEventA; // API calls
|
||||||
|
// B
|
||||||
|
EventWrapper* _pullEventB; // pulling data from ACM
|
||||||
|
EventWrapper* _pushEventB; // pushing data to ACM
|
||||||
|
EventWrapper* _processEventB; // process
|
||||||
|
EventWrapper* _apiEventB; // API calls
|
||||||
|
|
||||||
|
// keep track of the codec in either side.
|
||||||
|
uint8_t _codecCntrA;
|
||||||
|
uint8_t _codecCntrB;
|
||||||
|
|
||||||
|
// Is set to true if there is no encoder in either side
|
||||||
|
bool _thereIsEncoderA;
|
||||||
|
bool _thereIsEncoderB;
|
||||||
|
bool _thereIsDecoderA;
|
||||||
|
bool _thereIsDecoderB;
|
||||||
|
|
||||||
|
bool _sendVADA;
|
||||||
|
bool _sendDTXA;
|
||||||
|
ACMVADMode _sendVADModeA;
|
||||||
|
|
||||||
|
bool _sendVADB;
|
||||||
|
bool _sendDTXB;
|
||||||
|
ACMVADMode _sendVADModeB;
|
||||||
|
|
||||||
|
int32_t _minDelayA;
|
||||||
|
int32_t _minDelayB;
|
||||||
|
bool _payloadUsed[32];
|
||||||
|
|
||||||
|
AudioPlayoutMode _playoutModeA;
|
||||||
|
AudioPlayoutMode _playoutModeB;
|
||||||
|
|
||||||
|
ACMBackgroundNoiseMode _bgnModeA;
|
||||||
|
ACMBackgroundNoiseMode _bgnModeB;
|
||||||
|
|
||||||
|
int _receiveVADActivityA[3];
|
||||||
|
int _receiveVADActivityB[3];
|
||||||
|
bool _verbose;
|
||||||
|
|
||||||
|
int _dotPositionA;
|
||||||
|
int _dotMoveDirectionA;
|
||||||
|
int _dotPositionB;
|
||||||
|
int _dotMoveDirectionB;
|
||||||
|
|
||||||
|
char _movingDot[41];
|
||||||
|
|
||||||
|
DTMFDetector* _dtmfCallback;
|
||||||
|
VADCallback* _vadCallbackA;
|
||||||
|
VADCallback* _vadCallbackB;
|
||||||
|
RWLockWrapper& _apiTestRWLock;
|
||||||
|
bool _randomTest;
|
||||||
|
int _testNumA;
|
||||||
|
int _testNumB;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,459 +19,374 @@
|
|||||||
|
|
||||||
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 uint16_t payloadSize,
|
||||||
const uint8_t payloadType,
|
const RTPFragmentationHeader* fragmentation) {
|
||||||
const uint32_t timeStamp,
|
WebRtcRTPHeader rtpInfo;
|
||||||
const uint8_t* payloadData,
|
int32_t status;
|
||||||
const uint16_t payloadSize,
|
uint16_t payloadDataSize = payloadSize;
|
||||||
const RTPFragmentationHeader* fragmentation)
|
|
||||||
{
|
|
||||||
WebRtcRTPHeader rtpInfo;
|
|
||||||
int32_t status;
|
|
||||||
uint16_t payloadDataSize = payloadSize;
|
|
||||||
|
|
||||||
rtpInfo.header.markerBit = false;
|
rtpInfo.header.markerBit = false;
|
||||||
rtpInfo.header.ssrc = 0;
|
rtpInfo.header.ssrc = 0;
|
||||||
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 {
|
||||||
}
|
rtpInfo.type.Audio.isCNG = false;
|
||||||
else
|
}
|
||||||
{
|
if (frameType == kFrameEmpty) {
|
||||||
rtpInfo.type.Audio.isCNG = false;
|
// Skip this frame
|
||||||
}
|
|
||||||
if(frameType == kFrameEmpty)
|
|
||||||
{
|
|
||||||
// Skip this frame
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
rtpInfo.type.Audio.channel = 1;
|
|
||||||
// Treat fragmentation separately
|
|
||||||
if(fragmentation != NULL)
|
|
||||||
{
|
|
||||||
if((fragmentation->fragmentationTimeDiff[1] <= 0x3fff) && // silence for too long send only new data
|
|
||||||
(fragmentation->fragmentationVectorSize == 2))
|
|
||||||
{
|
|
||||||
// only 0x80 if we have multiple blocks
|
|
||||||
_payloadData[0] = 0x80 + fragmentation->fragmentationPlType[1];
|
|
||||||
uint32_t REDheader = (((uint32_t)fragmentation->fragmentationTimeDiff[1]) << 10) + fragmentation->fragmentationLength[1];
|
|
||||||
_payloadData[1] = uint8_t((REDheader >> 16) & 0x000000FF);
|
|
||||||
_payloadData[2] = uint8_t((REDheader >> 8) & 0x000000FF);
|
|
||||||
_payloadData[3] = uint8_t(REDheader & 0x000000FF);
|
|
||||||
|
|
||||||
_payloadData[4] = fragmentation->fragmentationPlType[0];
|
|
||||||
// copy the RED data
|
|
||||||
memcpy(_payloadData + 5,
|
|
||||||
payloadData + fragmentation->fragmentationOffset[1],
|
|
||||||
fragmentation->fragmentationLength[1]);
|
|
||||||
// copy the normal data
|
|
||||||
memcpy(_payloadData + 5 + fragmentation->fragmentationLength[1],
|
|
||||||
payloadData + fragmentation->fragmentationOffset[0],
|
|
||||||
fragmentation->fragmentationLength[0]);
|
|
||||||
payloadDataSize += 5;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
// single block (newest one)
|
|
||||||
memcpy(_payloadData,
|
|
||||||
payloadData + fragmentation->fragmentationOffset[0],
|
|
||||||
fragmentation->fragmentationLength[0]);
|
|
||||||
payloadDataSize = uint16_t(fragmentation->fragmentationLength[0]);
|
|
||||||
rtpInfo.header.payloadType = fragmentation->fragmentationPlType[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memcpy(_payloadData, payloadData, payloadDataSize);
|
|
||||||
if(_isStereo)
|
|
||||||
{
|
|
||||||
if(_leftChannel)
|
|
||||||
{
|
|
||||||
memcpy(&_rtpInfo, &rtpInfo, sizeof(WebRtcRTPHeader));
|
|
||||||
_leftChannel = false;
|
|
||||||
rtpInfo.type.Audio.channel = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memcpy(&rtpInfo, &_rtpInfo, sizeof(WebRtcRTPHeader));
|
|
||||||
_leftChannel = true;
|
|
||||||
rtpInfo.type.Audio.channel = 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_channelCritSect->Enter();
|
|
||||||
if(_saveBitStream)
|
|
||||||
{
|
|
||||||
//fwrite(payloadData, sizeof(uint8_t), payloadSize, _bitStreamFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!_isStereo)
|
|
||||||
{
|
|
||||||
CalcStatistics(rtpInfo, payloadSize);
|
|
||||||
}
|
|
||||||
_lastInTimestamp = timeStamp;
|
|
||||||
_totalBytes += payloadDataSize;
|
|
||||||
_channelCritSect->Leave();
|
|
||||||
|
|
||||||
if(_useFECTestWithPacketLoss)
|
|
||||||
{
|
|
||||||
_packetLoss += 1;
|
|
||||||
if(_packetLoss == 3)
|
|
||||||
{
|
|
||||||
_packetLoss = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
status = _receiverACM->IncomingPacket(_payloadData, payloadDataSize,
|
|
||||||
rtpInfo);
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Channel::CalcStatistics(
|
|
||||||
WebRtcRTPHeader& rtpInfo,
|
|
||||||
uint16_t payloadSize)
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
if((rtpInfo.header.payloadType != _lastPayloadType) &&
|
|
||||||
(_lastPayloadType != -1))
|
|
||||||
{
|
|
||||||
// payload-type is changed.
|
|
||||||
// we have to terminate the calculations on the previous payload type
|
|
||||||
// we ignore the last packet in that payload type just to make things
|
|
||||||
// easier.
|
|
||||||
for(n = 0; n < MAX_NUM_PAYLOADS; n++)
|
|
||||||
{
|
|
||||||
if(_lastPayloadType == _payloadStats[n].payloadType)
|
|
||||||
{
|
|
||||||
_payloadStats[n].newPacket = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_lastPayloadType = rtpInfo.header.payloadType;
|
|
||||||
|
|
||||||
bool newPayload = true;
|
|
||||||
ACMTestPayloadStats* currentPayloadStr = NULL;
|
|
||||||
for(n = 0; n < MAX_NUM_PAYLOADS; n++)
|
|
||||||
{
|
|
||||||
if(rtpInfo.header.payloadType == _payloadStats[n].payloadType)
|
|
||||||
{
|
|
||||||
newPayload = false;
|
|
||||||
currentPayloadStr = &_payloadStats[n];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!newPayload)
|
|
||||||
{
|
|
||||||
if(!currentPayloadStr->newPacket)
|
|
||||||
{
|
|
||||||
uint32_t lastFrameSizeSample = (uint32_t)((uint32_t)rtpInfo.header.timestamp -
|
|
||||||
(uint32_t)currentPayloadStr->lastTimestamp);
|
|
||||||
assert(lastFrameSizeSample > 0);
|
|
||||||
int k = 0;
|
|
||||||
while((currentPayloadStr->frameSizeStats[k].frameSizeSample !=
|
|
||||||
lastFrameSizeSample) &&
|
|
||||||
(currentPayloadStr->frameSizeStats[k].frameSizeSample != 0))
|
|
||||||
{
|
|
||||||
k++;
|
|
||||||
}
|
|
||||||
ACMTestFrameSizeStats* currentFrameSizeStats =
|
|
||||||
&(currentPayloadStr->frameSizeStats[k]);
|
|
||||||
currentFrameSizeStats->frameSizeSample = (int16_t)lastFrameSizeSample;
|
|
||||||
|
|
||||||
// increment the number of encoded samples.
|
|
||||||
currentFrameSizeStats->totalEncodedSamples +=
|
|
||||||
lastFrameSizeSample;
|
|
||||||
// increment the number of recveived packets
|
|
||||||
currentFrameSizeStats->numPackets++;
|
|
||||||
// increment the total number of bytes (this is based on
|
|
||||||
// the previous payload we don't know the frame-size of
|
|
||||||
// the current payload.
|
|
||||||
currentFrameSizeStats->totalPayloadLenByte +=
|
|
||||||
currentPayloadStr->lastPayloadLenByte;
|
|
||||||
// store the maximum payload-size (this is based on
|
|
||||||
// the previous payload we don't know the frame-size of
|
|
||||||
// the current payload.
|
|
||||||
if(currentFrameSizeStats->maxPayloadLen <
|
|
||||||
currentPayloadStr->lastPayloadLenByte)
|
|
||||||
{
|
|
||||||
currentFrameSizeStats->maxPayloadLen =
|
|
||||||
currentPayloadStr->lastPayloadLenByte;
|
|
||||||
}
|
|
||||||
// store the current values for the next time
|
|
||||||
currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp;
|
|
||||||
currentPayloadStr->lastPayloadLenByte = payloadSize;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
currentPayloadStr->newPacket = false;
|
|
||||||
currentPayloadStr->lastPayloadLenByte = payloadSize;
|
|
||||||
currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp;
|
|
||||||
currentPayloadStr->payloadType = rtpInfo.header.payloadType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
n = 0;
|
|
||||||
while(_payloadStats[n].payloadType != -1)
|
|
||||||
{
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
// first packet
|
|
||||||
_payloadStats[n].newPacket = false;
|
|
||||||
_payloadStats[n].lastPayloadLenByte = payloadSize;
|
|
||||||
_payloadStats[n].lastTimestamp = rtpInfo.header.timestamp;
|
|
||||||
_payloadStats[n].payloadType = rtpInfo.header.payloadType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Channel::Channel(int16_t chID) :
|
|
||||||
_receiverACM(NULL),
|
|
||||||
_seqNo(0),
|
|
||||||
_channelCritSect(CriticalSectionWrapper::CreateCriticalSection()),
|
|
||||||
_bitStreamFile(NULL),
|
|
||||||
_saveBitStream(false),
|
|
||||||
_lastPayloadType(-1),
|
|
||||||
_isStereo(false),
|
|
||||||
_leftChannel(true),
|
|
||||||
_lastInTimestamp(0),
|
|
||||||
_packetLoss(0),
|
|
||||||
_useFECTestWithPacketLoss(false),
|
|
||||||
_beginTime(TickTime::MillisecondTimestamp()),
|
|
||||||
_totalBytes(0)
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
int k;
|
|
||||||
for(n = 0; n < MAX_NUM_PAYLOADS; n++)
|
|
||||||
{
|
|
||||||
_payloadStats[n].payloadType = -1;
|
|
||||||
_payloadStats[n].newPacket = true;
|
|
||||||
for(k = 0; k < MAX_NUM_FRAMESIZES; k++)
|
|
||||||
{
|
|
||||||
_payloadStats[n].frameSizeStats[k].frameSizeSample = 0;
|
|
||||||
_payloadStats[n].frameSizeStats[k].maxPayloadLen = 0;
|
|
||||||
_payloadStats[n].frameSizeStats[k].numPackets = 0;
|
|
||||||
_payloadStats[n].frameSizeStats[k].totalPayloadLenByte = 0;
|
|
||||||
_payloadStats[n].frameSizeStats[k].totalEncodedSamples = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(chID >= 0)
|
|
||||||
{
|
|
||||||
_saveBitStream = true;
|
|
||||||
char bitStreamFileName[500];
|
|
||||||
sprintf(bitStreamFileName, "bitStream_%d.dat", chID);
|
|
||||||
_bitStreamFile = fopen(bitStreamFileName, "wb");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_saveBitStream = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Channel::~Channel()
|
|
||||||
{
|
|
||||||
delete _channelCritSect;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Channel::RegisterReceiverACM(AudioCodingModule* acm)
|
|
||||||
{
|
|
||||||
_receiverACM = acm;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Channel::ResetStats()
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
int k;
|
|
||||||
_channelCritSect->Enter();
|
|
||||||
_lastPayloadType = -1;
|
|
||||||
for(n = 0; n < MAX_NUM_PAYLOADS; n++)
|
|
||||||
{
|
|
||||||
_payloadStats[n].payloadType = -1;
|
|
||||||
_payloadStats[n].newPacket = true;
|
|
||||||
for(k = 0; k < MAX_NUM_FRAMESIZES; k++)
|
|
||||||
{
|
|
||||||
_payloadStats[n].frameSizeStats[k].frameSizeSample = 0;
|
|
||||||
_payloadStats[n].frameSizeStats[k].maxPayloadLen = 0;
|
|
||||||
_payloadStats[n].frameSizeStats[k].numPackets = 0;
|
|
||||||
_payloadStats[n].frameSizeStats[k].totalPayloadLenByte = 0;
|
|
||||||
_payloadStats[n].frameSizeStats[k].totalEncodedSamples = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_beginTime = TickTime::MillisecondTimestamp();
|
|
||||||
_totalBytes = 0;
|
|
||||||
_channelCritSect->Leave();
|
|
||||||
}
|
|
||||||
|
|
||||||
int16_t
|
|
||||||
Channel::Stats(CodecInst& codecInst, ACMTestPayloadStats& payloadStats)
|
|
||||||
{
|
|
||||||
_channelCritSect->Enter();
|
|
||||||
int n;
|
|
||||||
payloadStats.payloadType = -1;
|
|
||||||
for(n = 0; n < MAX_NUM_PAYLOADS; n++)
|
|
||||||
{
|
|
||||||
if(_payloadStats[n].payloadType == codecInst.pltype)
|
|
||||||
{
|
|
||||||
memcpy(&payloadStats, &_payloadStats[n], sizeof(ACMTestPayloadStats));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(payloadStats.payloadType == -1)
|
|
||||||
{
|
|
||||||
_channelCritSect->Leave();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
for(n = 0; n < MAX_NUM_FRAMESIZES; n++)
|
|
||||||
{
|
|
||||||
if(payloadStats.frameSizeStats[n].frameSizeSample == 0)
|
|
||||||
{
|
|
||||||
_channelCritSect->Leave();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
payloadStats.frameSizeStats[n].usageLenSec =
|
|
||||||
(double)payloadStats.frameSizeStats[n].totalEncodedSamples
|
|
||||||
/ (double)codecInst.plfreq;
|
|
||||||
|
|
||||||
payloadStats.frameSizeStats[n].rateBitPerSec =
|
|
||||||
payloadStats.frameSizeStats[n].totalPayloadLenByte * 8 /
|
|
||||||
payloadStats.frameSizeStats[n].usageLenSec;
|
|
||||||
|
|
||||||
}
|
|
||||||
_channelCritSect->Leave();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
rtpInfo.type.Audio.channel = 1;
|
||||||
Channel::Stats(uint32_t* numPackets)
|
// Treat fragmentation separately
|
||||||
{
|
if (fragmentation != NULL) {
|
||||||
_channelCritSect->Enter();
|
// If silence for too long, send only new data.
|
||||||
int k;
|
if ((fragmentation->fragmentationTimeDiff[1] <= 0x3fff) &&
|
||||||
int n;
|
(fragmentation->fragmentationVectorSize == 2)) {
|
||||||
memset(numPackets, 0, MAX_NUM_PAYLOADS * sizeof(uint32_t));
|
// only 0x80 if we have multiple blocks
|
||||||
for(k = 0; k < MAX_NUM_PAYLOADS; k++)
|
_payloadData[0] = 0x80 + fragmentation->fragmentationPlType[1];
|
||||||
{
|
uint32_t REDheader = (((uint32_t) fragmentation->fragmentationTimeDiff[1])
|
||||||
if(_payloadStats[k].payloadType == -1)
|
<< 10) + fragmentation->fragmentationLength[1];
|
||||||
{
|
_payloadData[1] = uint8_t((REDheader >> 16) & 0x000000FF);
|
||||||
break;
|
_payloadData[2] = uint8_t((REDheader >> 8) & 0x000000FF);
|
||||||
}
|
_payloadData[3] = uint8_t(REDheader & 0x000000FF);
|
||||||
numPackets[k] = 0;
|
|
||||||
for(n = 0; n < MAX_NUM_FRAMESIZES; n++)
|
_payloadData[4] = fragmentation->fragmentationPlType[0];
|
||||||
{
|
// copy the RED data
|
||||||
if(_payloadStats[k].frameSizeStats[n].frameSizeSample == 0)
|
memcpy(_payloadData + 5,
|
||||||
{
|
payloadData + fragmentation->fragmentationOffset[1],
|
||||||
break;
|
fragmentation->fragmentationLength[1]);
|
||||||
}
|
// copy the normal data
|
||||||
numPackets[k] +=
|
memcpy(_payloadData + 5 + fragmentation->fragmentationLength[1],
|
||||||
_payloadStats[k].frameSizeStats[n].numPackets;
|
payloadData + fragmentation->fragmentationOffset[0],
|
||||||
}
|
fragmentation->fragmentationLength[0]);
|
||||||
|
payloadDataSize += 5;
|
||||||
|
} else {
|
||||||
|
// single block (newest one)
|
||||||
|
memcpy(_payloadData, payloadData + fragmentation->fragmentationOffset[0],
|
||||||
|
fragmentation->fragmentationLength[0]);
|
||||||
|
payloadDataSize = uint16_t(fragmentation->fragmentationLength[0]);
|
||||||
|
rtpInfo.header.payloadType = fragmentation->fragmentationPlType[0];
|
||||||
}
|
}
|
||||||
_channelCritSect->Leave();
|
} else {
|
||||||
}
|
memcpy(_payloadData, payloadData, payloadDataSize);
|
||||||
|
if (_isStereo) {
|
||||||
void
|
if (_leftChannel) {
|
||||||
Channel::Stats(uint8_t* payloadType, uint32_t* payloadLenByte)
|
memcpy(&_rtpInfo, &rtpInfo, sizeof(WebRtcRTPHeader));
|
||||||
{
|
_leftChannel = false;
|
||||||
_channelCritSect->Enter();
|
rtpInfo.type.Audio.channel = 1;
|
||||||
|
} else {
|
||||||
int k;
|
memcpy(&rtpInfo, &_rtpInfo, sizeof(WebRtcRTPHeader));
|
||||||
int n;
|
_leftChannel = true;
|
||||||
memset(payloadLenByte, 0, MAX_NUM_PAYLOADS * sizeof(uint32_t));
|
rtpInfo.type.Audio.channel = 2;
|
||||||
for(k = 0; k < MAX_NUM_PAYLOADS; k++)
|
}
|
||||||
{
|
|
||||||
if(_payloadStats[k].payloadType == -1)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
payloadType[k] = (uint8_t)_payloadStats[k].payloadType;
|
|
||||||
payloadLenByte[k] = 0;
|
|
||||||
for(n = 0; n < MAX_NUM_FRAMESIZES; n++)
|
|
||||||
{
|
|
||||||
if(_payloadStats[k].frameSizeStats[n].frameSizeSample == 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
payloadLenByte[k] += (uint16_t)
|
|
||||||
_payloadStats[k].frameSizeStats[n].totalPayloadLenByte;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_channelCritSect->Leave();
|
_channelCritSect->Enter();
|
||||||
}
|
if (_saveBitStream) {
|
||||||
|
//fwrite(payloadData, sizeof(uint8_t), payloadSize, _bitStreamFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_isStereo) {
|
||||||
|
CalcStatistics(rtpInfo, payloadSize);
|
||||||
|
}
|
||||||
|
_lastInTimestamp = timeStamp;
|
||||||
|
_totalBytes += payloadDataSize;
|
||||||
|
_channelCritSect->Leave();
|
||||||
|
|
||||||
void
|
if (_useFECTestWithPacketLoss) {
|
||||||
Channel::PrintStats(CodecInst& codecInst)
|
_packetLoss += 1;
|
||||||
{
|
if (_packetLoss == 3) {
|
||||||
ACMTestPayloadStats payloadStats;
|
_packetLoss = 0;
|
||||||
Stats(codecInst, payloadStats);
|
return 0;
|
||||||
printf("%s %d kHz\n",
|
|
||||||
codecInst.plname,
|
|
||||||
codecInst.plfreq / 1000);
|
|
||||||
printf("=====================================================\n");
|
|
||||||
if(payloadStats.payloadType == -1)
|
|
||||||
{
|
|
||||||
printf("No Packets are sent with payload-type %d (%s)\n\n",
|
|
||||||
codecInst.pltype,
|
|
||||||
codecInst.plname);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
for(int k = 0; k < MAX_NUM_FRAMESIZES; k++)
|
}
|
||||||
{
|
|
||||||
if(payloadStats.frameSizeStats[k].frameSizeSample == 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
printf("Frame-size.................... %d samples\n",
|
|
||||||
payloadStats.frameSizeStats[k].frameSizeSample);
|
|
||||||
printf("Average Rate.................. %.0f bits/sec\n",
|
|
||||||
payloadStats.frameSizeStats[k].rateBitPerSec);
|
|
||||||
printf("Maximum Payload-Size.......... %d Bytes\n",
|
|
||||||
payloadStats.frameSizeStats[k].maxPayloadLen);
|
|
||||||
printf("Maximum Instantaneous Rate.... %.0f bits/sec\n",
|
|
||||||
((double)payloadStats.frameSizeStats[k].maxPayloadLen * 8.0 *
|
|
||||||
(double)codecInst.plfreq) /
|
|
||||||
(double)payloadStats.frameSizeStats[k].frameSizeSample);
|
|
||||||
printf("Number of Packets............. %u\n",
|
|
||||||
(unsigned int)payloadStats.frameSizeStats[k].numPackets);
|
|
||||||
printf("Duration...................... %0.3f sec\n\n",
|
|
||||||
payloadStats.frameSizeStats[k].usageLenSec);
|
|
||||||
|
|
||||||
|
status = _receiverACM->IncomingPacket(_payloadData, payloadDataSize, rtpInfo);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, uint16_t payloadSize) {
|
||||||
|
int n;
|
||||||
|
if ((rtpInfo.header.payloadType != _lastPayloadType)
|
||||||
|
&& (_lastPayloadType != -1)) {
|
||||||
|
// payload-type is changed.
|
||||||
|
// we have to terminate the calculations on the previous payload type
|
||||||
|
// we ignore the last packet in that payload type just to make things
|
||||||
|
// easier.
|
||||||
|
for (n = 0; n < MAX_NUM_PAYLOADS; n++) {
|
||||||
|
if (_lastPayloadType == _payloadStats[n].payloadType) {
|
||||||
|
_payloadStats[n].newPacket = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
_lastPayloadType = rtpInfo.header.payloadType;
|
||||||
|
|
||||||
|
bool newPayload = true;
|
||||||
|
ACMTestPayloadStats* currentPayloadStr = NULL;
|
||||||
|
for (n = 0; n < MAX_NUM_PAYLOADS; n++) {
|
||||||
|
if (rtpInfo.header.payloadType == _payloadStats[n].payloadType) {
|
||||||
|
newPayload = false;
|
||||||
|
currentPayloadStr = &_payloadStats[n];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!newPayload) {
|
||||||
|
if (!currentPayloadStr->newPacket) {
|
||||||
|
uint32_t lastFrameSizeSample = (uint32_t)(
|
||||||
|
(uint32_t) rtpInfo.header.timestamp
|
||||||
|
- (uint32_t) currentPayloadStr->lastTimestamp);
|
||||||
|
assert(lastFrameSizeSample > 0);
|
||||||
|
int k = 0;
|
||||||
|
while ((currentPayloadStr->frameSizeStats[k].frameSizeSample
|
||||||
|
!= lastFrameSizeSample)
|
||||||
|
&& (currentPayloadStr->frameSizeStats[k].frameSizeSample != 0)) {
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
ACMTestFrameSizeStats* currentFrameSizeStats = &(currentPayloadStr
|
||||||
|
->frameSizeStats[k]);
|
||||||
|
currentFrameSizeStats->frameSizeSample = (int16_t) lastFrameSizeSample;
|
||||||
|
|
||||||
|
// increment the number of encoded samples.
|
||||||
|
currentFrameSizeStats->totalEncodedSamples += lastFrameSizeSample;
|
||||||
|
// increment the number of recveived packets
|
||||||
|
currentFrameSizeStats->numPackets++;
|
||||||
|
// increment the total number of bytes (this is based on
|
||||||
|
// the previous payload we don't know the frame-size of
|
||||||
|
// the current payload.
|
||||||
|
currentFrameSizeStats->totalPayloadLenByte += currentPayloadStr
|
||||||
|
->lastPayloadLenByte;
|
||||||
|
// store the maximum payload-size (this is based on
|
||||||
|
// the previous payload we don't know the frame-size of
|
||||||
|
// the current payload.
|
||||||
|
if (currentFrameSizeStats->maxPayloadLen
|
||||||
|
< currentPayloadStr->lastPayloadLenByte) {
|
||||||
|
currentFrameSizeStats->maxPayloadLen = currentPayloadStr
|
||||||
|
->lastPayloadLenByte;
|
||||||
|
}
|
||||||
|
// store the current values for the next time
|
||||||
|
currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp;
|
||||||
|
currentPayloadStr->lastPayloadLenByte = payloadSize;
|
||||||
|
} else {
|
||||||
|
currentPayloadStr->newPacket = false;
|
||||||
|
currentPayloadStr->lastPayloadLenByte = payloadSize;
|
||||||
|
currentPayloadStr->lastTimestamp = rtpInfo.header.timestamp;
|
||||||
|
currentPayloadStr->payloadType = rtpInfo.header.payloadType;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
n = 0;
|
||||||
|
while (_payloadStats[n].payloadType != -1) {
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
// first packet
|
||||||
|
_payloadStats[n].newPacket = false;
|
||||||
|
_payloadStats[n].lastPayloadLenByte = payloadSize;
|
||||||
|
_payloadStats[n].lastTimestamp = rtpInfo.header.timestamp;
|
||||||
|
_payloadStats[n].payloadType = rtpInfo.header.payloadType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
Channel::Channel(int16_t chID)
|
||||||
Channel::LastInTimestamp()
|
: _receiverACM(NULL),
|
||||||
{
|
_seqNo(0),
|
||||||
uint32_t timestamp;
|
_channelCritSect(CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
_channelCritSect->Enter();
|
_bitStreamFile(NULL),
|
||||||
timestamp = _lastInTimestamp;
|
_saveBitStream(false),
|
||||||
|
_lastPayloadType(-1),
|
||||||
|
_isStereo(false),
|
||||||
|
_leftChannel(true),
|
||||||
|
_lastInTimestamp(0),
|
||||||
|
_packetLoss(0),
|
||||||
|
_useFECTestWithPacketLoss(false),
|
||||||
|
_beginTime(TickTime::MillisecondTimestamp()),
|
||||||
|
_totalBytes(0) {
|
||||||
|
int n;
|
||||||
|
int k;
|
||||||
|
for (n = 0; n < MAX_NUM_PAYLOADS; n++) {
|
||||||
|
_payloadStats[n].payloadType = -1;
|
||||||
|
_payloadStats[n].newPacket = true;
|
||||||
|
for (k = 0; k < MAX_NUM_FRAMESIZES; k++) {
|
||||||
|
_payloadStats[n].frameSizeStats[k].frameSizeSample = 0;
|
||||||
|
_payloadStats[n].frameSizeStats[k].maxPayloadLen = 0;
|
||||||
|
_payloadStats[n].frameSizeStats[k].numPackets = 0;
|
||||||
|
_payloadStats[n].frameSizeStats[k].totalPayloadLenByte = 0;
|
||||||
|
_payloadStats[n].frameSizeStats[k].totalEncodedSamples = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (chID >= 0) {
|
||||||
|
_saveBitStream = true;
|
||||||
|
char bitStreamFileName[500];
|
||||||
|
sprintf(bitStreamFileName, "bitStream_%d.dat", chID);
|
||||||
|
_bitStreamFile = fopen(bitStreamFileName, "wb");
|
||||||
|
} else {
|
||||||
|
_saveBitStream = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Channel::~Channel() {
|
||||||
|
delete _channelCritSect;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Channel::RegisterReceiverACM(AudioCodingModule* acm) {
|
||||||
|
_receiverACM = acm;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Channel::ResetStats() {
|
||||||
|
int n;
|
||||||
|
int k;
|
||||||
|
_channelCritSect->Enter();
|
||||||
|
_lastPayloadType = -1;
|
||||||
|
for (n = 0; n < MAX_NUM_PAYLOADS; n++) {
|
||||||
|
_payloadStats[n].payloadType = -1;
|
||||||
|
_payloadStats[n].newPacket = true;
|
||||||
|
for (k = 0; k < MAX_NUM_FRAMESIZES; k++) {
|
||||||
|
_payloadStats[n].frameSizeStats[k].frameSizeSample = 0;
|
||||||
|
_payloadStats[n].frameSizeStats[k].maxPayloadLen = 0;
|
||||||
|
_payloadStats[n].frameSizeStats[k].numPackets = 0;
|
||||||
|
_payloadStats[n].frameSizeStats[k].totalPayloadLenByte = 0;
|
||||||
|
_payloadStats[n].frameSizeStats[k].totalEncodedSamples = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_beginTime = TickTime::MillisecondTimestamp();
|
||||||
|
_totalBytes = 0;
|
||||||
|
_channelCritSect->Leave();
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t Channel::Stats(CodecInst& codecInst,
|
||||||
|
ACMTestPayloadStats& payloadStats) {
|
||||||
|
_channelCritSect->Enter();
|
||||||
|
int n;
|
||||||
|
payloadStats.payloadType = -1;
|
||||||
|
for (n = 0; n < MAX_NUM_PAYLOADS; n++) {
|
||||||
|
if (_payloadStats[n].payloadType == codecInst.pltype) {
|
||||||
|
memcpy(&payloadStats, &_payloadStats[n], sizeof(ACMTestPayloadStats));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (payloadStats.payloadType == -1) {
|
||||||
_channelCritSect->Leave();
|
_channelCritSect->Leave();
|
||||||
return timestamp;
|
return -1;
|
||||||
|
}
|
||||||
|
for (n = 0; n < MAX_NUM_FRAMESIZES; n++) {
|
||||||
|
if (payloadStats.frameSizeStats[n].frameSizeSample == 0) {
|
||||||
|
_channelCritSect->Leave();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
payloadStats.frameSizeStats[n].usageLenSec = (double) payloadStats
|
||||||
|
.frameSizeStats[n].totalEncodedSamples / (double) codecInst.plfreq;
|
||||||
|
|
||||||
|
payloadStats.frameSizeStats[n].rateBitPerSec =
|
||||||
|
payloadStats.frameSizeStats[n].totalPayloadLenByte * 8
|
||||||
|
/ payloadStats.frameSizeStats[n].usageLenSec;
|
||||||
|
|
||||||
|
}
|
||||||
|
_channelCritSect->Leave();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
void Channel::Stats(uint32_t* numPackets) {
|
||||||
Channel::BitRate()
|
_channelCritSect->Enter();
|
||||||
{
|
int k;
|
||||||
double rate;
|
int n;
|
||||||
uint64_t currTime = TickTime::MillisecondTimestamp();
|
memset(numPackets, 0, MAX_NUM_PAYLOADS * sizeof(uint32_t));
|
||||||
_channelCritSect->Enter();
|
for (k = 0; k < MAX_NUM_PAYLOADS; k++) {
|
||||||
rate = ((double)_totalBytes * 8.0)/ (double)(currTime - _beginTime);
|
if (_payloadStats[k].payloadType == -1) {
|
||||||
_channelCritSect->Leave();
|
break;
|
||||||
return rate;
|
}
|
||||||
|
numPackets[k] = 0;
|
||||||
|
for (n = 0; n < MAX_NUM_FRAMESIZES; n++) {
|
||||||
|
if (_payloadStats[k].frameSizeStats[n].frameSizeSample == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
numPackets[k] += _payloadStats[k].frameSizeStats[n].numPackets;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_channelCritSect->Leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
void Channel::Stats(uint8_t* payloadType, uint32_t* payloadLenByte) {
|
||||||
|
_channelCritSect->Enter();
|
||||||
|
|
||||||
|
int k;
|
||||||
|
int n;
|
||||||
|
memset(payloadLenByte, 0, MAX_NUM_PAYLOADS * sizeof(uint32_t));
|
||||||
|
for (k = 0; k < MAX_NUM_PAYLOADS; k++) {
|
||||||
|
if (_payloadStats[k].payloadType == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
payloadType[k] = (uint8_t) _payloadStats[k].payloadType;
|
||||||
|
payloadLenByte[k] = 0;
|
||||||
|
for (n = 0; n < MAX_NUM_FRAMESIZES; n++) {
|
||||||
|
if (_payloadStats[k].frameSizeStats[n].frameSizeSample == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
payloadLenByte[k] += (uint16_t) _payloadStats[k].frameSizeStats[n]
|
||||||
|
.totalPayloadLenByte;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_channelCritSect->Leave();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Channel::PrintStats(CodecInst& codecInst) {
|
||||||
|
ACMTestPayloadStats payloadStats;
|
||||||
|
Stats(codecInst, payloadStats);
|
||||||
|
printf("%s %d kHz\n", codecInst.plname, codecInst.plfreq / 1000);
|
||||||
|
printf("=====================================================\n");
|
||||||
|
if (payloadStats.payloadType == -1) {
|
||||||
|
printf("No Packets are sent with payload-type %d (%s)\n\n",
|
||||||
|
codecInst.pltype, codecInst.plname);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int k = 0; k < MAX_NUM_FRAMESIZES; k++) {
|
||||||
|
if (payloadStats.frameSizeStats[k].frameSizeSample == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
printf("Frame-size.................... %d samples\n",
|
||||||
|
payloadStats.frameSizeStats[k].frameSizeSample);
|
||||||
|
printf("Average Rate.................. %.0f bits/sec\n",
|
||||||
|
payloadStats.frameSizeStats[k].rateBitPerSec);
|
||||||
|
printf("Maximum Payload-Size.......... %d Bytes\n",
|
||||||
|
payloadStats.frameSizeStats[k].maxPayloadLen);
|
||||||
|
printf(
|
||||||
|
"Maximum Instantaneous Rate.... %.0f bits/sec\n",
|
||||||
|
((double) payloadStats.frameSizeStats[k].maxPayloadLen * 8.0
|
||||||
|
* (double) codecInst.plfreq)
|
||||||
|
/ (double) payloadStats.frameSizeStats[k].frameSizeSample);
|
||||||
|
printf("Number of Packets............. %u\n",
|
||||||
|
(unsigned int) payloadStats.frameSizeStats[k].numPackets);
|
||||||
|
printf("Duration...................... %0.3f sec\n\n",
|
||||||
|
payloadStats.frameSizeStats[k].usageLenSec);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t Channel::LastInTimestamp() {
|
||||||
|
uint32_t timestamp;
|
||||||
|
_channelCritSect->Enter();
|
||||||
|
timestamp = _lastInTimestamp;
|
||||||
|
_channelCritSect->Leave();
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
double Channel::BitRate() {
|
||||||
|
double rate;
|
||||||
|
uint64_t currTime = TickTime::MillisecondTimestamp();
|
||||||
|
_channelCritSect->Enter();
|
||||||
|
rate = ((double) _totalBytes * 8.0) / (double) (currTime - _beginTime);
|
||||||
|
_channelCritSect->Leave();
|
||||||
|
return rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
|
@ -23,103 +23,83 @@ 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;
|
||||||
{
|
int16_t maxPayloadLen;
|
||||||
uint16_t frameSizeSample;
|
uint32_t numPackets;
|
||||||
int16_t maxPayloadLen;
|
uint64_t totalPayloadLenByte;
|
||||||
uint32_t numPackets;
|
uint64_t totalEncodedSamples;
|
||||||
uint64_t totalPayloadLenByte;
|
double rateBitPerSec;
|
||||||
uint64_t totalEncodedSamples;
|
double usageLenSec;
|
||||||
double rateBitPerSec;
|
|
||||||
double usageLenSec;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ACMTestPayloadStats
|
struct ACMTestPayloadStats {
|
||||||
{
|
bool newPacket;
|
||||||
bool newPacket;
|
int16_t payloadType;
|
||||||
int16_t payloadType;
|
int16_t lastPayloadLenByte;
|
||||||
int16_t lastPayloadLenByte;
|
uint32_t lastTimestamp;
|
||||||
uint32_t lastTimestamp;
|
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 uint16_t payloadSize,
|
||||||
const uint32_t timeStamp,
|
const RTPFragmentationHeader* fragmentation);
|
||||||
const uint8_t* payloadData,
|
|
||||||
const uint16_t payloadSize,
|
|
||||||
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;
|
||||||
// 60msec * 32 sample(max)/msec * 2 description (maybe) * 2 bytes/sample
|
// 60msec * 32 sample(max)/msec * 2 description (maybe) * 2 bytes/sample
|
||||||
uint8_t _payloadData[60 * 32 * 2 * 2];
|
uint8_t _payloadData[60 * 32 * 2 * 2];
|
||||||
|
|
||||||
CriticalSectionWrapper* _channelCritSect;
|
CriticalSectionWrapper* _channelCritSect;
|
||||||
FILE* _bitStreamFile;
|
FILE* _bitStreamFile;
|
||||||
bool _saveBitStream;
|
bool _saveBitStream;
|
||||||
int16_t _lastPayloadType;
|
int16_t _lastPayloadType;
|
||||||
ACMTestPayloadStats _payloadStats[MAX_NUM_PAYLOADS];
|
ACMTestPayloadStats _payloadStats[MAX_NUM_PAYLOADS];
|
||||||
bool _isStereo;
|
bool _isStereo;
|
||||||
WebRtcRTPHeader _rtpInfo;
|
WebRtcRTPHeader _rtpInfo;
|
||||||
bool _leftChannel;
|
bool _leftChannel;
|
||||||
uint32_t _lastInTimestamp;
|
uint32_t _lastInTimestamp;
|
||||||
// FEC Test variables
|
// FEC Test variables
|
||||||
int16_t _packetLoss;
|
int16_t _packetLoss;
|
||||||
bool _useFECTestWithPacketLoss;
|
bool _useFECTestWithPacketLoss;
|
||||||
uint64_t _beginTime;
|
uint64_t _beginTime;
|
||||||
uint64_t _totalBytes;
|
uint64_t _totalBytes;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -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.
|
||||||
@ -127,7 +125,7 @@ void Sender::Run() {
|
|||||||
if (!Add10MsData()) {
|
if (!Add10MsData()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!Process()) { // This could be done in a processing thread
|
if (!Process()) { // This could be done in a processing thread
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,16 +153,16 @@ 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;
|
||||||
|
|
||||||
if (testMode == 1) {
|
if (testMode == 1) {
|
||||||
playSampFreq=recvCodec.plfreq;
|
playSampFreq = recvCodec.plfreq;
|
||||||
_pcmFile.Open(file_name, recvCodec.plfreq, "wb+");
|
_pcmFile.Open(file_name, recvCodec.plfreq, "wb+");
|
||||||
} else if (testMode == 0) {
|
} else if (testMode == 0) {
|
||||||
playSampFreq=32000;
|
playSampFreq = 32000;
|
||||||
_pcmFile.Open(file_name, 32000, "wb+");
|
_pcmFile.Open(file_name, 32000, "wb+");
|
||||||
} else {
|
} else {
|
||||||
printf("\nValid output frequencies:\n");
|
printf("\nValid output frequencies:\n");
|
||||||
@ -172,7 +170,7 @@ void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
|
|||||||
printf("which means output frequency equal to received signal frequency");
|
printf("which means output frequency equal to received signal frequency");
|
||||||
printf("\n\nChoose output sampling frequency: ");
|
printf("\n\nChoose output sampling frequency: ");
|
||||||
ASSERT_GT(scanf("%d", &playSampFreq), 0);
|
ASSERT_GT(scanf("%d", &playSampFreq), 0);
|
||||||
file_name = webrtc::test::OutputPath() + "encodeDecode_out.pcm";
|
file_name = webrtc::test::OutputPath() + "encodeDecode_out.pcm";
|
||||||
_pcmFile.Open(file_name, playSampFreq, "wb+");
|
_pcmFile.Open(file_name, playSampFreq, "wb+");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +182,7 @@ void Receiver::Setup(AudioCodingModule *acm, RTPStream *rtpStream) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Receiver::Teardown() {
|
void Receiver::Teardown() {
|
||||||
delete [] _playoutBuffer;
|
delete[] _playoutBuffer;
|
||||||
_pcmFile.Close();
|
_pcmFile.Close();
|
||||||
if (testMode > 1)
|
if (testMode > 1)
|
||||||
Trace::ReturnTrace();
|
Trace::ReturnTrace();
|
||||||
@ -205,16 +203,16 @@ bool Receiver::IncomingPacket() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
_realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload,
|
_realPayloadSizeBytes = _rtpStream->Read(&_rtpInfo, _incomingPayload,
|
||||||
_payloadSizeBytes, &_nextTime);
|
_payloadSizeBytes, &_nextTime);
|
||||||
if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile()) {
|
if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile()) {
|
||||||
_firstTime = true;
|
_firstTime = true;
|
||||||
}
|
}
|
||||||
@ -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,20 +262,20 @@ 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) {
|
||||||
//testMode == 0 for autotest
|
//testMode == 0 for autotest
|
||||||
//testMode == 1 for testing all codecs/parameters
|
//testMode == 1 for testing all codecs/parameters
|
||||||
//testMode > 1 for specific user-input test (as it was used before)
|
//testMode > 1 for specific user-input test (as it was used before)
|
||||||
_testMode = testMode;
|
_testMode = testMode;
|
||||||
if(_testMode != 0) {
|
if (_testMode != 0) {
|
||||||
Trace::CreateTrace();
|
Trace::CreateTrace();
|
||||||
Trace::SetTraceFile((webrtc::test::OutputPath() +
|
Trace::SetTraceFile(
|
||||||
"acm_encdec_trace.txt").c_str());
|
(webrtc::test::OutputPath() + "acm_encdec_trace.txt").c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncodeDecodeTest::Perform() {
|
void EncodeDecodeTest::Perform() {
|
||||||
@ -289,9 +286,9 @@ void EncodeDecodeTest::Perform() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int numCodecs = 1;
|
int numCodecs = 1;
|
||||||
int codePars[3]; // Frequency, packet size, rate.
|
int codePars[3]; // Frequency, packet size, rate.
|
||||||
int numPars[52]; // Number of codec parameters sets (freq, pacsize, rate)
|
int numPars[52]; // Number of codec parameters sets (freq, pacsize, rate)
|
||||||
// to test, for a given codec.
|
// to test, for a given codec.
|
||||||
|
|
||||||
codePars[0] = 0;
|
codePars[0] = 0;
|
||||||
codePars[1] = 0;
|
codePars[1] = 0;
|
||||||
@ -390,4 +387,4 @@ void EncodeDecodeTest::EncodeToFile(int fileType, int codeId, int* codePars,
|
|||||||
AudioCodingModule::Destroy(acm);
|
AudioCodingModule::Destroy(acm);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -24,21 +24,18 @@ namespace webrtc {
|
|||||||
#define MAX_INCOMING_PAYLOAD 8096
|
#define MAX_INCOMING_PAYLOAD 8096
|
||||||
|
|
||||||
// TestPacketization callback which writes the encoded payloads to file
|
// TestPacketization callback which writes the encoded payloads to file
|
||||||
class TestPacketization: public AudioPacketizationCallback {
|
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;
|
||||||
@ -92,7 +89,7 @@ class Receiver {
|
|||||||
uint32_t _nextTime;
|
uint32_t _nextTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EncodeDecodeTest: public ACMTest {
|
class EncodeDecodeTest : public ACMTest {
|
||||||
public:
|
public:
|
||||||
EncodeDecodeTest();
|
EncodeDecodeTest();
|
||||||
EncodeDecodeTest(int testMode);
|
EncodeDecodeTest(int testMode);
|
||||||
@ -109,6 +106,6 @@ class EncodeDecodeTest: public ACMTest {
|
|||||||
Receiver _receiver;
|
Receiver _receiver;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,8 +30,8 @@ PCMFile::PCMFile()
|
|||||||
rewinded_(false),
|
rewinded_(false),
|
||||||
read_stereo_(false),
|
read_stereo_(false),
|
||||||
save_stereo_(false) {
|
save_stereo_(false) {
|
||||||
timestamp_ = (((uint32_t)rand() & 0x0000FFFF) << 16) |
|
timestamp_ = (((uint32_t) rand() & 0x0000FFFF) << 16) |
|
||||||
((uint32_t)rand() & 0x0000FFFF);
|
((uint32_t) rand() & 0x0000FFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
PCMFile::PCMFile(uint32_t timestamp)
|
PCMFile::PCMFile(uint32_t timestamp)
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
@ -25,257 +25,223 @@
|
|||||||
|
|
||||||
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) |
|
||||||
rtpInfo->header.timestamp = (static_cast<uint32_t>(rtpHeader[4])<<24) |
|
rtpHeader[3];
|
||||||
(static_cast<uint32_t>(rtpHeader[5])<<16) |
|
rtpInfo->header.timestamp = (static_cast<uint32_t>(rtpHeader[4]) << 24) |
|
||||||
(static_cast<uint32_t>(rtpHeader[6])<<8) |
|
(static_cast<uint32_t>(rtpHeader[5]) << 16) |
|
||||||
rtpHeader[7];
|
(static_cast<uint32_t>(rtpHeader[6]) << 8) | 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);
|
rtpHeader[3] = (unsigned char) ((seqNo) & 0xFF);
|
||||||
rtpHeader[3]=(unsigned char)((seqNo)&0xFF);
|
rtpHeader[4] = (unsigned char) ((timeStamp >> 24) & 0xFF);
|
||||||
rtpHeader[4]=(unsigned char)((timeStamp>>24)&0xFF);
|
rtpHeader[5] = (unsigned char) ((timeStamp >> 16) & 0xFF);
|
||||||
rtpHeader[5]=(unsigned char)((timeStamp>>16)&0xFF);
|
|
||||||
|
|
||||||
rtpHeader[6]=(unsigned char)((timeStamp>>8)&0xFF);
|
rtpHeader[6] = (unsigned char) ((timeStamp >> 8) & 0xFF);
|
||||||
rtpHeader[7]=(unsigned char)(timeStamp & 0xFF);
|
rtpHeader[7] = (unsigned char) (timeStamp & 0xFF);
|
||||||
|
|
||||||
rtpHeader[8]=(unsigned char)((ssrc>>24)&0xFF);
|
rtpHeader[8] = (unsigned char) ((ssrc >> 24) & 0xFF);
|
||||||
rtpHeader[9]=(unsigned char)((ssrc>>16)&0xFF);
|
rtpHeader[9] = (unsigned char) ((ssrc >> 16) & 0xFF);
|
||||||
|
|
||||||
rtpHeader[10]=(unsigned char)((ssrc>>8)&0xFF);
|
rtpHeader[10] = (unsigned char) ((ssrc >> 8) & 0xFF);
|
||||||
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),
|
||||||
:
|
timeStamp(timeStamp),
|
||||||
payloadType(payloadType),
|
seqNo(seqNo),
|
||||||
timeStamp(timeStamp),
|
payloadSize(payloadSize),
|
||||||
seqNo(seqNo),
|
frequency(frequency) {
|
||||||
payloadSize(payloadSize),
|
if (payloadSize > 0) {
|
||||||
frequency(frequency)
|
this->payloadData = new uint8_t[payloadSize];
|
||||||
{
|
memcpy(this->payloadData, payloadData, payloadSize);
|
||||||
if (payloadSize > 0)
|
}
|
||||||
{
|
|
||||||
this->payloadData = new uint8_t[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,
|
||||||
{
|
payloadSize, frequency);
|
||||||
RTPPacket *packet = new RTPPacket(payloadType, timeStamp, seqNo, payloadData, 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,
|
_queueRWLock->AcquireLockShared();
|
||||||
uint16_t payloadSize,
|
RTPPacket *packet = _rtpQueue.front();
|
||||||
uint32_t* offset)
|
_rtpQueue.pop();
|
||||||
{
|
_queueRWLock->ReleaseLockShared();
|
||||||
_queueRWLock->AcquireLockShared();
|
rtpInfo->header.markerBit = 1;
|
||||||
RTPPacket *packet = _rtpQueue.front();
|
rtpInfo->header.payloadType = packet->payloadType;
|
||||||
_rtpQueue.pop();
|
rtpInfo->header.sequenceNumber = packet->seqNo;
|
||||||
_queueRWLock->ReleaseLockShared();
|
rtpInfo->header.ssrc = 0;
|
||||||
rtpInfo->header.markerBit = 1;
|
rtpInfo->header.timestamp = packet->timeStamp;
|
||||||
rtpInfo->header.payloadType = packet->payloadType;
|
if (packet->payloadSize > 0 && payloadSize >= packet->payloadSize) {
|
||||||
rtpInfo->header.sequenceNumber = packet->seqNo;
|
memcpy(payloadData, packet->payloadData, packet->payloadSize);
|
||||||
rtpInfo->header.ssrc = 0;
|
} else {
|
||||||
rtpInfo->header.timestamp = packet->timeStamp;
|
return 0;
|
||||||
if (packet->payloadSize > 0 && payloadSize >= packet->payloadSize)
|
}
|
||||||
{
|
*offset = (packet->timeStamp / (packet->frequency / 1000));
|
||||||
memcpy(payloadData, packet->payloadData, packet->payloadSize);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*offset = (packet->timeStamp/(packet->frequency/1000));
|
|
||||||
|
|
||||||
return packet->payloadSize;
|
return packet->payloadSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool RTPBuffer::EndOfFile() const {
|
||||||
RTPBuffer::EndOfFile() const
|
_queueRWLock->AcquireLockShared();
|
||||||
{
|
bool eof = _rtpQueue.empty();
|
||||||
_queueRWLock->AcquireLockShared();
|
_queueRWLock->ReleaseLockShared();
|
||||||
bool eof = _rtpQueue.empty();
|
return eof;
|
||||||
_queueRWLock->ReleaseLockShared();
|
|
||||||
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);
|
||||||
{
|
ADD_FAILURE() << "Unable to write file";
|
||||||
printf("Cannot write file %s.\n", filename);
|
exit(1);
|
||||||
ADD_FAILURE() << "Unable to write file";
|
}
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTPFile::Close()
|
void RTPFile::Close() {
|
||||||
{
|
if (_rtpFile != NULL) {
|
||||||
if (_rtpFile != NULL)
|
fclose(_rtpFile);
|
||||||
{
|
_rtpFile = NULL;
|
||||||
fclose(_rtpFile);
|
}
|
||||||
_rtpFile = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RTPFile::WriteHeader() {
|
||||||
void RTPFile::WriteHeader()
|
// Write data in a format that NetEQ and RTP Play can parse
|
||||||
{
|
fprintf(_rtpFile, "#!RTPencode%s\n", "1.0");
|
||||||
// Write data in a format that NetEQ and RTP Play can parse
|
uint32_t dummy_variable = 0;
|
||||||
fprintf(_rtpFile, "#!RTPencode%s\n", "1.0");
|
// should be converted to network endian format, but does not matter when 0
|
||||||
uint32_t dummy_variable = 0;
|
if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) {
|
||||||
// should be converted to network endian format, but does not matter when 0
|
return;
|
||||||
if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) {
|
}
|
||||||
return;
|
if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) {
|
||||||
}
|
return;
|
||||||
if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) {
|
}
|
||||||
return;
|
if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) {
|
||||||
}
|
return;
|
||||||
if (fwrite(&dummy_variable, 4, 1, _rtpFile) != 1) {
|
}
|
||||||
return;
|
if (fwrite(&dummy_variable, 2, 1, _rtpFile) != 1) {
|
||||||
}
|
return;
|
||||||
if (fwrite(&dummy_variable, 2, 1, _rtpFile) != 1) {
|
}
|
||||||
return;
|
if (fwrite(&dummy_variable, 2, 1, _rtpFile) != 1) {
|
||||||
}
|
return;
|
||||||
if (fwrite(&dummy_variable, 2, 1, _rtpFile) != 1) {
|
}
|
||||||
return;
|
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];
|
EXPECT_TRUE(fgets(fileHeader, 40, _rtpFile) != 0);
|
||||||
EXPECT_TRUE(fgets(fileHeader, 40, _rtpFile) != 0);
|
EXPECT_EQ(1u, fread(&start_sec, 4, 1, _rtpFile));
|
||||||
EXPECT_EQ(1u, fread(&start_sec, 4, 1, _rtpFile));
|
start_sec = ntohl(start_sec);
|
||||||
start_sec=ntohl(start_sec);
|
EXPECT_EQ(1u, fread(&start_usec, 4, 1, _rtpFile));
|
||||||
EXPECT_EQ(1u, fread(&start_usec, 4, 1, _rtpFile));
|
start_usec = ntohl(start_usec);
|
||||||
start_usec=ntohl(start_usec);
|
EXPECT_EQ(1u, fread(&source, 4, 1, _rtpFile));
|
||||||
EXPECT_EQ(1u, fread(&source, 4, 1, _rtpFile));
|
source = ntohl(source);
|
||||||
source=ntohl(source);
|
EXPECT_EQ(1u, fread(&port, 2, 1, _rtpFile));
|
||||||
EXPECT_EQ(1u, fread(&port, 2, 1, _rtpFile));
|
port = ntohs(port);
|
||||||
port=ntohs(port);
|
EXPECT_EQ(1u, fread(&padding, 2, 1, _rtpFile));
|
||||||
EXPECT_EQ(1u, fread(&padding, 2, 1, _rtpFile));
|
padding = ntohs(padding);
|
||||||
padding=ntohs(padding);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
uint16_t lengthBytes = htons(12 + payloadSize + 8);
|
||||||
uint16_t lengthBytes = htons(12 + payloadSize + 8);
|
uint16_t plen = htons(12 + payloadSize);
|
||||||
uint16_t plen = htons(12 + payloadSize);
|
uint32_t offsetMs;
|
||||||
uint32_t offsetMs;
|
|
||||||
|
|
||||||
offsetMs = (timeStamp/(frequency/1000));
|
offsetMs = (timeStamp / (frequency / 1000));
|
||||||
offsetMs = htonl(offsetMs);
|
offsetMs = htonl(offsetMs);
|
||||||
if (fwrite(&lengthBytes, 2, 1, _rtpFile) != 1) {
|
if (fwrite(&lengthBytes, 2, 1, _rtpFile) != 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (fwrite(&plen, 2, 1, _rtpFile) != 1) {
|
if (fwrite(&plen, 2, 1, _rtpFile) != 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (fwrite(&offsetMs, 4, 1, _rtpFile) != 1) {
|
if (fwrite(&offsetMs, 4, 1, _rtpFile) != 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (fwrite(rtpHeader, 12, 1, _rtpFile) != 1) {
|
if (fwrite(rtpHeader, 12, 1, _rtpFile) != 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (fwrite(payloadData, 1, payloadSize, _rtpFile) != payloadSize) {
|
if (fwrite(payloadData, 1, payloadSize, _rtpFile) != payloadSize) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
uint16_t lengthBytes;
|
||||||
uint32_t* offset)
|
uint16_t plen;
|
||||||
{
|
uint8_t rtpHeader[12];
|
||||||
uint16_t lengthBytes;
|
size_t read_len = fread(&lengthBytes, 2, 1, _rtpFile);
|
||||||
uint16_t plen;
|
/* Check if we have reached end of file. */
|
||||||
uint8_t rtpHeader[12];
|
if ((read_len == 0) && feof(_rtpFile)) {
|
||||||
size_t read_len = fread(&lengthBytes, 2, 1, _rtpFile);
|
_rtpEOF = true;
|
||||||
/* Check if we have reached end of file. */
|
return 0;
|
||||||
if ((read_len == 0) && feof(_rtpFile))
|
}
|
||||||
{
|
EXPECT_EQ(1u, fread(&plen, 2, 1, _rtpFile));
|
||||||
_rtpEOF = true;
|
EXPECT_EQ(1u, fread(offset, 4, 1, _rtpFile));
|
||||||
return 0;
|
lengthBytes = ntohs(lengthBytes);
|
||||||
}
|
plen = ntohs(plen);
|
||||||
EXPECT_EQ(1u, fread(&plen, 2, 1, _rtpFile));
|
*offset = ntohl(*offset);
|
||||||
EXPECT_EQ(1u, fread(offset, 4, 1, _rtpFile));
|
EXPECT_GT(plen, 11);
|
||||||
lengthBytes = ntohs(lengthBytes);
|
|
||||||
plen = ntohs(plen);
|
|
||||||
*offset = ntohl(*offset);
|
|
||||||
EXPECT_GT(plen, 11);
|
|
||||||
|
|
||||||
EXPECT_EQ(1u, fread(rtpHeader, 12, 1, _rtpFile));
|
EXPECT_EQ(1u, fread(rtpHeader, 12, 1, _rtpFile));
|
||||||
ParseRTPHeader(rtpInfo, rtpHeader);
|
ParseRTPHeader(rtpInfo, rtpHeader);
|
||||||
rtpInfo->type.Audio.isCNG = false;
|
rtpInfo->type.Audio.isCNG = false;
|
||||||
rtpInfo->type.Audio.channel = 1;
|
rtpInfo->type.Audio.channel = 1;
|
||||||
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) {
|
||||||
}
|
return -1;
|
||||||
if (lengthBytes < 20)
|
}
|
||||||
{
|
lengthBytes -= 20;
|
||||||
return -1;
|
EXPECT_EQ(lengthBytes, fread(payloadData, 1, lengthBytes, _rtpFile));
|
||||||
}
|
return lengthBytes;
|
||||||
lengthBytes -= 20;
|
|
||||||
EXPECT_EQ(lengthBytes, fread(payloadData, 1, lengthBytes, _rtpFile));
|
|
||||||
return lengthBytes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -20,84 +20,97 @@
|
|||||||
|
|
||||||
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,
|
||||||
const uint16_t payloadSize, uint32_t frequency) = 0;
|
const uint16_t payloadSize, uint32_t frequency) = 0;
|
||||||
|
|
||||||
// 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,
|
virtual bool EndOfFile() const = 0;
|
||||||
uint32_t* offset) = 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, int16_t seqNo,
|
||||||
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);
|
|
||||||
~RTPPacket();
|
~RTPPacket();
|
||||||
uint8_t payloadType;
|
|
||||||
uint32_t timeStamp;
|
uint8_t payloadType;
|
||||||
int16_t seqNo;
|
uint32_t timeStamp;
|
||||||
uint8_t* payloadData;
|
int16_t seqNo;
|
||||||
uint16_t payloadSize;
|
uint8_t* payloadData;
|
||||||
uint32_t frequency;
|
uint16_t payloadSize;
|
||||||
|
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,
|
|
||||||
const int16_t seqNo, const uint8_t* payloadData,
|
void Write(const uint8_t payloadType, const uint32_t timeStamp,
|
||||||
const uint16_t payloadSize, uint32_t frequency);
|
const int16_t seqNo, const uint8_t* payloadData,
|
||||||
uint16_t Read(WebRtcRTPHeader* rtpInfo,
|
const uint16_t payloadSize, uint32_t frequency);
|
||||||
uint8_t* payloadData,
|
|
||||||
uint16_t payloadSize,
|
uint16_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
|
||||||
uint32_t* offset);
|
uint16_t payloadSize, uint32_t* offset);
|
||||||
virtual bool EndOfFile() const;
|
|
||||||
private:
|
virtual bool EndOfFile() const;
|
||||||
RWLockWrapper* _queueRWLock;
|
|
||||||
std::queue<RTPPacket *> _rtpQueue;
|
private:
|
||||||
|
RWLockWrapper* _queueRWLock;
|
||||||
|
std::queue<RTPPacket *> _rtpQueue;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RTPFile : public RTPStream
|
class RTPFile : public RTPStream {
|
||||||
{
|
public:
|
||||||
public:
|
~RTPFile() {
|
||||||
~RTPFile(){}
|
}
|
||||||
RTPFile() : _rtpFile(NULL),_rtpEOF(false) {}
|
|
||||||
void Open(const char *outFilename, const char *mode);
|
RTPFile()
|
||||||
void Close();
|
: _rtpFile(NULL),
|
||||||
void WriteHeader();
|
_rtpEOF(false) {
|
||||||
void ReadHeader();
|
}
|
||||||
void Write(const uint8_t payloadType, const uint32_t timeStamp,
|
|
||||||
const int16_t seqNo, const uint8_t* payloadData,
|
void Open(const char *outFilename, const char *mode);
|
||||||
const uint16_t payloadSize, uint32_t frequency);
|
|
||||||
uint16_t Read(WebRtcRTPHeader* rtpInfo,
|
void Close();
|
||||||
uint8_t* payloadData,
|
|
||||||
uint16_t payloadSize,
|
void WriteHeader();
|
||||||
uint32_t* offset);
|
|
||||||
bool EndOfFile() const { return _rtpEOF; }
|
void ReadHeader();
|
||||||
private:
|
|
||||||
FILE* _rtpFile;
|
void Write(const uint8_t payloadType, const uint32_t timeStamp,
|
||||||
bool _rtpEOF;
|
const int16_t seqNo, const uint8_t* payloadData,
|
||||||
|
const uint16_t payloadSize, uint32_t frequency);
|
||||||
|
|
||||||
|
uint16_t Read(WebRtcRTPHeader* rtpInfo, uint8_t* payloadData,
|
||||||
|
uint16_t payloadSize, uint32_t* offset);
|
||||||
|
|
||||||
|
bool EndOfFile() const {
|
||||||
|
return _rtpEOF;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
FILE* _rtpFile;
|
||||||
|
bool _rtpEOF;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,210 +23,183 @@ 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);
|
delete _channel;
|
||||||
delete _channel;
|
_inFile.Close();
|
||||||
_inFile.Close();
|
_outFile.Close();
|
||||||
_outFile.Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t
|
int16_t SpatialAudio::Setup() {
|
||||||
SpatialAudio::Setup()
|
// Create ACMs and the Channel;
|
||||||
{
|
_acmLeft = AudioCodingModule::Create(1);
|
||||||
// Create ACMs and the Channel;
|
_acmRight = AudioCodingModule::Create(2);
|
||||||
_acmLeft = AudioCodingModule::Create(1);
|
_acmReceiver = AudioCodingModule::Create(3);
|
||||||
_acmRight = AudioCodingModule::Create(2);
|
_channel = new Channel;
|
||||||
_acmReceiver = AudioCodingModule::Create(3);
|
|
||||||
_channel = new Channel;
|
|
||||||
|
|
||||||
// Register callback for the sender side.
|
// Register callback for the sender side.
|
||||||
CHECK_ERROR(_acmLeft->RegisterTransportCallback(_channel));
|
CHECK_ERROR(_acmLeft->RegisterTransportCallback(_channel));
|
||||||
CHECK_ERROR(_acmRight->RegisterTransportCallback(_channel));
|
CHECK_ERROR(_acmRight->RegisterTransportCallback(_channel));
|
||||||
// Register the receiver ACM in channel
|
// Register the receiver ACM in channel
|
||||||
_channel->RegisterReceiverACM(_acmReceiver);
|
_channel->RegisterReceiverACM(_acmReceiver);
|
||||||
|
|
||||||
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, &sampFreqHz);
|
||||||
PCMFile::ChooseFile(&output_file, MAX_FILE_NAME_LENGTH_BYTE,
|
} else {
|
||||||
&sampFreqHz);
|
output_file = webrtc::test::OutputPath() + "testspatial_out.pcm";
|
||||||
|
}
|
||||||
|
_outFile.Open(output_file, sampFreqHz, "wb", false);
|
||||||
|
_outFile.SaveStereo(true);
|
||||||
|
|
||||||
|
// Register all available codes as receiving codecs.
|
||||||
|
CodecInst codecInst;
|
||||||
|
int status;
|
||||||
|
uint8_t num_encoders = _acmReceiver->NumberOfCodecs();
|
||||||
|
// Register all available codes as receiving codecs once more.
|
||||||
|
for (uint8_t n = 0; n < num_encoders; n++) {
|
||||||
|
status = _acmReceiver->Codec(n, &codecInst);
|
||||||
|
if (status < 0) {
|
||||||
|
printf("Error in Codec(), no matching codec found");
|
||||||
}
|
}
|
||||||
else
|
status = _acmReceiver->RegisterReceiveCodec(codecInst);
|
||||||
{
|
if (status < 0) {
|
||||||
output_file = webrtc::test::OutputPath() + "testspatial_out.pcm";
|
printf("Error in RegisterReceiveCodec() for payload type %d",
|
||||||
|
codecInst.pltype);
|
||||||
}
|
}
|
||||||
_outFile.Open(output_file, sampFreqHz, "wb", false);
|
}
|
||||||
_outFile.SaveStereo(true);
|
|
||||||
|
|
||||||
// Register all available codes as receiving codecs.
|
return 0;
|
||||||
CodecInst codecInst;
|
|
||||||
int status;
|
|
||||||
uint8_t num_encoders = _acmReceiver->NumberOfCodecs();
|
|
||||||
// Register all available codes as receiving codecs once more.
|
|
||||||
for (uint8_t n = 0; n < num_encoders; n++) {
|
|
||||||
status = _acmReceiver->Codec(n, &codecInst);
|
|
||||||
if (status < 0) {
|
|
||||||
printf("Error in Codec(), no matching codec found");
|
|
||||||
}
|
|
||||||
status = _acmReceiver->RegisterReceiveCodec(codecInst);
|
|
||||||
if (status < 0) {
|
|
||||||
printf("Error in RegisterReceiveCodec() for payload type %d",
|
|
||||||
codecInst.pltype);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SpatialAudio::Perform() {
|
||||||
SpatialAudio::Perform()
|
if (_testMode == 0) {
|
||||||
{
|
printf("Running SpatialAudio Test");
|
||||||
if(_testMode == 0)
|
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1,
|
||||||
{
|
"---------- SpatialAudio ----------");
|
||||||
printf("Running SpatialAudio Test");
|
}
|
||||||
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1,
|
|
||||||
"---------- SpatialAudio ----------");
|
|
||||||
}
|
|
||||||
|
|
||||||
Setup();
|
Setup();
|
||||||
|
|
||||||
CodecInst codecInst;
|
CodecInst codecInst;
|
||||||
_acmLeft->Codec((uint8_t)1, &codecInst);
|
_acmLeft->Codec((uint8_t) 1, &codecInst);
|
||||||
CHECK_ERROR(_acmLeft->RegisterSendCodec(codecInst));
|
CHECK_ERROR(_acmLeft->RegisterSendCodec(codecInst));
|
||||||
EncodeDecode();
|
EncodeDecode();
|
||||||
|
|
||||||
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;
|
|
||||||
CHECK_ERROR(_acmLeft->RegisterSendCodec(codecInst));
|
|
||||||
CHECK_ERROR(_acmRight->RegisterSendCodec(codecInst));
|
|
||||||
|
|
||||||
EncodeDecode(leftPanning[pannCntr], rightPanning[pannCntr]);
|
|
||||||
pannCntr++;
|
|
||||||
|
|
||||||
// Change codec
|
|
||||||
_acmLeft->Codec((uint8_t)3, &codecInst);
|
|
||||||
codecInst.pacsize = 320;
|
|
||||||
CHECK_ERROR(_acmLeft->RegisterSendCodec(codecInst));
|
|
||||||
CHECK_ERROR(_acmRight->RegisterSendCodec(codecInst));
|
|
||||||
|
|
||||||
EncodeDecode(leftPanning[pannCntr], rightPanning[pannCntr]);
|
|
||||||
pannCntr++;
|
|
||||||
if(_testMode == 0)
|
|
||||||
{
|
|
||||||
printf(".");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_acmLeft->Codec((uint8_t)4, &codecInst);
|
|
||||||
CHECK_ERROR(_acmLeft->RegisterSendCodec(codecInst));
|
|
||||||
EncodeDecode();
|
|
||||||
|
|
||||||
_acmLeft->Codec((uint8_t)0, &codecInst);
|
|
||||||
codecInst.pacsize = 480;
|
codecInst.pacsize = 480;
|
||||||
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;
|
|
||||||
while(pannCntr >= 0)
|
EncodeDecode(leftPanning[pannCntr], rightPanning[pannCntr]);
|
||||||
{
|
pannCntr++;
|
||||||
EncodeDecode(leftPanning[pannCntr], rightPanning[pannCntr]);
|
|
||||||
pannCntr--;
|
// Change codec
|
||||||
if(_testMode == 0)
|
_acmLeft->Codec((uint8_t) 3, &codecInst);
|
||||||
{
|
codecInst.pacsize = 320;
|
||||||
printf(".");
|
CHECK_ERROR(_acmLeft->RegisterSendCodec(codecInst));
|
||||||
}
|
CHECK_ERROR(_acmRight->RegisterSendCodec(codecInst));
|
||||||
|
|
||||||
|
EncodeDecode(leftPanning[pannCntr], rightPanning[pannCntr]);
|
||||||
|
pannCntr++;
|
||||||
|
if (_testMode == 0) {
|
||||||
|
printf(".");
|
||||||
}
|
}
|
||||||
if(_testMode == 0)
|
}
|
||||||
{
|
|
||||||
printf("Done!\n");
|
_acmLeft->Codec((uint8_t) 4, &codecInst);
|
||||||
|
CHECK_ERROR(_acmLeft->RegisterSendCodec(codecInst));
|
||||||
|
EncodeDecode();
|
||||||
|
|
||||||
|
_acmLeft->Codec((uint8_t) 0, &codecInst);
|
||||||
|
codecInst.pacsize = 480;
|
||||||
|
CHECK_ERROR(_acmLeft->RegisterSendCodec(codecInst));
|
||||||
|
CHECK_ERROR(_acmRight->RegisterSendCodec(codecInst));
|
||||||
|
pannCntr = NUM_PANN_COEFFS - 1;
|
||||||
|
while (pannCntr >= 0) {
|
||||||
|
EncodeDecode(leftPanning[pannCntr], rightPanning[pannCntr]);
|
||||||
|
pannCntr--;
|
||||||
|
if (_testMode == 0) {
|
||||||
|
printf(".");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (_testMode == 0) {
|
||||||
|
printf("Done!\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SpatialAudio::EncodeDecode(const double leftPanning,
|
||||||
SpatialAudio::EncodeDecode(
|
const double rightPanning) {
|
||||||
const double leftPanning,
|
AudioFrame audioFrame;
|
||||||
const double rightPanning)
|
int32_t outFileSampFreq = _outFile.SamplingFrequency();
|
||||||
{
|
|
||||||
AudioFrame audioFrame;
|
|
||||||
int32_t outFileSampFreq = _outFile.SamplingFrequency();
|
|
||||||
|
|
||||||
const double rightToLeftRatio = rightPanning / leftPanning;
|
const double rightToLeftRatio = rightPanning / leftPanning;
|
||||||
|
|
||||||
_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] * leftPanning + 0.5);
|
||||||
audioFrame.data_[n] = (int16_t)floor(
|
|
||||||
audioFrame.data_[n] * leftPanning + 0.5);
|
|
||||||
}
|
|
||||||
CHECK_ERROR(_acmLeft->Add10MsData(audioFrame));
|
|
||||||
|
|
||||||
for(int n = 0; n < audioFrame.samples_per_channel_; n++)
|
|
||||||
{
|
|
||||||
audioFrame.data_[n] = (int16_t)floor(
|
|
||||||
audioFrame.data_[n] * rightToLeftRatio + 0.5);
|
|
||||||
}
|
|
||||||
CHECK_ERROR(_acmRight->Add10MsData(audioFrame));
|
|
||||||
|
|
||||||
CHECK_ERROR(_acmLeft->Process());
|
|
||||||
CHECK_ERROR(_acmRight->Process());
|
|
||||||
|
|
||||||
CHECK_ERROR(_acmReceiver->PlayoutData10Ms(outFileSampFreq,
|
|
||||||
&audioFrame));
|
|
||||||
_outFile.Write10MsData(audioFrame);
|
|
||||||
}
|
}
|
||||||
_inFile.Rewind();
|
CHECK_ERROR(_acmLeft->Add10MsData(audioFrame));
|
||||||
|
|
||||||
|
for (int n = 0; n < audioFrame.samples_per_channel_; n++) {
|
||||||
|
audioFrame.data_[n] = (int16_t) floor(
|
||||||
|
audioFrame.data_[n] * rightToLeftRatio + 0.5);
|
||||||
|
}
|
||||||
|
CHECK_ERROR(_acmRight->Add10MsData(audioFrame));
|
||||||
|
|
||||||
|
CHECK_ERROR(_acmLeft->Process());
|
||||||
|
CHECK_ERROR(_acmRight->Process());
|
||||||
|
|
||||||
|
CHECK_ERROR(_acmReceiver->PlayoutData10Ms(outFileSampFreq, &audioFrame));
|
||||||
|
_outFile.Write10MsData(audioFrame);
|
||||||
|
}
|
||||||
|
_inFile.Rewind();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void SpatialAudio::EncodeDecode() {
|
||||||
SpatialAudio::EncodeDecode()
|
AudioFrame audioFrame;
|
||||||
{
|
int32_t outFileSampFreq = _outFile.SamplingFrequency();
|
||||||
AudioFrame audioFrame;
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -21,27 +21,26 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class SpatialAudio : public ACMTest
|
class SpatialAudio : public ACMTest {
|
||||||
{
|
public:
|
||||||
public:
|
SpatialAudio(int testMode);
|
||||||
SpatialAudio(int testMode);
|
~SpatialAudio();
|
||||||
~SpatialAudio();
|
|
||||||
|
|
||||||
void Perform();
|
void Perform();
|
||||||
private:
|
private:
|
||||||
int16_t Setup();
|
int16_t Setup();
|
||||||
void EncodeDecode(double leftPanning, double rightPanning);
|
void EncodeDecode(double leftPanning, double rightPanning);
|
||||||
void EncodeDecode();
|
void EncodeDecode();
|
||||||
|
|
||||||
AudioCodingModule* _acmLeft;
|
AudioCodingModule* _acmLeft;
|
||||||
AudioCodingModule* _acmRight;
|
AudioCodingModule* _acmRight;
|
||||||
AudioCodingModule* _acmReceiver;
|
AudioCodingModule* _acmReceiver;
|
||||||
Channel* _channel;
|
Channel* _channel;
|
||||||
PCMFile _inFile;
|
PCMFile _inFile;
|
||||||
PCMFile _outFile;
|
PCMFile _outFile;
|
||||||
int _testMode;
|
int _testMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -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;
|
||||||
|
@ -35,7 +35,7 @@ class TestPack : public AudioPacketizationCallback {
|
|||||||
void reset_payload_size();
|
void reset_payload_size();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AudioCodingModule* receiver_acm_;
|
AudioCodingModule* receiver_acm_;
|
||||||
uint16_t sequence_number_;
|
uint16_t sequence_number_;
|
||||||
uint8_t payload_data_[60 * 32 * 2 * 2];
|
uint8_t payload_data_[60 * 32 * 2 * 2];
|
||||||
uint32_t timestamp_diff_;
|
uint32_t timestamp_diff_;
|
||||||
|
@ -22,581 +22,453 @@
|
|||||||
|
|
||||||
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);
|
||||||
{
|
_acmA = NULL;
|
||||||
AudioCodingModule::Destroy(_acmA);
|
}
|
||||||
_acmA = NULL;
|
if (_acmB != NULL) {
|
||||||
}
|
AudioCodingModule::Destroy(_acmB);
|
||||||
if(_acmB != NULL)
|
_acmB = NULL;
|
||||||
{
|
}
|
||||||
AudioCodingModule::Destroy(_acmB);
|
if (_channelA2B != NULL) {
|
||||||
_acmB = NULL;
|
delete _channelA2B;
|
||||||
}
|
_channelA2B = NULL;
|
||||||
if(_channelA2B != NULL)
|
}
|
||||||
{
|
|
||||||
delete _channelA2B;
|
|
||||||
_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 = webrtc::test::ResourcePath(
|
||||||
|
"audio_coding/testfile32kHz", "pcm");
|
||||||
|
_inFileA.Open(file_name, 32000, "rb");
|
||||||
|
|
||||||
|
bool fecEnabled;
|
||||||
|
|
||||||
|
_acmA = AudioCodingModule::Create(0);
|
||||||
|
_acmB = AudioCodingModule::Create(1);
|
||||||
|
|
||||||
|
_acmA->InitializeReceiver();
|
||||||
|
_acmB->InitializeReceiver();
|
||||||
|
|
||||||
|
uint8_t numEncoders = _acmA->NumberOfCodecs();
|
||||||
|
CodecInst myCodecParam;
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("Registering codecs at receiver... \n");
|
||||||
|
}
|
||||||
|
for (uint8_t n = 0; n < numEncoders; n++) {
|
||||||
|
_acmB->Codec(n, &myCodecParam);
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("%s\n", myCodecParam.plname);
|
||||||
}
|
}
|
||||||
const std::string file_name =
|
_acmB->RegisterReceiveCodec(myCodecParam);
|
||||||
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
|
}
|
||||||
_inFileA.Open(file_name, 32000, "rb");
|
|
||||||
|
|
||||||
bool fecEnabled;
|
// Create and connect the channel
|
||||||
|
_channelA2B = new Channel;
|
||||||
|
_acmA->RegisterTransportCallback(_channelA2B);
|
||||||
|
_channelA2B->RegisterReceiverACM(_acmB);
|
||||||
|
|
||||||
_acmA = AudioCodingModule::Create(0);
|
if (_testMode != 0) {
|
||||||
_acmB = AudioCodingModule::Create(1);
|
printf("===============================================================\n");
|
||||||
|
printf("%d ", _testCntr++);
|
||||||
_acmA->InitializeReceiver();
|
} else {
|
||||||
_acmB->InitializeReceiver();
|
printf(".");
|
||||||
|
}
|
||||||
uint8_t numEncoders = _acmA->NumberOfCodecs();
|
|
||||||
CodecInst myCodecParam;
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("Registering codecs at receiver... \n");
|
|
||||||
}
|
|
||||||
for(uint8_t n = 0; n < numEncoders; n++)
|
|
||||||
{
|
|
||||||
_acmB->Codec(n, &myCodecParam);
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("%s\n", myCodecParam.plname);
|
|
||||||
}
|
|
||||||
_acmB->RegisterReceiveCodec(myCodecParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create and connect the channel
|
|
||||||
_channelA2B = new Channel;
|
|
||||||
_acmA->RegisterTransportCallback(_channelA2B);
|
|
||||||
_channelA2B->RegisterReceiverACM(_acmB);
|
|
||||||
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("=======================================================================\n");
|
|
||||||
printf("%d ",_testCntr++);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf(".");
|
|
||||||
}
|
|
||||||
#ifndef WEBRTC_CODEC_G722
|
#ifndef WEBRTC_CODEC_G722
|
||||||
printf("G722 needs to be activated to run this test\n");
|
printf("G722 needs to be activated to run this test\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
#endif
|
#endif
|
||||||
char nameG722[] = "G722";
|
char nameG722[] = "G722";
|
||||||
RegisterSendCodec('A', nameG722, 16000);
|
RegisterSendCodec('A', nameG722, 16000);
|
||||||
char nameCN[] = "CN";
|
char nameCN[] = "CN";
|
||||||
RegisterSendCodec('A', nameCN, 16000);
|
RegisterSendCodec('A', nameCN, 16000);
|
||||||
char nameRED[] = "RED";
|
char nameRED[] = "RED";
|
||||||
RegisterSendCodec('A', nameRED);
|
RegisterSendCodec('A', nameRED);
|
||||||
OpenOutFile(_testCntr);
|
OpenOutFile(_testCntr);
|
||||||
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 {
|
||||||
}
|
printf(".");
|
||||||
else
|
}
|
||||||
{
|
_acmA->SetFECStatus(true);
|
||||||
printf(".");
|
fecEnabled = _acmA->FECStatus();
|
||||||
}
|
if (_testMode != 0) {
|
||||||
_acmA->SetFECStatus(true);
|
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
|
||||||
fecEnabled = _acmA->FECStatus();
|
DisplaySendReceiveCodec();
|
||||||
if(_testMode != 0)
|
}
|
||||||
{
|
OpenOutFile(_testCntr);
|
||||||
printf("FEC currently %s\n",(fecEnabled?"ON":"OFF"));
|
Run();
|
||||||
DisplaySendReceiveCodec();
|
_outFileB.Close();
|
||||||
}
|
|
||||||
OpenOutFile(_testCntr);
|
|
||||||
Run();
|
|
||||||
_outFileB.Close();
|
|
||||||
|
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("===============================================================\n");
|
||||||
|
printf("%d ", _testCntr++);
|
||||||
|
} else {
|
||||||
|
printf(".");
|
||||||
|
}
|
||||||
|
char nameISAC[] = "iSAC";
|
||||||
|
RegisterSendCodec('A', nameISAC, 16000);
|
||||||
|
OpenOutFile(_testCntr);
|
||||||
|
SetVAD(true, true, VADVeryAggr);
|
||||||
|
_acmA->SetFECStatus(false);
|
||||||
|
fecEnabled = _acmA->FECStatus();
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
|
||||||
|
DisplaySendReceiveCodec();
|
||||||
|
}
|
||||||
|
Run();
|
||||||
|
_outFileB.Close();
|
||||||
|
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("===============================================================\n");
|
||||||
|
printf("%d ", _testCntr++);
|
||||||
|
} else {
|
||||||
|
printf(".");
|
||||||
|
}
|
||||||
|
_acmA->SetFECStatus(true);
|
||||||
|
fecEnabled = _acmA->FECStatus();
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
|
||||||
|
DisplaySendReceiveCodec();
|
||||||
|
}
|
||||||
|
OpenOutFile(_testCntr);
|
||||||
|
Run();
|
||||||
|
_outFileB.Close();
|
||||||
|
|
||||||
if(_testMode != 0)
|
if (_testMode != 0) {
|
||||||
{
|
printf("===============================================================\n");
|
||||||
printf("=======================================================================\n");
|
printf("%d ", _testCntr++);
|
||||||
printf("%d ",_testCntr++);
|
} else {
|
||||||
}
|
printf(".");
|
||||||
else
|
}
|
||||||
{
|
|
||||||
printf(".");
|
|
||||||
}
|
|
||||||
char nameISAC[] = "iSAC";
|
|
||||||
RegisterSendCodec('A',nameISAC, 16000);
|
|
||||||
OpenOutFile(_testCntr);
|
|
||||||
SetVAD(true, true, VADVeryAggr);
|
|
||||||
_acmA->SetFECStatus(false);
|
|
||||||
fecEnabled = _acmA->FECStatus();
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("FEC currently %s\n",(fecEnabled?"ON":"OFF"));
|
|
||||||
DisplaySendReceiveCodec();
|
|
||||||
}
|
|
||||||
Run();
|
|
||||||
_outFileB.Close();
|
|
||||||
|
|
||||||
|
RegisterSendCodec('A', nameISAC, 32000);
|
||||||
|
OpenOutFile(_testCntr);
|
||||||
|
SetVAD(true, true, VADVeryAggr);
|
||||||
|
_acmA->SetFECStatus(false);
|
||||||
|
fecEnabled = _acmA->FECStatus();
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
|
||||||
|
DisplaySendReceiveCodec();
|
||||||
|
}
|
||||||
|
Run();
|
||||||
|
_outFileB.Close();
|
||||||
|
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("===============================================================\n");
|
||||||
|
printf("%d ", _testCntr++);
|
||||||
|
} else {
|
||||||
|
printf(".");
|
||||||
|
}
|
||||||
|
_acmA->SetFECStatus(true);
|
||||||
|
fecEnabled = _acmA->FECStatus();
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
|
||||||
|
DisplaySendReceiveCodec();
|
||||||
|
}
|
||||||
|
OpenOutFile(_testCntr);
|
||||||
|
Run();
|
||||||
|
_outFileB.Close();
|
||||||
|
|
||||||
if(_testMode != 0)
|
if (_testMode != 0) {
|
||||||
{
|
printf("===============================================================\n");
|
||||||
printf("=======================================================================\n");
|
printf("%d ", _testCntr++);
|
||||||
printf("%d ",_testCntr++);
|
} else {
|
||||||
}
|
printf(".");
|
||||||
else
|
}
|
||||||
{
|
|
||||||
printf(".");
|
|
||||||
}
|
|
||||||
_acmA->SetFECStatus(true);
|
|
||||||
fecEnabled = _acmA->FECStatus();
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("FEC currently %s\n",(fecEnabled?"ON":"OFF"));
|
|
||||||
DisplaySendReceiveCodec();
|
|
||||||
}
|
|
||||||
OpenOutFile(_testCntr);
|
|
||||||
Run();
|
|
||||||
_outFileB.Close();
|
|
||||||
|
|
||||||
|
RegisterSendCodec('A', nameISAC, 32000);
|
||||||
|
OpenOutFile(_testCntr);
|
||||||
|
SetVAD(false, false, VADNormal);
|
||||||
|
_acmA->SetFECStatus(true);
|
||||||
|
fecEnabled = _acmA->FECStatus();
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
|
||||||
|
DisplaySendReceiveCodec();
|
||||||
|
}
|
||||||
|
Run();
|
||||||
|
|
||||||
|
RegisterSendCodec('A', nameISAC, 16000);
|
||||||
|
fecEnabled = _acmA->FECStatus();
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
|
||||||
|
DisplaySendReceiveCodec();
|
||||||
|
}
|
||||||
|
Run();
|
||||||
|
|
||||||
if(_testMode != 0)
|
RegisterSendCodec('A', nameISAC, 32000);
|
||||||
{
|
fecEnabled = _acmA->FECStatus();
|
||||||
printf("=======================================================================\n");
|
if (_testMode != 0) {
|
||||||
printf("%d ",_testCntr++);
|
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
|
||||||
}
|
DisplaySendReceiveCodec();
|
||||||
else
|
}
|
||||||
{
|
Run();
|
||||||
printf(".");
|
|
||||||
}
|
|
||||||
|
|
||||||
RegisterSendCodec('A', nameISAC, 32000);
|
RegisterSendCodec('A', nameISAC, 16000);
|
||||||
OpenOutFile(_testCntr);
|
fecEnabled = _acmA->FECStatus();
|
||||||
SetVAD(true, true, VADVeryAggr);
|
if (_testMode != 0) {
|
||||||
_acmA->SetFECStatus(false);
|
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
|
||||||
fecEnabled = _acmA->FECStatus();
|
DisplaySendReceiveCodec();
|
||||||
if(_testMode != 0)
|
}
|
||||||
{
|
Run();
|
||||||
printf("FEC currently %s\n",(fecEnabled?"ON":"OFF"));
|
_outFileB.Close();
|
||||||
DisplaySendReceiveCodec();
|
|
||||||
}
|
|
||||||
Run();
|
|
||||||
_outFileB.Close();
|
|
||||||
|
|
||||||
|
_channelA2B->SetFECTestWithPacketLoss(true);
|
||||||
|
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("===============================================================\n");
|
||||||
|
printf("%d ", _testCntr++);
|
||||||
|
} else {
|
||||||
|
printf(".");
|
||||||
|
}
|
||||||
|
|
||||||
if(_testMode != 0)
|
RegisterSendCodec('A', nameG722);
|
||||||
{
|
RegisterSendCodec('A', nameCN, 16000);
|
||||||
printf("=======================================================================\n");
|
OpenOutFile(_testCntr);
|
||||||
printf("%d ",_testCntr++);
|
SetVAD(true, true, VADAggr);
|
||||||
}
|
_acmA->SetFECStatus(false);
|
||||||
else
|
fecEnabled = _acmA->FECStatus();
|
||||||
{
|
if (_testMode != 0) {
|
||||||
printf(".");
|
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
|
||||||
}
|
DisplaySendReceiveCodec();
|
||||||
_acmA->SetFECStatus(true);
|
}
|
||||||
fecEnabled = _acmA->FECStatus();
|
Run();
|
||||||
if(_testMode != 0)
|
_outFileB.Close();
|
||||||
{
|
|
||||||
printf("FEC currently %s\n",(fecEnabled?"ON":"OFF"));
|
|
||||||
DisplaySendReceiveCodec();
|
|
||||||
}
|
|
||||||
OpenOutFile(_testCntr);
|
|
||||||
Run();
|
|
||||||
_outFileB.Close();
|
|
||||||
|
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("===============================================================\n");
|
||||||
|
printf("%d ", _testCntr++);
|
||||||
|
} else {
|
||||||
|
printf(".");
|
||||||
|
}
|
||||||
|
_acmA->SetFECStatus(true);
|
||||||
|
fecEnabled = _acmA->FECStatus();
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
|
||||||
|
DisplaySendReceiveCodec();
|
||||||
|
}
|
||||||
|
OpenOutFile(_testCntr);
|
||||||
|
Run();
|
||||||
|
_outFileB.Close();
|
||||||
|
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("===============================================================\n");
|
||||||
|
printf("%d ", _testCntr++);
|
||||||
|
} else {
|
||||||
|
printf(".");
|
||||||
|
}
|
||||||
|
RegisterSendCodec('A', nameISAC, 16000);
|
||||||
|
OpenOutFile(_testCntr);
|
||||||
|
SetVAD(true, true, VADVeryAggr);
|
||||||
|
_acmA->SetFECStatus(false);
|
||||||
|
fecEnabled = _acmA->FECStatus();
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
|
||||||
|
DisplaySendReceiveCodec();
|
||||||
|
}
|
||||||
|
Run();
|
||||||
|
_outFileB.Close();
|
||||||
|
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("===============================================================\n");
|
||||||
|
printf("%d ", _testCntr++);
|
||||||
|
} else {
|
||||||
|
printf(".");
|
||||||
|
}
|
||||||
|
_acmA->SetFECStatus(true);
|
||||||
|
fecEnabled = _acmA->FECStatus();
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
|
||||||
|
DisplaySendReceiveCodec();
|
||||||
|
}
|
||||||
|
OpenOutFile(_testCntr);
|
||||||
|
Run();
|
||||||
|
_outFileB.Close();
|
||||||
|
|
||||||
if(_testMode != 0)
|
if (_testMode != 0) {
|
||||||
{
|
printf("===============================================================\n");
|
||||||
printf("=======================================================================\n");
|
printf("%d ", _testCntr++);
|
||||||
printf("%d ",_testCntr++);
|
} else {
|
||||||
}
|
printf(".");
|
||||||
else
|
}
|
||||||
{
|
RegisterSendCodec('A', nameISAC, 32000);
|
||||||
printf(".");
|
OpenOutFile(_testCntr);
|
||||||
}
|
SetVAD(true, true, VADVeryAggr);
|
||||||
|
_acmA->SetFECStatus(false);
|
||||||
|
fecEnabled = _acmA->FECStatus();
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
|
||||||
|
DisplaySendReceiveCodec();
|
||||||
|
}
|
||||||
|
Run();
|
||||||
|
_outFileB.Close();
|
||||||
|
|
||||||
RegisterSendCodec('A', nameISAC, 32000);
|
if (_testMode != 0) {
|
||||||
OpenOutFile(_testCntr);
|
printf("===============================================================\n");
|
||||||
SetVAD(false, false, VADNormal);
|
printf("%d ", _testCntr++);
|
||||||
_acmA->SetFECStatus(true);
|
} else {
|
||||||
fecEnabled = _acmA->FECStatus();
|
printf(".");
|
||||||
if(_testMode != 0)
|
}
|
||||||
{
|
_acmA->SetFECStatus(true);
|
||||||
printf("FEC currently %s\n",(fecEnabled?"ON":"OFF"));
|
fecEnabled = _acmA->FECStatus();
|
||||||
DisplaySendReceiveCodec();
|
if (_testMode != 0) {
|
||||||
}
|
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
|
||||||
Run();
|
DisplaySendReceiveCodec();
|
||||||
|
}
|
||||||
|
OpenOutFile(_testCntr);
|
||||||
|
Run();
|
||||||
|
_outFileB.Close();
|
||||||
|
|
||||||
|
if (_testMode != 0) {
|
||||||
RegisterSendCodec('A', nameISAC, 16000);
|
printf("===============================================================\n");
|
||||||
fecEnabled = _acmA->FECStatus();
|
printf("%d ", _testCntr++);
|
||||||
if(_testMode != 0)
|
} else {
|
||||||
{
|
printf(".");
|
||||||
printf("FEC currently %s\n",(fecEnabled?"ON":"OFF"));
|
}
|
||||||
DisplaySendReceiveCodec();
|
RegisterSendCodec('A', nameISAC, 32000);
|
||||||
}
|
OpenOutFile(_testCntr);
|
||||||
Run();
|
SetVAD(false, false, VADNormal);
|
||||||
|
_acmA->SetFECStatus(true);
|
||||||
|
fecEnabled = _acmA->FECStatus();
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
|
||||||
|
DisplaySendReceiveCodec();
|
||||||
|
}
|
||||||
|
Run();
|
||||||
|
|
||||||
RegisterSendCodec('A', nameISAC, 32000);
|
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();
|
|
||||||
|
|
||||||
RegisterSendCodec('A', nameISAC, 16000);
|
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();
|
}
|
||||||
}
|
Run();
|
||||||
Run();
|
|
||||||
_outFileB.Close();
|
|
||||||
|
|
||||||
|
RegisterSendCodec('A', nameISAC, 16000);
|
||||||
|
fecEnabled = _acmA->FECStatus();
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("FEC currently %s\n", (fecEnabled ? "ON" : "OFF"));
|
||||||
|
DisplaySendReceiveCodec();
|
||||||
|
}
|
||||||
|
Run();
|
||||||
|
_outFileB.Close();
|
||||||
|
|
||||||
|
if (_testMode == 0) {
|
||||||
|
printf("Done!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_channelA2B->SetFECTestWithPacketLoss(true);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("=======================================================================\n");
|
|
||||||
printf("%d ",_testCntr++);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf(".");
|
|
||||||
}
|
|
||||||
|
|
||||||
RegisterSendCodec('A',nameG722);
|
|
||||||
RegisterSendCodec('A', nameCN, 16000);
|
|
||||||
OpenOutFile(_testCntr);
|
|
||||||
SetVAD(true, true, VADAggr);
|
|
||||||
_acmA->SetFECStatus(false);
|
|
||||||
fecEnabled = _acmA->FECStatus();
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("FEC currently %s\n",(fecEnabled?"ON":"OFF"));
|
|
||||||
DisplaySendReceiveCodec();
|
|
||||||
}
|
|
||||||
Run();
|
|
||||||
_outFileB.Close();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("=======================================================================\n");
|
|
||||||
printf("%d ",_testCntr++);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf(".");
|
|
||||||
}
|
|
||||||
_acmA->SetFECStatus(true);
|
|
||||||
fecEnabled = _acmA->FECStatus();
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("FEC currently %s\n",(fecEnabled?"ON":"OFF"));
|
|
||||||
DisplaySendReceiveCodec();
|
|
||||||
}
|
|
||||||
OpenOutFile(_testCntr);
|
|
||||||
Run();
|
|
||||||
_outFileB.Close();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("=======================================================================\n");
|
|
||||||
printf("%d ",_testCntr++);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf(".");
|
|
||||||
}
|
|
||||||
RegisterSendCodec('A', nameISAC, 16000);
|
|
||||||
OpenOutFile(_testCntr);
|
|
||||||
SetVAD(true, true, VADVeryAggr);
|
|
||||||
_acmA->SetFECStatus(false);
|
|
||||||
fecEnabled = _acmA->FECStatus();
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("FEC currently %s\n",(fecEnabled?"ON":"OFF"));
|
|
||||||
DisplaySendReceiveCodec();
|
|
||||||
}
|
|
||||||
Run();
|
|
||||||
_outFileB.Close();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("=======================================================================\n");
|
|
||||||
printf("%d ",_testCntr++);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf(".");
|
|
||||||
}
|
|
||||||
_acmA->SetFECStatus(true);
|
|
||||||
fecEnabled = _acmA->FECStatus();
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("FEC currently %s\n",(fecEnabled?"ON":"OFF"));
|
|
||||||
DisplaySendReceiveCodec();
|
|
||||||
}
|
|
||||||
OpenOutFile(_testCntr);
|
|
||||||
Run();
|
|
||||||
_outFileB.Close();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("=======================================================================\n");
|
|
||||||
printf("%d ",_testCntr++);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf(".");
|
|
||||||
}
|
|
||||||
RegisterSendCodec('A', nameISAC, 32000);
|
|
||||||
OpenOutFile(_testCntr);
|
|
||||||
SetVAD(true, true, VADVeryAggr);
|
|
||||||
_acmA->SetFECStatus(false);
|
|
||||||
fecEnabled = _acmA->FECStatus();
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("FEC currently %s\n",(fecEnabled?"ON":"OFF"));
|
|
||||||
DisplaySendReceiveCodec();
|
|
||||||
}
|
|
||||||
Run();
|
|
||||||
_outFileB.Close();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("=======================================================================\n");
|
|
||||||
printf("%d ",_testCntr++);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf(".");
|
|
||||||
}
|
|
||||||
_acmA->SetFECStatus(true);
|
|
||||||
fecEnabled = _acmA->FECStatus();
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("FEC currently %s\n",(fecEnabled?"ON":"OFF"));
|
|
||||||
DisplaySendReceiveCodec();
|
|
||||||
}
|
|
||||||
OpenOutFile(_testCntr);
|
|
||||||
Run();
|
|
||||||
_outFileB.Close();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("=======================================================================\n");
|
|
||||||
printf("%d ",_testCntr++);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf(".");
|
|
||||||
}
|
|
||||||
RegisterSendCodec('A', nameISAC, 32000);
|
|
||||||
OpenOutFile(_testCntr);
|
|
||||||
SetVAD(false, false, VADNormal);
|
|
||||||
_acmA->SetFECStatus(true);
|
|
||||||
fecEnabled = _acmA->FECStatus();
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("FEC currently %s\n",(fecEnabled?"ON":"OFF"));
|
|
||||||
DisplaySendReceiveCodec();
|
|
||||||
}
|
|
||||||
Run();
|
|
||||||
|
|
||||||
|
|
||||||
RegisterSendCodec('A', nameISAC, 16000);
|
|
||||||
fecEnabled = _acmA->FECStatus();
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("FEC currently %s\n",(fecEnabled?"ON":"OFF"));
|
|
||||||
DisplaySendReceiveCodec();
|
|
||||||
}
|
|
||||||
Run();
|
|
||||||
|
|
||||||
RegisterSendCodec('A', nameISAC, 32000);
|
|
||||||
fecEnabled = _acmA->FECStatus();
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("FEC currently %s\n",(fecEnabled?"ON":"OFF"));
|
|
||||||
DisplaySendReceiveCodec();
|
|
||||||
}
|
|
||||||
Run();
|
|
||||||
|
|
||||||
RegisterSendCodec('A', nameISAC, 16000);
|
|
||||||
fecEnabled = _acmA->FECStatus();
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("FEC currently %s\n",(fecEnabled?"ON":"OFF"));
|
|
||||||
DisplaySendReceiveCodec();
|
|
||||||
}
|
|
||||||
Run();
|
|
||||||
_outFileB.Close();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(_testMode == 0)
|
|
||||||
{
|
|
||||||
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",
|
return _acmA->SetVAD(enableDTX, enableVAD, vadMode);
|
||||||
enableVAD? "ON":"OFF",
|
|
||||||
(int16_t)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 {
|
||||||
}
|
printf("Registering %s for side %c\n", codecName, side);
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
printf("Registering %s for side %c\n", codecName, side);
|
std::cout << std::flush;
|
||||||
}
|
AudioCodingModule* myACM;
|
||||||
|
switch (side) {
|
||||||
|
case 'A': {
|
||||||
|
myACM = _acmA;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'B': {
|
||||||
|
myACM = _acmB;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
std::cout << std::flush;
|
|
||||||
AudioCodingModule* myACM;
|
|
||||||
switch(side)
|
|
||||||
{
|
|
||||||
case 'A':
|
|
||||||
{
|
|
||||||
myACM = _acmA;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'B':
|
|
||||||
{
|
|
||||||
myACM = _acmB;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
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));
|
||||||
|
|
||||||
// initialization was succesful
|
// initialization was succesful
|
||||||
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;
|
||||||
{
|
secPassed++;
|
||||||
msecPassed = 0;
|
|
||||||
secPassed++;
|
|
||||||
}
|
|
||||||
if(((secPassed%5) == 4) && (msecPassed == 0) && (_testCntr > 14))
|
|
||||||
{
|
|
||||||
printf("%3u:%3u ", secPassed, msecPassed);
|
|
||||||
_acmA->SetFECStatus(false);
|
|
||||||
printf("FEC currently %s\n",(_acmA->FECStatus()?"ON":"OFF"));
|
|
||||||
}
|
|
||||||
if(((secPassed%5) == 4) && (msecPassed >= 990) && (_testCntr > 14))
|
|
||||||
{
|
|
||||||
printf("%3u:%3u ", secPassed, msecPassed);
|
|
||||||
_acmA->SetFECStatus(true);
|
|
||||||
printf("FEC currently %s\n",(_acmA->FECStatus()?"ON":"OFF"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_inFileA.Rewind();
|
if (((secPassed % 5) == 4) && (msecPassed == 0) && (_testCntr > 14)) {
|
||||||
|
printf("%3u:%3u ", secPassed, msecPassed);
|
||||||
|
_acmA->SetFECStatus(false);
|
||||||
|
printf("FEC currently %s\n", (_acmA->FECStatus() ? "ON" : "OFF"));
|
||||||
|
}
|
||||||
|
if (((secPassed % 5) == 4) && (msecPassed >= 990) && (_testCntr > 14)) {
|
||||||
|
printf("%3u:%3u ", secPassed, msecPassed);
|
||||||
|
_acmA->SetFECStatus(true);
|
||||||
|
printf("FEC currently %s\n", (_acmA->FECStatus() ? "ON" : "OFF"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_inFileA.Rewind();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestFEC::OpenOutFile(int16_t test_number) {
|
void TestFEC::OpenOutFile(int16_t test_number) {
|
||||||
@ -613,13 +485,12 @@ 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);
|
_acmB->ReceiveCodec(&myCodecParam);
|
||||||
_acmB->ReceiveCodec(&myCodecParam);
|
printf("%s\n", myCodecParam.plname);
|
||||||
printf("%s\n", myCodecParam.plname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -17,33 +17,33 @@
|
|||||||
|
|
||||||
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,
|
||||||
void Run();
|
int32_t sampFreqHz = -1);
|
||||||
void OpenOutFile(int16_t testNumber);
|
void Run();
|
||||||
void DisplaySendReceiveCodec();
|
void OpenOutFile(int16_t testNumber);
|
||||||
int32_t SetVAD(bool enableDTX, bool enableVAD, ACMVADMode vadMode);
|
void DisplaySendReceiveCodec();
|
||||||
AudioCodingModule* _acmA;
|
int32_t SetVAD(bool enableDTX, bool enableVAD, ACMVADMode vadMode);
|
||||||
AudioCodingModule* _acmB;
|
AudioCodingModule* _acmA;
|
||||||
|
AudioCodingModule* _acmB;
|
||||||
|
|
||||||
Channel* _channelA2B;
|
Channel* _channelA2B;
|
||||||
|
|
||||||
PCMFile _inFileA;
|
PCMFile _inFileA;
|
||||||
PCMFile _outFileB;
|
PCMFile _outFileB;
|
||||||
int16_t _testCntr;
|
int16_t _testCntr;
|
||||||
int _testMode;
|
int _testMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,22 +33,23 @@ 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,
|
const uint16_t payload_size,
|
||||||
const uint16_t payload_size,
|
const RTPFragmentationHeader* fragmentation) {
|
||||||
const RTPFragmentationHeader* fragmentation) {
|
|
||||||
WebRtcRTPHeader rtp_info;
|
WebRtcRTPHeader rtp_info;
|
||||||
int32_t status = 0;
|
int32_t status = 0;
|
||||||
|
|
||||||
@ -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();
|
||||||
@ -449,26 +450,26 @@ void TestStereo::Perform() {
|
|||||||
char codec_opus[] = "opus";
|
char codec_opus[] = "opus";
|
||||||
// Run Opus with 10 ms frame size.
|
// Run Opus with 10 ms frame size.
|
||||||
RegisterSendCodec('A', codec_opus, 48000, 64000, 480, codec_channels,
|
RegisterSendCodec('A', codec_opus, 48000, 64000, 480, codec_channels,
|
||||||
opus_pltype_);
|
opus_pltype_);
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
// Run Opus with 20 ms frame size.
|
// Run Opus with 20 ms frame size.
|
||||||
RegisterSendCodec('A', codec_opus, 48000, 64000, 480*2, codec_channels,
|
RegisterSendCodec('A', codec_opus, 48000, 64000, 480*2, codec_channels,
|
||||||
opus_pltype_);
|
opus_pltype_);
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
// Run Opus with 40 ms frame size.
|
// Run Opus with 40 ms frame size.
|
||||||
RegisterSendCodec('A', codec_opus, 48000, 64000, 480*4, codec_channels,
|
RegisterSendCodec('A', codec_opus, 48000, 64000, 480*4, codec_channels,
|
||||||
opus_pltype_);
|
opus_pltype_);
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
// Run Opus with 60 ms frame size.
|
// Run Opus with 60 ms frame size.
|
||||||
RegisterSendCodec('A', codec_opus, 48000, 64000, 480*6, codec_channels,
|
RegisterSendCodec('A', codec_opus, 48000, 64000, 480*6, codec_channels,
|
||||||
opus_pltype_);
|
opus_pltype_);
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
// Run Opus with 20 ms frame size and different bitrates.
|
// Run Opus with 20 ms frame size and different bitrates.
|
||||||
RegisterSendCodec('A', codec_opus, 48000, 40000, 960, codec_channels,
|
RegisterSendCodec('A', codec_opus, 48000, 40000, 960, codec_channels,
|
||||||
opus_pltype_);
|
opus_pltype_);
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
RegisterSendCodec('A', codec_opus, 48000, 510000, 960, codec_channels,
|
RegisterSendCodec('A', codec_opus, 48000, 510000, 960, codec_channels,
|
||||||
opus_pltype_);
|
opus_pltype_);
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
out_file_.Close();
|
out_file_.Close();
|
||||||
#endif
|
#endif
|
||||||
@ -488,7 +489,7 @@ void TestStereo::Perform() {
|
|||||||
channel_a2b_->set_codec_mode(kStereo);
|
channel_a2b_->set_codec_mode(kStereo);
|
||||||
OpenOutFile(test_cntr_);
|
OpenOutFile(test_cntr_);
|
||||||
RegisterSendCodec('A', codec_g722, 16000, 64000, 160, codec_channels,
|
RegisterSendCodec('A', codec_g722, 16000, 64000, 160, codec_channels,
|
||||||
g722_pltype_);
|
g722_pltype_);
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
out_file_.Close();
|
out_file_.Close();
|
||||||
#endif
|
#endif
|
||||||
@ -502,7 +503,7 @@ void TestStereo::Perform() {
|
|||||||
channel_a2b_->set_codec_mode(kStereo);
|
channel_a2b_->set_codec_mode(kStereo);
|
||||||
OpenOutFile(test_cntr_);
|
OpenOutFile(test_cntr_);
|
||||||
RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels,
|
RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels,
|
||||||
l16_8khz_pltype_);
|
l16_8khz_pltype_);
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
out_file_.Close();
|
out_file_.Close();
|
||||||
if (test_mode_ != 0) {
|
if (test_mode_ != 0) {
|
||||||
@ -513,7 +514,7 @@ void TestStereo::Perform() {
|
|||||||
test_cntr_++;
|
test_cntr_++;
|
||||||
OpenOutFile(test_cntr_);
|
OpenOutFile(test_cntr_);
|
||||||
RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels,
|
RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels,
|
||||||
l16_16khz_pltype_);
|
l16_16khz_pltype_);
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
out_file_.Close();
|
out_file_.Close();
|
||||||
if (test_mode_ != 0) {
|
if (test_mode_ != 0) {
|
||||||
@ -524,7 +525,7 @@ void TestStereo::Perform() {
|
|||||||
test_cntr_++;
|
test_cntr_++;
|
||||||
OpenOutFile(test_cntr_);
|
OpenOutFile(test_cntr_);
|
||||||
RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels,
|
RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels,
|
||||||
l16_32khz_pltype_);
|
l16_32khz_pltype_);
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
out_file_.Close();
|
out_file_.Close();
|
||||||
#endif
|
#endif
|
||||||
@ -555,7 +556,7 @@ void TestStereo::Perform() {
|
|||||||
channel_a2b_->set_codec_mode(kStereo);
|
channel_a2b_->set_codec_mode(kStereo);
|
||||||
OpenOutFile(test_cntr_);
|
OpenOutFile(test_cntr_);
|
||||||
RegisterSendCodec('A', codec_celt, 32000, 64000, 640, codec_channels,
|
RegisterSendCodec('A', codec_celt, 32000, 64000, 640, codec_channels,
|
||||||
celt_pltype_);
|
celt_pltype_);
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
out_file_.Close();
|
out_file_.Close();
|
||||||
#endif
|
#endif
|
||||||
@ -571,7 +572,7 @@ void TestStereo::Perform() {
|
|||||||
channel_a2b_->set_codec_mode(kStereo);
|
channel_a2b_->set_codec_mode(kStereo);
|
||||||
OpenOutFile(test_cntr_);
|
OpenOutFile(test_cntr_);
|
||||||
RegisterSendCodec('A', codec_opus, 48000, 64000, 960, codec_channels,
|
RegisterSendCodec('A', codec_opus, 48000, 64000, 960, codec_channels,
|
||||||
opus_pltype_);
|
opus_pltype_);
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
|
|
||||||
// Encode in mono, decode in stereo mode.
|
// Encode in mono, decode in stereo mode.
|
||||||
@ -597,8 +598,7 @@ void TestStereo::Perform() {
|
|||||||
test_cntr_++;
|
test_cntr_++;
|
||||||
OpenOutFile(test_cntr_);
|
OpenOutFile(test_cntr_);
|
||||||
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.
|
||||||
@ -619,7 +619,7 @@ void TestStereo::Perform() {
|
|||||||
test_cntr_++;
|
test_cntr_++;
|
||||||
OpenOutFile(test_cntr_);
|
OpenOutFile(test_cntr_);
|
||||||
RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels,
|
RegisterSendCodec('A', codec_l16, 8000, 128000, 80, codec_channels,
|
||||||
l16_8khz_pltype_);
|
l16_8khz_pltype_);
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
out_file_.Close();
|
out_file_.Close();
|
||||||
if (test_mode_ != 0) {
|
if (test_mode_ != 0) {
|
||||||
@ -630,18 +630,18 @@ void TestStereo::Perform() {
|
|||||||
test_cntr_++;
|
test_cntr_++;
|
||||||
OpenOutFile(test_cntr_);
|
OpenOutFile(test_cntr_);
|
||||||
RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels,
|
RegisterSendCodec('A', codec_l16, 16000, 256000, 160, codec_channels,
|
||||||
l16_16khz_pltype_);
|
l16_16khz_pltype_);
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
out_file_.Close();
|
out_file_.Close();
|
||||||
if (test_mode_ != 0) {
|
if (test_mode_ != 0) {
|
||||||
printf("==============================================================\n");
|
printf("==============================================================\n");
|
||||||
printf("Test number: %d\n", test_cntr_ + 1);
|
printf("Test number: %d\n", test_cntr_ + 1);
|
||||||
printf("Test type: Stereo-to-mono\n");
|
printf("Test type: Stereo-to-mono\n");
|
||||||
}
|
}
|
||||||
test_cntr_++;
|
test_cntr_++;
|
||||||
OpenOutFile(test_cntr_);
|
OpenOutFile(test_cntr_);
|
||||||
RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels,
|
RegisterSendCodec('A', codec_l16, 32000, 512000, 320, codec_channels,
|
||||||
l16_32khz_pltype_);
|
l16_32khz_pltype_);
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
out_file_.Close();
|
out_file_.Close();
|
||||||
#endif
|
#endif
|
||||||
@ -670,7 +670,7 @@ void TestStereo::Perform() {
|
|||||||
test_cntr_++;
|
test_cntr_++;
|
||||||
OpenOutFile(test_cntr_);
|
OpenOutFile(test_cntr_);
|
||||||
RegisterSendCodec('A', codec_celt, 32000, 64000, 640, codec_channels,
|
RegisterSendCodec('A', codec_celt, 32000, 64000, 640, codec_channels,
|
||||||
celt_pltype_);
|
celt_pltype_);
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
out_file_.Close();
|
out_file_.Close();
|
||||||
#endif
|
#endif
|
||||||
@ -684,7 +684,7 @@ void TestStereo::Perform() {
|
|||||||
OpenOutFile(test_cntr_);
|
OpenOutFile(test_cntr_);
|
||||||
// Encode and decode in mono.
|
// Encode and decode in mono.
|
||||||
RegisterSendCodec('A', codec_opus, 48000, 32000, 960, codec_channels,
|
RegisterSendCodec('A', codec_opus, 48000, 32000, 960, codec_channels,
|
||||||
opus_pltype_);
|
opus_pltype_);
|
||||||
CodecInst opus_codec_param;
|
CodecInst opus_codec_param;
|
||||||
for (uint8_t n = 0; n < num_encoders; n++) {
|
for (uint8_t n = 0; n < num_encoders; n++) {
|
||||||
EXPECT_EQ(0, acm_b_->Codec(n, &opus_codec_param));
|
EXPECT_EQ(0, acm_b_->Codec(n, &opus_codec_param));
|
||||||
@ -795,12 +795,11 @@ 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) /
|
||||||
static_cast<float>(sampling_freq_hz * 8) + 0.875);
|
static_cast<float>(sampling_freq_hz * 8) + 0.875);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set pointer to the ACM where to register the codec
|
// Set pointer to the ACM where to register the codec
|
||||||
@ -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");
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
@ -22,360 +22,324 @@
|
|||||||
|
|
||||||
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);
|
||||||
{
|
_acmA = NULL;
|
||||||
AudioCodingModule::Destroy(_acmA);
|
}
|
||||||
_acmA = NULL;
|
if (_acmB != NULL) {
|
||||||
}
|
AudioCodingModule::Destroy(_acmB);
|
||||||
if(_acmB != NULL)
|
_acmB = NULL;
|
||||||
{
|
}
|
||||||
AudioCodingModule::Destroy(_acmB);
|
if (_channelA2B != NULL) {
|
||||||
_acmB = NULL;
|
delete _channelA2B;
|
||||||
}
|
_channelA2B = NULL;
|
||||||
if(_channelA2B != NULL)
|
}
|
||||||
{
|
|
||||||
delete _channelA2B;
|
|
||||||
_channelA2B = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestVADDTX::Perform()
|
void TestVADDTX::Perform() {
|
||||||
{
|
if (_testMode == 0) {
|
||||||
if(_testMode == 0)
|
printf("Running VAD/DTX Test");
|
||||||
{
|
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1,
|
||||||
printf("Running VAD/DTX Test");
|
"---------- TestVADDTX ----------");
|
||||||
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1,
|
}
|
||||||
"---------- TestVADDTX ----------");
|
|
||||||
|
const std::string file_name = webrtc::test::ResourcePath(
|
||||||
|
"audio_coding/testfile32kHz", "pcm");
|
||||||
|
_inFileA.Open(file_name, 32000, "rb");
|
||||||
|
|
||||||
|
_acmA = AudioCodingModule::Create(0);
|
||||||
|
_acmB = AudioCodingModule::Create(1);
|
||||||
|
|
||||||
|
_acmA->InitializeReceiver();
|
||||||
|
_acmB->InitializeReceiver();
|
||||||
|
|
||||||
|
uint8_t numEncoders = _acmA->NumberOfCodecs();
|
||||||
|
CodecInst myCodecParam;
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("Registering codecs at receiver... \n");
|
||||||
|
}
|
||||||
|
for (uint8_t n = 0; n < numEncoders; n++) {
|
||||||
|
_acmB->Codec(n, &myCodecParam);
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("%s\n", myCodecParam.plname);
|
||||||
}
|
}
|
||||||
|
if (!strcmp(myCodecParam.plname, "opus")) {
|
||||||
const std::string file_name =
|
// Use mono decoding for Opus in the VAD/DTX test.
|
||||||
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
|
myCodecParam.channels = 1;
|
||||||
_inFileA.Open(file_name, 32000, "rb");
|
|
||||||
|
|
||||||
_acmA = AudioCodingModule::Create(0);
|
|
||||||
_acmB = AudioCodingModule::Create(1);
|
|
||||||
|
|
||||||
_acmA->InitializeReceiver();
|
|
||||||
_acmB->InitializeReceiver();
|
|
||||||
|
|
||||||
uint8_t numEncoders = _acmA->NumberOfCodecs();
|
|
||||||
CodecInst myCodecParam;
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("Registering codecs at receiver... \n");
|
|
||||||
}
|
|
||||||
for(uint8_t n = 0; n < numEncoders; n++)
|
|
||||||
{
|
|
||||||
_acmB->Codec(n, &myCodecParam);
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("%s\n", myCodecParam.plname);
|
|
||||||
}
|
|
||||||
if (!strcmp(myCodecParam.plname, "opus")) {
|
|
||||||
// Use mono decoding for Opus in the VAD/DTX test.
|
|
||||||
myCodecParam.channels = 1;
|
|
||||||
}
|
|
||||||
_acmB->RegisterReceiveCodec(myCodecParam);
|
|
||||||
}
|
}
|
||||||
|
_acmB->RegisterReceiveCodec(myCodecParam);
|
||||||
|
}
|
||||||
|
|
||||||
// Create and connect the channel
|
// Create and connect the channel
|
||||||
_channelA2B = new Channel;
|
_channelA2B = new Channel;
|
||||||
_acmA->RegisterTransportCallback(_channelA2B);
|
_acmA->RegisterTransportCallback(_channelA2B);
|
||||||
_channelA2B->RegisterReceiverACM(_acmB);
|
_channelA2B->RegisterReceiverACM(_acmB);
|
||||||
|
|
||||||
_acmA->RegisterVADCallback(&_monitor);
|
_acmA->RegisterVADCallback(&_monitor);
|
||||||
|
|
||||||
|
int16_t testCntr = 1;
|
||||||
int16_t testCntr = 1;
|
int16_t testResults = 0;
|
||||||
int16_t testResults = 0;
|
|
||||||
|
|
||||||
#ifdef WEBRTC_CODEC_ISAC
|
#ifdef WEBRTC_CODEC_ISAC
|
||||||
// Open outputfile
|
// Open outputfile
|
||||||
OpenOutFile(testCntr++);
|
OpenOutFile(testCntr++);
|
||||||
|
|
||||||
// Register iSAC WB as send codec
|
// Register iSAC WB as send codec
|
||||||
char nameISAC[] = "ISAC";
|
char nameISAC[] = "ISAC";
|
||||||
RegisterSendCodec('A', nameISAC, 16000);
|
RegisterSendCodec('A', nameISAC, 16000);
|
||||||
|
|
||||||
// Run the five test cased
|
// Run the five test cased
|
||||||
runTestCases();
|
runTestCases();
|
||||||
|
|
||||||
// Close file
|
// Close file
|
||||||
_outFileB.Close();
|
_outFileB.Close();
|
||||||
|
|
||||||
// Open outputfile
|
// Open outputfile
|
||||||
OpenOutFile(testCntr++);
|
OpenOutFile(testCntr++);
|
||||||
|
|
||||||
// Register iSAC SWB as send codec
|
// Register iSAC SWB as send codec
|
||||||
RegisterSendCodec('A', nameISAC, 32000);
|
RegisterSendCodec('A', nameISAC, 32000);
|
||||||
|
|
||||||
// Run the five test cased
|
// Run the five test cased
|
||||||
runTestCases();
|
runTestCases();
|
||||||
|
|
||||||
// Close file
|
// Close file
|
||||||
_outFileB.Close();
|
_outFileB.Close();
|
||||||
#endif
|
#endif
|
||||||
#ifdef WEBRTC_CODEC_ILBC
|
#ifdef WEBRTC_CODEC_ILBC
|
||||||
// Open outputfile
|
// Open outputfile
|
||||||
OpenOutFile(testCntr++);
|
OpenOutFile(testCntr++);
|
||||||
|
|
||||||
// Register iLBC as send codec
|
// Register iLBC as send codec
|
||||||
char nameILBC[] = "ilbc";
|
char nameILBC[] = "ilbc";
|
||||||
RegisterSendCodec('A', nameILBC);
|
RegisterSendCodec('A', nameILBC);
|
||||||
|
|
||||||
// Run the five test cased
|
// Run the five test cased
|
||||||
runTestCases();
|
runTestCases();
|
||||||
|
|
||||||
// Close file
|
// Close file
|
||||||
_outFileB.Close();
|
_outFileB.Close();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef WEBRTC_CODEC_OPUS
|
#ifdef WEBRTC_CODEC_OPUS
|
||||||
// Open outputfile
|
// Open outputfile
|
||||||
OpenOutFile(testCntr++);
|
OpenOutFile(testCntr++);
|
||||||
|
|
||||||
// Register Opus as send codec
|
// Register Opus as send codec
|
||||||
char nameOPUS[] = "opus";
|
char nameOPUS[] = "opus";
|
||||||
RegisterSendCodec('A', nameOPUS);
|
RegisterSendCodec('A', nameOPUS);
|
||||||
|
|
||||||
// Run the five test cased
|
// Run the five test cased
|
||||||
runTestCases();
|
runTestCases();
|
||||||
|
|
||||||
// Close file
|
// Close file
|
||||||
_outFileB.Close();
|
_outFileB.Close();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
if(_testMode) {
|
if (_testMode) {
|
||||||
printf("Done!\n");
|
printf("Done!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
_acmA->SendCodec(&myCodecParam);
|
|
||||||
printf("%s\n", myCodecParam.plname);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf(".");
|
|
||||||
}
|
|
||||||
// #1 DTX = OFF, VAD = ON, VADNormal
|
|
||||||
if(_testMode != 0)
|
|
||||||
printf("Test #1 ");
|
|
||||||
SetVAD(false, true, VADNormal);
|
|
||||||
Run();
|
|
||||||
_testResults += VerifyTest();
|
|
||||||
|
|
||||||
// #2 DTX = OFF, VAD = ON, VADAggr
|
|
||||||
if(_testMode != 0)
|
|
||||||
printf("Test #2 ");
|
|
||||||
SetVAD(false, true, VADAggr);
|
|
||||||
Run();
|
|
||||||
_testResults += VerifyTest();
|
|
||||||
|
|
||||||
// #3 DTX = ON, VAD = ON, VADLowBitrate
|
|
||||||
if(_testMode != 0)
|
|
||||||
printf("Test #3 ");
|
|
||||||
SetVAD(true, true, VADLowBitrate);
|
|
||||||
Run();
|
|
||||||
_testResults += VerifyTest();
|
|
||||||
|
|
||||||
// #4 DTX = ON, VAD = ON, VADVeryAggr
|
|
||||||
if(_testMode != 0)
|
|
||||||
printf("Test #4 ");
|
|
||||||
SetVAD(true, true, VADVeryAggr);
|
|
||||||
Run();
|
|
||||||
_testResults += VerifyTest();
|
|
||||||
|
|
||||||
// #5 DTX = ON, VAD = OFF, VADNormal
|
|
||||||
if(_testMode != 0)
|
|
||||||
printf("Test #5 ");
|
|
||||||
SetVAD(true, false, VADNormal);
|
|
||||||
Run();
|
|
||||||
_testResults += VerifyTest();
|
|
||||||
|
|
||||||
}
|
|
||||||
void TestVADDTX::runTestInternalDTX()
|
|
||||||
{
|
|
||||||
// #6 DTX = ON, VAD = ON, VADNormal
|
|
||||||
if(_testMode != 0)
|
|
||||||
printf("Test #6 ");
|
|
||||||
|
|
||||||
SetVAD(true, true, VADNormal);
|
|
||||||
if(_acmA->ReplaceInternalDTXWithWebRtc(true) < 0) {
|
|
||||||
printf("Was not able to replace DTX since CN was not registered\n");
|
|
||||||
}
|
|
||||||
Run();
|
|
||||||
_testResults += VerifyTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestVADDTX::SetVAD(bool statusDTX, bool statusVAD, int16_t vadMode)
|
|
||||||
{
|
|
||||||
bool dtxEnabled, vadEnabled;
|
|
||||||
ACMVADMode vadModeSet;
|
|
||||||
|
|
||||||
if (_acmA->SetVAD(statusDTX, statusVAD, (ACMVADMode) vadMode) < 0) {
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
if (_acmA->VAD(&dtxEnabled, &vadEnabled, &vadModeSet) < 0) {
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
if(statusDTX != dtxEnabled)
|
|
||||||
{
|
|
||||||
printf("DTX: %s not the same as requested: %s\n",
|
|
||||||
dtxEnabled? "ON":"OFF", dtxEnabled? "OFF":"ON");
|
|
||||||
}
|
|
||||||
if(((statusVAD == true) && (vadEnabled == false)) ||
|
|
||||||
((statusVAD == false) && (vadEnabled == false) &&
|
|
||||||
(statusDTX == true)))
|
|
||||||
{
|
|
||||||
printf("VAD: %s not the same as requested: %s\n",
|
|
||||||
vadEnabled? "ON":"OFF", vadEnabled? "OFF":"ON");
|
|
||||||
}
|
|
||||||
if(vadModeSet != vadMode)
|
|
||||||
{
|
|
||||||
printf("VAD mode: %d not the same as requested: %d\n",
|
|
||||||
(int16_t)vadModeSet, (int16_t)vadMode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Requested VAD/DTX settings
|
|
||||||
_setStruct.statusDTX = statusDTX;
|
|
||||||
_setStruct.statusVAD = statusVAD;
|
|
||||||
_setStruct.vadMode = (ACMVADMode) vadMode;
|
|
||||||
|
|
||||||
// VAD settings after setting VAD in ACM
|
|
||||||
_getStruct.statusDTX = dtxEnabled;
|
|
||||||
_getStruct.statusVAD = vadEnabled;
|
|
||||||
_getStruct.vadMode = vadModeSet;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
VADDTXstruct TestVADDTX::GetVAD()
|
|
||||||
{
|
|
||||||
VADDTXstruct retStruct;
|
|
||||||
bool dtxEnabled, vadEnabled;
|
|
||||||
ACMVADMode vadModeSet;
|
|
||||||
|
|
||||||
if (_acmA->VAD(&dtxEnabled, &vadEnabled, &vadModeSet) < 0) {
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
retStruct.statusDTX = dtxEnabled;
|
|
||||||
retStruct.statusVAD = vadEnabled;
|
|
||||||
retStruct.vadMode = vadModeSet;
|
|
||||||
return retStruct;
|
|
||||||
}
|
|
||||||
|
|
||||||
int16_t TestVADDTX::RegisterSendCodec(char side,
|
|
||||||
char* codecName,
|
|
||||||
int32_t samplingFreqHz,
|
|
||||||
int32_t rateKbps)
|
|
||||||
{
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("Registering %s for side %c\n", codecName, side);
|
|
||||||
}
|
|
||||||
std::cout << std::flush;
|
|
||||||
AudioCodingModule* myACM;
|
|
||||||
switch(side)
|
|
||||||
{
|
|
||||||
case 'A':
|
|
||||||
{
|
|
||||||
myACM = _acmA;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'B':
|
|
||||||
{
|
|
||||||
myACM = _acmB;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(myACM == NULL)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
CodecInst myCodecParam;
|
CodecInst myCodecParam;
|
||||||
for(int16_t codecCntr = 0; codecCntr < myACM->NumberOfCodecs();
|
_acmA->SendCodec(&myCodecParam);
|
||||||
codecCntr++)
|
printf("%s\n", myCodecParam.plname);
|
||||||
{
|
} else {
|
||||||
CHECK_ERROR(myACM->Codec((uint8_t)codecCntr, &myCodecParam));
|
printf(".");
|
||||||
if(!STR_CASE_CMP(myCodecParam.plname, codecName))
|
}
|
||||||
{
|
// #1 DTX = OFF, VAD = ON, VADNormal
|
||||||
if((samplingFreqHz == -1) || (myCodecParam.plfreq == samplingFreqHz))
|
if (_testMode != 0)
|
||||||
{
|
printf("Test #1 ");
|
||||||
if((rateKbps == -1) || (myCodecParam.rate == rateKbps))
|
SetVAD(false, true, VADNormal);
|
||||||
{
|
Run();
|
||||||
break;
|
_testResults += VerifyTest();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// We only allow VAD/DTX when sending mono.
|
// #2 DTX = OFF, VAD = ON, VADAggr
|
||||||
myCodecParam.channels = 1;
|
if (_testMode != 0)
|
||||||
CHECK_ERROR(myACM->RegisterSendCodec(myCodecParam));
|
printf("Test #2 ");
|
||||||
|
SetVAD(false, true, VADAggr);
|
||||||
|
Run();
|
||||||
|
_testResults += VerifyTest();
|
||||||
|
|
||||||
// initialization was succesful
|
// #3 DTX = ON, VAD = ON, VADLowBitrate
|
||||||
return 0;
|
if (_testMode != 0)
|
||||||
|
printf("Test #3 ");
|
||||||
|
SetVAD(true, true, VADLowBitrate);
|
||||||
|
Run();
|
||||||
|
_testResults += VerifyTest();
|
||||||
|
|
||||||
|
// #4 DTX = ON, VAD = ON, VADVeryAggr
|
||||||
|
if (_testMode != 0)
|
||||||
|
printf("Test #4 ");
|
||||||
|
SetVAD(true, true, VADVeryAggr);
|
||||||
|
Run();
|
||||||
|
_testResults += VerifyTest();
|
||||||
|
|
||||||
|
// #5 DTX = ON, VAD = OFF, VADNormal
|
||||||
|
if (_testMode != 0)
|
||||||
|
printf("Test #5 ");
|
||||||
|
SetVAD(true, false, VADNormal);
|
||||||
|
Run();
|
||||||
|
_testResults += VerifyTest();
|
||||||
|
|
||||||
|
}
|
||||||
|
void TestVADDTX::runTestInternalDTX() {
|
||||||
|
// #6 DTX = ON, VAD = ON, VADNormal
|
||||||
|
if (_testMode != 0)
|
||||||
|
printf("Test #6 ");
|
||||||
|
|
||||||
|
SetVAD(true, true, VADNormal);
|
||||||
|
if (_acmA->ReplaceInternalDTXWithWebRtc(true) < 0) {
|
||||||
|
printf("Was not able to replace DTX since CN was not registered\n");
|
||||||
|
}
|
||||||
|
Run();
|
||||||
|
_testResults += VerifyTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestVADDTX::Run()
|
void TestVADDTX::SetVAD(bool statusDTX, bool statusVAD, int16_t vadMode) {
|
||||||
{
|
bool dtxEnabled, vadEnabled;
|
||||||
AudioFrame audioFrame;
|
ACMVADMode vadModeSet;
|
||||||
|
|
||||||
uint16_t SamplesIn10MsecA = _inFileA.PayloadLength10Ms();
|
if (_acmA->SetVAD(statusDTX, statusVAD, (ACMVADMode) vadMode) < 0) {
|
||||||
uint32_t timestampA = 1;
|
assert(false);
|
||||||
int32_t outFreqHzB = _outFileB.SamplingFrequency();
|
}
|
||||||
|
if (_acmA->VAD(&dtxEnabled, &vadEnabled, &vadModeSet) < 0) {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
while(!_inFileA.EndOfFile())
|
if (_testMode != 0) {
|
||||||
{
|
if (statusDTX != dtxEnabled) {
|
||||||
_inFileA.Read10MsData(audioFrame);
|
printf("DTX: %s not the same as requested: %s\n",
|
||||||
audioFrame.timestamp_ = timestampA;
|
dtxEnabled ? "ON" : "OFF", dtxEnabled ? "OFF" : "ON");
|
||||||
timestampA += SamplesIn10MsecA;
|
|
||||||
CHECK_ERROR(_acmA->Add10MsData(audioFrame));
|
|
||||||
|
|
||||||
CHECK_ERROR(_acmA->Process());
|
|
||||||
|
|
||||||
CHECK_ERROR(_acmB->PlayoutData10Ms(outFreqHzB, &audioFrame));
|
|
||||||
_outFileB.Write10MsData(audioFrame.data_, audioFrame.samples_per_channel_);
|
|
||||||
}
|
}
|
||||||
|
if (((statusVAD == true) && (vadEnabled == false)) ||
|
||||||
|
((statusVAD == false) && (vadEnabled == false) &&
|
||||||
|
(statusDTX == true))) {
|
||||||
|
printf("VAD: %s not the same as requested: %s\n",
|
||||||
|
vadEnabled ? "ON" : "OFF", vadEnabled ? "OFF" : "ON");
|
||||||
|
}
|
||||||
|
if (vadModeSet != vadMode) {
|
||||||
|
printf("VAD mode: %d not the same as requested: %d\n",
|
||||||
|
(int16_t) vadModeSet, (int16_t) vadMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Requested VAD/DTX settings
|
||||||
|
_setStruct.statusDTX = statusDTX;
|
||||||
|
_setStruct.statusVAD = statusVAD;
|
||||||
|
_setStruct.vadMode = (ACMVADMode) vadMode;
|
||||||
|
|
||||||
|
// VAD settings after setting VAD in ACM
|
||||||
|
_getStruct.statusDTX = dtxEnabled;
|
||||||
|
_getStruct.statusVAD = vadEnabled;
|
||||||
|
_getStruct.vadMode = vadModeSet;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
VADDTXstruct TestVADDTX::GetVAD() {
|
||||||
|
VADDTXstruct retStruct;
|
||||||
|
bool dtxEnabled, vadEnabled;
|
||||||
|
ACMVADMode vadModeSet;
|
||||||
|
|
||||||
|
if (_acmA->VAD(&dtxEnabled, &vadEnabled, &vadModeSet) < 0) {
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
retStruct.statusDTX = dtxEnabled;
|
||||||
|
retStruct.statusVAD = vadEnabled;
|
||||||
|
retStruct.vadMode = vadModeSet;
|
||||||
|
return retStruct;
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t TestVADDTX::RegisterSendCodec(char side, char* codecName,
|
||||||
|
int32_t samplingFreqHz,
|
||||||
|
int32_t rateKbps) {
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("Registering %s for side %c\n", codecName, side);
|
||||||
|
}
|
||||||
|
std::cout << std::flush;
|
||||||
|
AudioCodingModule* myACM;
|
||||||
|
switch (side) {
|
||||||
|
case 'A': {
|
||||||
|
myACM = _acmA;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'B': {
|
||||||
|
myACM = _acmB;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myACM == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
CodecInst myCodecParam;
|
||||||
|
for (int16_t codecCntr = 0; codecCntr < myACM->NumberOfCodecs();
|
||||||
|
codecCntr++) {
|
||||||
|
CHECK_ERROR(myACM->Codec((uint8_t) codecCntr, &myCodecParam));
|
||||||
|
if (!STR_CASE_CMP(myCodecParam.plname, codecName)) {
|
||||||
|
if ((samplingFreqHz == -1) || (myCodecParam.plfreq == samplingFreqHz)) {
|
||||||
|
if ((rateKbps == -1) || (myCodecParam.rate == rateKbps)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We only allow VAD/DTX when sending mono.
|
||||||
|
myCodecParam.channels = 1;
|
||||||
|
CHECK_ERROR(myACM->RegisterSendCodec(myCodecParam));
|
||||||
|
|
||||||
|
// initialization was succesful
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestVADDTX::Run() {
|
||||||
|
AudioFrame audioFrame;
|
||||||
|
|
||||||
|
uint16_t SamplesIn10MsecA = _inFileA.PayloadLength10Ms();
|
||||||
|
uint32_t timestampA = 1;
|
||||||
|
int32_t outFreqHzB = _outFileB.SamplingFrequency();
|
||||||
|
|
||||||
|
while (!_inFileA.EndOfFile()) {
|
||||||
|
_inFileA.Read10MsData(audioFrame);
|
||||||
|
audioFrame.timestamp_ = timestampA;
|
||||||
|
timestampA += SamplesIn10MsecA;
|
||||||
|
CHECK_ERROR(_acmA->Add10MsData(audioFrame));
|
||||||
|
|
||||||
|
CHECK_ERROR(_acmA->Process());
|
||||||
|
|
||||||
|
CHECK_ERROR(_acmB->PlayoutData10Ms(outFreqHzB, &audioFrame));
|
||||||
|
_outFileB.Write10MsData(audioFrame.data_, audioFrame.samples_per_channel_);
|
||||||
|
}
|
||||||
#ifdef PRINT_STAT
|
#ifdef PRINT_STAT
|
||||||
_monitor.PrintStatistics(_testMode);
|
_monitor.PrintStatistics(_testMode);
|
||||||
#endif
|
#endif
|
||||||
_inFileA.Rewind();
|
_inFileA.Rewind();
|
||||||
_monitor.GetStatistics(_statCounter);
|
_monitor.GetStatistics(_statCounter);
|
||||||
_monitor.ResetStatistics();
|
_monitor.ResetStatistics();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestVADDTX::OpenOutFile(int16_t test_number) {
|
void TestVADDTX::OpenOutFile(int16_t test_number) {
|
||||||
@ -392,142 +356,133 @@ 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
|
||||||
{
|
uint8_t statusEF = 0;
|
||||||
// Verify empty frame result
|
uint8_t vadPattern = 0;
|
||||||
uint8_t statusEF = 0;
|
uint8_t emptyFramePattern[6];
|
||||||
uint8_t vadPattern = 0;
|
CodecInst myCodecParam;
|
||||||
uint8_t emptyFramePattern[6];
|
_acmA->SendCodec(&myCodecParam);
|
||||||
CodecInst myCodecParam;
|
bool dtxInUse = true;
|
||||||
_acmA->SendCodec(&myCodecParam);
|
bool isReplaced = false;
|
||||||
bool dtxInUse = true;
|
if ((STR_CASE_CMP(myCodecParam.plname, "G729") == 0)
|
||||||
bool isReplaced = false;
|
|| (STR_CASE_CMP(myCodecParam.plname, "G723") == 0)
|
||||||
if ((STR_CASE_CMP(myCodecParam.plname,"G729") == 0) ||
|
|| (STR_CASE_CMP(myCodecParam.plname, "AMR") == 0)
|
||||||
(STR_CASE_CMP(myCodecParam.plname,"G723") == 0) ||
|
|| (STR_CASE_CMP(myCodecParam.plname, "AMR-wb") == 0)
|
||||||
(STR_CASE_CMP(myCodecParam.plname,"AMR") == 0) ||
|
|| (STR_CASE_CMP(myCodecParam.plname, "speex") == 0)) {
|
||||||
(STR_CASE_CMP(myCodecParam.plname,"AMR-wb") == 0) ||
|
_acmA->IsInternalDTXReplacedWithWebRtc(&isReplaced);
|
||||||
(STR_CASE_CMP(myCodecParam.plname,"speex") == 0))
|
if (!isReplaced) {
|
||||||
{
|
dtxInUse = false;
|
||||||
_acmA->IsInternalDTXReplacedWithWebRtc(&isReplaced);
|
|
||||||
if (!isReplaced)
|
|
||||||
{
|
|
||||||
dtxInUse = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check for error in VAD/DTX settings
|
// Check for error in VAD/DTX settings
|
||||||
if (_getStruct.statusDTX != _setStruct.statusDTX){
|
if (_getStruct.statusDTX != _setStruct.statusDTX) {
|
||||||
// DTX status doesn't match expected
|
// DTX status doesn't match expected
|
||||||
vadPattern |= 4;
|
vadPattern |= 4;
|
||||||
|
}
|
||||||
|
if (_getStruct.statusDTX) {
|
||||||
|
if ((!_getStruct.statusVAD && dtxInUse)
|
||||||
|
|| (!dtxInUse && (_getStruct.statusVAD != _setStruct.statusVAD))) {
|
||||||
|
// Missmatch in VAD setting
|
||||||
|
vadPattern |= 2;
|
||||||
}
|
}
|
||||||
if (_getStruct.statusDTX){
|
} else {
|
||||||
if ((!_getStruct.statusVAD && dtxInUse) || (!dtxInUse && (_getStruct.statusVAD !=_setStruct.statusVAD)))
|
if (_getStruct.statusVAD != _setStruct.statusVAD) {
|
||||||
{
|
// VAD status doesn't match expected
|
||||||
// Missmatch in VAD setting
|
vadPattern |= 2;
|
||||||
vadPattern |= 2;
|
}
|
||||||
}
|
}
|
||||||
|
if (_getStruct.vadMode != _setStruct.vadMode) {
|
||||||
|
// VAD Mode doesn't match expected
|
||||||
|
vadPattern |= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set expected empty frame pattern
|
||||||
|
int ii;
|
||||||
|
for (ii = 0; ii < 6; ii++) {
|
||||||
|
emptyFramePattern[ii] = 0;
|
||||||
|
}
|
||||||
|
// 0 - "kNoEncoding", not important to check.
|
||||||
|
// Codecs with packetsize != 80 samples will get this output.
|
||||||
|
// 1 - "kActiveNormalEncoded", expect to receive some frames with this label .
|
||||||
|
// 2 - "kPassiveNormalEncoded".
|
||||||
|
// 3 - "kPassiveDTXNB".
|
||||||
|
// 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)
|
||||||
|
for (int ii = 1; ii < 6; ii++) {
|
||||||
|
if (emptyFramePattern[ii]) {
|
||||||
|
statusEF |= (_statCounter[ii] == 0);
|
||||||
} else {
|
} else {
|
||||||
if (_getStruct.statusVAD != _setStruct.statusVAD){
|
statusEF |= (_statCounter[ii] > 0);
|
||||||
// VAD status doesn't match expected
|
|
||||||
vadPattern |= 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (_getStruct.vadMode != _setStruct.vadMode){
|
}
|
||||||
// VAD Mode doesn't match expected
|
if ((statusEF == 0) && (vadPattern == 0)) {
|
||||||
vadPattern |= 1;
|
if (_testMode != 0) {
|
||||||
|
printf(" Test OK!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set expected empty frame pattern
|
|
||||||
int ii;
|
|
||||||
for (ii = 0; ii < 6; ii++) {
|
|
||||||
emptyFramePattern[ii] = 0;
|
|
||||||
}
|
|
||||||
emptyFramePattern[0] = 1; // "kNoEncoding", not important to check. Codecs with packetsize != 80 samples will get this output.
|
|
||||||
emptyFramePattern[1] = 1; // Expect to always receive some frames labeled "kActiveNormalEncoded"
|
|
||||||
emptyFramePattern[2] = (((!_getStruct.statusDTX && _getStruct.statusVAD) || (!dtxInUse && _getStruct.statusDTX))); // "kPassiveNormalEncoded"
|
|
||||||
emptyFramePattern[3] = ((_getStruct.statusDTX && dtxInUse && (_acmA->SendFrequency() == 8000))); // "kPassiveDTXNB"
|
|
||||||
emptyFramePattern[4] = ((_getStruct.statusDTX && dtxInUse && (_acmA->SendFrequency() == 16000))); // "kPassiveDTXWB"
|
|
||||||
emptyFramePattern[5] = ((_getStruct.statusDTX && dtxInUse && (_acmA->SendFrequency() == 32000))); // "kPassiveDTXSWB"
|
|
||||||
|
|
||||||
// Check pattern 1-5 (skip 0)
|
|
||||||
for (int ii = 1; ii < 6; ii++)
|
|
||||||
{
|
|
||||||
if (emptyFramePattern[ii])
|
|
||||||
{
|
|
||||||
statusEF |= (_statCounter[ii] == 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
statusEF |= (_statCounter[ii] > 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((statusEF == 0) && (vadPattern == 0))
|
|
||||||
{
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf(" Test OK!\n");
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (statusEF)
|
|
||||||
{
|
|
||||||
printf("\t\t\tUnexpected empty frame result!\n");
|
|
||||||
}
|
|
||||||
if (vadPattern)
|
|
||||||
{
|
|
||||||
printf("\t\t\tUnexpected SetVAD() result!\tDTX: %d\tVAD: %d\tMode: %d\n", (vadPattern >> 2) & 1, (vadPattern >> 1) & 1, vadPattern & 1);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ActivityMonitor::ActivityMonitor()
|
|
||||||
{
|
|
||||||
_counter[0] = _counter[1] = _counter[2] = _counter[3] = _counter[4] = _counter[5] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ActivityMonitor::~ActivityMonitor()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ActivityMonitor::InFrameType(int16_t frameType)
|
|
||||||
{
|
|
||||||
_counter[frameType]++;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else {
|
||||||
|
if (statusEF) {
|
||||||
void ActivityMonitor::PrintStatistics(int testMode)
|
printf("\t\t\tUnexpected empty frame result!\n");
|
||||||
{
|
|
||||||
if(testMode != 0)
|
|
||||||
{
|
|
||||||
printf("\n");
|
|
||||||
printf("kActiveNormalEncoded kPassiveNormalEncoded kPassiveDTXWB kPassiveDTXNB kPassiveDTXSWB kFrameEmpty\n");
|
|
||||||
|
|
||||||
printf("%19u", _counter[1]);
|
|
||||||
printf("%22u", _counter[2]);
|
|
||||||
printf("%14u", _counter[3]);
|
|
||||||
printf("%14u", _counter[4]);
|
|
||||||
printf("%14u", _counter[5]);
|
|
||||||
printf("%11u", _counter[0]);
|
|
||||||
|
|
||||||
printf("\n\n");
|
|
||||||
}
|
}
|
||||||
}
|
if (vadPattern) {
|
||||||
|
printf("\t\t\tUnexpected SetVAD() result!\tDTX: %d\tVAD: %d\tMode: %d\n",
|
||||||
void ActivityMonitor::ResetStatistics()
|
(vadPattern >> 2) & 1, (vadPattern >> 1) & 1, vadPattern & 1);
|
||||||
{
|
|
||||||
_counter[0] = _counter[1] = _counter[2] = _counter[3] = _counter[4] = _counter[5] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActivityMonitor::GetStatistics(uint32_t* getCounter)
|
|
||||||
{
|
|
||||||
for (int ii = 0; ii < 6; ii++)
|
|
||||||
{
|
|
||||||
getCounter[ii] = _counter[ii];
|
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
ActivityMonitor::ActivityMonitor() {
|
||||||
|
_counter[0] = _counter[1] = _counter[2] = _counter[3] = _counter[4] =
|
||||||
|
_counter[5] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActivityMonitor::~ActivityMonitor() {
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t ActivityMonitor::InFrameType(int16_t frameType) {
|
||||||
|
_counter[frameType]++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActivityMonitor::PrintStatistics(int testMode) {
|
||||||
|
if (testMode != 0) {
|
||||||
|
printf("\n");
|
||||||
|
printf("kActiveNormalEncoded kPassiveNormalEncoded kPassiveDTXWB ");
|
||||||
|
printf("kPassiveDTXNB kPassiveDTXSWB kFrameEmpty\n");
|
||||||
|
printf("%19u", _counter[1]);
|
||||||
|
printf("%22u", _counter[2]);
|
||||||
|
printf("%14u", _counter[3]);
|
||||||
|
printf("%14u", _counter[4]);
|
||||||
|
printf("%14u", _counter[5]);
|
||||||
|
printf("%11u", _counter[0]);
|
||||||
|
printf("\n\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActivityMonitor::ResetStatistics() {
|
||||||
|
_counter[0] = _counter[1] = _counter[2] = _counter[3] = _counter[4] =
|
||||||
|
_counter[5] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActivityMonitor::GetStatistics(uint32_t* getCounter) {
|
||||||
|
for (int ii = 0; ii < 6; ii++) {
|
||||||
|
getCounter[ii] = _counter[ii];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
|
@ -17,74 +17,70 @@
|
|||||||
|
|
||||||
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();
|
int32_t InFrameType(int16_t frameType);
|
||||||
int32_t InFrameType(int16_t frameType);
|
void PrintStatistics(int testMode);
|
||||||
void PrintStatistics(int testMode);
|
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,
|
||||||
{
|
// kActiveNormalEncoded,
|
||||||
kNoEncoding,
|
// kPassiveNormalEncoded,
|
||||||
kActiveNormalEncoded,
|
// kPassiveDTXNB,
|
||||||
kPassiveNormalEncoded,
|
// kPassiveDTXWB,
|
||||||
kPassiveDTXNB,
|
// kPassiveDTXSWB
|
||||||
kPassiveDTXWB,
|
// };
|
||||||
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,
|
||||||
int32_t rateKhz = -1);
|
int32_t rateKhz = -1);
|
||||||
void Run();
|
void Run();
|
||||||
void OpenOutFile(int16_t testNumber);
|
void OpenOutFile(int16_t testNumber);
|
||||||
void runTestCases();
|
void runTestCases();
|
||||||
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;
|
||||||
|
|
||||||
Channel* _channelA2B;
|
Channel* _channelA2B;
|
||||||
|
|
||||||
PCMFile _inFileA;
|
PCMFile _inFileA;
|
||||||
PCMFile _outFileB;
|
PCMFile _outFileB;
|
||||||
|
|
||||||
ActivityMonitor _monitor;
|
ActivityMonitor _monitor;
|
||||||
uint32_t _statCounter[6];
|
uint32_t _statCounter[6];
|
||||||
|
|
||||||
int _testMode;
|
int _testMode;
|
||||||
int _testResults;
|
int _testResults;
|
||||||
VADDTXstruct _setStruct;
|
VADDTXstruct _setStruct;
|
||||||
VADDTXstruct _getStruct;
|
VADDTXstruct _getStruct;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -122,7 +122,7 @@ void PopulateTests(std::vector<ACMTest*>* tests) {
|
|||||||
TEST(AudioCodingModuleTest, TestAllCodecs) {
|
TEST(AudioCodingModuleTest, TestAllCodecs) {
|
||||||
Trace::CreateTrace();
|
Trace::CreateTrace();
|
||||||
Trace::SetTraceFile((webrtc::test::OutputPath() +
|
Trace::SetTraceFile((webrtc::test::OutputPath() +
|
||||||
"acm_allcodecs_trace.txt").c_str());
|
"acm_allcodecs_trace.txt").c_str());
|
||||||
webrtc::TestAllCodecs(ACM_TEST_MODE).Perform();
|
webrtc::TestAllCodecs(ACM_TEST_MODE).Perform();
|
||||||
Trace::ReturnTrace();
|
Trace::ReturnTrace();
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ TEST(AudioCodingModuleTest, TestAllCodecs) {
|
|||||||
TEST(AudioCodingModuleTest, TestOpus) {
|
TEST(AudioCodingModuleTest, TestOpus) {
|
||||||
Trace::CreateTrace();
|
Trace::CreateTrace();
|
||||||
Trace::SetTraceFile((webrtc::test::OutputPath() +
|
Trace::SetTraceFile((webrtc::test::OutputPath() +
|
||||||
"acm_opus_trace.txt").c_str());
|
"acm_opus_trace.txt").c_str());
|
||||||
webrtc::OpusTest().Perform();
|
webrtc::OpusTest().Perform();
|
||||||
Trace::ReturnTrace();
|
Trace::ReturnTrace();
|
||||||
}
|
}
|
||||||
|
@ -12,66 +12,47 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
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) {
|
||||||
{
|
_timedTraceFile = fopen(fileName, "w");
|
||||||
if(_timedTraceFile == NULL)
|
}
|
||||||
{
|
if (_timedTraceFile == NULL) {
|
||||||
_timedTraceFile = fopen(fileName, "w");
|
return -1;
|
||||||
}
|
}
|
||||||
if(_timedTraceFile == NULL)
|
return 0;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
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);
|
||||||
{
|
double seconds = _timeEllapsedSec - minutes * 60;
|
||||||
unsigned int minutes = (uint32_t)floor(_timeEllapsedSec / 60.0);
|
//char myFormat[100] = "%8.2f, %3u:%05.2f: %s\n";
|
||||||
double seconds = _timeEllapsedSec - minutes * 60;
|
if (_timedTraceFile != NULL) {
|
||||||
//char myFormat[100] = "%8.2f, %3u:%05.2f: %s\n";
|
fprintf(_timedTraceFile, "%8.2f, %3u:%05.2f: %s\n", _timeEllapsedSec,
|
||||||
if(_timedTraceFile != NULL)
|
minutes, seconds, message);
|
||||||
{
|
}
|
||||||
fprintf(_timedTraceFile, "%8.2f, %3u:%05.2f: %s\n",
|
|
||||||
_timeEllapsedSec,
|
|
||||||
minutes,
|
|
||||||
seconds,
|
|
||||||
message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -16,22 +16,20 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
|
class TimedTrace {
|
||||||
|
public:
|
||||||
|
TimedTrace();
|
||||||
|
~TimedTrace();
|
||||||
|
|
||||||
class TimedTrace
|
void SetTimeEllapsed(double myTime);
|
||||||
{
|
double TimeEllapsed();
|
||||||
public:
|
void Tick10Msec();
|
||||||
TimedTrace();
|
int16_t SetUp(char* fileName);
|
||||||
~TimedTrace();
|
void TimedLogg(char* message);
|
||||||
|
|
||||||
void SetTimeEllapsed(double myTime);
|
private:
|
||||||
double TimeEllapsed();
|
static double _timeEllapsedSec;
|
||||||
void Tick10Msec();
|
static FILE* _timedTraceFile;
|
||||||
int16_t SetUp(char* fileName);
|
|
||||||
void TimedLogg(char* message);
|
|
||||||
|
|
||||||
private:
|
|
||||||
static double _timeEllapsedSec;
|
|
||||||
static FILE* _timedTraceFile;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,423 +30,386 @@ 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);
|
|
||||||
|
|
||||||
AudioCodingModule::Destroy(_acmRefA);
|
AudioCodingModule::Destroy(_acmRefA);
|
||||||
AudioCodingModule::Destroy(_acmRefB);
|
AudioCodingModule::Destroy(_acmRefB);
|
||||||
|
|
||||||
delete _channel_A2B;
|
delete _channel_A2B;
|
||||||
delete _channel_B2A;
|
delete _channel_B2A;
|
||||||
|
|
||||||
delete _channelRef_A2B;
|
delete _channelRef_A2B;
|
||||||
delete _channelRef_B2A;
|
delete _channelRef_B2A;
|
||||||
#ifdef WEBRTC_DTMF_DETECTION
|
#ifdef WEBRTC_DTMF_DETECTION
|
||||||
if(_dtmfDetectorA != NULL)
|
if(_dtmfDetectorA != NULL)
|
||||||
{
|
{
|
||||||
delete _dtmfDetectorA;
|
delete _dtmfDetectorA;
|
||||||
}
|
}
|
||||||
if(_dtmfDetectorB != NULL)
|
if(_dtmfDetectorB != NULL)
|
||||||
{
|
{
|
||||||
delete _dtmfDetectorB;
|
delete _dtmfDetectorB;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
_inFileA.Close();
|
_inFileA.Close();
|
||||||
_inFileB.Close();
|
_inFileB.Close();
|
||||||
_outFileA.Close();
|
_outFileA.Close();
|
||||||
_outFileB.Close();
|
_outFileB.Close();
|
||||||
_outFileRefA.Close();
|
_outFileRefA.Close();
|
||||||
_outFileRefB.Close();
|
_outFileRefB.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t TwoWayCommunication::ChooseCodec(uint8_t* codecID_A,
|
||||||
|
uint8_t* codecID_B) {
|
||||||
|
AudioCodingModule* tmpACM = AudioCodingModule::Create(0);
|
||||||
|
uint8_t noCodec = tmpACM->NumberOfCodecs();
|
||||||
|
CodecInst codecInst;
|
||||||
|
printf("List of Supported Codecs\n");
|
||||||
|
printf("========================\n");
|
||||||
|
for (uint8_t codecCntr = 0; codecCntr < noCodec; codecCntr++) {
|
||||||
|
tmpACM->Codec(codecCntr, &codecInst);
|
||||||
|
printf("%d- %s\n", codecCntr, codecInst.plname);
|
||||||
|
}
|
||||||
|
printf("\nChoose a send codec for side A [0]: ");
|
||||||
|
char myStr[15] = "";
|
||||||
|
EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL);
|
||||||
|
*codecID_A = (uint8_t) atoi(myStr);
|
||||||
|
|
||||||
uint8_t
|
printf("\nChoose a send codec for side B [0]: ");
|
||||||
TwoWayCommunication::ChooseCodec(uint8_t* codecID_A,
|
EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL);
|
||||||
uint8_t* codecID_B)
|
*codecID_B = (uint8_t) atoi(myStr);
|
||||||
{
|
|
||||||
AudioCodingModule* tmpACM = AudioCodingModule::Create(0);
|
|
||||||
uint8_t noCodec = tmpACM->NumberOfCodecs();
|
|
||||||
CodecInst codecInst;
|
|
||||||
printf("List of Supported Codecs\n");
|
|
||||||
printf("========================\n");
|
|
||||||
for(uint8_t codecCntr = 0; codecCntr < noCodec; codecCntr++)
|
|
||||||
{
|
|
||||||
tmpACM->Codec(codecCntr, &codecInst);
|
|
||||||
printf("%d- %s\n", codecCntr, codecInst.plname);
|
|
||||||
}
|
|
||||||
printf("\nChoose a send codec for side A [0]: ");
|
|
||||||
char myStr[15] = "";
|
|
||||||
EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL);
|
|
||||||
*codecID_A = (uint8_t)atoi(myStr);
|
|
||||||
|
|
||||||
printf("\nChoose a send codec for side B [0]: ");
|
AudioCodingModule::Destroy(tmpACM);
|
||||||
EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL);
|
printf("\n");
|
||||||
*codecID_B = (uint8_t)atoi(myStr);
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
AudioCodingModule::Destroy(tmpACM);
|
int16_t TwoWayCommunication::SetUp() {
|
||||||
|
_acmA = AudioCodingModule::Create(1);
|
||||||
|
_acmB = AudioCodingModule::Create(2);
|
||||||
|
|
||||||
|
_acmRefA = AudioCodingModule::Create(3);
|
||||||
|
_acmRefB = AudioCodingModule::Create(4);
|
||||||
|
|
||||||
|
uint8_t codecID_A;
|
||||||
|
uint8_t codecID_B;
|
||||||
|
|
||||||
|
ChooseCodec(&codecID_A, &codecID_B);
|
||||||
|
CodecInst codecInst_A;
|
||||||
|
CodecInst codecInst_B;
|
||||||
|
CodecInst dummyCodec;
|
||||||
|
_acmA->Codec(codecID_A, &codecInst_A);
|
||||||
|
_acmB->Codec(codecID_B, &codecInst_B);
|
||||||
|
|
||||||
|
_acmA->Codec(6, &dummyCodec);
|
||||||
|
|
||||||
|
//--- Set A codecs
|
||||||
|
CHECK_ERROR(_acmA->RegisterSendCodec(codecInst_A));
|
||||||
|
CHECK_ERROR(_acmA->RegisterReceiveCodec(codecInst_B));
|
||||||
|
#ifdef WEBRTC_DTMF_DETECTION
|
||||||
|
_dtmfDetectorA = new(DTMFDetector);
|
||||||
|
CHECK_ERROR(_acmA->RegisterIncomingMessagesCallback(_dtmfDetectorA,
|
||||||
|
ACMUSA));
|
||||||
|
#endif
|
||||||
|
//--- Set ref-A codecs
|
||||||
|
CHECK_ERROR(_acmRefA->RegisterSendCodec(codecInst_A));
|
||||||
|
CHECK_ERROR(_acmRefA->RegisterReceiveCodec(codecInst_B));
|
||||||
|
|
||||||
|
//--- Set B codecs
|
||||||
|
CHECK_ERROR(_acmB->RegisterSendCodec(codecInst_B));
|
||||||
|
CHECK_ERROR(_acmB->RegisterReceiveCodec(codecInst_A));
|
||||||
|
#ifdef WEBRTC_DTMF_DETECTION
|
||||||
|
_dtmfDetectorB = new(DTMFDetector);
|
||||||
|
CHECK_ERROR(_acmB->RegisterIncomingMessagesCallback(_dtmfDetectorB,
|
||||||
|
ACMUSA));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//--- Set ref-B codecs
|
||||||
|
CHECK_ERROR(_acmRefB->RegisterSendCodec(codecInst_B));
|
||||||
|
CHECK_ERROR(_acmRefB->RegisterReceiveCodec(codecInst_A));
|
||||||
|
|
||||||
|
uint16_t frequencyHz;
|
||||||
|
|
||||||
|
//--- Input A
|
||||||
|
std::string in_file_name = webrtc::test::ResourcePath(
|
||||||
|
"audio_coding/testfile32kHz", "pcm");
|
||||||
|
frequencyHz = 32000;
|
||||||
|
printf("Enter input file at side A [%s]: ", in_file_name.c_str());
|
||||||
|
PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz);
|
||||||
|
_inFileA.Open(in_file_name, frequencyHz, "rb");
|
||||||
|
|
||||||
|
//--- Output A
|
||||||
|
std::string out_file_a = webrtc::test::OutputPath() + "outA.pcm";
|
||||||
|
printf("Output file at side A: %s\n", out_file_a.c_str());
|
||||||
|
printf("Sampling frequency (in Hz) of the above file: %u\n", frequencyHz);
|
||||||
|
_outFileA.Open(out_file_a, frequencyHz, "wb");
|
||||||
|
std::string ref_file_name = webrtc::test::OutputPath() + "ref_outA.pcm";
|
||||||
|
_outFileRefA.Open(ref_file_name, frequencyHz, "wb");
|
||||||
|
|
||||||
|
//--- Input B
|
||||||
|
in_file_name = webrtc::test::ResourcePath("audio_coding/testfile32kHz",
|
||||||
|
"pcm");
|
||||||
|
frequencyHz = 32000;
|
||||||
|
printf("\n\nEnter input file at side B [%s]: ", in_file_name.c_str());
|
||||||
|
PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz);
|
||||||
|
_inFileB.Open(in_file_name, frequencyHz, "rb");
|
||||||
|
|
||||||
|
//--- Output B
|
||||||
|
std::string out_file_b = webrtc::test::OutputPath() + "outB.pcm";
|
||||||
|
printf("Output file at side B: %s\n", out_file_b.c_str());
|
||||||
|
printf("Sampling frequency (in Hz) of the above file: %u\n", frequencyHz);
|
||||||
|
_outFileB.Open(out_file_b, frequencyHz, "wb");
|
||||||
|
ref_file_name = webrtc::test::OutputPath() + "ref_outB.pcm";
|
||||||
|
_outFileRefB.Open(ref_file_name, frequencyHz, "wb");
|
||||||
|
|
||||||
|
//--- Set A-to-B channel
|
||||||
|
_channel_A2B = new Channel;
|
||||||
|
_acmA->RegisterTransportCallback(_channel_A2B);
|
||||||
|
_channel_A2B->RegisterReceiverACM(_acmB);
|
||||||
|
//--- Do the same for the reference
|
||||||
|
_channelRef_A2B = new Channel;
|
||||||
|
_acmRefA->RegisterTransportCallback(_channelRef_A2B);
|
||||||
|
_channelRef_A2B->RegisterReceiverACM(_acmRefB);
|
||||||
|
|
||||||
|
//--- Set B-to-A channel
|
||||||
|
_channel_B2A = new Channel;
|
||||||
|
_acmB->RegisterTransportCallback(_channel_B2A);
|
||||||
|
_channel_B2A->RegisterReceiverACM(_acmA);
|
||||||
|
//--- Do the same for reference
|
||||||
|
_channelRef_B2A = new Channel;
|
||||||
|
_acmRefB->RegisterTransportCallback(_channelRef_B2A);
|
||||||
|
_channelRef_B2A->RegisterReceiverACM(_acmRefA);
|
||||||
|
|
||||||
|
// The clicks will be more obvious when we
|
||||||
|
// are in FAX mode.
|
||||||
|
_acmB->SetPlayoutMode(fax);
|
||||||
|
_acmRefB->SetPlayoutMode(fax);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t TwoWayCommunication::SetUpAutotest() {
|
||||||
|
_acmA = AudioCodingModule::Create(1);
|
||||||
|
_acmB = AudioCodingModule::Create(2);
|
||||||
|
|
||||||
|
_acmRefA = AudioCodingModule::Create(3);
|
||||||
|
_acmRefB = AudioCodingModule::Create(4);
|
||||||
|
|
||||||
|
CodecInst codecInst_A;
|
||||||
|
CodecInst codecInst_B;
|
||||||
|
CodecInst dummyCodec;
|
||||||
|
|
||||||
|
_acmA->Codec("ISAC", &codecInst_A, 16000, 1);
|
||||||
|
_acmB->Codec("L16", &codecInst_B, 8000, 1);
|
||||||
|
_acmA->Codec(6, &dummyCodec);
|
||||||
|
|
||||||
|
//--- Set A codecs
|
||||||
|
CHECK_ERROR(_acmA->RegisterSendCodec(codecInst_A));
|
||||||
|
CHECK_ERROR(_acmA->RegisterReceiveCodec(codecInst_B));
|
||||||
|
#ifdef WEBRTC_DTMF_DETECTION
|
||||||
|
_dtmfDetectorA = new(DTMFDetector);
|
||||||
|
CHECK_ERROR(_acmA->RegisterIncomingMessagesCallback(_dtmfDetectorA,
|
||||||
|
ACMUSA));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//--- Set ref-A codecs
|
||||||
|
CHECK_ERROR(_acmRefA->RegisterSendCodec(codecInst_A));
|
||||||
|
CHECK_ERROR(_acmRefA->RegisterReceiveCodec(codecInst_B));
|
||||||
|
|
||||||
|
//--- Set B codecs
|
||||||
|
CHECK_ERROR(_acmB->RegisterSendCodec(codecInst_B));
|
||||||
|
CHECK_ERROR(_acmB->RegisterReceiveCodec(codecInst_A));
|
||||||
|
#ifdef WEBRTC_DTMF_DETECTION
|
||||||
|
_dtmfDetectorB = new(DTMFDetector);
|
||||||
|
CHECK_ERROR(_acmB->RegisterIncomingMessagesCallback(_dtmfDetectorB,
|
||||||
|
ACMUSA));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//--- Set ref-B codecs
|
||||||
|
CHECK_ERROR(_acmRefB->RegisterSendCodec(codecInst_B));
|
||||||
|
CHECK_ERROR(_acmRefB->RegisterReceiveCodec(codecInst_A));
|
||||||
|
|
||||||
|
uint16_t frequencyHz;
|
||||||
|
|
||||||
|
//--- Input A and B
|
||||||
|
std::string in_file_name = webrtc::test::ResourcePath(
|
||||||
|
"audio_coding/testfile32kHz", "pcm");
|
||||||
|
frequencyHz = 16000;
|
||||||
|
_inFileA.Open(in_file_name, frequencyHz, "rb");
|
||||||
|
_inFileB.Open(in_file_name, frequencyHz, "rb");
|
||||||
|
|
||||||
|
//--- Output A
|
||||||
|
std::string output_file_a = webrtc::test::OutputPath() + "outAutotestA.pcm";
|
||||||
|
frequencyHz = 16000;
|
||||||
|
_outFileA.Open(output_file_a, frequencyHz, "wb");
|
||||||
|
std::string output_ref_file_a = webrtc::test::OutputPath()
|
||||||
|
+ "ref_outAutotestA.pcm";
|
||||||
|
_outFileRefA.Open(output_ref_file_a, frequencyHz, "wb");
|
||||||
|
|
||||||
|
//--- Output B
|
||||||
|
std::string output_file_b = webrtc::test::OutputPath() + "outAutotestB.pcm";
|
||||||
|
frequencyHz = 16000;
|
||||||
|
_outFileB.Open(output_file_b, frequencyHz, "wb");
|
||||||
|
std::string output_ref_file_b = webrtc::test::OutputPath()
|
||||||
|
+ "ref_outAutotestB.pcm";
|
||||||
|
_outFileRefB.Open(output_ref_file_b, frequencyHz, "wb");
|
||||||
|
|
||||||
|
//--- Set A-to-B channel
|
||||||
|
_channel_A2B = new Channel;
|
||||||
|
_acmA->RegisterTransportCallback(_channel_A2B);
|
||||||
|
_channel_A2B->RegisterReceiverACM(_acmB);
|
||||||
|
//--- Do the same for the reference
|
||||||
|
_channelRef_A2B = new Channel;
|
||||||
|
_acmRefA->RegisterTransportCallback(_channelRef_A2B);
|
||||||
|
_channelRef_A2B->RegisterReceiverACM(_acmRefB);
|
||||||
|
|
||||||
|
//--- Set B-to-A channel
|
||||||
|
_channel_B2A = new Channel;
|
||||||
|
_acmB->RegisterTransportCallback(_channel_B2A);
|
||||||
|
_channel_B2A->RegisterReceiverACM(_acmA);
|
||||||
|
//--- Do the same for reference
|
||||||
|
_channelRef_B2A = new Channel;
|
||||||
|
_acmRefB->RegisterTransportCallback(_channelRef_B2A);
|
||||||
|
_channelRef_B2A->RegisterReceiverACM(_acmRefA);
|
||||||
|
|
||||||
|
// The clicks will be more obvious when we
|
||||||
|
// are in FAX mode.
|
||||||
|
_acmB->SetPlayoutMode(fax);
|
||||||
|
_acmRefB->SetPlayoutMode(fax);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TwoWayCommunication::Perform() {
|
||||||
|
if (_testMode == 0) {
|
||||||
|
printf("Running TwoWayCommunication Test");
|
||||||
|
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
|
||||||
|
"---------- TwoWayCommunication ----------");
|
||||||
|
SetUpAutotest();
|
||||||
|
} else {
|
||||||
|
SetUp();
|
||||||
|
}
|
||||||
|
unsigned int msecPassed = 0;
|
||||||
|
unsigned int secPassed = 0;
|
||||||
|
|
||||||
|
int32_t outFreqHzA = _outFileA.SamplingFrequency();
|
||||||
|
int32_t outFreqHzB = _outFileB.SamplingFrequency();
|
||||||
|
|
||||||
|
AudioFrame audioFrame;
|
||||||
|
|
||||||
|
CodecInst codecInst_B;
|
||||||
|
CodecInst dummy;
|
||||||
|
|
||||||
|
_acmB->SendCodec(&codecInst_B);
|
||||||
|
|
||||||
|
if (_testMode != 0) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
return 0;
|
printf("sec:msec A B\n");
|
||||||
}
|
printf("-------- ----- -----\n");
|
||||||
|
}
|
||||||
|
|
||||||
int16_t TwoWayCommunication::SetUp()
|
while (!_inFileA.EndOfFile() && !_inFileB.EndOfFile()) {
|
||||||
{
|
_inFileA.Read10MsData(audioFrame);
|
||||||
_acmA = AudioCodingModule::Create(1);
|
_acmA->Add10MsData(audioFrame);
|
||||||
_acmB = AudioCodingModule::Create(2);
|
_acmRefA->Add10MsData(audioFrame);
|
||||||
|
|
||||||
_acmRefA = AudioCodingModule::Create(3);
|
_inFileB.Read10MsData(audioFrame);
|
||||||
_acmRefB = AudioCodingModule::Create(4);
|
_acmB->Add10MsData(audioFrame);
|
||||||
|
_acmRefB->Add10MsData(audioFrame);
|
||||||
|
|
||||||
uint8_t codecID_A;
|
_acmA->Process();
|
||||||
uint8_t codecID_B;
|
_acmB->Process();
|
||||||
|
_acmRefA->Process();
|
||||||
|
_acmRefB->Process();
|
||||||
|
|
||||||
ChooseCodec(&codecID_A, &codecID_B);
|
_acmA->PlayoutData10Ms(outFreqHzA, &audioFrame);
|
||||||
CodecInst codecInst_A;
|
_outFileA.Write10MsData(audioFrame);
|
||||||
CodecInst codecInst_B;
|
|
||||||
CodecInst dummyCodec;
|
|
||||||
_acmA->Codec(codecID_A, &codecInst_A);
|
|
||||||
_acmB->Codec(codecID_B, &codecInst_B);
|
|
||||||
|
|
||||||
_acmA->Codec(6, &dummyCodec);
|
_acmRefA->PlayoutData10Ms(outFreqHzA, &audioFrame);
|
||||||
|
_outFileRefA.Write10MsData(audioFrame);
|
||||||
|
|
||||||
//--- Set A codecs
|
_acmB->PlayoutData10Ms(outFreqHzB, &audioFrame);
|
||||||
CHECK_ERROR(_acmA->RegisterSendCodec(codecInst_A));
|
_outFileB.Write10MsData(audioFrame);
|
||||||
CHECK_ERROR(_acmA->RegisterReceiveCodec(codecInst_B));
|
|
||||||
#ifdef WEBRTC_DTMF_DETECTION
|
|
||||||
_dtmfDetectorA = new(DTMFDetector);
|
|
||||||
CHECK_ERROR(_acmA->RegisterIncomingMessagesCallback(_dtmfDetectorA,
|
|
||||||
ACMUSA));
|
|
||||||
#endif
|
|
||||||
//--- Set ref-A codecs
|
|
||||||
CHECK_ERROR(_acmRefA->RegisterSendCodec(codecInst_A));
|
|
||||||
CHECK_ERROR(_acmRefA->RegisterReceiveCodec(codecInst_B));
|
|
||||||
|
|
||||||
//--- Set B codecs
|
_acmRefB->PlayoutData10Ms(outFreqHzB, &audioFrame);
|
||||||
CHECK_ERROR(_acmB->RegisterSendCodec(codecInst_B));
|
_outFileRefB.Write10MsData(audioFrame);
|
||||||
CHECK_ERROR(_acmB->RegisterReceiveCodec(codecInst_A));
|
|
||||||
#ifdef WEBRTC_DTMF_DETECTION
|
|
||||||
_dtmfDetectorB = new(DTMFDetector);
|
|
||||||
CHECK_ERROR(_acmB->RegisterIncomingMessagesCallback(_dtmfDetectorB,
|
|
||||||
ACMUSA));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//--- Set ref-B codecs
|
msecPassed += 10;
|
||||||
CHECK_ERROR(_acmRefB->RegisterSendCodec(codecInst_B));
|
if (msecPassed >= 1000) {
|
||||||
CHECK_ERROR(_acmRefB->RegisterReceiveCodec(codecInst_A));
|
msecPassed = 0;
|
||||||
|
secPassed++;
|
||||||
uint16_t frequencyHz;
|
}
|
||||||
|
if (((secPassed % 5) == 4) && (msecPassed == 0)) {
|
||||||
//--- Input A
|
if (_testMode != 0) {
|
||||||
std::string in_file_name =
|
printf("%3u:%3u ", secPassed, msecPassed);
|
||||||
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
|
}
|
||||||
frequencyHz = 32000;
|
_acmA->ResetEncoder();
|
||||||
printf("Enter input file at side A [%s]: ", in_file_name.c_str());
|
if (_testMode == 0) {
|
||||||
PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz);
|
|
||||||
_inFileA.Open(in_file_name, frequencyHz, "rb");
|
|
||||||
|
|
||||||
//--- Output A
|
|
||||||
std::string out_file_a = webrtc::test::OutputPath() + "outA.pcm";
|
|
||||||
printf("Output file at side A: %s\n", out_file_a.c_str());
|
|
||||||
printf("Sampling frequency (in Hz) of the above file: %u\n",
|
|
||||||
frequencyHz);
|
|
||||||
_outFileA.Open(out_file_a, frequencyHz, "wb");
|
|
||||||
std::string ref_file_name = webrtc::test::OutputPath() + "ref_outA.pcm";
|
|
||||||
_outFileRefA.Open(ref_file_name, frequencyHz, "wb");
|
|
||||||
|
|
||||||
//--- Input B
|
|
||||||
in_file_name =
|
|
||||||
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
|
|
||||||
frequencyHz = 32000;
|
|
||||||
printf("\n\nEnter input file at side B [%s]: ", in_file_name.c_str());
|
|
||||||
PCMFile::ChooseFile(&in_file_name, 499, &frequencyHz);
|
|
||||||
_inFileB.Open(in_file_name, frequencyHz, "rb");
|
|
||||||
|
|
||||||
//--- Output B
|
|
||||||
std::string out_file_b = webrtc::test::OutputPath() + "outB.pcm";
|
|
||||||
printf("Output file at side B: %s\n", out_file_b.c_str());
|
|
||||||
printf("Sampling frequency (in Hz) of the above file: %u\n",
|
|
||||||
frequencyHz);
|
|
||||||
_outFileB.Open(out_file_b, frequencyHz, "wb");
|
|
||||||
ref_file_name = webrtc::test::OutputPath() + "ref_outB.pcm";
|
|
||||||
_outFileRefB.Open(ref_file_name, frequencyHz, "wb");
|
|
||||||
|
|
||||||
//--- Set A-to-B channel
|
|
||||||
_channel_A2B = new Channel;
|
|
||||||
_acmA->RegisterTransportCallback(_channel_A2B);
|
|
||||||
_channel_A2B->RegisterReceiverACM(_acmB);
|
|
||||||
//--- Do the same for the reference
|
|
||||||
_channelRef_A2B = new Channel;
|
|
||||||
_acmRefA->RegisterTransportCallback(_channelRef_A2B);
|
|
||||||
_channelRef_A2B->RegisterReceiverACM(_acmRefB);
|
|
||||||
|
|
||||||
//--- Set B-to-A channel
|
|
||||||
_channel_B2A = new Channel;
|
|
||||||
_acmB->RegisterTransportCallback(_channel_B2A);
|
|
||||||
_channel_B2A->RegisterReceiverACM(_acmA);
|
|
||||||
//--- Do the same for reference
|
|
||||||
_channelRef_B2A = new Channel;
|
|
||||||
_acmRefB->RegisterTransportCallback(_channelRef_B2A);
|
|
||||||
_channelRef_B2A->RegisterReceiverACM(_acmRefA);
|
|
||||||
|
|
||||||
// The clicks will be more obvious when we
|
|
||||||
// are in FAX mode.
|
|
||||||
_acmB->SetPlayoutMode(fax);
|
|
||||||
_acmRefB->SetPlayoutMode(fax);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int16_t TwoWayCommunication::SetUpAutotest()
|
|
||||||
{
|
|
||||||
_acmA = AudioCodingModule::Create(1);
|
|
||||||
_acmB = AudioCodingModule::Create(2);
|
|
||||||
|
|
||||||
_acmRefA = AudioCodingModule::Create(3);
|
|
||||||
_acmRefB = AudioCodingModule::Create(4);
|
|
||||||
|
|
||||||
CodecInst codecInst_A;
|
|
||||||
CodecInst codecInst_B;
|
|
||||||
CodecInst dummyCodec;
|
|
||||||
|
|
||||||
_acmA->Codec("ISAC", &codecInst_A, 16000, 1);
|
|
||||||
_acmB->Codec("L16", &codecInst_B, 8000, 1);
|
|
||||||
_acmA->Codec(6, &dummyCodec);
|
|
||||||
|
|
||||||
//--- Set A codecs
|
|
||||||
CHECK_ERROR(_acmA->RegisterSendCodec(codecInst_A));
|
|
||||||
CHECK_ERROR(_acmA->RegisterReceiveCodec(codecInst_B));
|
|
||||||
#ifdef WEBRTC_DTMF_DETECTION
|
|
||||||
_dtmfDetectorA = new(DTMFDetector);
|
|
||||||
CHECK_ERROR(_acmA->RegisterIncomingMessagesCallback(_dtmfDetectorA,
|
|
||||||
ACMUSA));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//--- Set ref-A codecs
|
|
||||||
CHECK_ERROR(_acmRefA->RegisterSendCodec(codecInst_A));
|
|
||||||
CHECK_ERROR(_acmRefA->RegisterReceiveCodec(codecInst_B));
|
|
||||||
|
|
||||||
//--- Set B codecs
|
|
||||||
CHECK_ERROR(_acmB->RegisterSendCodec(codecInst_B));
|
|
||||||
CHECK_ERROR(_acmB->RegisterReceiveCodec(codecInst_A));
|
|
||||||
#ifdef WEBRTC_DTMF_DETECTION
|
|
||||||
_dtmfDetectorB = new(DTMFDetector);
|
|
||||||
CHECK_ERROR(_acmB->RegisterIncomingMessagesCallback(_dtmfDetectorB,
|
|
||||||
ACMUSA));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//--- Set ref-B codecs
|
|
||||||
CHECK_ERROR(_acmRefB->RegisterSendCodec(codecInst_B));
|
|
||||||
CHECK_ERROR(_acmRefB->RegisterReceiveCodec(codecInst_A));
|
|
||||||
|
|
||||||
uint16_t frequencyHz;
|
|
||||||
|
|
||||||
//--- Input A and B
|
|
||||||
std::string in_file_name =
|
|
||||||
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
|
|
||||||
frequencyHz = 16000;
|
|
||||||
_inFileA.Open(in_file_name, frequencyHz, "rb");
|
|
||||||
_inFileB.Open(in_file_name, frequencyHz, "rb");
|
|
||||||
|
|
||||||
//--- Output A
|
|
||||||
std::string output_file_a = webrtc::test::OutputPath() + "outAutotestA.pcm";
|
|
||||||
frequencyHz = 16000;
|
|
||||||
_outFileA.Open(output_file_a, frequencyHz, "wb");
|
|
||||||
std::string output_ref_file_a = webrtc::test::OutputPath() +
|
|
||||||
"ref_outAutotestA.pcm";
|
|
||||||
_outFileRefA.Open(output_ref_file_a, frequencyHz, "wb");
|
|
||||||
|
|
||||||
//--- Output B
|
|
||||||
std::string output_file_b = webrtc::test::OutputPath() + "outAutotestB.pcm";
|
|
||||||
frequencyHz = 16000;
|
|
||||||
_outFileB.Open(output_file_b, frequencyHz, "wb");
|
|
||||||
std::string output_ref_file_b = webrtc::test::OutputPath() +
|
|
||||||
"ref_outAutotestB.pcm";
|
|
||||||
_outFileRefB.Open(output_ref_file_b, frequencyHz, "wb");
|
|
||||||
|
|
||||||
//--- Set A-to-B channel
|
|
||||||
_channel_A2B = new Channel;
|
|
||||||
_acmA->RegisterTransportCallback(_channel_A2B);
|
|
||||||
_channel_A2B->RegisterReceiverACM(_acmB);
|
|
||||||
//--- Do the same for the reference
|
|
||||||
_channelRef_A2B = new Channel;
|
|
||||||
_acmRefA->RegisterTransportCallback(_channelRef_A2B);
|
|
||||||
_channelRef_A2B->RegisterReceiverACM(_acmRefB);
|
|
||||||
|
|
||||||
//--- Set B-to-A channel
|
|
||||||
_channel_B2A = new Channel;
|
|
||||||
_acmB->RegisterTransportCallback(_channel_B2A);
|
|
||||||
_channel_B2A->RegisterReceiverACM(_acmA);
|
|
||||||
//--- Do the same for reference
|
|
||||||
_channelRef_B2A = new Channel;
|
|
||||||
_acmRefB->RegisterTransportCallback(_channelRef_B2A);
|
|
||||||
_channelRef_B2A->RegisterReceiverACM(_acmRefA);
|
|
||||||
|
|
||||||
// The clicks will be more obvious when we
|
|
||||||
// are in FAX mode.
|
|
||||||
_acmB->SetPlayoutMode(fax);
|
|
||||||
_acmRefB->SetPlayoutMode(fax);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TwoWayCommunication::Perform()
|
|
||||||
{
|
|
||||||
if(_testMode == 0)
|
|
||||||
{
|
|
||||||
printf("Running TwoWayCommunication Test");
|
|
||||||
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
|
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
|
||||||
"---------- TwoWayCommunication ----------");
|
"---------- Errors expected");
|
||||||
SetUpAutotest();
|
printf(".");
|
||||||
|
} else {
|
||||||
|
printf("Reset Encoder (click in side B) ");
|
||||||
|
printf("Initialize Sender (no audio in side A)\n");
|
||||||
|
}
|
||||||
|
CHECK_ERROR(_acmB->InitializeSender());
|
||||||
}
|
}
|
||||||
else
|
if (((secPassed % 5) == 4) && (msecPassed >= 990)) {
|
||||||
{
|
if (_testMode == 0) {
|
||||||
SetUp();
|
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
|
||||||
|
"----- END: Errors expected");
|
||||||
|
printf(".");
|
||||||
|
} else {
|
||||||
|
printf("%3u:%3u ", secPassed, msecPassed);
|
||||||
|
printf(" ");
|
||||||
|
printf("Register Send Codec (audio back in side A)\n");
|
||||||
|
}
|
||||||
|
CHECK_ERROR(_acmB->RegisterSendCodec(codecInst_B));
|
||||||
|
CHECK_ERROR(_acmB->SendCodec(&dummy));
|
||||||
}
|
}
|
||||||
unsigned int msecPassed = 0;
|
if (((secPassed % 7) == 6) && (msecPassed == 0)) {
|
||||||
unsigned int secPassed = 0;
|
CHECK_ERROR(_acmB->ResetDecoder());
|
||||||
|
if (_testMode == 0) {
|
||||||
int32_t outFreqHzA = _outFileA.SamplingFrequency();
|
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
|
||||||
int32_t outFreqHzB = _outFileB.SamplingFrequency();
|
"---------- Errors expected");
|
||||||
|
printf(".");
|
||||||
AudioFrame audioFrame;
|
} else {
|
||||||
|
printf("%3u:%3u ", secPassed, msecPassed);
|
||||||
CodecInst codecInst_B;
|
printf("Initialize Receiver (no audio in side A) ");
|
||||||
CodecInst dummy;
|
printf("Reset Decoder\n");
|
||||||
|
}
|
||||||
_acmB->SendCodec(&codecInst_B);
|
CHECK_ERROR(_acmA->InitializeReceiver());
|
||||||
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("\n");
|
|
||||||
printf("sec:msec A B\n");
|
|
||||||
printf("-------- ----- -----\n");
|
|
||||||
}
|
}
|
||||||
|
if (((secPassed % 7) == 6) && (msecPassed >= 990)) {
|
||||||
while(!_inFileA.EndOfFile() && !_inFileB.EndOfFile())
|
if (_testMode == 0) {
|
||||||
{
|
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
|
||||||
_inFileA.Read10MsData(audioFrame);
|
"----- END: Errors expected");
|
||||||
_acmA->Add10MsData(audioFrame);
|
printf(".");
|
||||||
_acmRefA->Add10MsData(audioFrame);
|
} else {
|
||||||
|
printf("%3u:%3u ", secPassed, msecPassed);
|
||||||
_inFileB.Read10MsData(audioFrame);
|
printf("Register Receive Coded (audio back in side A)\n");
|
||||||
_acmB->Add10MsData(audioFrame);
|
}
|
||||||
_acmRefB->Add10MsData(audioFrame);
|
CHECK_ERROR(_acmA->RegisterReceiveCodec(codecInst_B));
|
||||||
|
|
||||||
|
|
||||||
_acmA->Process();
|
|
||||||
_acmB->Process();
|
|
||||||
_acmRefA->Process();
|
|
||||||
_acmRefB->Process();
|
|
||||||
|
|
||||||
_acmA->PlayoutData10Ms(outFreqHzA, &audioFrame);
|
|
||||||
_outFileA.Write10MsData(audioFrame);
|
|
||||||
|
|
||||||
_acmRefA->PlayoutData10Ms(outFreqHzA, &audioFrame);
|
|
||||||
_outFileRefA.Write10MsData(audioFrame);
|
|
||||||
|
|
||||||
_acmB->PlayoutData10Ms(outFreqHzB, &audioFrame);
|
|
||||||
_outFileB.Write10MsData(audioFrame);
|
|
||||||
|
|
||||||
_acmRefB->PlayoutData10Ms(outFreqHzB, &audioFrame);
|
|
||||||
_outFileRefB.Write10MsData(audioFrame);
|
|
||||||
|
|
||||||
msecPassed += 10;
|
|
||||||
if(msecPassed >= 1000)
|
|
||||||
{
|
|
||||||
msecPassed = 0;
|
|
||||||
secPassed++;
|
|
||||||
}
|
|
||||||
if(((secPassed%5) == 4) && (msecPassed == 0))
|
|
||||||
{
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("%3u:%3u ", secPassed, msecPassed);
|
|
||||||
}
|
|
||||||
_acmA->ResetEncoder();
|
|
||||||
if(_testMode == 0)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
|
|
||||||
"---------- Errors expected");
|
|
||||||
printf(".");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Reset Encoder (click in side B) ");
|
|
||||||
printf("Initialize Sender (no audio in side A)\n");
|
|
||||||
}
|
|
||||||
CHECK_ERROR(_acmB->InitializeSender());
|
|
||||||
}
|
|
||||||
if(((secPassed%5) == 4) && (msecPassed >= 990))
|
|
||||||
{
|
|
||||||
if(_testMode == 0)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
|
|
||||||
"----- END: Errors expected");
|
|
||||||
printf(".");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("%3u:%3u ", secPassed, msecPassed);
|
|
||||||
printf(" ");
|
|
||||||
printf("Register Send Codec (audio back in side A)\n");
|
|
||||||
}
|
|
||||||
CHECK_ERROR(_acmB->RegisterSendCodec(codecInst_B));
|
|
||||||
CHECK_ERROR(_acmB->SendCodec(&dummy));
|
|
||||||
}
|
|
||||||
if(((secPassed%7) == 6) && (msecPassed == 0))
|
|
||||||
{
|
|
||||||
CHECK_ERROR(_acmB->ResetDecoder());
|
|
||||||
if(_testMode == 0)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
|
|
||||||
"---------- Errors expected");
|
|
||||||
printf(".");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("%3u:%3u ", secPassed, msecPassed);
|
|
||||||
printf("Initialize Receiver (no audio in side A) ");
|
|
||||||
printf("Reset Decoder\n");
|
|
||||||
}
|
|
||||||
CHECK_ERROR(_acmA->InitializeReceiver());
|
|
||||||
}
|
|
||||||
if(((secPassed%7) == 6) && (msecPassed >= 990))
|
|
||||||
{
|
|
||||||
if(_testMode == 0)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1,
|
|
||||||
"----- END: Errors expected");
|
|
||||||
printf(".");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("%3u:%3u ", secPassed, msecPassed);
|
|
||||||
printf("Register Receive Coded (audio back in side A)\n");
|
|
||||||
}
|
|
||||||
CHECK_ERROR(_acmA->RegisterReceiveCodec(codecInst_B));
|
|
||||||
}
|
|
||||||
//Sleep(9);
|
|
||||||
}
|
|
||||||
if(_testMode == 0)
|
|
||||||
{
|
|
||||||
printf("Done!\n");
|
|
||||||
}
|
}
|
||||||
|
//Sleep(9);
|
||||||
|
}
|
||||||
|
if (_testMode == 0) {
|
||||||
|
printf("Done!\n");
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WEBRTC_DTMF_DETECTION
|
#ifdef WEBRTC_DTMF_DETECTION
|
||||||
printf("\nDTMF at Side A\n");
|
printf("\nDTMF at Side A\n");
|
||||||
_dtmfDetectorA->PrintDetectedDigits();
|
_dtmfDetectorA->PrintDetectedDigits();
|
||||||
|
|
||||||
printf("\nDTMF at Side B\n");
|
printf("\nDTMF at Side B\n");
|
||||||
_dtmfDetectorB->PrintDetectedDigits();
|
_dtmfDetectorB->PrintDetectedDigits();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -19,42 +19,41 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class TwoWayCommunication : public ACMTest
|
class TwoWayCommunication : public ACMTest {
|
||||||
{
|
public:
|
||||||
public:
|
TwoWayCommunication(int testMode = 1);
|
||||||
TwoWayCommunication(int testMode = 1);
|
~TwoWayCommunication();
|
||||||
~TwoWayCommunication();
|
|
||||||
|
|
||||||
void Perform();
|
void Perform();
|
||||||
private:
|
private:
|
||||||
uint8_t ChooseCodec(uint8_t* codecID_A, uint8_t* codecID_B);
|
uint8_t ChooseCodec(uint8_t* codecID_A, uint8_t* codecID_B);
|
||||||
int16_t SetUp();
|
int16_t SetUp();
|
||||||
int16_t SetUpAutotest();
|
int16_t SetUpAutotest();
|
||||||
|
|
||||||
AudioCodingModule* _acmA;
|
AudioCodingModule* _acmA;
|
||||||
AudioCodingModule* _acmB;
|
AudioCodingModule* _acmB;
|
||||||
|
|
||||||
AudioCodingModule* _acmRefA;
|
AudioCodingModule* _acmRefA;
|
||||||
AudioCodingModule* _acmRefB;
|
AudioCodingModule* _acmRefB;
|
||||||
|
|
||||||
Channel* _channel_A2B;
|
Channel* _channel_A2B;
|
||||||
Channel* _channel_B2A;
|
Channel* _channel_B2A;
|
||||||
|
|
||||||
Channel* _channelRef_A2B;
|
Channel* _channelRef_A2B;
|
||||||
Channel* _channelRef_B2A;
|
Channel* _channelRef_B2A;
|
||||||
|
|
||||||
PCMFile _inFileA;
|
PCMFile _inFileA;
|
||||||
PCMFile _inFileB;
|
PCMFile _inFileB;
|
||||||
|
|
||||||
PCMFile _outFileA;
|
PCMFile _outFileA;
|
||||||
PCMFile _outFileB;
|
PCMFile _outFileB;
|
||||||
|
|
||||||
PCMFile _outFileRefA;
|
PCMFile _outFileRefA;
|
||||||
PCMFile _outFileRefB;
|
PCMFile _outFileRefB;
|
||||||
|
|
||||||
int _testMode;
|
int _testMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -63,25 +63,24 @@ class DelayTest {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
DelayTest()
|
DelayTest()
|
||||||
: acm_a_(NULL),
|
: acm_a_(NULL),
|
||||||
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() {}
|
||||||
|
|
||||||
void TearDown() {
|
void TearDown() {
|
||||||
if(acm_a_ != NULL) {
|
if (acm_a_ != NULL) {
|
||||||
AudioCodingModule::Destroy(acm_a_);
|
AudioCodingModule::Destroy(acm_a_);
|
||||||
acm_a_ = NULL;
|
acm_a_ = NULL;
|
||||||
}
|
}
|
||||||
if(acm_b_ != NULL) {
|
if (acm_b_ != NULL) {
|
||||||
AudioCodingModule::Destroy(acm_b_);
|
AudioCodingModule::Destroy(acm_b_);
|
||||||
acm_b_ = NULL;
|
acm_b_ = NULL;
|
||||||
}
|
}
|
||||||
if(channel_a2b_ != NULL) {
|
if (channel_a2b_ != NULL) {
|
||||||
delete channel_a2b_;
|
delete channel_a2b_;
|
||||||
channel_a2b_ = NULL;
|
channel_a2b_ = NULL;
|
||||||
}
|
}
|
||||||
@ -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");
|
||||||
@ -108,15 +107,15 @@ class DelayTest {
|
|||||||
|
|
||||||
uint8_t num_encoders = acm_a_->NumberOfCodecs();
|
uint8_t num_encoders = acm_a_->NumberOfCodecs();
|
||||||
CodecInst my_codec_param;
|
CodecInst my_codec_param;
|
||||||
for(int n = 0; n < num_encoders; n++) {
|
for (int n = 0; n < num_encoders; n++) {
|
||||||
acm_b_->Codec(n, &my_codec_param);
|
acm_b_->Codec(n, &my_codec_param);
|
||||||
if (STR_CASE_CMP(my_codec_param.plname, "opus") == 0)
|
if (STR_CASE_CMP(my_codec_param.plname, "opus") == 0)
|
||||||
my_codec_param.channels = 1;
|
my_codec_param.channels = 1;
|
||||||
else if (my_codec_param.channels > 1)
|
else if (my_codec_param.channels > 1)
|
||||||
continue;
|
continue;
|
||||||
if (STR_CASE_CMP(my_codec_param.plname, "CN") == 0 &&
|
if (STR_CASE_CMP(my_codec_param.plname, "CN") == 0 &&
|
||||||
my_codec_param.plfreq == 48000)
|
my_codec_param.plfreq == 48000)
|
||||||
continue;
|
continue;
|
||||||
if (STR_CASE_CMP(my_codec_param.plname, "telephone-event") == 0)
|
if (STR_CASE_CMP(my_codec_param.plname, "telephone-event") == 0)
|
||||||
continue;
|
continue;
|
||||||
acm_b_->RegisterReceiveCodec(my_codec_param);
|
acm_b_->RegisterReceiveCodec(my_codec_param);
|
||||||
@ -141,14 +140,13 @@ class DelayTest {
|
|||||||
void ApplyConfig(const Config& config) {
|
void ApplyConfig(const Config& config) {
|
||||||
printf("====================================\n");
|
printf("====================================\n");
|
||||||
printf("Test %d \n"
|
printf("Test %d \n"
|
||||||
"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");
|
|
||||||
SendCodec(config.codec);
|
SendCodec(config.codec);
|
||||||
ConfigAcm(config.acm);
|
ConfigAcm(config.acm);
|
||||||
ConfigChannel(config.packet_loss);
|
ConfigChannel(config.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,11 +173,9 @@ 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_"
|
std::cout << "Output file: " << file_stream.str() << std::endl << std::endl;
|
||||||
<< FLAGS_delay << "ms.pcm";
|
|
||||||
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");
|
||||||
}
|
}
|
||||||
@ -194,7 +191,7 @@ class DelayTest {
|
|||||||
uint32_t received_ts;
|
uint32_t received_ts;
|
||||||
double average_delay = 0;
|
double average_delay = 0;
|
||||||
double inst_delay_sec = 0;
|
double inst_delay_sec = 0;
|
||||||
while(num_frames < (duration_sec * 100)) {
|
while (num_frames < (duration_sec * 100)) {
|
||||||
if (in_file_a_.EndOfFile()) {
|
if (in_file_a_.EndOfFile()) {
|
||||||
in_file_a_.Rewind();
|
in_file_a_.Rewind();
|
||||||
}
|
}
|
||||||
@ -206,27 +203,24 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
in_file_a_.Read10MsData(audio_frame);
|
in_file_a_.Read10MsData(audio_frame);
|
||||||
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;
|
||||||
@ -248,7 +242,7 @@ class DelayTest {
|
|||||||
int encoding_sample_rate_hz_;
|
int encoding_sample_rate_hz_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
|
@ -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 ::testing::Test {
|
public AudioPacketizationCallback,
|
||||||
|
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,17 +114,17 @@ 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) {
|
||||||
memcpy(&red_encoder_, &my_codec, sizeof(my_codec));
|
memcpy(&red_encoder_, &my_codec, sizeof(my_codec));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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,10 +272,10 @@ 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));
|
||||||
EXPECT_LE(EqualPayloadLength(stream_index, position), my_tolerance);
|
EXPECT_LE(EqualPayloadLength(stream_index, position), my_tolerance);
|
||||||
if (my_tolerance == 0)
|
if (my_tolerance == 0)
|
||||||
@ -282,10 +288,11 @@ 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,
|
||||||
const RTPFragmentationHeader* fragmentation) {
|
uint16_t payload_size,
|
||||||
|
const RTPFragmentationHeader* fragmentation) {
|
||||||
int position;
|
int position;
|
||||||
int stream_index;
|
int stream_index;
|
||||||
|
|
||||||
@ -297,12 +304,12 @@ int32_t DualStreamTest::SendData(
|
|||||||
// As the oldest payloads are in the higher indices of fragmentation,
|
// As the oldest payloads are in the higher indices of fragmentation,
|
||||||
// to be able to check the increment of timestamps are correct we loop
|
// to be able to check the increment of timestamps are correct we loop
|
||||||
// backward.
|
// backward.
|
||||||
for (int n = fragmentation->fragmentationVectorSize - 1; n >= 0 ; --n) {
|
for (int n = fragmentation->fragmentationVectorSize - 1; n >= 0; --n) {
|
||||||
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;
|
||||||
@ -469,7 +475,7 @@ TEST_F(DualStreamTest, Api) {
|
|||||||
|
|
||||||
// Not allowed to register secondary codec if primary is not registered yet.
|
// Not allowed to register secondary codec if primary is not registered yet.
|
||||||
ASSERT_EQ(-1,
|
ASSERT_EQ(-1,
|
||||||
acm_dual_stream_->RegisterSecondarySendCodec(secondary_encoder_));
|
acm_dual_stream_->RegisterSecondarySendCodec(secondary_encoder_));
|
||||||
ASSERT_EQ(-1, acm_dual_stream_->SecondarySendCodec(&my_codec));
|
ASSERT_EQ(-1, acm_dual_stream_->SecondarySendCodec(&my_codec));
|
||||||
|
|
||||||
ASSERT_EQ(0, acm_dual_stream_->RegisterSendCodec(primary_encoder_));
|
ASSERT_EQ(0, acm_dual_stream_->RegisterSendCodec(primary_encoder_));
|
||||||
@ -486,7 +492,7 @@ TEST_F(DualStreamTest, Api) {
|
|||||||
EXPECT_EQ(VADNormal, vad_mode);
|
EXPECT_EQ(VADNormal, vad_mode);
|
||||||
|
|
||||||
ASSERT_EQ(0,
|
ASSERT_EQ(0,
|
||||||
acm_dual_stream_->RegisterSecondarySendCodec(secondary_encoder_));
|
acm_dual_stream_->RegisterSecondarySendCodec(secondary_encoder_));
|
||||||
|
|
||||||
ASSERT_EQ(0, acm_dual_stream_->SecondarySendCodec(&my_codec));
|
ASSERT_EQ(0, acm_dual_stream_->SecondarySendCodec(&my_codec));
|
||||||
ASSERT_EQ(0, memcmp(&my_codec, &secondary_encoder_, sizeof(my_codec)));
|
ASSERT_EQ(0, memcmp(&my_codec, &secondary_encoder_, sizeof(my_codec)));
|
||||||
@ -512,4 +518,5 @@ TEST_F(DualStreamTest, Api) {
|
|||||||
EXPECT_EQ(VADVeryAggr, vad_mode);
|
EXPECT_EQ(VADVeryAggr, vad_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
}
|
||||||
|
// namespace webrtc
|
||||||
|
@ -32,536 +32,466 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
void SetISACConfigDefault(
|
void SetISACConfigDefault(ACMTestISACConfig& isacConfig) {
|
||||||
ACMTestISACConfig& isacConfig)
|
isacConfig.currentRateBitPerSec = 0;
|
||||||
{
|
isacConfig.currentFrameSizeMsec = 0;
|
||||||
isacConfig.currentRateBitPerSec = 0;
|
isacConfig.maxRateBitPerSec = 0;
|
||||||
isacConfig.currentFrameSizeMsec = 0;
|
isacConfig.maxPayloadSizeByte = 0;
|
||||||
isacConfig.maxRateBitPerSec = 0;
|
isacConfig.encodingMode = -1;
|
||||||
isacConfig.maxPayloadSizeByte = 0;
|
isacConfig.initRateBitPerSec = 0;
|
||||||
isacConfig.encodingMode = -1;
|
isacConfig.initFrameSizeInMsec = 0;
|
||||||
isacConfig.initRateBitPerSec = 0;
|
isacConfig.enforceFrameSize = false;
|
||||||
isacConfig.initFrameSizeInMsec = 0;
|
return;
|
||||||
isacConfig.enforceFrameSize = false;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t SetISAConfig(ACMTestISACConfig& isacConfig, AudioCodingModule* acm,
|
||||||
|
int testMode) {
|
||||||
|
|
||||||
int16_t SetISAConfig(
|
if ((isacConfig.currentRateBitPerSec != 0)
|
||||||
ACMTestISACConfig& isacConfig,
|
|| (isacConfig.currentFrameSizeMsec != 0)) {
|
||||||
AudioCodingModule* acm,
|
CodecInst sendCodec;
|
||||||
int testMode)
|
acm->SendCodec(&sendCodec);
|
||||||
{
|
if (isacConfig.currentRateBitPerSec < 0) {
|
||||||
|
sendCodec.rate = -1;
|
||||||
|
CHECK_ERROR(acm->RegisterSendCodec(sendCodec));
|
||||||
|
if (testMode != 0) {
|
||||||
|
printf("ISAC-%s Registered in adaptive (channel-dependent) mode.\n",
|
||||||
|
(sendCodec.plfreq == 32000) ? "swb" : "wb");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
if((isacConfig.currentRateBitPerSec != 0) ||
|
if (isacConfig.currentRateBitPerSec != 0) {
|
||||||
(isacConfig.currentFrameSizeMsec != 0))
|
sendCodec.rate = isacConfig.currentRateBitPerSec;
|
||||||
{
|
}
|
||||||
CodecInst sendCodec;
|
if (isacConfig.currentFrameSizeMsec != 0) {
|
||||||
acm->SendCodec(&sendCodec);
|
sendCodec.pacsize = isacConfig.currentFrameSizeMsec
|
||||||
if(isacConfig.currentRateBitPerSec < 0)
|
* (sendCodec.plfreq / 1000);
|
||||||
{
|
}
|
||||||
sendCodec.rate = -1;
|
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",
|
||||||
{
|
(int) isacConfig.currentRateBitPerSec,
|
||||||
printf("ISAC-%s Registered in adaptive (channel-dependent) mode.\n",
|
(int) sendCodec.pacsize / (sendCodec.plfreq / 1000));
|
||||||
(sendCodec.plfreq == 32000)? "swb":"wb");
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
if(isacConfig.currentRateBitPerSec != 0)
|
|
||||||
{
|
|
||||||
sendCodec.rate = isacConfig.currentRateBitPerSec;
|
|
||||||
}
|
|
||||||
if(isacConfig.currentFrameSizeMsec != 0)
|
|
||||||
{
|
|
||||||
sendCodec.pacsize = isacConfig.currentFrameSizeMsec *
|
|
||||||
(sendCodec.plfreq / 1000);
|
|
||||||
}
|
|
||||||
CHECK_ERROR(acm->RegisterSendCodec(sendCodec));
|
|
||||||
if(testMode != 0)
|
|
||||||
{
|
|
||||||
printf("Target rate is set to %d bit/sec with frame-size %d ms \n",
|
|
||||||
(int)isacConfig.currentRateBitPerSec,
|
|
||||||
(int)sendCodec.pacsize / (sendCodec.plfreq / 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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) ||
|
}
|
||||||
(isacConfig.initRateBitPerSec != 0))
|
if ((isacConfig.initFrameSizeInMsec != 0)
|
||||||
{
|
|| (isacConfig.initRateBitPerSec != 0)) {
|
||||||
CHECK_ERROR(acm->ConfigISACBandwidthEstimator(
|
CHECK_ERROR(
|
||||||
(uint8_t)isacConfig.initFrameSizeInMsec,
|
acm->ConfigISACBandwidthEstimator(
|
||||||
(uint16_t)isacConfig.initRateBitPerSec,
|
(uint8_t) isacConfig.initFrameSizeInMsec,
|
||||||
|
(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))
|
|
||||||
{
|
|
||||||
printf("Initialize BWE to %u bit/sec send-bandwidth\n",
|
|
||||||
isacConfig.initRateBitPerSec);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if ((isacConfig.initRateBitPerSec != 0) && (testMode != 0)) {
|
||||||
|
printf("Initialize BWE to %u bit/sec send-bandwidth\n",
|
||||||
|
isacConfig.initRateBitPerSec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
delete _channel_A2B;
|
delete _channel_A2B;
|
||||||
delete _channel_B2A;
|
delete _channel_B2A;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t ISACTest::Setup() {
|
||||||
|
int codecCntr;
|
||||||
|
CodecInst codecParam;
|
||||||
|
|
||||||
int16_t
|
_acmA = AudioCodingModule::Create(1);
|
||||||
ISACTest::Setup()
|
_acmB = AudioCodingModule::Create(2);
|
||||||
{
|
|
||||||
int codecCntr;
|
|
||||||
CodecInst codecParam;
|
|
||||||
|
|
||||||
_acmA = AudioCodingModule::Create(1);
|
for (codecCntr = 0; codecCntr < AudioCodingModule::NumberOfCodecs();
|
||||||
_acmB = AudioCodingModule::Create(2);
|
codecCntr++) {
|
||||||
|
AudioCodingModule::Codec(codecCntr, &codecParam);
|
||||||
for(codecCntr = 0; codecCntr < AudioCodingModule::NumberOfCodecs(); codecCntr++)
|
if (!STR_CASE_CMP(codecParam.plname, "ISAC")
|
||||||
{
|
&& codecParam.plfreq == 16000) {
|
||||||
AudioCodingModule::Codec(codecCntr, &codecParam);
|
memcpy(&_paramISAC16kHz, &codecParam, sizeof(CodecInst));
|
||||||
if(!STR_CASE_CMP(codecParam.plname, "ISAC") && codecParam.plfreq == 16000)
|
_idISAC16kHz = codecCntr;
|
||||||
{
|
|
||||||
memcpy(&_paramISAC16kHz, &codecParam, sizeof(CodecInst));
|
|
||||||
_idISAC16kHz = codecCntr;
|
|
||||||
}
|
|
||||||
if(!STR_CASE_CMP(codecParam.plname, "ISAC") && codecParam.plfreq == 32000)
|
|
||||||
{
|
|
||||||
memcpy(&_paramISAC32kHz, &codecParam, sizeof(CodecInst));
|
|
||||||
_idISAC32kHz = codecCntr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!STR_CASE_CMP(codecParam.plname, "ISAC")
|
||||||
// register both iSAC-wb & iSAC-swb in both sides as receiver codecs
|
&& codecParam.plfreq == 32000) {
|
||||||
CHECK_ERROR(_acmA->RegisterReceiveCodec(_paramISAC16kHz));
|
memcpy(&_paramISAC32kHz, &codecParam, sizeof(CodecInst));
|
||||||
CHECK_ERROR(_acmA->RegisterReceiveCodec(_paramISAC32kHz));
|
_idISAC32kHz = codecCntr;
|
||||||
CHECK_ERROR(_acmB->RegisterReceiveCodec(_paramISAC16kHz));
|
|
||||||
CHECK_ERROR(_acmB->RegisterReceiveCodec(_paramISAC32kHz));
|
|
||||||
|
|
||||||
//--- Set A-to-B channel
|
|
||||||
_channel_A2B = new Channel;
|
|
||||||
CHECK_ERROR(_acmA->RegisterTransportCallback(_channel_A2B));
|
|
||||||
_channel_A2B->RegisterReceiverACM(_acmB);
|
|
||||||
|
|
||||||
//--- Set B-to-A channel
|
|
||||||
_channel_B2A = new Channel;
|
|
||||||
CHECK_ERROR(_acmB->RegisterTransportCallback(_channel_B2A));
|
|
||||||
_channel_B2A->RegisterReceiverACM(_acmA);
|
|
||||||
|
|
||||||
file_name_swb_ =
|
|
||||||
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
|
|
||||||
|
|
||||||
_acmB->RegisterSendCodec(_paramISAC16kHz);
|
|
||||||
_acmA->RegisterSendCodec(_paramISAC32kHz);
|
|
||||||
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("Side A Send Codec\n");
|
|
||||||
printf("%s %d\n", _paramISAC32kHz.plname, _paramISAC32kHz.plfreq);
|
|
||||||
|
|
||||||
printf("Side B Send Codec\n");
|
|
||||||
printf("%s %d\n", _paramISAC16kHz.plname, _paramISAC16kHz.plfreq);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_inFileA.Open(file_name_swb_, 32000, "rb");
|
// register both iSAC-wb & iSAC-swb in both sides as receiver codecs
|
||||||
std::string fileNameA = webrtc::test::OutputPath() + "testisac_a.pcm";
|
CHECK_ERROR(_acmA->RegisterReceiveCodec(_paramISAC16kHz));
|
||||||
std::string fileNameB = webrtc::test::OutputPath() + "testisac_b.pcm";
|
CHECK_ERROR(_acmA->RegisterReceiveCodec(_paramISAC32kHz));
|
||||||
_outFileA.Open(fileNameA, 32000, "wb");
|
CHECK_ERROR(_acmB->RegisterReceiveCodec(_paramISAC16kHz));
|
||||||
_outFileB.Open(fileNameB, 32000, "wb");
|
CHECK_ERROR(_acmB->RegisterReceiveCodec(_paramISAC32kHz));
|
||||||
|
|
||||||
while(!_inFileA.EndOfFile())
|
//--- Set A-to-B channel
|
||||||
{
|
_channel_A2B = new Channel;
|
||||||
Run10ms();
|
CHECK_ERROR(_acmA->RegisterTransportCallback(_channel_A2B));
|
||||||
}
|
_channel_A2B->RegisterReceiverACM(_acmB);
|
||||||
CodecInst receiveCodec;
|
|
||||||
CHECK_ERROR(_acmA->ReceiveCodec(&receiveCodec));
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("Side A Receive Codec\n");
|
|
||||||
printf("%s %d\n", receiveCodec.plname, receiveCodec.plfreq);
|
|
||||||
}
|
|
||||||
|
|
||||||
CHECK_ERROR(_acmB->ReceiveCodec(&receiveCodec));
|
//--- Set B-to-A channel
|
||||||
if(_testMode != 0)
|
_channel_B2A = new Channel;
|
||||||
{
|
CHECK_ERROR(_acmB->RegisterTransportCallback(_channel_B2A));
|
||||||
printf("Side B Receive Codec\n");
|
_channel_B2A->RegisterReceiverACM(_acmA);
|
||||||
printf("%s %d\n", receiveCodec.plname, receiveCodec.plfreq);
|
|
||||||
}
|
|
||||||
|
|
||||||
_inFileA.Close();
|
file_name_swb_ = webrtc::test::ResourcePath("audio_coding/testfile32kHz",
|
||||||
_outFileA.Close();
|
"pcm");
|
||||||
_outFileB.Close();
|
|
||||||
|
|
||||||
return 0;
|
_acmB->RegisterSendCodec(_paramISAC16kHz);
|
||||||
|
_acmA->RegisterSendCodec(_paramISAC32kHz);
|
||||||
|
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("Side A Send Codec\n");
|
||||||
|
printf("%s %d\n", _paramISAC32kHz.plname, _paramISAC32kHz.plfreq);
|
||||||
|
|
||||||
|
printf("Side B Send Codec\n");
|
||||||
|
printf("%s %d\n", _paramISAC16kHz.plname, _paramISAC16kHz.plfreq);
|
||||||
|
}
|
||||||
|
|
||||||
|
_inFileA.Open(file_name_swb_, 32000, "rb");
|
||||||
|
std::string fileNameA = webrtc::test::OutputPath() + "testisac_a.pcm";
|
||||||
|
std::string fileNameB = webrtc::test::OutputPath() + "testisac_b.pcm";
|
||||||
|
_outFileA.Open(fileNameA, 32000, "wb");
|
||||||
|
_outFileB.Open(fileNameB, 32000, "wb");
|
||||||
|
|
||||||
|
while (!_inFileA.EndOfFile()) {
|
||||||
|
Run10ms();
|
||||||
|
}
|
||||||
|
CodecInst receiveCodec;
|
||||||
|
CHECK_ERROR(_acmA->ReceiveCodec(&receiveCodec));
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("Side A Receive Codec\n");
|
||||||
|
printf("%s %d\n", receiveCodec.plname, receiveCodec.plfreq);
|
||||||
|
}
|
||||||
|
|
||||||
|
CHECK_ERROR(_acmB->ReceiveCodec(&receiveCodec));
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("Side B Receive Codec\n");
|
||||||
|
printf("%s %d\n", receiveCodec.plname, receiveCodec.plfreq);
|
||||||
|
}
|
||||||
|
|
||||||
|
_inFileA.Close();
|
||||||
|
_outFileA.Close();
|
||||||
|
_outFileB.Close();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ISACTest::Perform() {
|
||||||
|
if (_testMode == 0) {
|
||||||
|
printf("Running iSAC Test");
|
||||||
|
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1,
|
||||||
|
"---------- iSACTest ----------");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
Setup();
|
||||||
ISACTest::Perform()
|
|
||||||
{
|
|
||||||
if(_testMode == 0)
|
|
||||||
{
|
|
||||||
printf("Running iSAC Test");
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceAudioCoding, -1, "---------- iSACTest ----------");
|
|
||||||
}
|
|
||||||
|
|
||||||
Setup();
|
int16_t testNr = 0;
|
||||||
|
ACMTestISACConfig wbISACConfig;
|
||||||
|
ACMTestISACConfig swbISACConfig;
|
||||||
|
|
||||||
int16_t testNr = 0;
|
SetISACConfigDefault(wbISACConfig);
|
||||||
ACMTestISACConfig wbISACConfig;
|
SetISACConfigDefault(swbISACConfig);
|
||||||
ACMTestISACConfig swbISACConfig;
|
|
||||||
|
|
||||||
|
wbISACConfig.currentRateBitPerSec = -1;
|
||||||
|
swbISACConfig.currentRateBitPerSec = -1;
|
||||||
|
testNr++;
|
||||||
|
EncodeDecode(testNr, wbISACConfig, swbISACConfig);
|
||||||
|
|
||||||
|
if (_testMode != 0) {
|
||||||
SetISACConfigDefault(wbISACConfig);
|
SetISACConfigDefault(wbISACConfig);
|
||||||
SetISACConfigDefault(swbISACConfig);
|
SetISACConfigDefault(swbISACConfig);
|
||||||
|
|
||||||
wbISACConfig.currentRateBitPerSec = -1;
|
wbISACConfig.currentRateBitPerSec = -1;
|
||||||
swbISACConfig.currentRateBitPerSec = -1;
|
swbISACConfig.currentRateBitPerSec = -1;
|
||||||
|
wbISACConfig.initRateBitPerSec = 13000;
|
||||||
|
wbISACConfig.initFrameSizeInMsec = 60;
|
||||||
|
swbISACConfig.initRateBitPerSec = 20000;
|
||||||
|
swbISACConfig.initFrameSizeInMsec = 30;
|
||||||
testNr++;
|
testNr++;
|
||||||
EncodeDecode(testNr, wbISACConfig, swbISACConfig);
|
EncodeDecode(testNr, wbISACConfig, swbISACConfig);
|
||||||
|
|
||||||
if (_testMode != 0)
|
|
||||||
{
|
|
||||||
SetISACConfigDefault(wbISACConfig);
|
|
||||||
SetISACConfigDefault(swbISACConfig);
|
|
||||||
|
|
||||||
wbISACConfig.currentRateBitPerSec = -1;
|
|
||||||
swbISACConfig.currentRateBitPerSec = -1;
|
|
||||||
wbISACConfig.initRateBitPerSec = 13000;
|
|
||||||
wbISACConfig.initFrameSizeInMsec = 60;
|
|
||||||
swbISACConfig.initRateBitPerSec = 20000;
|
|
||||||
swbISACConfig.initFrameSizeInMsec = 30;
|
|
||||||
testNr++;
|
|
||||||
EncodeDecode(testNr, wbISACConfig, swbISACConfig);
|
|
||||||
|
|
||||||
SetISACConfigDefault(wbISACConfig);
|
|
||||||
SetISACConfigDefault(swbISACConfig);
|
|
||||||
|
|
||||||
wbISACConfig.currentRateBitPerSec = 20000;
|
|
||||||
swbISACConfig.currentRateBitPerSec = 48000;
|
|
||||||
testNr++;
|
|
||||||
EncodeDecode(testNr, wbISACConfig, swbISACConfig);
|
|
||||||
|
|
||||||
wbISACConfig.currentRateBitPerSec = 16000;
|
|
||||||
swbISACConfig.currentRateBitPerSec = 30000;
|
|
||||||
wbISACConfig.currentFrameSizeMsec = 60;
|
|
||||||
testNr++;
|
|
||||||
EncodeDecode(testNr, wbISACConfig, swbISACConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetISACConfigDefault(wbISACConfig);
|
SetISACConfigDefault(wbISACConfig);
|
||||||
SetISACConfigDefault(swbISACConfig);
|
SetISACConfigDefault(swbISACConfig);
|
||||||
|
|
||||||
|
wbISACConfig.currentRateBitPerSec = 20000;
|
||||||
|
swbISACConfig.currentRateBitPerSec = 48000;
|
||||||
testNr++;
|
testNr++;
|
||||||
EncodeDecode(testNr, wbISACConfig, swbISACConfig);
|
EncodeDecode(testNr, wbISACConfig, swbISACConfig);
|
||||||
|
|
||||||
int user_input;
|
wbISACConfig.currentRateBitPerSec = 16000;
|
||||||
if((_testMode == 0) || (_testMode == 1))
|
swbISACConfig.currentRateBitPerSec = 30000;
|
||||||
{
|
wbISACConfig.currentFrameSizeMsec = 60;
|
||||||
swbISACConfig.maxPayloadSizeByte = (uint16_t)200;
|
|
||||||
wbISACConfig.maxPayloadSizeByte = (uint16_t)200;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Enter the max payload-size for side A: ");
|
|
||||||
CHECK_ERROR(scanf("%d", &user_input));
|
|
||||||
swbISACConfig.maxPayloadSizeByte = (uint16_t)user_input;
|
|
||||||
printf("Enter the max payload-size for side B: ");
|
|
||||||
CHECK_ERROR(scanf("%d", &user_input));
|
|
||||||
wbISACConfig.maxPayloadSizeByte = (uint16_t)user_input;
|
|
||||||
}
|
|
||||||
testNr++;
|
testNr++;
|
||||||
EncodeDecode(testNr, wbISACConfig, swbISACConfig);
|
EncodeDecode(testNr, wbISACConfig, swbISACConfig);
|
||||||
|
}
|
||||||
|
|
||||||
_acmA->ResetEncoder();
|
SetISACConfigDefault(wbISACConfig);
|
||||||
_acmB->ResetEncoder();
|
SetISACConfigDefault(swbISACConfig);
|
||||||
SetISACConfigDefault(wbISACConfig);
|
testNr++;
|
||||||
SetISACConfigDefault(swbISACConfig);
|
EncodeDecode(testNr, wbISACConfig, swbISACConfig);
|
||||||
|
|
||||||
if((_testMode == 0) || (_testMode == 1))
|
int user_input;
|
||||||
{
|
if ((_testMode == 0) || (_testMode == 1)) {
|
||||||
swbISACConfig.maxRateBitPerSec = (uint32_t)48000;
|
swbISACConfig.maxPayloadSizeByte = (uint16_t) 200;
|
||||||
wbISACConfig.maxRateBitPerSec = (uint32_t)48000;
|
wbISACConfig.maxPayloadSizeByte = (uint16_t) 200;
|
||||||
}
|
} else {
|
||||||
else
|
printf("Enter the max payload-size for side A: ");
|
||||||
{
|
CHECK_ERROR(scanf("%d", &user_input));
|
||||||
printf("Enter the max rate for side A: ");
|
swbISACConfig.maxPayloadSizeByte = (uint16_t) user_input;
|
||||||
CHECK_ERROR(scanf("%d", &user_input));
|
printf("Enter the max payload-size for side B: ");
|
||||||
swbISACConfig.maxRateBitPerSec = (uint32_t)user_input;
|
CHECK_ERROR(scanf("%d", &user_input));
|
||||||
printf("Enter the max rate for side B: ");
|
wbISACConfig.maxPayloadSizeByte = (uint16_t) user_input;
|
||||||
CHECK_ERROR(scanf("%d", &user_input));
|
}
|
||||||
wbISACConfig.maxRateBitPerSec = (uint32_t)user_input;
|
testNr++;
|
||||||
}
|
EncodeDecode(testNr, wbISACConfig, swbISACConfig);
|
||||||
|
|
||||||
testNr++;
|
|
||||||
EncodeDecode(testNr, wbISACConfig, swbISACConfig);
|
|
||||||
|
|
||||||
|
_acmA->ResetEncoder();
|
||||||
|
_acmB->ResetEncoder();
|
||||||
|
SetISACConfigDefault(wbISACConfig);
|
||||||
|
SetISACConfigDefault(swbISACConfig);
|
||||||
|
|
||||||
testNr++;
|
if ((_testMode == 0) || (_testMode == 1)) {
|
||||||
if(_testMode == 0)
|
swbISACConfig.maxRateBitPerSec = (uint32_t) 48000;
|
||||||
{
|
wbISACConfig.maxRateBitPerSec = (uint32_t) 48000;
|
||||||
SwitchingSamplingRate(testNr, 4);
|
} else {
|
||||||
printf("Done!\n");
|
printf("Enter the max rate for side A: ");
|
||||||
}
|
CHECK_ERROR(scanf("%d", &user_input));
|
||||||
else
|
swbISACConfig.maxRateBitPerSec = (uint32_t) user_input;
|
||||||
{
|
printf("Enter the max rate for side B: ");
|
||||||
SwitchingSamplingRate(testNr, 80);
|
CHECK_ERROR(scanf("%d", &user_input));
|
||||||
}
|
wbISACConfig.maxRateBitPerSec = (uint32_t) user_input;
|
||||||
|
}
|
||||||
|
|
||||||
|
testNr++;
|
||||||
|
EncodeDecode(testNr, wbISACConfig, swbISACConfig);
|
||||||
|
|
||||||
|
testNr++;
|
||||||
|
if (_testMode == 0) {
|
||||||
|
SwitchingSamplingRate(testNr, 4);
|
||||||
|
printf("Done!\n");
|
||||||
|
} else {
|
||||||
|
SwitchingSamplingRate(testNr, 80);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ISACTest::Run10ms() {
|
||||||
|
AudioFrame audioFrame;
|
||||||
|
|
||||||
void
|
_inFileA.Read10MsData(audioFrame);
|
||||||
ISACTest::Run10ms()
|
CHECK_ERROR(_acmA->Add10MsData(audioFrame));
|
||||||
{
|
|
||||||
AudioFrame audioFrame;
|
|
||||||
|
|
||||||
_inFileA.Read10MsData(audioFrame);
|
CHECK_ERROR(_acmB->Add10MsData(audioFrame));
|
||||||
CHECK_ERROR(_acmA->Add10MsData(audioFrame));
|
|
||||||
|
|
||||||
CHECK_ERROR(_acmB->Add10MsData(audioFrame));
|
CHECK_ERROR(_acmA->Process());
|
||||||
|
CHECK_ERROR(_acmB->Process());
|
||||||
|
|
||||||
CHECK_ERROR(_acmA->Process());
|
CHECK_ERROR(_acmA->PlayoutData10Ms(32000, &audioFrame));
|
||||||
CHECK_ERROR(_acmB->Process());
|
_outFileA.Write10MsData(audioFrame);
|
||||||
|
|
||||||
CHECK_ERROR(_acmA->PlayoutData10Ms(32000, &audioFrame));
|
CHECK_ERROR(_acmB->PlayoutData10Ms(32000, &audioFrame));
|
||||||
_outFileA.Write10MsData(audioFrame);
|
_outFileB.Write10MsData(audioFrame);
|
||||||
|
|
||||||
CHECK_ERROR(_acmB->PlayoutData10Ms(32000, &audioFrame));
|
|
||||||
_outFileB.Write10MsData(audioFrame);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ISACTest::EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig,
|
||||||
ISACTest::EncodeDecode(
|
ACMTestISACConfig& swbISACConfig) {
|
||||||
int testNr,
|
if (_testMode == 0) {
|
||||||
ACMTestISACConfig& wbISACConfig,
|
printf(".");
|
||||||
ACMTestISACConfig& swbISACConfig)
|
} else {
|
||||||
{
|
printf("\nTest %d:\n\n", testNr);
|
||||||
if(_testMode == 0)
|
}
|
||||||
{
|
|
||||||
printf(".");
|
// Files in Side A and B
|
||||||
}
|
_inFileA.Open(file_name_swb_, 32000, "rb", true);
|
||||||
else
|
_inFileB.Open(file_name_swb_, 32000, "rb", true);
|
||||||
{
|
|
||||||
printf("\nTest %d:\n\n", testNr);
|
std::string file_name_out;
|
||||||
|
std::stringstream file_stream_a;
|
||||||
|
std::stringstream file_stream_b;
|
||||||
|
file_stream_a << webrtc::test::OutputPath();
|
||||||
|
file_stream_b << webrtc::test::OutputPath();
|
||||||
|
if (_testMode == 0) {
|
||||||
|
file_stream_a << "out_iSACTest_A_" << testNr << ".pcm";
|
||||||
|
file_stream_b << "out_iSACTest_B_" << testNr << ".pcm";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
file_stream_a << "outA_" << testNr << ".pcm";
|
||||||
|
file_stream_b << "outB_" << testNr << ".pcm";
|
||||||
|
}
|
||||||
|
file_name_out = file_stream_a.str();
|
||||||
|
_outFileA.Open(file_name_out, 32000, "wb");
|
||||||
|
file_name_out = file_stream_b.str();
|
||||||
|
_outFileB.Open(file_name_out, 32000, "wb");
|
||||||
|
|
||||||
|
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC16kHz));
|
||||||
|
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC32kHz));
|
||||||
|
|
||||||
|
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC32kHz));
|
||||||
|
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC16kHz));
|
||||||
|
if (_testMode != 0) {
|
||||||
|
printf("Side A Sending Super-Wideband \n");
|
||||||
|
printf("Side B Sending Wideband\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
SetISAConfig(swbISACConfig, _acmA, _testMode);
|
||||||
|
SetISAConfig(wbISACConfig, _acmB, _testMode);
|
||||||
|
|
||||||
|
bool adaptiveMode = false;
|
||||||
|
if ((swbISACConfig.currentRateBitPerSec == -1)
|
||||||
|
|| (wbISACConfig.currentRateBitPerSec == -1)) {
|
||||||
|
adaptiveMode = true;
|
||||||
|
}
|
||||||
|
_myTimer.Reset();
|
||||||
|
_channel_A2B->ResetStats();
|
||||||
|
_channel_B2A->ResetStats();
|
||||||
|
|
||||||
|
char currentTime[500];
|
||||||
|
if (_testMode == 2)
|
||||||
|
printf("\n");
|
||||||
|
CodecInst sendCodec;
|
||||||
|
EventWrapper* myEvent = EventWrapper::Create();
|
||||||
|
myEvent->StartTimer(true, 10);
|
||||||
|
while (!(_inFileA.EndOfFile() || _inFileA.Rewinded())) {
|
||||||
|
Run10ms();
|
||||||
|
_myTimer.Tick10ms();
|
||||||
|
_myTimer.CurrentTimeHMS(currentTime);
|
||||||
|
if (_testMode == 2)
|
||||||
|
printf("\r%s ", currentTime);
|
||||||
|
|
||||||
|
if ((adaptiveMode) && (_testMode != 0)) {
|
||||||
|
myEvent->Wait(5000);
|
||||||
|
|
||||||
|
_acmA->SendCodec(&sendCodec);
|
||||||
|
if (_testMode == 2)
|
||||||
|
printf("[%d] ", sendCodec.rate);
|
||||||
|
_acmB->SendCodec(&sendCodec);
|
||||||
|
if (_testMode == 2)
|
||||||
|
printf("[%d] ", sendCodec.rate);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Files in Side A and B
|
if (_testMode != 0) {
|
||||||
_inFileA.Open(file_name_swb_, 32000, "rb", true);
|
printf("\n\nSide A statistics\n\n");
|
||||||
_inFileB.Open(file_name_swb_, 32000, "rb", true);
|
_channel_A2B->PrintStats(_paramISAC32kHz);
|
||||||
|
|
||||||
std::string file_name_out;
|
printf("\n\nSide B statistics\n\n");
|
||||||
std::stringstream file_stream_a;
|
_channel_B2A->PrintStats(_paramISAC16kHz);
|
||||||
std::stringstream file_stream_b;
|
}
|
||||||
file_stream_a << webrtc::test::OutputPath();
|
|
||||||
file_stream_b << webrtc::test::OutputPath();
|
|
||||||
if(_testMode == 0)
|
|
||||||
{
|
|
||||||
file_stream_a << "out_iSACTest_A_" << testNr << ".pcm";
|
|
||||||
file_stream_b << "out_iSACTest_B_" << testNr << ".pcm";
|
|
||||||
|
|
||||||
}
|
_channel_A2B->ResetStats();
|
||||||
else
|
_channel_B2A->ResetStats();
|
||||||
{
|
|
||||||
file_stream_a << "outA_" << testNr << ".pcm";
|
|
||||||
file_stream_b << "outB_" << testNr << ".pcm";
|
|
||||||
}
|
|
||||||
file_name_out = file_stream_a.str();
|
|
||||||
_outFileA.Open(file_name_out, 32000, "wb");
|
|
||||||
file_name_out = file_stream_b.str();
|
|
||||||
_outFileB.Open(file_name_out, 32000, "wb");
|
|
||||||
|
|
||||||
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC16kHz));
|
if (_testMode != 0)
|
||||||
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC32kHz));
|
printf("\n");
|
||||||
|
_outFileA.Close();
|
||||||
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC32kHz));
|
_outFileB.Close();
|
||||||
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC16kHz));
|
_inFileA.Close();
|
||||||
if(_testMode != 0)
|
_inFileB.Close();
|
||||||
{
|
|
||||||
printf("Side A Sending Super-Wideband \n");
|
|
||||||
printf("Side B Sending Wideband\n\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
SetISAConfig(swbISACConfig, _acmA, _testMode);
|
|
||||||
SetISAConfig(wbISACConfig, _acmB, _testMode);
|
|
||||||
|
|
||||||
bool adaptiveMode = false;
|
|
||||||
if((swbISACConfig.currentRateBitPerSec == -1) ||
|
|
||||||
(wbISACConfig.currentRateBitPerSec == -1))
|
|
||||||
{
|
|
||||||
adaptiveMode = true;
|
|
||||||
}
|
|
||||||
_myTimer.Reset();
|
|
||||||
_channel_A2B->ResetStats();
|
|
||||||
_channel_B2A->ResetStats();
|
|
||||||
|
|
||||||
char currentTime[500];
|
|
||||||
if(_testMode == 2) printf("\n");
|
|
||||||
CodecInst sendCodec;
|
|
||||||
EventWrapper* myEvent = EventWrapper::Create();
|
|
||||||
myEvent->StartTimer(true, 10);
|
|
||||||
while(!(_inFileA.EndOfFile() || _inFileA.Rewinded()))
|
|
||||||
{
|
|
||||||
Run10ms();
|
|
||||||
_myTimer.Tick10ms();
|
|
||||||
_myTimer.CurrentTimeHMS(currentTime);
|
|
||||||
if(_testMode == 2) printf("\r%s ", currentTime);
|
|
||||||
|
|
||||||
if((adaptiveMode) && (_testMode != 0))
|
|
||||||
{
|
|
||||||
myEvent->Wait(5000);
|
|
||||||
|
|
||||||
_acmA->SendCodec(&sendCodec);
|
|
||||||
if(_testMode == 2) printf("[%d] ", sendCodec.rate);
|
|
||||||
_acmB->SendCodec(&sendCodec);
|
|
||||||
if(_testMode == 2) printf("[%d] ", sendCodec.rate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_testMode != 0)
|
|
||||||
{
|
|
||||||
printf("\n\nSide A statistics\n\n");
|
|
||||||
_channel_A2B->PrintStats(_paramISAC32kHz);
|
|
||||||
|
|
||||||
printf("\n\nSide B statistics\n\n");
|
|
||||||
_channel_B2A->PrintStats(_paramISAC16kHz);
|
|
||||||
}
|
|
||||||
|
|
||||||
_channel_A2B->ResetStats();
|
|
||||||
_channel_B2A->ResetStats();
|
|
||||||
|
|
||||||
if(_testMode != 0) printf("\n");
|
|
||||||
_outFileA.Close();
|
|
||||||
_outFileB.Close();
|
|
||||||
_inFileA.Close();
|
|
||||||
_inFileB.Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ISACTest::SwitchingSamplingRate(int testNr, int maxSampRateChange) {
|
||||||
ISACTest::SwitchingSamplingRate(
|
// Files in Side A
|
||||||
int testNr,
|
_inFileA.Open(file_name_swb_, 32000, "rb");
|
||||||
int maxSampRateChange)
|
_inFileB.Open(file_name_swb_, 32000, "rb");
|
||||||
{
|
|
||||||
// Files in Side A
|
|
||||||
_inFileA.Open(file_name_swb_, 32000, "rb");
|
|
||||||
_inFileB.Open(file_name_swb_, 32000, "rb");
|
|
||||||
|
|
||||||
std::string file_name_out;
|
std::string file_name_out;
|
||||||
std::stringstream file_stream_a;
|
std::stringstream file_stream_a;
|
||||||
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 {
|
||||||
}
|
printf("\nTest %d", testNr);
|
||||||
else
|
printf(" Alternate between WB and SWB at the sender Side\n\n");
|
||||||
{
|
file_stream_a << "outA_" << testNr << ".pcm";
|
||||||
printf("\nTest %d", testNr);
|
file_stream_b << "outB_" << testNr << ".pcm";
|
||||||
printf(" Alternate between WB and SWB at the sender Side\n\n");
|
}
|
||||||
file_stream_a << "outA_" << testNr << ".pcm";
|
file_name_out = file_stream_a.str();
|
||||||
file_stream_b << "outB_" << testNr << ".pcm";
|
_outFileA.Open(file_name_out, 32000, "wb");
|
||||||
}
|
file_name_out = file_stream_b.str();
|
||||||
file_name_out = file_stream_a.str();
|
_outFileB.Open(file_name_out, 32000, "wb");
|
||||||
_outFileA.Open(file_name_out, 32000, "wb");
|
|
||||||
file_name_out = file_stream_b.str();
|
|
||||||
_outFileB.Open(file_name_out, 32000, "wb");
|
|
||||||
|
|
||||||
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");
|
}
|
||||||
|
|
||||||
|
int numSendCodecChanged = 0;
|
||||||
|
_myTimer.Reset();
|
||||||
|
char currentTime[50];
|
||||||
|
while (numSendCodecChanged < (maxSampRateChange << 1)) {
|
||||||
|
Run10ms();
|
||||||
|
_myTimer.Tick10ms();
|
||||||
|
_myTimer.CurrentTimeHMS(currentTime);
|
||||||
|
if (_testMode == 2)
|
||||||
|
printf("\r%s", currentTime);
|
||||||
|
if (_inFileA.EndOfFile()) {
|
||||||
|
if (_inFileA.SamplingFrequency() == 16000) {
|
||||||
|
if (_testMode != 0)
|
||||||
|
printf("\nSide A switched to Send Super-Wideband\n");
|
||||||
|
_inFileA.Close();
|
||||||
|
_inFileA.Open(file_name_swb_, 32000, "rb");
|
||||||
|
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC32kHz));
|
||||||
|
} else {
|
||||||
|
if (_testMode != 0)
|
||||||
|
printf("\nSide A switched to Send Wideband\n");
|
||||||
|
_inFileA.Close();
|
||||||
|
_inFileA.Open(file_name_swb_, 32000, "rb");
|
||||||
|
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC16kHz));
|
||||||
|
}
|
||||||
|
numSendCodecChanged++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int numSendCodecChanged = 0;
|
if (_inFileB.EndOfFile()) {
|
||||||
_myTimer.Reset();
|
if (_inFileB.SamplingFrequency() == 16000) {
|
||||||
char currentTime[50];
|
if (_testMode != 0)
|
||||||
while(numSendCodecChanged < (maxSampRateChange<<1))
|
printf("\nSide B switched to Send Super-Wideband\n");
|
||||||
{
|
_inFileB.Close();
|
||||||
Run10ms();
|
_inFileB.Open(file_name_swb_, 32000, "rb");
|
||||||
_myTimer.Tick10ms();
|
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC32kHz));
|
||||||
_myTimer.CurrentTimeHMS(currentTime);
|
} else {
|
||||||
if(_testMode == 2) printf("\r%s", currentTime);
|
if (_testMode != 0)
|
||||||
if(_inFileA.EndOfFile())
|
printf("\nSide B switched to Send Wideband\n");
|
||||||
{
|
_inFileB.Close();
|
||||||
if(_inFileA.SamplingFrequency() == 16000)
|
_inFileB.Open(file_name_swb_, 32000, "rb");
|
||||||
{
|
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC16kHz));
|
||||||
if(_testMode != 0) printf("\nSide A switched to Send Super-Wideband\n");
|
}
|
||||||
_inFileA.Close();
|
numSendCodecChanged++;
|
||||||
_inFileA.Open(file_name_swb_, 32000, "rb");
|
|
||||||
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC32kHz));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(_testMode != 0) printf("\nSide A switched to Send Wideband\n");
|
|
||||||
_inFileA.Close();
|
|
||||||
_inFileA.Open(file_name_swb_, 32000, "rb");
|
|
||||||
CHECK_ERROR(_acmA->RegisterSendCodec(_paramISAC16kHz));
|
|
||||||
}
|
|
||||||
numSendCodecChanged++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_inFileB.EndOfFile())
|
|
||||||
{
|
|
||||||
if(_inFileB.SamplingFrequency() == 16000)
|
|
||||||
{
|
|
||||||
if(_testMode != 0) printf("\nSide B switched to Send Super-Wideband\n");
|
|
||||||
_inFileB.Close();
|
|
||||||
_inFileB.Open(file_name_swb_, 32000, "rb");
|
|
||||||
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC32kHz));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(_testMode != 0) printf("\nSide B switched to Send Wideband\n");
|
|
||||||
_inFileB.Close();
|
|
||||||
_inFileB.Open(file_name_swb_, 32000, "rb");
|
|
||||||
CHECK_ERROR(_acmB->RegisterSendCodec(_paramISAC16kHz));
|
|
||||||
}
|
|
||||||
numSendCodecChanged++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_outFileA.Close();
|
}
|
||||||
_outFileB.Close();
|
_outFileA.Close();
|
||||||
_inFileA.Close();
|
_outFileB.Close();
|
||||||
_inFileB.Close();
|
_inFileA.Close();
|
||||||
|
_inFileB.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -25,80 +25,70 @@
|
|||||||
|
|
||||||
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;
|
int16_t maxPayloadSizeByte;
|
||||||
int16_t maxPayloadSizeByte;
|
int16_t encodingMode;
|
||||||
int16_t encodingMode;
|
uint32_t initRateBitPerSec;
|
||||||
uint32_t initRateBitPerSec;
|
int16_t initFrameSizeInMsec;
|
||||||
int16_t initFrameSizeInMsec;
|
bool enforceFrameSize;
|
||||||
bool enforceFrameSize;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ISACTest : public ACMTest {
|
||||||
|
public:
|
||||||
|
ISACTest(int testMode);
|
||||||
|
~ISACTest();
|
||||||
|
|
||||||
|
void Perform();
|
||||||
|
private:
|
||||||
|
int16_t Setup();
|
||||||
|
int16_t SetupConference();
|
||||||
|
int16_t RunConference();
|
||||||
|
|
||||||
class ISACTest : public ACMTest
|
void Run10ms();
|
||||||
{
|
|
||||||
public:
|
|
||||||
ISACTest(int testMode);
|
|
||||||
~ISACTest();
|
|
||||||
|
|
||||||
void Perform();
|
void EncodeDecode(int testNr, ACMTestISACConfig& wbISACConfig,
|
||||||
private:
|
ACMTestISACConfig& swbISACConfig);
|
||||||
int16_t Setup();
|
|
||||||
int16_t SetupConference();
|
|
||||||
int16_t RunConference();
|
|
||||||
|
|
||||||
|
void TestBWE(int testNr);
|
||||||
|
|
||||||
void Run10ms();
|
void SwitchingSamplingRate(int testNr, int maxSampRateChange);
|
||||||
|
|
||||||
void EncodeDecode(
|
AudioCodingModule* _acmA;
|
||||||
int testNr,
|
AudioCodingModule* _acmB;
|
||||||
ACMTestISACConfig& wbISACConfig,
|
|
||||||
ACMTestISACConfig& swbISACConfig);
|
|
||||||
|
|
||||||
void TestBWE(
|
|
||||||
int testNr);
|
|
||||||
|
|
||||||
void SwitchingSamplingRate(
|
Channel* _channel_A2B;
|
||||||
int testNr,
|
Channel* _channel_B2A;
|
||||||
int maxSampRateChange);
|
|
||||||
|
|
||||||
AudioCodingModule* _acmA;
|
PCMFile _inFileA;
|
||||||
AudioCodingModule* _acmB;
|
PCMFile _inFileB;
|
||||||
|
|
||||||
Channel* _channel_A2B;
|
PCMFile _outFileA;
|
||||||
Channel* _channel_B2A;
|
PCMFile _outFileB;
|
||||||
|
|
||||||
PCMFile _inFileA;
|
uint8_t _idISAC16kHz;
|
||||||
PCMFile _inFileB;
|
uint8_t _idISAC32kHz;
|
||||||
|
CodecInst _paramISAC16kHz;
|
||||||
|
CodecInst _paramISAC32kHz;
|
||||||
|
|
||||||
PCMFile _outFileA;
|
std::string file_name_swb_;
|
||||||
PCMFile _outFileB;
|
|
||||||
|
|
||||||
uint8_t _idISAC16kHz;
|
ACMTestTimer _myTimer;
|
||||||
uint8_t _idISAC32kHz;
|
int _testMode;
|
||||||
CodecInst _paramISAC16kHz;
|
|
||||||
CodecInst _paramISAC32kHz;
|
|
||||||
|
|
||||||
std::string file_name_swb_;
|
AudioCodingModule* _defaultACM32;
|
||||||
|
AudioCodingModule* _defaultACM16;
|
||||||
|
|
||||||
ACMTestTimer _myTimer;
|
AudioCodingModule* _confACM[NO_OF_CLIENTS];
|
||||||
int _testMode;
|
AudioCodingModule* _clientACM[NO_OF_CLIENTS];
|
||||||
|
Channel* _conf2Client[NO_OF_CLIENTS];
|
||||||
AudioCodingModule* _defaultACM32;
|
Channel* _client2Conf[NO_OF_CLIENTS];
|
||||||
AudioCodingModule* _defaultACM16;
|
|
||||||
|
|
||||||
AudioCodingModule* _confACM[NO_OF_CLIENTS];
|
|
||||||
AudioCodingModule* _clientACM[NO_OF_CLIENTS];
|
|
||||||
Channel* _conf2Client[NO_OF_CLIENTS];
|
|
||||||
Channel* _client2Conf[NO_OF_CLIENTS];
|
|
||||||
|
|
||||||
PCMFile _clientOutFile[NO_OF_CLIENTS];
|
PCMFile _clientOutFile[NO_OF_CLIENTS];
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,27 +41,28 @@ double FrameRms(AudioFrame& frame) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class InitialPlayoutDelayTest : public ::testing::Test {
|
class InitialPlayoutDelayTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
InitialPlayoutDelayTest()
|
InitialPlayoutDelayTest()
|
||||||
: acm_a_(NULL),
|
: acm_a_(NULL),
|
||||||
acm_b_(NULL),
|
acm_b_(NULL),
|
||||||
channel_a2b_(NULL) {
|
channel_a2b_(NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
~InitialPlayoutDelayTest() {}
|
~InitialPlayoutDelayTest() {
|
||||||
|
}
|
||||||
|
|
||||||
void TearDown() {
|
void TearDown() {
|
||||||
if(acm_a_ != NULL) {
|
if (acm_a_ != NULL) {
|
||||||
AudioCodingModule::Destroy(acm_a_);
|
AudioCodingModule::Destroy(acm_a_);
|
||||||
acm_a_ = NULL;
|
acm_a_ = NULL;
|
||||||
}
|
}
|
||||||
if(acm_b_ != NULL) {
|
if (acm_b_ != NULL) {
|
||||||
AudioCodingModule::Destroy(acm_b_);
|
AudioCodingModule::Destroy(acm_b_);
|
||||||
acm_b_ = NULL;
|
acm_b_ = NULL;
|
||||||
}
|
}
|
||||||
if(channel_a2b_ != NULL) {
|
if (channel_a2b_ != NULL) {
|
||||||
delete channel_a2b_;
|
delete channel_a2b_;
|
||||||
channel_a2b_ = NULL;
|
channel_a2b_ = NULL;
|
||||||
}
|
}
|
||||||
@ -76,8 +77,8 @@ class InitialPlayoutDelayTest : public ::testing::Test {
|
|||||||
|
|
||||||
// Register all L16 codecs in receiver.
|
// Register all L16 codecs in receiver.
|
||||||
CodecInst codec;
|
CodecInst codec;
|
||||||
const int kFsHz[3] = {8000, 16000, 32000};
|
const int kFsHz[3] = { 8000, 16000, 32000 };
|
||||||
const int kChannels[2] = {1, 2};
|
const int kChannels[2] = { 1, 2 };
|
||||||
for (int n = 0; n < 3; ++n) {
|
for (int n = 0; n < 3; ++n) {
|
||||||
for (int k = 0; k < 2; ++k) {
|
for (int k = 0; k < 2; ++k) {
|
||||||
AudioCodingModule::Codec("L16", &codec, kFsHz[n], kChannels[k]);
|
AudioCodingModule::Codec("L16", &codec, kFsHz[n], kChannels[k]);
|
||||||
@ -109,7 +110,7 @@ class InitialPlayoutDelayTest : public ::testing::Test {
|
|||||||
double rms = 0;
|
double rms = 0;
|
||||||
acm_a_->RegisterSendCodec(codec);
|
acm_a_->RegisterSendCodec(codec);
|
||||||
acm_b_->SetInitialPlayoutDelay(initial_delay_ms);
|
acm_b_->SetInitialPlayoutDelay(initial_delay_ms);
|
||||||
while(rms < kAmp / 2) {
|
while (rms < kAmp / 2) {
|
||||||
in_audio_frame.timestamp_ = timestamp;
|
in_audio_frame.timestamp_ = timestamp;
|
||||||
timestamp += in_audio_frame.samples_per_channel_;
|
timestamp += in_audio_frame.samples_per_channel_;
|
||||||
ASSERT_EQ(0, acm_a_->Add10MsData(in_audio_frame));
|
ASSERT_EQ(0, acm_a_->Add10MsData(in_audio_frame));
|
||||||
@ -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
|
||||||
|
@ -23,413 +23,310 @@
|
|||||||
|
|
||||||
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,
|
h = _hour;
|
||||||
unsigned char& s,
|
m = _min;
|
||||||
unsigned short& ms)
|
s = _sec;
|
||||||
{
|
ms = _msec;
|
||||||
h = _hour;
|
return;
|
||||||
m = _min;
|
|
||||||
s = _sec;
|
|
||||||
ms = _msec;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACMTestTimer::Adjust()
|
void ACMTestTimer::Adjust() {
|
||||||
{
|
unsigned int n;
|
||||||
unsigned int n;
|
if (_msec >= 1000) {
|
||||||
if(_msec >= 1000)
|
n = _msec / 1000;
|
||||||
{
|
_msec -= (1000 * n);
|
||||||
n = _msec / 1000;
|
_sec += n;
|
||||||
_msec -= (1000 * n);
|
}
|
||||||
_sec += n;
|
if (_sec >= 60) {
|
||||||
}
|
n = _sec / 60;
|
||||||
if(_sec >= 60)
|
_sec -= (n * 60);
|
||||||
{
|
_min += n;
|
||||||
n = _sec / 60;
|
}
|
||||||
_sec -= (n * 60);
|
if (_min >= 60) {
|
||||||
_min += n;
|
n = _min / 60;
|
||||||
}
|
_min -= (n * 60);
|
||||||
if(_min >= 60)
|
_hour += n;
|
||||||
{
|
}
|
||||||
n = _min / 60;
|
}
|
||||||
_min -= (n * 60);
|
|
||||||
_hour += n;
|
int16_t ChooseCodec(CodecInst& codecInst) {
|
||||||
|
|
||||||
|
PrintCodecs();
|
||||||
|
//AudioCodingModule* tmpACM = AudioCodingModule::Create(0);
|
||||||
|
uint8_t noCodec = AudioCodingModule::NumberOfCodecs();
|
||||||
|
int8_t codecID;
|
||||||
|
bool outOfRange = false;
|
||||||
|
char myStr[15] = "";
|
||||||
|
do {
|
||||||
|
printf("\nChoose a codec [0]: ");
|
||||||
|
EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL);
|
||||||
|
codecID = atoi(myStr);
|
||||||
|
if ((codecID < 0) || (codecID >= noCodec)) {
|
||||||
|
printf("\nOut of range.\n");
|
||||||
|
outOfRange = true;
|
||||||
}
|
}
|
||||||
|
} while (outOfRange);
|
||||||
|
|
||||||
|
CHECK_ERROR(AudioCodingModule::Codec((uint8_t )codecID, &codecInst));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrintCodecs() {
|
||||||
|
uint8_t noCodec = AudioCodingModule::NumberOfCodecs();
|
||||||
|
|
||||||
int16_t
|
CodecInst codecInst;
|
||||||
ChooseCodec(
|
printf("No Name [Hz] [bps]\n");
|
||||||
CodecInst& codecInst)
|
for (uint8_t codecCntr = 0; codecCntr < noCodec; codecCntr++) {
|
||||||
{
|
AudioCodingModule::Codec(codecCntr, &codecInst);
|
||||||
|
printf("%2d- %-18s %5d %6d\n", codecCntr, codecInst.plname,
|
||||||
|
codecInst.plfreq, codecInst.rate);
|
||||||
|
}
|
||||||
|
|
||||||
PrintCodecs();
|
}
|
||||||
//AudioCodingModule* tmpACM = AudioCodingModule::Create(0);
|
|
||||||
uint8_t noCodec = AudioCodingModule::NumberOfCodecs();
|
|
||||||
int8_t codecID;
|
|
||||||
bool outOfRange = false;
|
|
||||||
char myStr[15] = "";
|
|
||||||
do
|
|
||||||
{
|
|
||||||
printf("\nChoose a codec [0]: ");
|
|
||||||
EXPECT_TRUE(fgets(myStr, 10, stdin) != NULL);
|
|
||||||
codecID = atoi(myStr);
|
|
||||||
if((codecID < 0) || (codecID >= noCodec))
|
|
||||||
{
|
|
||||||
printf("\nOut of range.\n");
|
|
||||||
outOfRange = true;
|
|
||||||
}
|
|
||||||
} while(outOfRange);
|
|
||||||
|
|
||||||
CHECK_ERROR(AudioCodingModule::Codec((uint8_t)codecID, &codecInst));
|
CircularBuffer::CircularBuffer(uint32_t len)
|
||||||
|
: _buff(NULL),
|
||||||
|
_idx(0),
|
||||||
|
_buffIsFull(false),
|
||||||
|
_calcAvg(false),
|
||||||
|
_calcVar(false),
|
||||||
|
_sum(0),
|
||||||
|
_sumSqr(0) {
|
||||||
|
_buff = new double[len];
|
||||||
|
if (_buff == NULL) {
|
||||||
|
_buffLen = 0;
|
||||||
|
} else {
|
||||||
|
for (uint32_t n = 0; n < len; n++) {
|
||||||
|
_buff[n] = 0;
|
||||||
|
}
|
||||||
|
_buffLen = len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CircularBuffer::~CircularBuffer() {
|
||||||
|
if (_buff != NULL) {
|
||||||
|
delete[] _buff;
|
||||||
|
_buff = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CircularBuffer::Update(const double newVal) {
|
||||||
|
assert(_buffLen > 0);
|
||||||
|
|
||||||
|
// store the value that is going to be overwritten
|
||||||
|
double oldVal = _buff[_idx];
|
||||||
|
// record the new value
|
||||||
|
_buff[_idx] = newVal;
|
||||||
|
// increment the index, to point to where we would
|
||||||
|
// write next
|
||||||
|
_idx++;
|
||||||
|
// it is a circular buffer, if we are at the end
|
||||||
|
// we have to cycle to the beginning
|
||||||
|
if (_idx >= _buffLen) {
|
||||||
|
// flag that the buffer is filled up.
|
||||||
|
_buffIsFull = true;
|
||||||
|
_idx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update
|
||||||
|
|
||||||
|
if (_calcAvg) {
|
||||||
|
// for the average we have to update
|
||||||
|
// the sum
|
||||||
|
_sum += (newVal - oldVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_calcVar) {
|
||||||
|
// to calculate variance we have to update
|
||||||
|
// the sum of squares
|
||||||
|
_sumSqr += (double) (newVal - oldVal) * (double) (newVal + oldVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CircularBuffer::SetArithMean(bool enable) {
|
||||||
|
assert(_buffLen > 0);
|
||||||
|
|
||||||
|
if (enable && !_calcAvg) {
|
||||||
|
uint32_t lim;
|
||||||
|
if (_buffIsFull) {
|
||||||
|
lim = _buffLen;
|
||||||
|
} else {
|
||||||
|
lim = _idx;
|
||||||
|
}
|
||||||
|
_sum = 0;
|
||||||
|
for (uint32_t n = 0; n < lim; n++) {
|
||||||
|
_sum += _buff[n];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_calcAvg = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CircularBuffer::SetVariance(bool enable) {
|
||||||
|
assert(_buffLen > 0);
|
||||||
|
|
||||||
|
if (enable && !_calcVar) {
|
||||||
|
uint32_t lim;
|
||||||
|
if (_buffIsFull) {
|
||||||
|
lim = _buffLen;
|
||||||
|
} else {
|
||||||
|
lim = _idx;
|
||||||
|
}
|
||||||
|
_sumSqr = 0;
|
||||||
|
for (uint32_t n = 0; n < lim; n++) {
|
||||||
|
_sumSqr += _buff[n] * _buff[n];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_calcAvg = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t CircularBuffer::ArithMean(double& mean) {
|
||||||
|
assert(_buffLen > 0);
|
||||||
|
|
||||||
|
if (_buffIsFull) {
|
||||||
|
|
||||||
|
mean = _sum / (double) _buffLen;
|
||||||
return 0;
|
return 0;
|
||||||
|
} else {
|
||||||
|
if (_idx > 0) {
|
||||||
|
mean = _sum / (double) _idx;
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int16_t CircularBuffer::Variance(double& var) {
|
||||||
PrintCodecs()
|
assert(_buffLen > 0);
|
||||||
{
|
|
||||||
uint8_t noCodec = AudioCodingModule::NumberOfCodecs();
|
|
||||||
|
|
||||||
CodecInst codecInst;
|
if (_buffIsFull) {
|
||||||
printf("No Name [Hz] [bps]\n");
|
var = _sumSqr / (double) _buffLen;
|
||||||
for(uint8_t codecCntr = 0; codecCntr < noCodec; codecCntr++)
|
|
||||||
{
|
|
||||||
AudioCodingModule::Codec(codecCntr, &codecInst);
|
|
||||||
printf("%2d- %-18s %5d %6d\n",
|
|
||||||
codecCntr, codecInst.plname, codecInst.plfreq, codecInst.rate);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
CircularBuffer::CircularBuffer(uint32_t len):
|
|
||||||
_buff(NULL),
|
|
||||||
_idx(0),
|
|
||||||
_buffIsFull(false),
|
|
||||||
_calcAvg(false),
|
|
||||||
_calcVar(false),
|
|
||||||
_sum(0),
|
|
||||||
_sumSqr(0)
|
|
||||||
{
|
|
||||||
_buff = new double[len];
|
|
||||||
if(_buff == NULL)
|
|
||||||
{
|
|
||||||
_buffLen = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for(uint32_t n = 0; n < len; n++)
|
|
||||||
{
|
|
||||||
_buff[n] = 0;
|
|
||||||
}
|
|
||||||
_buffLen = len;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CircularBuffer::~CircularBuffer()
|
|
||||||
{
|
|
||||||
if(_buff != NULL)
|
|
||||||
{
|
|
||||||
delete [] _buff;
|
|
||||||
_buff = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
CircularBuffer::Update(
|
|
||||||
const double newVal)
|
|
||||||
{
|
|
||||||
assert(_buffLen > 0);
|
|
||||||
|
|
||||||
// store the value that is going to be overwritten
|
|
||||||
double oldVal = _buff[_idx];
|
|
||||||
// record the new value
|
|
||||||
_buff[_idx] = newVal;
|
|
||||||
// increment the index, to point to where we would
|
|
||||||
// write next
|
|
||||||
_idx++;
|
|
||||||
// it is a circular buffer, if we are at the end
|
|
||||||
// we have to cycle to the beginning
|
|
||||||
if(_idx >= _buffLen)
|
|
||||||
{
|
|
||||||
// flag that the buffer is filled up.
|
|
||||||
_buffIsFull = true;
|
|
||||||
_idx = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update
|
|
||||||
|
|
||||||
if(_calcAvg)
|
|
||||||
{
|
|
||||||
// for the average we have to update
|
|
||||||
// the sum
|
|
||||||
_sum += (newVal - oldVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_calcVar)
|
|
||||||
{
|
|
||||||
// to calculate variance we have to update
|
|
||||||
// the sum of squares
|
|
||||||
_sumSqr += (double)(newVal - oldVal) * (double)(newVal + oldVal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
CircularBuffer::SetArithMean(
|
|
||||||
bool enable)
|
|
||||||
{
|
|
||||||
assert(_buffLen > 0);
|
|
||||||
|
|
||||||
if(enable && !_calcAvg)
|
|
||||||
{
|
|
||||||
uint32_t lim;
|
|
||||||
if(_buffIsFull)
|
|
||||||
{
|
|
||||||
lim = _buffLen;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lim = _idx;
|
|
||||||
}
|
|
||||||
_sum = 0;
|
|
||||||
for(uint32_t n = 0; n < lim; n++)
|
|
||||||
{
|
|
||||||
_sum += _buff[n];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_calcAvg = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
CircularBuffer::SetVariance(
|
|
||||||
bool enable)
|
|
||||||
{
|
|
||||||
assert(_buffLen > 0);
|
|
||||||
|
|
||||||
if(enable && !_calcVar)
|
|
||||||
{
|
|
||||||
uint32_t lim;
|
|
||||||
if(_buffIsFull)
|
|
||||||
{
|
|
||||||
lim = _buffLen;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lim = _idx;
|
|
||||||
}
|
|
||||||
_sumSqr = 0;
|
|
||||||
for(uint32_t n = 0; n < lim; n++)
|
|
||||||
{
|
|
||||||
_sumSqr += _buff[n] * _buff[n];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_calcAvg = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
int16_t
|
|
||||||
CircularBuffer::ArithMean(double& mean)
|
|
||||||
{
|
|
||||||
assert(_buffLen > 0);
|
|
||||||
|
|
||||||
if(_buffIsFull)
|
|
||||||
{
|
|
||||||
|
|
||||||
mean = _sum / (double)_buffLen;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(_idx > 0)
|
|
||||||
{
|
|
||||||
mean = _sum / (double)_idx;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int16_t
|
|
||||||
CircularBuffer::Variance(double& var)
|
|
||||||
{
|
|
||||||
assert(_buffLen > 0);
|
|
||||||
|
|
||||||
if(_buffIsFull)
|
|
||||||
{
|
|
||||||
var = _sumSqr / (double)_buffLen;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(_idx > 0)
|
|
||||||
{
|
|
||||||
var = _sumSqr / (double)_idx;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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++)
|
|
||||||
{
|
|
||||||
if(!STR_CASE_CMP(payloadName, fixPayloadTypeCodecs[n]))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DTMFDetector::DTMFDetector()
|
|
||||||
{
|
|
||||||
for(int16_t n = 0; n < 1000; n++)
|
|
||||||
{
|
|
||||||
_toneCntr[n] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DTMFDetector::~DTMFDetector()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t DTMFDetector::IncomingDtmf(const uint8_t digitDtmf, const bool /* toneEnded */)
|
|
||||||
{
|
|
||||||
fprintf(stdout, "%d-",digitDtmf);
|
|
||||||
_toneCntr[digitDtmf]++;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else {
|
||||||
|
if (_idx > 0) {
|
||||||
void DTMFDetector::PrintDetectedDigits()
|
var = _sumSqr / (double) _idx;
|
||||||
{
|
return 0;
|
||||||
for(int16_t n = 0; n < 1000; n++)
|
} else {
|
||||||
{
|
return -1;
|
||||||
if(_toneCntr[n] > 0)
|
|
||||||
{
|
|
||||||
fprintf(stdout, "%d %u msec, \n", n, _toneCntr[n]*10);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fprintf(stdout, "\n");
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool FixedPayloadTypeCodec(const char* payloadName) {
|
||||||
VADCallback::Reset()
|
char fixPayloadTypeCodecs[NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE][32] = { "PCMU",
|
||||||
{
|
"PCMA", "GSM", "G723", "DVI4", "LPC", "PCMA", "G722", "QCELP", "CN",
|
||||||
for(int n = 0; n < 6; n++)
|
"MPA", "G728", "G729" };
|
||||||
{
|
|
||||||
_numFrameTypes[n] = 0;
|
for (int n = 0; n < NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE; n++) {
|
||||||
|
if (!STR_CASE_CMP(payloadName, fixPayloadTypeCodecs[n])) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
VADCallback::VADCallback()
|
DTMFDetector::DTMFDetector() {
|
||||||
{
|
for (int16_t n = 0; n < 1000; n++) {
|
||||||
for(int n = 0; n < 6; n++)
|
_toneCntr[n] = 0;
|
||||||
{
|
}
|
||||||
_numFrameTypes[n] = 0;
|
}
|
||||||
|
|
||||||
|
DTMFDetector::~DTMFDetector() {
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t DTMFDetector::IncomingDtmf(const uint8_t digitDtmf,
|
||||||
|
const bool /* toneEnded */) {
|
||||||
|
fprintf(stdout, "%d-", digitDtmf);
|
||||||
|
_toneCntr[digitDtmf]++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DTMFDetector::PrintDetectedDigits() {
|
||||||
|
for (int16_t n = 0; n < 1000; n++) {
|
||||||
|
if (_toneCntr[n] > 0) {
|
||||||
|
fprintf(stdout, "%d %u msec, \n", n, _toneCntr[n] * 10);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
fprintf(stdout, "\n");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void VADCallback::Reset() {
|
||||||
VADCallback::PrintFrameTypes()
|
for (int n = 0; n < 6; n++) {
|
||||||
{
|
_numFrameTypes[n] = 0;
|
||||||
fprintf(stdout, "No encoding.................. %d\n", _numFrameTypes[0]);
|
}
|
||||||
fprintf(stdout, "Active normal encoded........ %d\n", _numFrameTypes[1]);
|
|
||||||
fprintf(stdout, "Passive normal encoded....... %d\n", _numFrameTypes[2]);
|
|
||||||
fprintf(stdout, "Passive DTX wideband......... %d\n", _numFrameTypes[3]);
|
|
||||||
fprintf(stdout, "Passive DTX narrowband....... %d\n", _numFrameTypes[4]);
|
|
||||||
fprintf(stdout, "Passive DTX super-wideband... %d\n", _numFrameTypes[5]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t
|
VADCallback::VADCallback() {
|
||||||
VADCallback::InFrameType(
|
for (int n = 0; n < 6; n++) {
|
||||||
int16_t frameType)
|
_numFrameTypes[n] = 0;
|
||||||
{
|
}
|
||||||
_numFrameTypes[frameType]++;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
void VADCallback::PrintFrameTypes() {
|
||||||
|
fprintf(stdout, "No encoding.................. %d\n", _numFrameTypes[0]);
|
||||||
|
fprintf(stdout, "Active normal encoded........ %d\n", _numFrameTypes[1]);
|
||||||
|
fprintf(stdout, "Passive normal encoded....... %d\n", _numFrameTypes[2]);
|
||||||
|
fprintf(stdout, "Passive DTX wideband......... %d\n", _numFrameTypes[3]);
|
||||||
|
fprintf(stdout, "Passive DTX narrowband....... %d\n", _numFrameTypes[4]);
|
||||||
|
fprintf(stdout, "Passive DTX super-wideband... %d\n", _numFrameTypes[5]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t VADCallback::InFrameType(int16_t frameType) {
|
||||||
|
_numFrameTypes[frameType]++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
|
@ -17,166 +17,138 @@
|
|||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
//-----------------------------
|
//-----------------------------
|
||||||
#define CHECK_ERROR(f) \
|
#define CHECK_ERROR(f) \
|
||||||
do { \
|
do { \
|
||||||
EXPECT_GE(f, 0) << "Error Calling API"; \
|
EXPECT_GE(f, 0) << "Error Calling API"; \
|
||||||
}while(0)
|
} while(0)
|
||||||
|
|
||||||
//-----------------------------
|
//-----------------------------
|
||||||
#define CHECK_PROTECTED(f) \
|
#define CHECK_PROTECTED(f) \
|
||||||
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)
|
|
||||||
|
|
||||||
//----------------------------
|
//----------------------------
|
||||||
#define CHECK_ERROR_MT(f) \
|
#define CHECK_ERROR_MT(f) \
|
||||||
do { \
|
do { \
|
||||||
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__); \
|
||||||
} \
|
} \
|
||||||
}while(0)
|
} while(0)
|
||||||
|
|
||||||
//----------------------------
|
//----------------------------
|
||||||
#define CHECK_PROTECTED_MT(f) \
|
#define CHECK_PROTECTED_MT(f) \
|
||||||
do { \
|
do { \
|
||||||
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) \
|
||||||
|
do { \
|
||||||
|
if (acm != NULL) { \
|
||||||
|
AudioCodingModule::Destroy(acm); \
|
||||||
|
acm = NULL; \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
#define DESTROY_ACM(acm) \
|
#define DELETE_POINTER(p) \
|
||||||
do { \
|
do { \
|
||||||
if(acm != NULL) { \
|
if (p != NULL) { \
|
||||||
AudioCodingModule::Destroy(acm); \
|
delete p; \
|
||||||
acm = NULL; \
|
p = NULL; \
|
||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
class ACMTestTimer {
|
||||||
|
public:
|
||||||
|
ACMTestTimer();
|
||||||
|
~ACMTestTimer();
|
||||||
|
|
||||||
#define DELETE_POINTER(p) \
|
void Reset();
|
||||||
do { \
|
void Tick10ms();
|
||||||
if(p != NULL) { \
|
void Tick1ms();
|
||||||
delete p; \
|
void Tick100ms();
|
||||||
p = NULL; \
|
void Tick1sec();
|
||||||
} \
|
void CurrentTimeHMS(char* currTime);
|
||||||
} while(0)
|
void CurrentTime(unsigned long& h, unsigned char& m, unsigned char& s,
|
||||||
|
unsigned short& ms);
|
||||||
|
|
||||||
class ACMTestTimer
|
private:
|
||||||
{
|
void Adjust();
|
||||||
public:
|
|
||||||
ACMTestTimer();
|
|
||||||
~ACMTestTimer();
|
|
||||||
|
|
||||||
void Reset();
|
unsigned short _msec;
|
||||||
void Tick10ms();
|
unsigned char _sec;
|
||||||
void Tick1ms();
|
unsigned char _min;
|
||||||
void Tick100ms();
|
unsigned long _hour;
|
||||||
void Tick1sec();
|
|
||||||
void CurrentTimeHMS(
|
|
||||||
char* currTime);
|
|
||||||
void CurrentTime(
|
|
||||||
unsigned long& h,
|
|
||||||
unsigned char& m,
|
|
||||||
unsigned char& s,
|
|
||||||
unsigned short& ms);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void Adjust();
|
|
||||||
|
|
||||||
unsigned short _msec;
|
|
||||||
unsigned char _sec;
|
|
||||||
unsigned char _min;
|
|
||||||
unsigned long _hour;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CircularBuffer {
|
||||||
|
public:
|
||||||
|
CircularBuffer(uint32_t len);
|
||||||
|
~CircularBuffer();
|
||||||
|
|
||||||
|
void SetArithMean(bool enable);
|
||||||
|
void SetVariance(bool enable);
|
||||||
|
|
||||||
class CircularBuffer
|
void Update(const double newVal);
|
||||||
{
|
void IsBufferFull();
|
||||||
public:
|
|
||||||
CircularBuffer(uint32_t len);
|
|
||||||
~CircularBuffer();
|
|
||||||
|
|
||||||
void SetArithMean(
|
int16_t Variance(double& var);
|
||||||
bool enable);
|
int16_t ArithMean(double& mean);
|
||||||
void SetVariance(
|
|
||||||
bool enable);
|
|
||||||
|
|
||||||
void Update(
|
protected:
|
||||||
const double newVal);
|
double* _buff;
|
||||||
void IsBufferFull();
|
uint32_t _idx;
|
||||||
|
uint32_t _buffLen;
|
||||||
|
|
||||||
int16_t Variance(double& var);
|
bool _buffIsFull;
|
||||||
int16_t ArithMean(double& mean);
|
bool _calcAvg;
|
||||||
|
bool _calcVar;
|
||||||
protected:
|
double _sum;
|
||||||
double* _buff;
|
double _sumSqr;
|
||||||
uint32_t _idx;
|
|
||||||
uint32_t _buffLen;
|
|
||||||
|
|
||||||
bool _buffIsFull;
|
|
||||||
bool _calcAvg;
|
|
||||||
bool _calcVar;
|
|
||||||
double _sum;
|
|
||||||
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 {
|
||||||
|
public:
|
||||||
|
DTMFDetector();
|
||||||
|
~DTMFDetector();
|
||||||
|
// used for inband DTMF detection
|
||||||
|
int32_t IncomingDtmf(const uint8_t digitDtmf, const bool toneEnded);
|
||||||
|
void PrintDetectedDigits();
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t _toneCntr[1000];
|
||||||
class DTMFDetector: public AudioCodingFeedback
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DTMFDetector();
|
|
||||||
~DTMFDetector();
|
|
||||||
// used for inband DTMF detection
|
|
||||||
int32_t IncomingDtmf(const uint8_t digitDtmf, const bool toneEnded);
|
|
||||||
void PrintDetectedDigits();
|
|
||||||
|
|
||||||
private:
|
|
||||||
uint32_t _toneCntr[1000];
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class VADCallback : public ACMVADCallback {
|
||||||
|
public:
|
||||||
|
VADCallback();
|
||||||
|
~VADCallback() {
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t InFrameType(int16_t frameType);
|
||||||
|
|
||||||
|
void PrintFrameTypes();
|
||||||
|
void Reset();
|
||||||
|
|
||||||
class VADCallback : public ACMVADCallback
|
private:
|
||||||
{
|
uint32_t _numFrameTypes[6];
|
||||||
public:
|
|
||||||
VADCallback();
|
|
||||||
~VADCallback(){}
|
|
||||||
|
|
||||||
int32_t InFrameType(
|
|
||||||
int16_t frameType);
|
|
||||||
|
|
||||||
void PrintFrameTypes();
|
|
||||||
void Reset();
|
|
||||||
|
|
||||||
private:
|
|
||||||
uint32_t _numFrameTypes[6];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user