diff --git a/src/modules/audio_coding/main/test/TestAllCodecs.cc b/src/modules/audio_coding/main/test/TestAllCodecs.cc index cafbc19489..7d3b32feba 100644 --- a/src/modules/audio_coding/main/test/TestAllCodecs.cc +++ b/src/modules/audio_coding/main/test/TestAllCodecs.cc @@ -11,865 +11,797 @@ #include "TestAllCodecs.h" #include -#include #include +#include "gtest/gtest.h" + +#include "audio_coding_module.h" #include "audio_coding_module_typedefs.h" #include "common_types.h" #include "engine_configurations.h" #include "testsupport/fileutils.h" #include "trace.h" +#include "typedefs.h" #include "utility.h" +// Description of the test: +// In this test we set up a one-way communication channel from a participant +// called "a" to a participant called "b". +// a -> channel_a_to_b -> b +// +// The test loops through all available mono codecs, encode at "a" sends over +// the channel, and decodes at "b". + namespace webrtc { -// Class for simulating packet handling -TestPack::TestPack(): -_receiverACM(NULL), -_seqNo(0), -_timeStampDiff(0), -_lastInTimestamp(0), -_totalBytes(0), -_payloadSize(0) -{ -} -TestPack::~TestPack() -{ +// Class for simulating packet handling. +TestPack::TestPack() + : receiver_acm_(NULL), + sequence_number_(0), + timestamp_diff_(0), + last_in_timestamp_(0), + total_bytes_(0), + payload_size_(0) { } -void -TestPack::RegisterReceiverACM(AudioCodingModule* acm) -{ - _receiverACM = acm; - return; -} -WebRtc_Word32 -TestPack::SendData( - const FrameType frameType, - const WebRtc_UWord8 payloadType, - const WebRtc_UWord32 timeStamp, - const WebRtc_UWord8* payloadData, - const WebRtc_UWord16 payloadSize, - const RTPFragmentationHeader* fragmentation) -{ - WebRtcRTPHeader rtpInfo; - WebRtc_Word32 status; - WebRtc_UWord16 payloadDataSize = payloadSize; - - rtpInfo.header.markerBit = false; - rtpInfo.header.ssrc = 0; - rtpInfo.header.sequenceNumber = _seqNo++; - rtpInfo.header.payloadType = payloadType; - rtpInfo.header.timestamp = timeStamp; - if(frameType == kAudioFrameCN) - { - rtpInfo.type.Audio.isCNG = true; - } - else - { - rtpInfo.type.Audio.isCNG = false; - } - if(frameType == kFrameEmpty) - { - // Skip this frame - return 0; - } - - rtpInfo.type.Audio.channel = 1; - memcpy(_payloadData, payloadData, payloadDataSize); - - status = _receiverACM->IncomingPacket(_payloadData, payloadDataSize, - rtpInfo); - - _payloadSize = payloadDataSize; - _timeStampDiff = timeStamp - _lastInTimestamp; - _lastInTimestamp = timeStamp; - _totalBytes += payloadDataSize; - return status; +TestPack::~TestPack() { } -WebRtc_UWord16 -TestPack::GetPayloadSize() -{ - return _payloadSize; +void TestPack::RegisterReceiverACM(AudioCodingModule* acm) { + receiver_acm_ = acm; + return; } +int32_t TestPack::SendData(FrameType frame_type, uint8_t payload_type, + uint32_t timestamp, const uint8_t* payload_data, + uint16_t payload_size, + const RTPFragmentationHeader* fragmentation) { + WebRtcRTPHeader rtp_info; + int32_t status; -WebRtc_UWord32 -TestPack::GetTimeStampDiff() -{ - return _timeStampDiff; + rtp_info.header.markerBit = false; + rtp_info.header.ssrc = 0; + rtp_info.header.sequenceNumber = sequence_number_++; + rtp_info.header.payloadType = payload_type; + rtp_info.header.timestamp = timestamp; + if (frame_type == kAudioFrameCN) { + rtp_info.type.Audio.isCNG = true; + } else { + rtp_info.type.Audio.isCNG = false; + } + if (frame_type == kFrameEmpty) { + // Skip this frame. + return 0; + } + + // Only run mono for all test cases. + rtp_info.type.Audio.channel = 1; + memcpy(payload_data_, payload_data, payload_size); + + status = receiver_acm_->IncomingPacket(payload_data_, payload_size, + rtp_info); + + payload_size_ = payload_size; + timestamp_diff_ = timestamp - last_in_timestamp_; + last_in_timestamp_ = timestamp; + total_bytes_ += payload_size; + return status; } -void -TestPack::ResetPayloadSize() -{ - _payloadSize = 0; +uint16_t TestPack::payload_size() { + return payload_size_; } -TestAllCodecs::TestAllCodecs(int testMode): -_acmA(NULL), -_acmB(NULL), -_channelA2B(NULL), -_testCntr(0), -_packSizeSamp(0), -_packSizeBytes(0), -_counter(0) -{ - // testMode = 0 for silent test (auto test) - _testMode = testMode; +uint32_t TestPack::timestamp_diff() { + return timestamp_diff_; } -TestAllCodecs::~TestAllCodecs() -{ - if(_acmA != NULL) - { - AudioCodingModule::Destroy(_acmA); - _acmA = NULL; - } - if(_acmB != NULL) - { - AudioCodingModule::Destroy(_acmB); - _acmB = NULL; - } - if(_channelA2B != NULL) - { - delete _channelA2B; - _channelA2B = NULL; - } +void TestPack::reset_payload_size() { + payload_size_ = 0; } -void TestAllCodecs::Perform() -{ +TestAllCodecs::TestAllCodecs(int test_mode) + : acm_a_(NULL), + acm_b_(NULL), + channel_a_to_b_(NULL), + test_count_(0), + packet_size_samples_(0), + packet_size_bytes_(0) { + // test_mode = 0 for silent test (auto test) + test_mode_ = test_mode; +} - char file[] = "./data/audio_coding/testfile32kHz.pcm"; - _inFileA.Open(file, 32000, "rb"); +TestAllCodecs::~TestAllCodecs() { + if (acm_a_ != NULL) { + AudioCodingModule::Destroy(acm_a_); + acm_a_ = NULL; + } + if (acm_b_ != NULL) { + AudioCodingModule::Destroy(acm_b_); + acm_b_ = NULL; + } + if (channel_a_to_b_ != NULL) { + delete channel_a_to_b_; + channel_a_to_b_ = NULL; + } +} - if(_testMode == 0) - { - printf("Running All Codecs Test"); - WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1, - "---------- TestAllCodecs ----------"); - } +void TestAllCodecs::Perform() { + char file[] = "./data/audio_coding/testfile32kHz.pcm"; + infile_a_.Open(file, 32000, "rb"); - _acmA = AudioCodingModule::Create(0); - _acmB = AudioCodingModule::Create(1); + if (test_mode_ == 0) { + WEBRTC_TRACE(kTraceStateInfo, kTraceAudioCoding, -1, + "---------- TestAllCodecs ----------"); + } - _acmA->InitializeReceiver(); - _acmB->InitializeReceiver(); + acm_a_ = AudioCodingModule::Create(0); + acm_b_ = AudioCodingModule::Create(1); - WebRtc_UWord8 numEncoders = _acmA->NumberOfCodecs(); - CodecInst myCodecParam; - - for(WebRtc_UWord8 n = 0; n < numEncoders; n++) - { - _acmB->Codec(n, myCodecParam); - _acmB->RegisterReceiveCodec(myCodecParam); - } + acm_a_->InitializeReceiver(); + acm_b_->InitializeReceiver(); - // Create and connect the channel - _channelA2B = new TestPack; - _acmA->RegisterTransportCallback(_channelA2B); - _channelA2B->RegisterReceiverACM(_acmB); + uint8_t num_encoders = acm_a_->NumberOfCodecs(); + CodecInst my_codec_param; + for (uint8_t n = 0; n < num_encoders; n++) { + acm_b_->Codec(n, my_codec_param); + acm_b_->RegisterReceiveCodec(my_codec_param); + } - // All codecs are tested for all allowed sampling frequencies, rates and packet sizes -#ifdef WEBRTC_CODEC_GSMAMR - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - OpenOutFile(_testCntr); - char codecAMR[] = "AMR"; - RegisterSendCodec('A', codecAMR, 8000, 4750, 160, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 4750, 320, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 4750, 480, 3); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 5150, 160, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 5150, 320, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 5150, 480, 3); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 5900, 160, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 5900, 320, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 5900, 480, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 6700, 160, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 6700, 320, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 6700, 480, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 7400, 160, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 7400, 320, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 7400, 480, 3); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 7950, 160, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 7950, 320, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 7950, 480, 3); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 10200, 160, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 10200, 320, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 10200, 480, 3); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 12200, 160, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 12200, 320, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMR, 8000, 12200, 480, 3); - Run(_channelA2B); - _outFileB.Close(); + // Create and connect the channel + channel_a_to_b_ = new TestPack; + acm_a_->RegisterTransportCallback(channel_a_to_b_); + channel_a_to_b_->RegisterReceiverACM(acm_b_); + + // All codecs are tested for all allowed sampling frequencies, rates and + // packet sizes. +#ifdef WEBRTC_CODEC_AMR + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + OpenOutFile(test_count_); + char codec_amr[] = "AMR"; + RegisterSendCodec('A', codec_amr, 8000, 4750, 160, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 4750, 320, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 4750, 480, 3); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 5150, 160, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 5150, 320, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 5150, 480, 3); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 5900, 160, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 5900, 320, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 5900, 480, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 6700, 160, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 6700, 320, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 6700, 480, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 7400, 160, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 7400, 320, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 7400, 480, 3); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 7950, 160, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 7950, 320, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 7950, 480, 3); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 10200, 160, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 10200, 320, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 10200, 480, 3); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 12200, 160, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 12200, 320, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amr, 8000, 12200, 480, 3); + Run(channel_a_to_b_); + outfile_b_.Close(); #endif -#ifdef WEBRTC_CODEC_GSMAMRWB - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - char codecAMRWB[] = "AMR-WB"; - OpenOutFile(_testCntr); - RegisterSendCodec('A', codecAMRWB, 16000, 7000, 320, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 7000, 640, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 7000, 960, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 9000, 320, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 9000, 640, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 9000, 960, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 12000, 320, 3); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 12000, 640, 6); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 12000, 960, 8); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 14000, 320, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 14000, 640, 4); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 14000, 960, 5); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 16000, 320, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 16000, 640, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 16000, 960, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 18000, 320, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 18000, 640, 4); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 18000, 960, 5); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 20000, 320, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 20000, 640, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 20000, 960, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 23000, 320, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 23000, 640, 3); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 23000, 960, 3); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 24000, 320, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 24000, 640, 2); - Run(_channelA2B); - RegisterSendCodec('A', codecAMRWB, 16000, 24000, 960, 2); - Run(_channelA2B); - _outFileB.Close(); +#ifdef WEBRTC_CODEC_AMRWB + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + char codec_amrwb[] = "AMR-WB"; + OpenOutFile(test_count_); + RegisterSendCodec('A', codec_amrwb, 16000, 7000, 320, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 7000, 640, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 7000, 960, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 9000, 320, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 9000, 640, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 9000, 960, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 12000, 320, 3); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 12000, 640, 6); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 12000, 960, 8); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 14000, 320, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 14000, 640, 4); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 14000, 960, 5); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 16000, 320, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 16000, 640, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 16000, 960, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 18000, 320, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 18000, 640, 4); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 18000, 960, 5); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 20000, 320, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 20000, 640, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 20000, 960, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 23000, 320, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 23000, 640, 3); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 23000, 960, 3); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 24000, 320, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 24000, 640, 2); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_amrwb, 16000, 24000, 960, 2); + Run(channel_a_to_b_); + outfile_b_.Close(); #endif #ifdef WEBRTC_CODEC_G722 - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - OpenOutFile(_testCntr); - char codecG722[] = "G722"; - RegisterSendCodec('A', codecG722, 16000, 64000, 160, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecG722, 16000, 64000, 320, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecG722, 16000, 64000, 480, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecG722, 16000, 64000, 640, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecG722, 16000, 64000, 800, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecG722, 16000, 64000, 960, 0); - Run(_channelA2B); - _outFileB.Close(); + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + OpenOutFile(test_count_); + char codec_g722[] = "G722"; + RegisterSendCodec('A', codec_g722, 16000, 64000, 160, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g722, 16000, 64000, 320, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g722, 16000, 64000, 480, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g722, 16000, 64000, 640, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g722, 16000, 64000, 800, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g722, 16000, 64000, 960, 0); + Run(channel_a_to_b_); + outfile_b_.Close(); #endif #ifdef WEBRTC_CODEC_G722_1 - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - OpenOutFile(_testCntr); - char codecG7221_1[] = "G7221"; - RegisterSendCodec('A', codecG7221_1, 16000, 32000, 320, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecG7221_1, 16000, 24000, 320, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecG7221_1, 16000, 16000, 320, 0); - Run(_channelA2B); - _outFileB.Close(); + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + OpenOutFile(test_count_); + char codec_g722_1[] = "G7221"; + RegisterSendCodec('A', codec_g722_1, 16000, 32000, 320, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g722_1, 16000, 24000, 320, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g722_1, 16000, 16000, 320, 0); + Run(channel_a_to_b_); + outfile_b_.Close(); #endif #ifdef WEBRTC_CODEC_G722_1C - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - OpenOutFile(_testCntr); - char codecG7221_2[] = "G7221"; - RegisterSendCodec('A', codecG7221_2, 32000, 48000, 640, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecG7221_2, 32000, 32000, 640, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecG7221_2, 32000, 24000, 640, 0); - Run(_channelA2B); - _outFileB.Close(); + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + OpenOutFile(test_count_); + char codec_g722_1c[] = "G7221"; + RegisterSendCodec('A', codec_g722_1c, 32000, 48000, 640, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g722_1c, 32000, 32000, 640, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g722_1c, 32000, 24000, 640, 0); + Run(channel_a_to_b_); + outfile_b_.Close(); #endif #ifdef WEBRTC_CODEC_G729 - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - OpenOutFile(_testCntr); - char codecG729[] = "G729"; - RegisterSendCodec('A', codecG729, 8000, 8000, 80, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecG729, 8000, 8000, 160, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecG729, 8000, 8000, 240, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecG729, 8000, 8000, 320, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecG729, 8000, 8000, 400, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecG729, 8000, 8000, 480, 0); - Run(_channelA2B); - _outFileB.Close(); + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + OpenOutFile(test_count_); + char codec_g729[] = "G729"; + RegisterSendCodec('A', codec_g729, 8000, 8000, 80, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729, 8000, 8000, 160, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729, 8000, 8000, 240, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729, 8000, 8000, 320, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729, 8000, 8000, 400, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729, 8000, 8000, 480, 0); + Run(channel_a_to_b_); + outfile_b_.Close(); #endif #ifdef WEBRTC_CODEC_G729_1 - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - OpenOutFile(_testCntr); - char codecG7291[] = "G7291"; - RegisterSendCodec('A', codecG7291, 16000, 8000, 320, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 8000, 640, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 8000, 960, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 12000, 320, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 12000, 640, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 12000, 960, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 14000, 320, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 14000, 640, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 14000, 960, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 16000, 320, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 16000, 640, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 16000, 960, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 18000, 320, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 18000, 640, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 18000, 960, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 20000, 320, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 20000, 640, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 20000, 960, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 22000, 320, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 22000, 640, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 22000, 960, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 24000, 320, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 24000, 640, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 24000, 960, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 26000, 320, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 26000, 640, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 26000, 960, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 28000, 320, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 28000, 640, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 28000, 960, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 30000, 320, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 30000, 640, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 30000, 960, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 32000, 320, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 32000, 640, 1); - Run(_channelA2B); - RegisterSendCodec('A', codecG7291, 16000, 32000, 960, 1); - Run(_channelA2B); - _outFileB.Close(); + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + OpenOutFile(test_count_); + char codec_g729_1[] = "G7291"; + RegisterSendCodec('A', codec_g729_1, 16000, 8000, 320, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 8000, 640, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 8000, 960, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 12000, 320, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 12000, 640, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 12000, 960, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 14000, 320, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 14000, 640, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 14000, 960, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 16000, 320, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 16000, 640, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 16000, 960, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 18000, 320, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 18000, 640, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 18000, 960, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 20000, 320, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 20000, 640, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 20000, 960, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 22000, 320, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 22000, 640, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 22000, 960, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 24000, 320, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 24000, 640, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 24000, 960, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 26000, 320, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 26000, 640, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 26000, 960, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 28000, 320, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 28000, 640, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 28000, 960, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 30000, 320, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 30000, 640, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 30000, 960, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 32000, 320, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 32000, 640, 1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_g729_1, 16000, 32000, 960, 1); + Run(channel_a_to_b_); + outfile_b_.Close(); #endif #ifdef WEBRTC_CODEC_GSMFR - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - OpenOutFile(_testCntr); - char codecGSM[] = "GSM"; - RegisterSendCodec('A', codecGSM, 8000, 13200, 160, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecGSM, 8000, 13200, 320, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecGSM, 8000, 13200, 480, 0); - Run(_channelA2B); - _outFileB.Close(); + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + OpenOutFile(test_count_); + char codec_gsmfr[] = "GSM"; + RegisterSendCodec('A', codec_gsmfr, 8000, 13200, 160, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_gsmfr, 8000, 13200, 320, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_gsmfr, 8000, 13200, 480, 0); + Run(channel_a_to_b_); + outfile_b_.Close(); #endif #ifdef WEBRTC_CODEC_ILBC - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - OpenOutFile(_testCntr); - char codecILBC[] = "ILBC"; - RegisterSendCodec('A', codecILBC, 8000, 13300, 240, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecILBC, 8000, 13300, 480, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecILBC, 8000, 15200, 160, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecILBC, 8000, 15200, 320, 0); - Run(_channelA2B); - _outFileB.Close(); + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + OpenOutFile(test_count_); + char codec_ilbc[] = "ILBC"; + RegisterSendCodec('A', codec_ilbc, 8000, 13300, 240, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_ilbc, 8000, 13300, 480, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_ilbc, 8000, 15200, 160, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_ilbc, 8000, 15200, 320, 0); + Run(channel_a_to_b_); + outfile_b_.Close(); #endif #if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - OpenOutFile(_testCntr); - char codecISAC[] = "ISAC"; - RegisterSendCodec('A', codecISAC, 16000, -1, 480, -1); - Run(_channelA2B); - RegisterSendCodec('A', codecISAC, 16000, -1, 960, -1); - Run(_channelA2B); - RegisterSendCodec('A', codecISAC, 16000, 15000, 480, -1); - Run(_channelA2B); - RegisterSendCodec('A', codecISAC, 16000, 32000, 960, -1); - Run(_channelA2B); - _outFileB.Close(); + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + OpenOutFile(test_count_); + char codec_isac[] = "ISAC"; + RegisterSendCodec('A', codec_isac, 16000, -1, 480, -1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_isac, 16000, -1, 960, -1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_isac, 16000, 15000, 480, -1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_isac, 16000, 32000, 960, -1); + Run(channel_a_to_b_); + outfile_b_.Close(); #endif #ifdef WEBRTC_CODEC_ISAC - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - OpenOutFile(_testCntr); - RegisterSendCodec('A', codecISAC, 32000, -1, 960, -1); - Run(_channelA2B); - RegisterSendCodec('A', codecISAC, 32000, 56000, 960, -1); - Run(_channelA2B); - RegisterSendCodec('A', codecISAC, 32000, 37000, 960, -1); - Run(_channelA2B); - RegisterSendCodec('A', codecISAC, 32000, 32000, 960, -1); - Run(_channelA2B); - _outFileB.Close(); + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + OpenOutFile(test_count_); + RegisterSendCodec('A', codec_isac, 32000, -1, 960, -1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_isac, 32000, 56000, 960, -1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_isac, 32000, 37000, 960, -1); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_isac, 32000, 32000, 960, -1); + Run(channel_a_to_b_); + outfile_b_.Close(); #endif #ifdef WEBRTC_CODEC_PCM16 - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - OpenOutFile(_testCntr); - char codecL16[] = "L16"; - RegisterSendCodec('A', codecL16, 8000, 128000, 80, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecL16, 8000, 128000, 160, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecL16, 8000, 128000, 240, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecL16, 8000, 128000, 320, 0); - Run(_channelA2B); - _outFileB.Close(); - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - OpenOutFile(_testCntr); - RegisterSendCodec('A', codecL16, 16000, 256000, 160, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecL16, 16000, 256000, 320, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecL16, 16000, 256000, 480, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecL16, 16000, 256000, 640, 0); - Run(_channelA2B); - _outFileB.Close(); - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - OpenOutFile(_testCntr); - RegisterSendCodec('A', codecL16, 32000, 512000, 320, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecL16, 32000, 512000, 640, 0); - Run(_channelA2B); - _outFileB.Close(); + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + OpenOutFile(test_count_); + char codec_l16[] = "L16"; + RegisterSendCodec('A', codec_l16, 8000, 128000, 80, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_l16, 8000, 128000, 160, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_l16, 8000, 128000, 240, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_l16, 8000, 128000, 320, 0); + Run(channel_a_to_b_); + outfile_b_.Close(); + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + OpenOutFile(test_count_); + RegisterSendCodec('A', codec_l16, 16000, 256000, 160, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_l16, 16000, 256000, 320, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_l16, 16000, 256000, 480, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_l16, 16000, 256000, 640, 0); + Run(channel_a_to_b_); + outfile_b_.Close(); + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + OpenOutFile(test_count_); + RegisterSendCodec('A', codec_l16, 32000, 512000, 320, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_l16, 32000, 512000, 640, 0); + Run(channel_a_to_b_); + outfile_b_.Close(); #endif - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - OpenOutFile(_testCntr); - char codecPCMA[] = "PCMA"; - RegisterSendCodec('A', codecPCMA, 8000, 64000, 80, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecPCMA, 8000, 64000, 160, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecPCMA, 8000, 64000, 240, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecPCMA, 8000, 64000, 320, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecPCMA, 8000, 64000, 400, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecPCMA, 8000, 64000, 480, 0); - Run(_channelA2B); - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - char codecPCMU[] = "PCMU"; - RegisterSendCodec('A', codecPCMU, 8000, 64000, 80, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecPCMU, 8000, 64000, 160, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecPCMU, 8000, 64000, 240, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecPCMU, 8000, 64000, 320, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecPCMU, 8000, 64000, 400, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecPCMU, 8000, 64000, 480, 0); - Run(_channelA2B); - _outFileB.Close(); + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + OpenOutFile(test_count_); + char codec_pcma[] = "PCMA"; + RegisterSendCodec('A', codec_pcma, 8000, 64000, 80, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_pcma, 8000, 64000, 160, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_pcma, 8000, 64000, 240, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_pcma, 8000, 64000, 320, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_pcma, 8000, 64000, 400, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_pcma, 8000, 64000, 480, 0); + Run(channel_a_to_b_); + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + char codec_pcmu[] = "PCMU"; + RegisterSendCodec('A', codec_pcmu, 8000, 64000, 80, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_pcmu, 8000, 64000, 160, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_pcmu, 8000, 64000, 240, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_pcmu, 8000, 64000, 320, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_pcmu, 8000, 64000, 400, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_pcmu, 8000, 64000, 480, 0); + Run(channel_a_to_b_); + outfile_b_.Close(); #ifdef WEBRTC_CODEC_SPEEX - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - OpenOutFile(_testCntr); - char codecSPEEX[] = "SPEEX"; - RegisterSendCodec('A', codecSPEEX, 8000, 2400, 160, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecSPEEX, 8000, 8000, 320, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecSPEEX, 8000, 18200, 480, 0); - Run(_channelA2B); - _outFileB.Close(); + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + OpenOutFile(test_count_); + char codec_speex[] = "SPEEX"; + RegisterSendCodec('A', codec_speex, 8000, 2400, 160, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_speex, 8000, 8000, 320, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_speex, 8000, 18200, 480, 0); + Run(channel_a_to_b_); + outfile_b_.Close(); - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - OpenOutFile(_testCntr); - RegisterSendCodec('A', codecSPEEX, 16000, 4000, 320, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecSPEEX, 16000, 12800, 640, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecSPEEX, 16000, 34200, 960, 0); - Run(_channelA2B); - _outFileB.Close(); + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + OpenOutFile(test_count_); + RegisterSendCodec('A', codec_speex, 16000, 4000, 320, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_speex, 16000, 12800, 640, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_speex, 16000, 34200, 960, 0); + Run(channel_a_to_b_); + outfile_b_.Close(); #endif #ifdef WEBRTC_CODEC_CELT - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("."); - } - _testCntr++; - OpenOutFile(_testCntr); - char codecCELT_32[] = "CELT"; - RegisterSendCodec('A', codecCELT_32, 32000, 48000, 640, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecCELT_32, 32000, 64000, 640, 0); - Run(_channelA2B); - RegisterSendCodec('A', codecCELT_32, 32000, 128000, 640, 0); - Run(_channelA2B); - _outFileB.Close(); + if (test_mode_ != 0) { + printf("===============================================================\n"); + } + test_count_++; + OpenOutFile(test_count_); + char codec_celt[] = "CELT"; + RegisterSendCodec('A', codec_celt, 32000, 48000, 640, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_celt, 32000, 64000, 640, 0); + Run(channel_a_to_b_); + RegisterSendCodec('A', codec_celt, 32000, 128000, 640, 0); + Run(channel_a_to_b_); + outfile_b_.Close(); #endif - if(_testMode != 0) { - printf("=======================================================================\n"); - } else { - printf("Done!\n"); - } + if (test_mode_ != 0) { + printf("===============================================================\n"); /* Print out all codecs that were not tested in the run */ - if(_testMode != 0) { - printf("The following codecs was not included in the test:\n"); -#ifndef WEBRTC_CODEC_GSMAMR - printf(" GSMAMR\n"); + printf("The following codecs was not included in the test:\n"); +#ifndef WEBRTC_CODEC_AMR + printf(" GSMAMR\n"); #endif -#ifndef WEBRTC_CODEC_GSMAMRWB - printf(" GSMAMR-wb\n"); +#ifndef WEBRTC_CODEC_AMRWB + printf(" GSMAMR-wb\n"); #endif #ifndef WEBRTC_CODEC_G722 - printf(" G.722\n"); + printf(" G.722\n"); #endif #ifndef WEBRTC_CODEC_G722_1 - printf(" G.722.1\n"); + printf(" G.722.1\n"); #endif #ifndef WEBRTC_CODEC_G722_1C - printf(" G.722.1C\n"); + printf(" G.722.1C\n"); #endif #ifndef WEBRTC_CODEC_G729 - printf(" G.729\n"); + printf(" G.729\n"); #endif #ifndef WEBRTC_CODEC_G729_1 - printf(" G.729.1\n"); + printf(" G.729.1\n"); #endif #ifndef WEBRTC_CODEC_GSMFR - printf(" GSMFR\n"); + printf(" GSMFR\n"); #endif #ifndef WEBRTC_CODEC_ILBC - printf(" iLBC\n"); + printf(" iLBC\n"); #endif #ifndef WEBRTC_CODEC_ISAC - printf(" ISAC float\n"); + printf(" ISAC float\n"); #endif #ifndef WEBRTC_CODEC_ISACFX - printf(" ISAC fix\n"); + printf(" ISAC fix\n"); #endif #ifndef WEBRTC_CODEC_PCM16 - printf(" PCM16\n"); + printf(" PCM16\n"); #endif #ifndef WEBRTC_CODEC_SPEEX - printf(" Speex\n"); + printf(" Speex\n"); #endif - printf("\nTo complete the test, listen to the %d number of output files.\n", _testCntr); - } + printf("\nTo complete the test, listen to the %d number of output files.\n", + test_count_); + } } // Register Codec to use in the test // -// Input: side - which ACM to use, 'A' or 'B' -// codecName - name to use when register the codec -// samplingFreqHz - sampling frequency in Herz -// rate - bitrate in bytes -// packSize - packet size in samples -// extraByte - if extra bytes needed compared to the bitrate +// Input: side - which ACM to use, 'A' or 'B' +// codec_name - name to use when register the codec +// sampling_freq_hz - sampling frequency in Herz +// rate - bitrate in bytes +// packet_size - packet size in samples +// extra_byte - if extra bytes needed compared to the bitrate // used when registering, can be an internal header // set to -1 if the codec is a variable rate codec -WebRtc_Word16 TestAllCodecs::RegisterSendCodec(char side, - char* codecName, - WebRtc_Word32 samplingFreqHz, - int rate, - int packSize, - int extraByte) -{ - if(_testMode != 0) { - // Print out codec and settings - printf("codec: %s Freq: %d Rate: %d PackSize: %d", codecName, samplingFreqHz, rate, packSize); +void TestAllCodecs::RegisterSendCodec(char side, char* codec_name, + int32_t sampling_freq_hz, int rate, + int packet_size, int extra_byte) { + if (test_mode_ != 0) { + // Print out codec and settings. + printf("codec: %s Freq: %d Rate: %d PackSize: %d\n", codec_name, + sampling_freq_hz, rate, packet_size); + } + + // Store packet-size in samples, used to validate the received packet. + // If G.722, store half the size to compensate for the timestamp bug in the + // RFC for G.722. + // If iSAC runs in adaptive mode, packet size in samples can change on the + // fly, so we exclude this test by setting |packet_size_samples_| to -1. + if (!strcmp(codec_name, "G722")) { + packet_size_samples_ = packet_size / 2; + } else if (!strcmp(codec_name, "ISAC") && (rate == -1)) { + packet_size_samples_ = -1; + } else { + packet_size_samples_ = packet_size; + } + + // Store the expected packet size in bytes, used to validate the received + // packet. If variable rate codec (extra_byte == -1), set to -1 (65535). + if (extra_byte != -1) { + // Add 0.875 to always round up to a whole byte + packet_size_bytes_ = + static_cast(static_cast(packet_size * rate) / + static_cast(sampling_freq_hz * 8) + 0.875) + extra_byte; + } else { + // Packets will have a variable size. + packet_size_bytes_ = -1; + } + + // Set pointer to the ACM where to register the codec. + AudioCodingModule* my_acm = NULL; + switch (side) { + case 'A': { + my_acm = acm_a_; + break; } - - // Store packetsize in samples, used to validate the recieved packet - _packSizeSamp = packSize; - - // Store the expected packet size in bytes, used to validate the recieved packet - // If variable rate codec (extraByte == -1), set to -1 (65535) - if (extraByte != -1) - { - // Add 0.875 to always round up to a whole byte - _packSizeBytes = (WebRtc_UWord16)((float)(packSize*rate)/(float)(samplingFreqHz*8)+0.875)+extraByte; - } - else - { - // Packets will have a variable size - _packSizeBytes = -1; + case 'B': { + my_acm = acm_b_; + break; } - - // Set pointer to the ACM where to register the codec - AudioCodingModule* myACM; - switch(side) - { - case 'A': - { - myACM = _acmA; - break; - } - case 'B': - { - myACM = _acmB; - break; - } - default: - return -1; + default: { + break; } + } + ASSERT_TRUE(my_acm != NULL); - if(myACM == NULL) - { - assert(false); - return -1; - } - CodecInst myCodecParam; - - // Get all codec paramters before registering - CHECK_ERROR(AudioCodingModule::Codec(codecName, myCodecParam, - samplingFreqHz, 1)); - myCodecParam.rate = rate; - myCodecParam.pacsize = packSize; - CHECK_ERROR(myACM->RegisterSendCodec(myCodecParam)); - - // initialization was succesful - return 0; + // Get all codec parameters before registering + CodecInst my_codec_param; + CHECK_ERROR(AudioCodingModule::Codec(codec_name, my_codec_param, + sampling_freq_hz, 1)); + my_codec_param.rate = rate; + my_codec_param.pacsize = packet_size; + CHECK_ERROR(my_acm->RegisterSendCodec(my_codec_param)); } -void TestAllCodecs::Run(TestPack* channel) -{ - AudioFrame audioFrame; +void TestAllCodecs::Run(TestPack* channel) { + AudioFrame audio_frame; - WebRtc_Word32 outFreqHzB = _outFileB.SamplingFrequency(); - WebRtc_UWord16 recSize; - WebRtc_UWord32 timeStampDiff; - channel->ResetPayloadSize(); - int errorCount = 0; + int32_t out_freq_hz = outfile_b_.SamplingFrequency(); + uint16_t receive_size; + uint32_t timestamp_diff; + channel->reset_payload_size(); + int error_count = 0; - // Only run 1 second for each test case - while((_counter<1000)&& (!_inFileA.EndOfFile())) - { - // Add 10 msec to ACM - _inFileA.Read10MsData(audioFrame); - CHECK_ERROR(_acmA->Add10MsData(audioFrame)); + int counter = 0; + while (!infile_a_.EndOfFile()) { + // Add 10 msec to ACM. + infile_a_.Read10MsData(audio_frame); + CHECK_ERROR(acm_a_->Add10MsData(audio_frame)); - // Run sender side of ACM - CHECK_ERROR(_acmA->Process()); + // Run sender side of ACM. + CHECK_ERROR(acm_a_->Process()); - // Verify that the received packet size matches the settings - recSize = channel->GetPayloadSize(); - if (recSize) { - if ((recSize != _packSizeBytes) && (_packSizeBytes < 65535)) { - errorCount++; - } + // Verify that the received packet size matches the settings. + receive_size = channel->payload_size(); + if (receive_size) { + if ((receive_size != packet_size_bytes_) && + (packet_size_bytes_ < 65535)) { + error_count++; + } - // Verify that the timestamp is updated with expected length - timeStampDiff = channel->GetTimeStampDiff(); - if ((_counter > 10) && (timeStampDiff != _packSizeSamp)) - errorCount++; - } - - - // Run received side of ACM - CHECK_ERROR(_acmB->PlayoutData10Ms(outFreqHzB, audioFrame)); - - // Write output speech to file - _outFileB.Write10MsData(audioFrame.data_, audioFrame.samples_per_channel_); + // Verify that the timestamp is updated with expected length. The counter + // is used to avoid problems when switching codec or frame size in the + // test. + timestamp_diff = channel->timestamp_diff(); + if ((counter > 10) && (timestamp_diff != packet_size_samples_) && + (packet_size_samples_ < 65535)) + error_count++; } - if (errorCount) - { - printf(" - test FAILED\n"); - } - else if(_testMode != 0) - { - printf(" - test PASSED\n"); - } + // Run received side of ACM. + CHECK_ERROR(acm_b_->PlayoutData10Ms(out_freq_hz, audio_frame)); - // Reset _counter - if (_counter == 1000) { - _counter = 0; - } - if (_inFileA.EndOfFile()) { - _inFileA.Rewind(); - } + // Write output speech to file. + outfile_b_.Write10MsData(audio_frame.data_, + audio_frame.samples_per_channel_); + + // Update loop counter + counter++; + } + + EXPECT_EQ(0, error_count); + + if (infile_a_.EndOfFile()) { + infile_a_.Rewind(); + } } -void TestAllCodecs::OpenOutFile(WebRtc_Word16 testNumber) -{ - char fileName[500]; - sprintf(fileName, "%s/testallcodecs_out_%02d.pcm", - webrtc::test::OutputPath().c_str(), testNumber); - _outFileB.Open(fileName, 32000, "wb"); +void TestAllCodecs::OpenOutFile(int test_number) { + std::string filename = webrtc::test::OutputPath(); + std::ostringstream test_number_str; + test_number_str << test_number; + filename += "testallcodecs_out_"; + filename += test_number_str.str(); + filename += ".pcm"; + outfile_b_.Open(filename.c_str(), 32000, "wb"); } -void TestAllCodecs::DisplaySendReceiveCodec() -{ - CodecInst myCodecParam; - _acmA->SendCodec(myCodecParam); - printf("%s -> ", myCodecParam.plname); - _acmB->ReceiveCodec(myCodecParam); - printf("%s\n", myCodecParam.plname); +void TestAllCodecs::DisplaySendReceiveCodec() { + CodecInst my_codec_param; + acm_a_->SendCodec(my_codec_param); + printf("%s -> ", my_codec_param.plname); + acm_b_->ReceiveCodec(my_codec_param); + printf("%s\n", my_codec_param.plname); } -} // namespace webrtc +} // namespace webrtc diff --git a/src/modules/audio_coding/main/test/TestAllCodecs.h b/src/modules/audio_coding/main/test/TestAllCodecs.h index e0d621f4fe..ef91913aa1 100644 --- a/src/modules/audio_coding/main/test/TestAllCodecs.h +++ b/src/modules/audio_coding/main/test/TestAllCodecs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -8,89 +8,72 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef TEST_ALL_CODECS_H -#define TEST_ALL_CODECS_H +#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_ALL_CODECS_H_ +#define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_ALL_CODECS_H_ #include "ACMTest.h" #include "Channel.h" #include "PCMFile.h" +#include "typedefs.h" namespace webrtc { -class TestPack : public AudioPacketizationCallback -{ -public: - TestPack(); - ~TestPack(); - - void RegisterReceiverACM(AudioCodingModule* acm); - - virtual WebRtc_Word32 SendData(const FrameType frameType, - const WebRtc_UWord8 payloadType, - const WebRtc_UWord32 timeStamp, - const WebRtc_UWord8* payloadData, - const WebRtc_UWord16 payloadSize, - const RTPFragmentationHeader* fragmentation); +class TestPack : public AudioPacketizationCallback { + public: + TestPack(); + ~TestPack(); - WebRtc_UWord16 GetPayloadSize(); - WebRtc_UWord32 GetTimeStampDiff(); - void ResetPayloadSize(); + void RegisterReceiverACM(AudioCodingModule* acm); -private: - AudioCodingModule* _receiverACM; - WebRtc_Word16 _seqNo; - WebRtc_UWord8 _payloadData[60 * 32 * 2 * 2]; - WebRtc_UWord32 _timeStampDiff; - WebRtc_UWord32 _lastInTimestamp; - WebRtc_UWord64 _totalBytes; - WebRtc_UWord16 _payloadSize; + int32_t SendData(FrameType frame_type, uint8_t payload_type, + uint32_t timestamp, const uint8_t* payload_data, + uint16_t payload_size, + const RTPFragmentationHeader* fragmentation); + + uint16_t payload_size(); + uint32_t timestamp_diff(); + void reset_payload_size(); + + private: + AudioCodingModule* receiver_acm_; + uint16_t sequence_number_; + uint8_t payload_data_[60 * 32 * 2 * 2]; + uint32_t timestamp_diff_; + uint32_t last_in_timestamp_; + uint64_t total_bytes_; + uint16_t payload_size_; }; -class TestAllCodecs : public ACMTest -{ -public: - TestAllCodecs(int testMode); - ~TestAllCodecs(); +class TestAllCodecs : public ACMTest { + public: + TestAllCodecs(int test_mode); + ~TestAllCodecs(); - void Perform(); -private: - // 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 for codecs which support - // several sampling frequency. - WebRtc_Word16 RegisterSendCodec(char side, - char* codecName, - WebRtc_Word32 sampFreqHz, - int rate, - int packSize, - int extraByte); + void Perform(); - void Run(TestPack* channel); - void OpenOutFile(WebRtc_Word16 testNumber); - void DisplaySendReceiveCodec(); + private: + // The default value of '-1' indicates that the registration is based only on + // codec name, and a sampling frequency matching is not required. + // This is useful for codecs which support several sampling frequency. + // Note! Only mono mode is tested in this test. + void RegisterSendCodec(char side, char* codec_name, int32_t sampling_freq_hz, + int rate, int packet_size, int extra_byte); - WebRtc_Word32 SendData( - const FrameType frameType, - const WebRtc_UWord8 payloadType, - const WebRtc_UWord32 timeStamp, - const WebRtc_UWord8* payloadData, - const WebRtc_UWord16 payloadSize, - const RTPFragmentationHeader* fragmentation); + void Run(TestPack* channel); + void OpenOutFile(int test_number); + void DisplaySendReceiveCodec(); - int _testMode; - - AudioCodingModule* _acmA; - AudioCodingModule* _acmB; - - TestPack* _channelA2B; - - PCMFile _inFileA; - PCMFile _outFileB; - WebRtc_Word16 _testCntr; - WebRtc_UWord16 _packSizeSamp; - WebRtc_UWord16 _packSizeBytes; - int _counter; + int test_mode_; + AudioCodingModule* acm_a_; + AudioCodingModule* acm_b_; + TestPack* channel_a_to_b_; + PCMFile infile_a_; + PCMFile outfile_b_; + int test_count_; + uint16_t packet_size_samples_; + uint16_t packet_size_bytes_; }; -#endif // TEST_ALL_CODECS_H +} // namespace webrtc -} // namespace webrtc +#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_TEST_ALL_CODECS_H_ diff --git a/src/modules/audio_coding/main/test/Tester.cc b/src/modules/audio_coding/main/test/Tester.cc index 710ea01bc1..c6ac601dbf 100644 --- a/src/modules/audio_coding/main/test/Tester.cc +++ b/src/modules/audio_coding/main/test/Tester.cc @@ -29,17 +29,46 @@ using webrtc::AudioCodingModule; using webrtc::Trace; +// This parameter is used to describe how to run the tests. It is normally +// set to 1, but in auto test all printing is turned off, and the parameter is +// set to 0. +#define ACM_TEST_MODE 1 + +// TODO(tlegrand): Add all tests as individual gtests, like already done for +// TestAllCodecs (ACM_TEST_ALL_ENC_DEC). + // Choose what tests to run by defining one or more of the following: -#define ACM_AUTO_TEST // Most common codecs and settings will be tested -//#define ACM_TEST_ENC_DEC // You decide what to test in run time. - // Used for debugging and for testing while implementing. -//#define ACM_TEST_TWO_WAY // Debugging -//#define ACM_TEST_ALL_ENC_DEC // Loop through all defined codecs and settings -//#define ACM_TEST_STEREO // Run stereo and spatial audio tests -//#define ACM_TEST_VAD_DTX // Run all VAD/DTX tests -//#define ACM_TEST_FEC // Test FEC (also called RED) -//#define ACM_TEST_CODEC_SPEC_API // Only iSAC has codec specfic APIs in this version -//#define ACM_TEST_FULL_API // Test all APIs with threads (long test) +// +// ACM_AUTO_TEST - Most common codecs and settings will be tested. All the +// other tests will be activated. +// ACM_TEST_ENC_DEC - You decide what to test in run time. Used for debugging +// and for testing while implementing. +// ACM_TEST_TWO_WAY - Mainly for debugging. +// ACM_TEST_ALL_CODECS - Loop through all defined codecs and settings. +// ACM_TEST_STEREO - Run stereo and spatial audio tests. +// ACM_TEST_VAD_DTX - Run all VAD/DTX tests. +// ACM_TEST_FEC - Test FEC (also called RED). +// ACM_TEST_CODEC_SPEC_API - Test the iSAC has codec specfic APIs. +// ACM_TEST_FULL_API - Test all APIs with threads (long test). + +#define ACM_AUTO_TEST +//#define ACM_TEST_ENC_DEC +//#define ACM_TEST_TWO_WAY +//#define ACM_TEST_ALL_CODECS +//#define ACM_TEST_STEREO +//#define ACM_TEST_VAD_DTX +//#define ACM_TEST_FEC +//#define ACM_TEST_CODEC_SPEC_API +//#define ACM_TEST_FULL_API + +// If Auto test is active, we activate all tests. +#ifdef ACM_AUTO_TEST +#undef ACM_TEST_MODE +#define ACM_TEST_MODE 0 +#ifndef ACM_TEST_ALL_CODECS +#define ACM_TEST_ALL_CODECS +#endif +#endif void PopulateTests(std::vector* tests) { Trace::CreateTrace(); @@ -50,7 +79,6 @@ void PopulateTests(std::vector* tests) { printf(" ACM auto test\n"); tests->push_back(new webrtc::EncodeDecodeTest(0)); tests->push_back(new webrtc::TwoWayCommunication(0)); - tests->push_back(new webrtc::TestAllCodecs(0)); tests->push_back(new webrtc::TestStereo(0)); tests->push_back(new webrtc::TestVADDTX(0)); tests->push_back(new webrtc::TestFEC(0)); @@ -64,10 +92,6 @@ void PopulateTests(std::vector* tests) { printf(" ACM two-way communication test\n"); tests->push_back(new webrtc::TwoWayCommunication(1)); #endif -#ifdef ACM_TEST_ALL_ENC_DEC - printf(" ACM all codecs test\n"); - tests->push_back(new webrtc::TestAllCodecs(1)); -#endif #ifdef ACM_TEST_STEREO printf(" ACM stereo test\n"); tests->push_back(new webrtc::TestStereo(1)); @@ -93,6 +117,17 @@ void PopulateTests(std::vector* tests) { // TODO(kjellander): Make this a proper gtest instead of using this single test // to run all the tests. + +#ifdef ACM_TEST_ALL_CODECS +TEST(AudioCodingModuleTest, TestAllCodecs) { + Trace::CreateTrace(); + Trace::SetTraceFile((webrtc::test::OutputPath() + + "acm_allcodecs_trace.txt").c_str()); + webrtc::TestAllCodecs(ACM_TEST_MODE).Perform(); + Trace::ReturnTrace(); +} +#endif + TEST(AudioCodingModuleTest, RunAllTests) { std::vector tests; PopulateTests(&tests);